-
-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[relay] Replace the iface to interface (#2473)
Replace the iface to interface
- Loading branch information
Showing
14 changed files
with
188 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package iface | ||
|
||
import ( | ||
"net" | ||
"time" | ||
|
||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes" | ||
|
||
"github.com/netbirdio/netbird/iface/bind" | ||
) | ||
|
||
type MockWGIface struct { | ||
CreateFunc func() error | ||
CreateOnAndroidFunc func(routeRange []string, ip string, domains []string) error | ||
IsUserspaceBindFunc func() bool | ||
NameFunc func() string | ||
AddressFunc func() WGAddress | ||
ToInterfaceFunc func() *net.Interface | ||
UpFunc func() (*bind.UniversalUDPMuxDefault, error) | ||
UpdateAddrFunc func(newAddr string) error | ||
UpdatePeerFunc func(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error | ||
RemovePeerFunc func(peerKey string) error | ||
AddAllowedIPFunc func(peerKey string, allowedIP string) error | ||
RemoveAllowedIPFunc func(peerKey string, allowedIP string) error | ||
CloseFunc func() error | ||
SetFilterFunc func(filter PacketFilter) error | ||
GetFilterFunc func() PacketFilter | ||
GetDeviceFunc func() *DeviceWrapper | ||
GetStatsFunc func(peerKey string) (WGStats, error) | ||
GetInterfaceGUIDStringFunc func() (string, error) | ||
} | ||
|
||
func (m *MockWGIface) GetInterfaceGUIDString() (string, error) { | ||
return m.GetInterfaceGUIDStringFunc() | ||
} | ||
|
||
func (m *MockWGIface) Create() error { | ||
return m.CreateFunc() | ||
} | ||
|
||
func (m *MockWGIface) CreateOnAndroid(routeRange []string, ip string, domains []string) error { | ||
return m.CreateOnAndroidFunc(routeRange, ip, domains) | ||
} | ||
|
||
func (m *MockWGIface) IsUserspaceBind() bool { | ||
return m.IsUserspaceBindFunc() | ||
} | ||
|
||
func (m *MockWGIface) Name() string { | ||
return m.NameFunc() | ||
} | ||
|
||
func (m *MockWGIface) Address() WGAddress { | ||
return m.AddressFunc() | ||
} | ||
|
||
func (m *MockWGIface) ToInterface() *net.Interface { | ||
return m.ToInterfaceFunc() | ||
} | ||
|
||
func (m *MockWGIface) Up() (*bind.UniversalUDPMuxDefault, error) { | ||
return m.UpFunc() | ||
} | ||
|
||
func (m *MockWGIface) UpdateAddr(newAddr string) error { | ||
return m.UpdateAddrFunc(newAddr) | ||
} | ||
|
||
func (m *MockWGIface) UpdatePeer(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error { | ||
return m.UpdatePeerFunc(peerKey, allowedIps, keepAlive, endpoint, preSharedKey) | ||
} | ||
|
||
func (m *MockWGIface) RemovePeer(peerKey string) error { | ||
return m.RemovePeerFunc(peerKey) | ||
} | ||
|
||
func (m *MockWGIface) AddAllowedIP(peerKey string, allowedIP string) error { | ||
return m.AddAllowedIPFunc(peerKey, allowedIP) | ||
} | ||
|
||
func (m *MockWGIface) RemoveAllowedIP(peerKey string, allowedIP string) error { | ||
return m.RemoveAllowedIPFunc(peerKey, allowedIP) | ||
} | ||
|
||
func (m *MockWGIface) Close() error { | ||
return m.CloseFunc() | ||
} | ||
|
||
func (m *MockWGIface) SetFilter(filter PacketFilter) error { | ||
return m.SetFilterFunc(filter) | ||
} | ||
|
||
func (m *MockWGIface) GetFilter() PacketFilter { | ||
return m.GetFilterFunc() | ||
} | ||
|
||
func (m *MockWGIface) GetDevice() *DeviceWrapper { | ||
return m.GetDeviceFunc() | ||
} | ||
|
||
func (m *MockWGIface) GetStats(peerKey string) (WGStats, error) { | ||
return m.GetStatsFunc(peerKey) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |