feat(internal/wireguard): opportunistic kernelspace
- Auto detect if kernelspace implementation is available - Fallback to Go userspace implementation if kernel is not available
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package netlink
|
||||
|
||||
import "github.com/vishvananda/netlink"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
//nolint:revive
|
||||
const (
|
||||
@@ -8,3 +12,20 @@ const (
|
||||
FAMILY_V4 = netlink.FAMILY_V4
|
||||
FAMILY_V6 = netlink.FAMILY_V6
|
||||
)
|
||||
|
||||
type WireguardChecker interface {
|
||||
IsWireguardSupported() (ok bool, err error)
|
||||
}
|
||||
|
||||
func (n *NetLink) IsWireguardSupported() (ok bool, err error) {
|
||||
families, err := netlink.GenlFamilyList()
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("cannot list gen 1 families: %w", err)
|
||||
}
|
||||
for _, family := range families {
|
||||
if family.Name == "wireguard" {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user