Documentation ¶
Index ¶
- Constants
- func WatchWireguardKernelInterfaces(events chan InterfaceEvent, errors chan error) error
- func WatchWireguardUserspaceInterfaces(events chan InterfaceEvent, errors chan error) error
- func WireguardModuleExists() bool
- type BaseInterface
- func (i *BaseInterface) AddAddress(ip *net.IPNet) error
- func (i *BaseInterface) AddPeer(pk wgtypes.Key) error
- func (i *BaseInterface) AddRoute(dst *net.IPNet) error
- func (i *BaseInterface) Close() error
- func (i *BaseInterface) Config() *wgtypes.Config
- func (i *BaseInterface) DumpConfig(wr io.Writer) error
- func (i *BaseInterface) Fixup() error
- func (i *BaseInterface) Marshal() *pb.Interface
- func (i *BaseInterface) Name() string
- func (i *BaseInterface) Peers() map[crypto.Key]*Peer
- func (i *BaseInterface) PrivateKey() crypto.Key
- func (i *BaseInterface) PublicKey() crypto.Key
- func (i *BaseInterface) RemovePeer(pk wgtypes.Key) error
- func (i *BaseInterface) Sync(newDev *wgtypes.Device) error
- func (i *BaseInterface) SyncConfig(cfgFilename string) error
- type Devices
- type Interface
- type InterfaceEvent
- type InterfaceEventOp
- type InterfaceList
- type KernelInterface
- type Peer
- func (p *Peer) Close() error
- func (p *Peer) Config() *wgtypes.PeerConfig
- func (p *Peer) EnsureHandshake() error
- func (p *Peer) InitiateHandshake() error
- func (p *Peer) OnModified(new *wgtypes.Peer, modified PeerModifier)
- func (p *Peer) PublicKey() crypto.Key
- func (p *Peer) PublicKeyPair() *crypto.KeyPair
- func (p *Peer) PublicPrivateKeyPair() *crypto.KeyPair
- func (p *Peer) Restart()
- func (p *Peer) String() string
- type PeerModifier
- type SignalingState
- type UserDevice
Constants ¶
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 ¶
func NewInterface ¶
func (*BaseInterface) AddAddress ¶
func (i *BaseInterface) AddAddress(ip *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) SyncConfig ¶
func (i *BaseInterface) SyncConfig(cfgFilename string) error
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 ¶
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) Config ¶
func (p *Peer) Config() *wgtypes.PeerConfig
Config return the Wireguard peer configuration
func (*Peer) EnsureHandshake ¶
EnsureHandshake initiated a new Wireguard handshake if the last one is older than 5 seconds
func (*Peer) InitiateHandshake ¶
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) PublicKeyPair ¶
PublicKeyPair returns both the public key of the local (our) and remote peer (theirs)
func (*Peer) PublicPrivateKeyPair ¶
PublicPrivateKeyPair returns both the public key of the local (our) and remote peer (theirs)
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