wgctrl-go/os_freebsd.go
Matt Layher 97bc4ad4a1
FreeBSD kernel support (#128)
* internal/freebsd: add initial version of FreeBSD support
* internal/wguser: Replace deprecated io/ioutil package with io
* internal/freebsd: prepare CI to run tests on FreeBSD
* test: sort AllowedIPs before diffing them
* test: skip integration test configure_peers_update_only on FreeBSD
* test: increase test timeout for slow FreeBSD tests
* add FreeBSD support to README

Signed-off-by: Steffen Vogel <post@steffenvogel.de>

* *: tidy
* go.mod: bump dependencies
* .builds: try to fix OpenBSD

Signed-off-by: Matt Layher <mdlayher@gmail.com>

Co-authored-by: Steffen Vogel <post@steffenvogel.de>
2022-11-04 09:57:56 -04:00

34 lines
727 B
Go

//go:build freebsd
// +build freebsd
package wgctrl
import (
"golang.zx2c4.com/wireguard/wgctrl/internal/wgfreebsd"
"golang.zx2c4.com/wireguard/wgctrl/internal/wginternal"
"golang.zx2c4.com/wireguard/wgctrl/internal/wguser"
)
// newClients configures wginternal.Clients for FreeBSD systems.
func newClients() ([]wginternal.Client, error) {
var clients []wginternal.Client
// FreeBSD has an in-kernel WireGuard implementation. Determine if it is
// available and make use of it if so.
kc, ok, err := wgfreebsd.New()
if err != nil {
return nil, err
}
if ok {
clients = append(clients, kc)
}
uc, err := wguser.New()
if err != nil {
return nil, err
}
clients = append(clients, uc)
return clients, nil
}