iface

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

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

WgInterfaceDefault is a default interface name of Wiretrustee

Variables

This section is empty.

Functions

func Exists

func Exists(iface string) (*bool, error)

Exists checks whether specified Wireguard device exists or not

func WireguardModExists

func WireguardModExists() bool

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

type WGIface

type WGIface struct {
	Name      string
	Port      int
	MTU       int
	Address   WGAddress
	Interface NetInterface
}

WGIface represents a interface instance

func NewWGIface

func NewWGIface(iface string, address string, mtu int) (WGIface, error)

NewWGIface Creates a new Wireguard interface instance

func (*WGIface) Close

func (w *WGIface) Close() error

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) CreateWithKernel

func (w *WGIface) CreateWithKernel() error

CreateWithKernel Creates a new Wireguard interface using kernel Wireguard module. Works for Linux and offers much better network performance

func (*WGIface) CreateWithUserspace

func (w *WGIface) CreateWithUserspace() error

CreateWithUserspace Creates a new Wireguard interface, using wireguard-go userspace implementation

func (*WGIface) GetListenPort

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

GetListenPort returns the listening port of the Wireguard endpoint

func (*WGIface) RemovePeer

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

RemovePeer removes a Wireguard Peer from the interface iface

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