iface

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package iface provides wireguard network interface creation and management

Index

Constants

View Source
const (
	DefaultMTU    = 1280
	DefaultWgPort = 51820
)
View Source
const WgInterfaceDefault = "wt0"

WgInterfaceDefault is a default interface name of Wiretrustee

Variables

View Source
var (
	// ErrModuleNotFound is the error resulting if a module can't be found.
	ErrModuleNotFound = errors.New("module not found")
)

Functions

func WireguardModuleIsLoaded added in v0.9.3

func WireguardModuleIsLoaded() bool

WireguardModuleIsLoaded check if we can load wireguard mod (linux only)

Types

type NativeLink struct {
	Link *netlink.Link
}

type NetInterface

type NetInterface interface {
	Close() error
}

NetInterface represents a generic network tunnel interface

type WGAddress

type WGAddress struct {
	IP      net.IP
	Network *net.IPNet
}

WGAddress Wireguard parsed address

func (*WGAddress) String added in v0.6.3

func (addr *WGAddress) String() string

type WGIface

type WGIface struct {
	Name      string
	Port      int
	MTU       int
	Address   WGAddress
	Interface NetInterface
	// contains filtered or unexported fields
}

WGIface represents a interface instance

func NewWGIFace added in v0.6.3

func NewWGIFace(iface string, address string, mtu int) (*WGIface, error)

NewWGIFace Creates a new Wireguard interface instance

func (*WGIface) AddAllowedIP added in v0.9.0

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

AddAllowedIP adds a prefix to the allowed IPs list of peer

func (*WGIface) Close

func (w *WGIface) Close() error

Close closes the tunnel interface

func (*WGIface) Configure

func (w *WGIface) Configure(privateKey string, port int) error

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

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.

func (*WGIface) GetAddress added in v0.9.0

func (w *WGIface) GetAddress() WGAddress

GetAddress returns the interface address

func (*WGIface) GetListenPort

func (w *WGIface) GetListenPort() (*int, error)

GetListenPort returns the listening port of the Wireguard endpoint

func (*WGIface) GetName added in v0.9.0

func (w *WGIface) GetName() string

GetName returns the interface name

func (*WGIface) RemoveAllowedIP added in v0.9.0

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) UpdateAddr added in v0.6.3

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

Jump to

Keyboard shortcuts

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