intf

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectionStateConnecting = 100
)

Variables

This section is empty.

Functions

func WatchWireguardKernelInterfaces

func WatchWireguardKernelInterfaces(events chan InterfaceEvent, errors chan error) error

func WatchWireguardUserspaceInterfaces

func WatchWireguardUserspaceInterfaces(events chan InterfaceEvent, errors chan error) error

func WireguardModuleExists

func WireguardModuleExists() bool

Types

type BaseInterface

type BaseInterface struct {
	wg.Device
	// contains filtered or unexported fields
}

func NewInterface

func NewInterface(dev *wgtypes.Device, client *wgctrl.Client, backend signaling.Backend, events chan *pb.Event, cfg *config.Config) (BaseInterface, error)

func (*BaseInterface) AddAddress

func (i *BaseInterface) AddAddress(ip *net.IPNet) error

func (*BaseInterface) AddPeer

func (i *BaseInterface) AddPeer(pk wgtypes.Key) error

func (*BaseInterface) AddRoute

func (i *BaseInterface) AddRoute(dst *net.IPNet) error

func (*BaseInterface) Close

func (i *BaseInterface) Close() error

func (*BaseInterface) Config

func (i *BaseInterface) Config() *wgtypes.Config

func (*BaseInterface) DumpConfig

func (i *BaseInterface) DumpConfig(wr io.Writer) error

func (*BaseInterface) Fixup

func (i *BaseInterface) Fixup() error

func (*BaseInterface) Marshal

func (i *BaseInterface) Marshal() *pb.Interface

func (*BaseInterface) Name

func (i *BaseInterface) Name() string

Name returns the Wireguard interface name

func (*BaseInterface) Peers

func (i *BaseInterface) Peers() map[crypto.Key]*Peer

Peers returns a map of Curve25519 public keys to Peers

func (*BaseInterface) PrivateKey

func (i *BaseInterface) PrivateKey() crypto.Key

PublicKey returns the Curve25519 private key of the Wireguard interface

func (*BaseInterface) PublicKey

func (i *BaseInterface) PublicKey() crypto.Key

PublicKey returns the Curve25519 public key of the Wireguard interface

func (*BaseInterface) RemovePeer

func (i *BaseInterface) RemovePeer(pk wgtypes.Key) error

func (*BaseInterface) Sync

func (i *BaseInterface) Sync(newDev *wgtypes.Device) error

func (*BaseInterface) SyncConfig

func (i *BaseInterface) SyncConfig(cfgFilename string) error

type Devices

type Devices []*wgtypes.Device

func (*Devices) GetByName

func (devs *Devices) GetByName(name string) *wgtypes.Device

type Interface

type Interface interface {
	io.Closer

	Dump(wr io.Writer, color bool, hideKeys bool)
	DumpConfig(wr io.Writer) error
	SyncConfig(cfg string) error

	AddPeer(peer wgtypes.Key) error
	RemovePeer(peer wgtypes.Key) error

	Sync(*wgtypes.Device) error

	Marshal() *pb.Interface

	// Getter
	Name() string
	PublicKey() crypto.Key
	PrivateKey() crypto.Key
	Peers() map[crypto.Key]*Peer
}

func CreateKernelInterface

func CreateKernelInterface(name string, client *wgctrl.Client, backend signaling.Backend, events chan *pb.Event, cfg *config.Config) (Interface, error)

func CreateUserInterface

func CreateUserInterface(name string, client *wgctrl.Client, backend signaling.Backend, events chan *pb.Event, cfg *config.Config) (Interface, error)

type InterfaceEvent

type InterfaceEvent struct {
	Op   InterfaceEventOp
	Name string
}

func (InterfaceEvent) String

func (e InterfaceEvent) String() string

type InterfaceEventOp

type InterfaceEventOp int
const (
	InterfaceAdded InterfaceEventOp = iota
	InterfaceDeleted
)

func (InterfaceEventOp) String

func (ls InterfaceEventOp) String() string

type InterfaceList

type InterfaceList []Interface

func (*InterfaceList) Close

func (l *InterfaceList) Close() error

func (*InterfaceList) GetByName

func (l *InterfaceList) GetByName(name string) Interface

func (*InterfaceList) GetByPublicKey

func (l *InterfaceList) GetByPublicKey(pk crypto.Key) Interface

type KernelInterface

type KernelInterface struct {
	BaseInterface
	// contains filtered or unexported fields
}

func (*KernelInterface) Close

func (i *KernelInterface) Close() error

func (*KernelInterface) Delete

func (i *KernelInterface) Delete() error

func (*KernelInterface) SetDown

func (i *KernelInterface) SetDown(mtu int) error

func (*KernelInterface) SetMTU

func (i *KernelInterface) SetMTU(mtu int) error

func (*KernelInterface) SetUp

func (i *KernelInterface) SetUp() error

type Peer

type Peer struct {
	wgtypes.Peer

	Interface *BaseInterface

	ConnectionState ice.ConnectionState
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(wgp *wgtypes.Peer, i *BaseInterface) (*Peer, error)

NewPeer creates a peer and initiates a new ICE agent

func (*Peer) Close

func (p *Peer) Close() error

Close destroys the peer as well as the ICE agent and proxies

func (*Peer) Config

func (p *Peer) Config() *wgtypes.PeerConfig

Config return the Wireguard peer configuration

func (*Peer) EnsureHandshake

func (p *Peer) EnsureHandshake() error

EnsureHandshake initiated a new Wireguard handshake if the last one is older than 5 seconds

func (*Peer) InitiateHandshake

func (p *Peer) InitiateHandshake() error

InitiateHandshake sends a single packet towards the peer which triggers Wireguard to initiate the handshake

func (*Peer) OnModified

func (p *Peer) OnModified(new *wgtypes.Peer, modified PeerModifier)

OnModified is a callback which gets called whenever a change of the Wireguard interface has been detected by the sync loop

func (*Peer) PublicKey

func (p *Peer) PublicKey() crypto.Key

PublicKey returns the Curve25199 public key of the Wireguard peer

func (*Peer) PublicKeyPair

func (p *Peer) PublicKeyPair() *crypto.KeyPair

PublicKeyPair returns both the public key of the local (our) and remote peer (theirs)

func (*Peer) PublicPrivateKeyPair

func (p *Peer) PublicPrivateKeyPair() *crypto.KeyPair

PublicPrivateKeyPair returns both the public key of the local (our) and remote peer (theirs)

func (*Peer) Restart

func (p *Peer) Restart()

Restart the ICE agent by creating a nee one

func (*Peer) String

func (p *Peer) String() string

String returns the peers public key as a base64-encoded string

type PeerModifier

type PeerModifier uint32
const (
	PeerModifiedNone              PeerModifier = 0
	PeerModifiedEndpoint          PeerModifier = (1 << 0)
	PeerModifiedKeepaliveInterval PeerModifier = (1 << 1)
	PeerModifiedProtocolVersion   PeerModifier = (1 << 2)
	PeerModifiedAllowedIPs        PeerModifier = (1 << 3)
	PeerModifiedHandshakeTime     PeerModifier = (1 << 4)
)

func (PeerModifier) Is

func (i PeerModifier) Is(j PeerModifier) bool

func (PeerModifier) String

func (i PeerModifier) String() string

func (PeerModifier) Strings

func (i PeerModifier) Strings() []string

type SignalingState

type SignalingState int

type UserDevice

type UserDevice struct {
	BaseInterface
	// contains filtered or unexported fields
}

func (*UserDevice) Close

func (i *UserDevice) Close() error

Jump to

Keyboard shortcuts

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