new constant for wireguard interface name

This commit is contained in:
Matthew R. Kasun
2022-12-21 03:31:37 -05:00
parent 38cd4d7700
commit 770a293049
5 changed files with 9 additions and 6 deletions

View File

@@ -52,7 +52,7 @@ func CreateEgressGateway(gateway models.EgressGatewayRequest) (models.Node, erro
postDownCmd := ""
ipv4, ipv6 := getNetworkProtocols(gateway.Ranges)
logger.Log(3, "creating egress gateway firewall in use is '", host.FirewallInUse, "'")
iface := "netmaker"
iface := models.WIREGUARD_INTERFACE
if host.OS == "linux" {
switch host.FirewallInUse {
case models.FIREWALL_NFTABLES:
@@ -154,7 +154,7 @@ func DeleteEgressGateway(network, nodeid string) (models.Node, error) {
logger.Log(3, "deleting egress gateway firewall in use is '", host.FirewallInUse, "'")
if node.IsIngressGateway { // check if node is still an ingress gateway before completely deleting postdown/up rules
// still have an ingress gateway so preserve it
iface := "netmaker"
iface := models.WIREGUARD_INTERFACE
if host.OS == "linux" {
switch host.FirewallInUse {
case models.FIREWALL_NFTABLES:
@@ -209,7 +209,7 @@ func CreateIngressGateway(netid string, nodeid string, failover bool) (models.No
node.IngressGatewayRange6 = network.AddressRange6
ipv4, ipv6 := getNetworkProtocols(cidrs)
logger.Log(3, "creating ingress gateway firewall in use is '", host.FirewallInUse, "'")
iface := "netmaker"
iface := models.WIREGUARD_INTERFACE
switch host.FirewallInUse {
case models.FIREWALL_NFTABLES:
// nftables only supported on Linux

View File

@@ -102,7 +102,7 @@ func GetExchangedBytesForNode(node *models.Node, metrics *models.Metrics) error
return err
}
defer wgclient.Close()
device, err := wgclient.Device("netmaker")
device, err := wgclient.Device(models.WIREGUARD_INTERFACE)
if err != nil {
return err
}

View File

@@ -183,7 +183,7 @@ func GetPeersForProxy(node *models.Node, onlyPeers bool) (manager.ProxyManagerPa
proxyPayload.Network = node.Network
//proxyPayload.InterfaceName = node.Interface
//hardcode or read from host ??
proxyPayload.InterfaceName = "netmaker"
proxyPayload.InterfaceName = models.WIREGUARD_INTERFACE
return proxyPayload, nil
}

View File

@@ -7,6 +7,9 @@ import (
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
// WIREGUARD_INTERFACE name of wireguard interface
const WIREGUARD_INTERFACE = "netmaker"
// Host - represents a host on the network
type Host struct {
ID uuid.UUID `json:"id" yaml:"id"`

View File

@@ -583,7 +583,7 @@ func (n *Node) Legacy(h *Host, s *ServerConfig, net *Network) *LegacyNode {
//l.AllowedIPs =
l.PersistentKeepalive = int32(n.PersistentKeepalive)
l.AccessKey = ""
l.Interface = "netmaker"
l.Interface = WIREGUARD_INTERFACE
//l.LastModified =
//l.ExpirationDateTime
//l.LastPeerUpdate