mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-14 10:50:45 +01:00
extend wginterface func with windows related things
This commit is contained in:
parent
1f949f8cee
commit
f28a657a1d
@ -17,26 +17,6 @@ const (
|
|||||||
DefaultWgPort = 51820
|
DefaultWgPort = 51820
|
||||||
)
|
)
|
||||||
|
|
||||||
type IWGIface interface {
|
|
||||||
Create() error
|
|
||||||
CreateOnAndroid(routeRange []string, ip string, domains []string) error
|
|
||||||
IsUserspaceBind() bool
|
|
||||||
Name() string
|
|
||||||
Address() WGAddress
|
|
||||||
ToInterface() *net.Interface
|
|
||||||
Up() (*bind.UniversalUDPMuxDefault, error)
|
|
||||||
UpdateAddr(newAddr string) error
|
|
||||||
UpdatePeer(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error
|
|
||||||
RemovePeer(peerKey string) error
|
|
||||||
AddAllowedIP(peerKey string, allowedIP string) error
|
|
||||||
RemoveAllowedIP(peerKey string, allowedIP string) error
|
|
||||||
Close() error
|
|
||||||
SetFilter(filter PacketFilter) error
|
|
||||||
GetFilter() PacketFilter
|
|
||||||
GetDevice() *DeviceWrapper
|
|
||||||
GetStats(peerKey string) (WGStats, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WGIface represents a interface instance
|
// WGIface represents a interface instance
|
||||||
type WGIface struct {
|
type WGIface struct {
|
||||||
tun wgTunDevice
|
tun wgTunDevice
|
||||||
|
@ -10,21 +10,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MockWGIface struct {
|
type MockWGIface struct {
|
||||||
IsUserspaceBindFunc func() bool
|
IsUserspaceBindFunc func() bool
|
||||||
NameFunc func() string
|
NameFunc func() string
|
||||||
AddressFunc func() WGAddress
|
AddressFunc func() WGAddress
|
||||||
ToInterfaceFunc func() *net.Interface
|
ToInterfaceFunc func() *net.Interface
|
||||||
UpFunc func() (*bind.UniversalUDPMuxDefault, error)
|
UpFunc func() (*bind.UniversalUDPMuxDefault, error)
|
||||||
UpdateAddrFunc func(newAddr string) error
|
UpdateAddrFunc func(newAddr string) error
|
||||||
UpdatePeerFunc func(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error
|
UpdatePeerFunc func(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error
|
||||||
RemovePeerFunc func(peerKey string) error
|
RemovePeerFunc func(peerKey string) error
|
||||||
AddAllowedIPFunc func(peerKey string, allowedIP string) error
|
AddAllowedIPFunc func(peerKey string, allowedIP string) error
|
||||||
RemoveAllowedIPFunc func(peerKey string, allowedIP string) error
|
RemoveAllowedIPFunc func(peerKey string, allowedIP string) error
|
||||||
CloseFunc func() error
|
CloseFunc func() error
|
||||||
SetFilterFunc func(filter PacketFilter) error
|
SetFilterFunc func(filter PacketFilter) error
|
||||||
GetFilterFunc func() PacketFilter
|
GetFilterFunc func() PacketFilter
|
||||||
GetDeviceFunc func() *DeviceWrapper
|
GetDeviceFunc func() *DeviceWrapper
|
||||||
GetStatsFunc func(peerKey string) (WGStats, error)
|
GetStatsFunc func(peerKey string) (WGStats, error)
|
||||||
|
GetInterfaceGUIDStringFunc func() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockWGIface) Create() error {
|
func (m *MockWGIface) Create() error {
|
||||||
|
32
iface/iwginterface.go
Normal file
32
iface/iwginterface.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package iface
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
|
|
||||||
|
"github.com/netbirdio/netbird/iface/bind"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IWGIface interface {
|
||||||
|
Create() error
|
||||||
|
CreateOnAndroid(routeRange []string, ip string, domains []string) error
|
||||||
|
IsUserspaceBind() bool
|
||||||
|
Name() string
|
||||||
|
Address() WGAddress
|
||||||
|
ToInterface() *net.Interface
|
||||||
|
Up() (*bind.UniversalUDPMuxDefault, error)
|
||||||
|
UpdateAddr(newAddr string) error
|
||||||
|
UpdatePeer(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error
|
||||||
|
RemovePeer(peerKey string) error
|
||||||
|
AddAllowedIP(peerKey string, allowedIP string) error
|
||||||
|
RemoveAllowedIP(peerKey string, allowedIP string) error
|
||||||
|
Close() error
|
||||||
|
SetFilter(filter PacketFilter) error
|
||||||
|
GetFilter() PacketFilter
|
||||||
|
GetDevice() *DeviceWrapper
|
||||||
|
GetStats(peerKey string) (WGStats, error)
|
||||||
|
}
|
31
iface/iwginterface_windows.go
Normal file
31
iface/iwginterface_windows.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package iface
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
|
|
||||||
|
"github.com/netbirdio/netbird/iface/bind"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IWGIface interface {
|
||||||
|
Create() error
|
||||||
|
CreateOnAndroid(routeRange []string, ip string, domains []string) error
|
||||||
|
IsUserspaceBind() bool
|
||||||
|
Name() string
|
||||||
|
Address() WGAddress
|
||||||
|
ToInterface() *net.Interface
|
||||||
|
Up() (*bind.UniversalUDPMuxDefault, error)
|
||||||
|
UpdateAddr(newAddr string) error
|
||||||
|
UpdatePeer(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error
|
||||||
|
RemovePeer(peerKey string) error
|
||||||
|
AddAllowedIP(peerKey string, allowedIP string) error
|
||||||
|
RemoveAllowedIP(peerKey string, allowedIP string) error
|
||||||
|
Close() error
|
||||||
|
SetFilter(filter PacketFilter) error
|
||||||
|
GetFilter() PacketFilter
|
||||||
|
GetDevice() *DeviceWrapper
|
||||||
|
GetStats(peerKey string) (WGStats, error)
|
||||||
|
GetInterfaceGUIDString() (string, error)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user