iface

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMTU         = 1280
	DefaultWgPort      = 51820
	WgInterfaceDefault = configurer.WgInterfaceDefault
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IWGIface

type IWGIface interface {
	Create() error
	CreateOnAndroid(routeRange []string, ip string, domains []string) error
	IsUserspaceBind() bool
	Name() string
	Address() device.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 device.PacketFilter) error
	GetFilter() device.PacketFilter
	GetDevice() *device.FilteredDevice
	GetStats(peerKey string) (configurer.WGStats, error)
}

type MockWGIface

type MockWGIface struct {
	CreateFunc                 func() error
	CreateOnAndroidFunc        func(routeRange []string, ip string, domains []string) error
	IsUserspaceBindFunc        func() bool
	NameFunc                   func() string
	AddressFunc                func() device.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 device.PacketFilter) error
	GetFilterFunc              func() device.PacketFilter
	GetDeviceFunc              func() *device.FilteredDevice
	GetStatsFunc               func(peerKey string) (configurer.WGStats, error)
	GetInterfaceGUIDStringFunc func() (string, error)
}

func (*MockWGIface) AddAllowedIP

func (m *MockWGIface) AddAllowedIP(peerKey string, allowedIP string) error

func (*MockWGIface) Address

func (m *MockWGIface) Address() device.WGAddress

func (*MockWGIface) Close

func (m *MockWGIface) Close() error

func (*MockWGIface) Create

func (m *MockWGIface) Create() error

func (*MockWGIface) CreateOnAndroid

func (m *MockWGIface) CreateOnAndroid(routeRange []string, ip string, domains []string) error

func (*MockWGIface) GetDevice

func (m *MockWGIface) GetDevice() *device.FilteredDevice

func (*MockWGIface) GetFilter

func (m *MockWGIface) GetFilter() device.PacketFilter

func (*MockWGIface) GetInterfaceGUIDString

func (m *MockWGIface) GetInterfaceGUIDString() (string, error)

func (*MockWGIface) GetStats

func (m *MockWGIface) GetStats(peerKey string) (configurer.WGStats, error)

func (*MockWGIface) IsUserspaceBind

func (m *MockWGIface) IsUserspaceBind() bool

func (*MockWGIface) Name

func (m *MockWGIface) Name() string

func (*MockWGIface) RemoveAllowedIP

func (m *MockWGIface) RemoveAllowedIP(peerKey string, allowedIP string) error

func (*MockWGIface) RemovePeer

func (m *MockWGIface) RemovePeer(peerKey string) error

func (*MockWGIface) SetFilter

func (m *MockWGIface) SetFilter(filter device.PacketFilter) error

func (*MockWGIface) ToInterface

func (m *MockWGIface) ToInterface() *net.Interface

func (*MockWGIface) Up

func (*MockWGIface) UpdateAddr

func (m *MockWGIface) UpdateAddr(newAddr string) error

func (*MockWGIface) UpdatePeer

func (m *MockWGIface) UpdatePeer(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error

type WGAddress

type WGAddress = device.WGAddress

type WGIface

type WGIface struct {
	// contains filtered or unexported fields
}

WGIface represents an interface instance

func NewWGIFace

func NewWGIFace(iFaceName string, address string, wgPort int, wgPrivKey string, mtu int, transportNet transport.Net, args *device.MobileIFaceArguments, filterFn bind.FilterFn) (*WGIface, error)

NewWGIFace Creates a new WireGuard interface instance

func (*WGIface) AddAllowedIP

func (w *WGIface) AddAllowedIP(peerKey string, allowedIP string) error

AddAllowedIP adds a prefix to the allowed IPs list of peer

func (*WGIface) Address

func (w *WGIface) Address() device.WGAddress

Address returns the interface address

func (*WGIface) Close

func (w *WGIface) Close() error

Close closes the tunnel interface

func (*WGIface) Create

func (w *WGIface) Create() error

Create creates a new Wireguard interface, sets a given IP and brings it up. Will reuse an existing one. this function is different on Android

func (*WGIface) CreateOnAndroid

func (w *WGIface) CreateOnAndroid([]string, string, []string) error

CreateOnAndroid this function make sense on mobile only

func (*WGIface) Destroy

func (w *WGIface) Destroy() error

func (*WGIface) GetDevice

func (w *WGIface) GetDevice() *device.FilteredDevice

GetDevice to interact with raw device (with filtering)

func (*WGIface) GetFilter

func (w *WGIface) GetFilter() device.PacketFilter

GetFilter returns packet filter used by interface if it uses userspace device implementation

func (*WGIface) GetStats

func (w *WGIface) GetStats(peerKey string) (configurer.WGStats, error)

GetStats returns the last handshake time, rx and tx bytes for the given peer

func (*WGIface) IsUserspaceBind

func (w *WGIface) IsUserspaceBind() bool

IsUserspaceBind indicates whether this interfaces is userspace with bind.ICEBind

func (*WGIface) Name

func (w *WGIface) Name() string

Name returns the interface name

func (*WGIface) RemoveAllowedIP

func (w *WGIface) RemoveAllowedIP(peerKey string, allowedIP string) error

RemoveAllowedIP removes a prefix from the allowed IPs list of peer

func (*WGIface) RemovePeer

func (w *WGIface) RemovePeer(peerKey string) error

RemovePeer removes a Wireguard Peer from the interface iface

func (*WGIface) SetFilter

func (w *WGIface) SetFilter(filter device.PacketFilter) error

SetFilter sets packet filters for the userspace implementation

func (*WGIface) ToInterface

func (r *WGIface) ToInterface() *net.Interface

ToInterface returns the net.Interface for the Wireguard interface

func (*WGIface) Up

Up configures a Wireguard interface The interface must exist before calling this method (e.g. call interface.Create() before)

func (*WGIface) UpdateAddr

func (w *WGIface) UpdateAddr(newAddr string) error

UpdateAddr updates address of the interface

func (*WGIface) UpdatePeer

func (w *WGIface) UpdatePeer(peerKey string, allowedIps string, keepAlive time.Duration, endpoint *net.UDPAddr, preSharedKey *wgtypes.Key) error

UpdatePeer updates existing Wireguard Peer or creates a new one if doesn't exist Endpoint is optional

type WGTunDevice

type WGTunDevice interface {
	Create() (device.WGConfigurer, error)
	Up() (*bind.UniversalUDPMuxDefault, error)
	UpdateAddr(address WGAddress) error
	WgAddress() WGAddress
	DeviceName() string
	Close() error
	FilteredDevice() *device.FilteredDevice
}

Directories

Path Synopsis
Package iface provides wireguard network interface creation and management
Package iface provides wireguard network interface creation and management
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
iface/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL