Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WireguardInterface ¶
type WireguardInterface struct { InterfaceName string // name of the wireguard interface IP net.IPNet // local ip of wg interface ListenPort int // UDP listening port PublicKey string // public key of interface }
WireguardInterface wraps basic information about a wireguard interface
func NewWireguardInterface ¶
func NewWireguardInterface(interfaceName string, ipnet net.IPNet) WireguardInterface
NewWireguardInterface creates a new WireguardInterface with a given name and ip
func NewWireguardInterfaceNoAddr ¶ added in v0.1.1
func NewWireguardInterfaceNoAddr(interfaceName string) WireguardInterface
NewWireguardInterface creates a new WireguardInterface with a given name but without an address assignement
type WireguardPeer ¶
type WireguardPeer struct { RemoteEndpointIP string ListenPort int Pubkey string AllowedIPs []net.IPNet Psk *string PersistentKeepaliveInterval time.Duration }
WireguardPeer is a single wireguard peer
type WireguardPeerIterator ¶
type WireguardPeerIterator func(p WireguardPeer)
type WireguardWrapper ¶
type WireguardWrapper interface { // AddInterface creates a wireguard interface from basic properties // (name, ip) AddInterface(intf WireguardInterface) error // AddInterfaceNoAddr is similar to AddInterface with the exception that no // IP address is added to the interface AddInterfaceNoAddr(intf WireguardInterface) error // DeleteInterface downs and deletes the interface DeleteInterface(intf WireguardInterface) error // SetInterfaceUp brings interface in UP state SetInterfaceUp(intf WireguardInterface) error // HasInterface checks if given interface exists (by name) HasInterface(intf WireguardInterface) (bool, error) // Configure makes sure that the wireguard interface // has a listen port configured and a keypair (by creatig one). // Needs endpoint ip and listen port from intf. // Extracts public key part and stores it in intf. Configure(intf *WireguardInterface) error // AddPeer adds a new peer to an existing interface AddPeer(intf WireguardInterface, peer WireguardPeer) (bool, error) // HasPeer check if a peer is present on an interface. Compares by public key only HasPeer(intf WireguardInterface, peer WireguardPeer) (bool, error) // RemoveAllPeers removes all peers on an existing interface RemoveAllPeers(intf WireguardInterface) error // RemovePeerByPubkey remove a single peer from an interface RemovePeerByPubkey(intf WireguardInterface, pubkey string) error // IteratePeers walks over the current list of peers of an interface IteratePeers(intf WireguardInterface, it WireguardPeerIterator) error // SetRoute checks if there is a route on given interface to network. If not, adds it. all using /sbin/ip SetRoute(intf WireguardInterface, networkCIDR string) error // DefaultRouteInterface returns the interface name behind the default route. DefaultRouteInterface() (string, error) }
WireguardWrapper is the main interface to work with wireguard interfaces
Click to show internal directories.
Click to hide internal directories.