Documentation ¶
Overview ¶
Package wireguard manipulates wireguard interfaces
Index ¶
- Constants
- Variables
- func ApplyWithoutWGQuick(nc *NCIface) error
- func DeleteOldInterface(iface string)
- func EndpointDetectedAlready(peerPubKey string) bool
- func GetDefaultGateway() (gwRoute netlink.Route, err error)
- func GetDefaultGatewayIp() (ip net.IP, err error)
- func GetDefaultGatewayV6() (gwRoute netlink.Route, err error)
- func GetIPNetfromIp(ip net.IP) (ipCidr *net.IPNet)
- func GetOriginalDefaulGw() (gwIP net.IP, err error)
- func GetPeer(ifaceName, peerPubKey string) (wgtypes.Peer, error)
- func IfaceDelta(currentNode *config.Node, newNode *config.Node) bool
- func IfaceExists(ifacename string) bool
- func RemoveEgressRoutes()
- func RemoveRoutes(addrs []ifaceAddress)
- func RemoveWithoutWGQuick(ifacename string) error
- func RestoreInternetGw() (err error)
- func SetEgressRoutes(egressRoutes []models.EgressNetworkRoutes)
- func SetInternetGw(gwIp net.IP) (err error)
- func SetPeers(replace bool) error
- func SetRoutes(addrs []ifaceAddress) error
- func SetRoutesFromCache()
- func ShouldReplace(incomingPeers []wgtypes.PeerConfig) bool
- func UpdatePeer(p *wgtypes.PeerConfig) error
- type NCIface
Constants ¶
const ( RouteTableName = 111 IPv4Network = "0.0.0.0/0" IPv6Network = "::/0" EgressRouteMetric = 256 )
Variables ¶
var (
ErrModuleNotFound = errors.New("module not found")
)
Functions ¶
func ApplyWithoutWGQuick ¶
ApplyWithoutWGQuick - Function for running the equivalent of "wg-quick up" for linux if wg-quick is missing
func DeleteOldInterface ¶
func DeleteOldInterface(iface string)
DeleteOldInterface - removes named interface
func EndpointDetectedAlready ¶
EndpointDetectedAlready - checks if better endpoint has been detected already
func GetDefaultGateway ¶
GetDefaultGateway - get current default gateway
func GetDefaultGatewayIp ¶
GetDefaultGatewayIp - get current default gateway
func GetDefaultGatewayV6 ¶
GetDefaultGatewayV6 - get current default gateway ipv6
func GetIPNetfromIp ¶
GetIPNetfromIp - converts ip into ipnet based network class
func GetOriginalDefaulGw ¶
GetOriginalDefaulGw - fetches system's original default gw
func IfaceDelta ¶
IfaceDelta - checks if the new node causes an interface change
func IfaceExists ¶
IfaceExists - return true if you can find the iface
func RemoveEgressRoutes ¶
func RemoveEgressRoutes()
func RemoveRoutes ¶
func RemoveRoutes(addrs []ifaceAddress)
RemoveRoutes - Remove routes to the interface
func RemoveWithoutWGQuick ¶
RemoveWithoutWGQuick - Function for running the equivalent of "wg-quick down" for linux if wg-quick is missing
func RestoreInternetGw ¶
func RestoreInternetGw() (err error)
RestoreInternetGw - delete the route in table ROUTE_TABLE_NAME and delet the rules
func SetEgressRoutes ¶
func SetEgressRoutes(egressRoutes []models.EgressNetworkRoutes)
func SetInternetGw ¶
SetInternetGw - set a new default gateway and add rules to activate it
func SetRoutes ¶
func SetRoutes(addrs []ifaceAddress) error
SetRoutes - sets additional routes to the interface
func SetRoutesFromCache ¶
func SetRoutesFromCache()
func ShouldReplace ¶
func ShouldReplace(incomingPeers []wgtypes.PeerConfig) bool
ShouldReplace - checks curr peers and incoming peers to see if the peers should be replaced
func UpdatePeer ¶
func UpdatePeer(p *wgtypes.PeerConfig) error
UpdatePeer replaces a wireguard peer temporarily making public func to pass staticchecks this function will be required in future when update node on server is refactored
Types ¶
type NCIface ¶
type NCIface struct { Iface netIface Name string Addresses []ifaceAddress MTU int Config wgtypes.Config }
NCIface - represents a Netclient network interface
func GetInterface ¶
func GetInterface() *NCIface
func NewNCIface ¶
NewNCIFace - creates a new Netclient interface in memory
func (*NCIface) ApplyAddrs ¶
netLink.ApplyAddrs - applies the assigned node addresses to given interface (netLink)
func (*NCIface) Create ¶
NCIface.Create - creates a linux WG interface based on a node's host config
func (*NCIface) UpdatePeer ¶
func (n *NCIface) UpdatePeer(p wgtypes.PeerConfig)
NCIface.UpdatePeer - Updates Peers from provided PeerConfig