removed isdualstack references

This commit is contained in:
0xdcarns
2022-04-19 14:42:04 -04:00
parent ca1c75b620
commit 8e976d1f55
13 changed files with 77 additions and 126 deletions

View File

@@ -152,11 +152,6 @@ func updateNetwork(w http.ResponseWriter, r *http.Request) {
return return
} }
// if newNetwork.IsDualStack != currentNetwork.IsDualStack && newNetwork.IsDualStack == "no" {
// // Remove IPv6 address from network nodes
// RemoveNetworkNodeIPv6Addresses(currentNetwork.NetID)
// }
if rangeupdate { if rangeupdate {
err = logic.UpdateNetworkNodeAddresses(network.NetID) err = logic.UpdateNetworkNodeAddresses(network.NetID)
if err != nil { if err != nil {

View File

@@ -408,7 +408,6 @@ func RemoveNetworkNodeIPv6Addresses(networkName string) error {
return err return err
} }
if node.Network == networkName { if node.Network == networkName {
node.IsDualStack = "no"
node.Address6 = "" node.Address6 = ""
data, err := json.Marshal(&node) data, err := json.Marshal(&node)
if err != nil { if err != nil {

View File

@@ -425,9 +425,7 @@ func SetNodeDefaults(node *models.Node) {
} }
} }
// == Parent Network settings == // == Parent Network settings ==
if node.IsDualStack == "" {
node.IsDualStack = parentNetwork.IsDualStack
}
if node.MTU == 0 { if node.MTU == 0 {
node.MTU = parentNetwork.DefaultMTU node.MTU = parentNetwork.DefaultMTU
} }
@@ -435,7 +433,6 @@ func SetNodeDefaults(node *models.Node) {
node.SetIPForwardingDefault() node.SetIPForwardingDefault()
node.SetDNSOnDefault() node.SetDNSOnDefault()
node.SetIsLocalDefault() node.SetIsLocalDefault()
node.SetIsDualStackDefault()
node.SetLastModified() node.SetLastModified()
node.SetDefaultName() node.SetDefaultName()
node.SetLastCheckIn() node.SetLastCheckIn()

View File

@@ -34,19 +34,19 @@ func GetHubPeer(networkName string) []models.Node {
*/ */
// GetNodePeers - fetches peers for a given node // GetNodePeers - fetches peers for a given node
func GetNodePeers(networkName, nodeid string, excludeRelayed bool, isP2S bool) ([]models.Node, error) { func GetNodePeers(network *models.Network, nodeid string, excludeRelayed bool, isP2S bool) ([]models.Node, error) {
var peers []models.Node var peers []models.Node
var networkNodes, egressNetworkNodes, err = getNetworkEgressAndNodes(networkName) var networkNodes, egressNetworkNodes, err = getNetworkEgressAndNodes(network.NetID)
if err != nil { if err != nil {
return peers, nil return peers, nil
} }
udppeers, errN := database.GetPeers(networkName) udppeers, errN := database.GetPeers(network.NetID)
if errN != nil { if errN != nil {
logger.Log(2, errN.Error()) logger.Log(2, errN.Error())
} }
currentNetworkACLs, aclErr := nodeacls.FetchAllACLs(nodeacls.NetworkID(networkName)) currentNetworkACLs, aclErr := nodeacls.FetchAllACLs(nodeacls.NetworkID(network.NetID))
if aclErr != nil { if aclErr != nil {
return peers, aclErr return peers, aclErr
} }
@@ -63,10 +63,9 @@ func GetNodePeers(networkName, nodeid string, excludeRelayed bool, isP2S bool) (
} }
peer.IsIngressGateway = node.IsIngressGateway peer.IsIngressGateway = node.IsIngressGateway
isDualStack := node.IsDualStack == "yes"
allow := node.IsRelayed != "yes" || !excludeRelayed allow := node.IsRelayed != "yes" || !excludeRelayed
if node.Network == networkName && node.IsPending != "yes" && allow { if node.Network == network.NetID && node.IsPending != "yes" && allow {
peer = setPeerInfo(&node) peer = setPeerInfo(&node)
if node.UDPHolePunch == "yes" && errN == nil && CheckEndpoint(udppeers[node.PublicKey]) { if node.UDPHolePunch == "yes" && errN == nil && CheckEndpoint(udppeers[node.PublicKey]) {
endpointstring := udppeers[node.PublicKey] endpointstring := udppeers[node.PublicKey]
@@ -84,12 +83,7 @@ func GetNodePeers(networkName, nodeid string, excludeRelayed bool, isP2S bool) (
peer.ListenPort = node.LocalListenPort peer.ListenPort = node.LocalListenPort
} }
if node.IsRelay == "yes" { if node.IsRelay == "yes" {
network, err := GetNetwork(networkName) peer.AllowedIPs = append(peer.AllowedIPs, network.AddressRange)
if err == nil {
peer.AllowedIPs = append(peer.AllowedIPs, network.AddressRange)
} else {
peer.AllowedIPs = append(peer.AllowedIPs, node.RelayAddrs...)
}
for _, egressNode := range egressNetworkNodes { for _, egressNode := range egressNetworkNodes {
if egressNode.IsRelayed == "yes" && StringSliceContains(node.RelayAddrs, egressNode.Address) { if egressNode.IsRelayed == "yes" && StringSliceContains(node.RelayAddrs, egressNode.Address) {
peer.AllowedIPs = append(peer.AllowedIPs, egressNode.EgressGatewayRanges...) peer.AllowedIPs = append(peer.AllowedIPs, egressNode.EgressGatewayRanges...)
@@ -99,8 +93,10 @@ func GetNodePeers(networkName, nodeid string, excludeRelayed bool, isP2S bool) (
if peer.IsIngressGateway == "yes" { // handle ingress stuff if peer.IsIngressGateway == "yes" { // handle ingress stuff
if currentExtClients, err := GetExtPeersList(&node); err == nil { if currentExtClients, err := GetExtPeersList(&node); err == nil {
for i := range currentExtClients { for i := range currentExtClients {
peer.AllowedIPs = append(peer.AllowedIPs, currentExtClients[i].Address) if network.IsIPv4 == "yes" {
if isDualStack { peer.AllowedIPs = append(peer.AllowedIPs, currentExtClients[i].Address)
}
if network.IsIPv6 == "yes" {
peer.AllowedIPs = append(peer.AllowedIPs, currentExtClients[i].Address6) peer.AllowedIPs = append(peer.AllowedIPs, currentExtClients[i].Address6)
} }
} }
@@ -135,7 +131,7 @@ func GetPeersList(refnode *models.Node) ([]models.Node, error) {
isP2S = true isP2S = true
} }
if relayedNodeAddr == "" { if relayedNodeAddr == "" {
peers, err = GetNodePeers(networkName, refnode.ID, excludeRelayed, isP2S) peers, err = GetNodePeers(&network, refnode.ID, excludeRelayed, isP2S)
} else { } else {
var relayNode models.Node var relayNode models.Node
relayNode, err = GetNodeRelay(networkName, relayedNodeAddr) relayNode, err = GetNodeRelay(networkName, relayedNodeAddr)
@@ -155,7 +151,7 @@ func GetPeersList(refnode *models.Node) ([]models.Node, error) {
} else { } else {
peerNode.AllowedIPs = append(peerNode.AllowedIPs, peerNode.RelayAddrs...) peerNode.AllowedIPs = append(peerNode.AllowedIPs, peerNode.RelayAddrs...)
} }
nodepeers, err := GetNodePeers(networkName, refnode.ID, false, isP2S) nodepeers, err := GetNodePeers(&network, refnode.ID, false, isP2S)
if err == nil && peerNode.UDPHolePunch == "yes" { if err == nil && peerNode.UDPHolePunch == "yes" {
for _, nodepeer := range nodepeers { for _, nodepeer := range nodepeers {
if nodepeer.Address == peerNode.Address { if nodepeer.Address == peerNode.Address {

View File

@@ -287,7 +287,7 @@ func GetServerPeers(serverNode *models.Node) ([]wgtypes.PeerConfig, bool, []stri
} }
ranges = nil ranges = nil
} }
if node.Address6 != "" && serverNode.IsDualStack == "yes" { if node.Address6 != "" {
var addr6 = net.IPNet{ var addr6 = net.IPNet{
IP: net.ParseIP(node.Address6), IP: net.ParseIP(node.Address6),
Mask: net.CIDRMask(128, 128), Mask: net.CIDRMask(128, 128),
@@ -357,7 +357,7 @@ func GetServerExtPeers(serverNode *models.Node) ([]wgtypes.PeerConfig, error) {
peeraddr, peeraddr,
} }
if extPeer.Address6 != "" && serverNode.IsDualStack == "yes" { if extPeer.Address6 != "" {
var addr6 = net.IPNet{ var addr6 = net.IPNet{
IP: net.ParseIP(extPeer.Address6), IP: net.ParseIP(extPeer.Address6),
Mask: net.CIDRMask(128, 128), Mask: net.CIDRMask(128, 128),

View File

@@ -50,9 +50,9 @@ func HasPeerConnected(node *models.Node) bool {
func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool { func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool {
// single comparison statements // single comparison statements
if newNode.Endpoint != currentNode.Endpoint || if newNode.Endpoint != currentNode.Endpoint ||
newNode.LocalAddress != currentNode.LocalAddress ||
newNode.PublicKey != currentNode.PublicKey || newNode.PublicKey != currentNode.PublicKey ||
newNode.Address != currentNode.Address || newNode.Address != currentNode.Address ||
newNode.Address6 != currentNode.Address6 ||
newNode.IsEgressGateway != currentNode.IsEgressGateway || newNode.IsEgressGateway != currentNode.IsEgressGateway ||
newNode.IsIngressGateway != currentNode.IsIngressGateway || newNode.IsIngressGateway != currentNode.IsIngressGateway ||
newNode.IsRelay != currentNode.IsRelay || newNode.IsRelay != currentNode.IsRelay ||
@@ -67,12 +67,6 @@ func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool {
} }
// multi-comparison statements // multi-comparison statements
if newNode.IsDualStack == "yes" {
if newNode.Address6 != currentNode.Address6 {
return true
}
}
if newNode.IsEgressGateway == "yes" { if newNode.IsEgressGateway == "yes" {
if len(currentNode.EgressGatewayRanges) != len(newNode.EgressGatewayRanges) { if len(currentNode.EgressGatewayRanges) != len(newNode.EgressGatewayRanges) {
return true return true
@@ -239,7 +233,7 @@ func initWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
_, _ = ncutils.RunCmd(ipExec+" -4 route add "+gateway+" dev "+ifacename, true) _, _ = ncutils.RunCmd(ipExec+" -4 route add "+gateway+" dev "+ifacename, true)
} }
} }
if node.Address6 != "" && node.IsDualStack == "yes" { if node.Address6 != "" {
logger.Log(1, "adding address:", node.Address6) logger.Log(1, "adding address:", node.Address6)
_, _ = ncutils.RunCmd(ipExec+" address add dev "+ifacename+" "+node.Address6+"/64", true) _, _ = ncutils.RunCmd(ipExec+" address add dev "+ifacename+" "+node.Address6+"/64", true)
} }

View File

@@ -21,7 +21,6 @@ type Network struct {
AccessKeys []AccessKey `json:"accesskeys" bson:"accesskeys"` AccessKeys []AccessKey `json:"accesskeys" bson:"accesskeys"`
AllowManualSignUp string `json:"allowmanualsignup" bson:"allowmanualsignup" validate:"checkyesorno"` AllowManualSignUp string `json:"allowmanualsignup" bson:"allowmanualsignup" validate:"checkyesorno"`
IsLocal string `json:"islocal" bson:"islocal" validate:"checkyesorno"` IsLocal string `json:"islocal" bson:"islocal" validate:"checkyesorno"`
IsDualStack string `json:"isdualstack" bson:"isdualstack" validate:"checkyesorno"` // ** IsDualStack deprecated **
IsIPv4 string `json:"isipv4" bson:"isipv4" validate:"checkyesorno"` IsIPv4 string `json:"isipv4" bson:"isipv4" validate:"checkyesorno"`
IsIPv6 string `json:"isipv6" bson:"isipv6" validate:"checkyesorno"` IsIPv6 string `json:"isipv6" bson:"isipv6" validate:"checkyesorno"`
IsPointToSite string `json:"ispointtosite" bson:"ispointtosite" validate:"checkyesorno"` IsPointToSite string `json:"ispointtosite" bson:"ispointtosite" validate:"checkyesorno"`
@@ -77,16 +76,6 @@ func (network *Network) SetDefaults() {
if network.AllowManualSignUp == "" { if network.AllowManualSignUp == "" {
network.AllowManualSignUp = "no" network.AllowManualSignUp = "no"
} }
if network.IsDualStack == "" {
network.IsDualStack = "no"
}
if network.IsDualStack == "yes" {
network.IsIPv6 = "yes"
network.IsIPv4 = "yes"
} else {
network.IsIPv6 = "no"
network.IsIPv4 = "yes"
}
if network.IsIPv4 == "" { if network.IsIPv4 == "" {
network.IsIPv4 = "yes" network.IsIPv4 = "yes"

View File

@@ -33,56 +33,53 @@ var seededRand *rand.Rand = rand.New(
// Node - struct for node model // Node - struct for node model
type Node struct { type Node struct {
ID string `json:"id,omitempty" bson:"id,omitempty" yaml:"id,omitempty" validate:"required,min=5"` ID string `json:"id,omitempty" bson:"id,omitempty" yaml:"id,omitempty" validate:"required,min=5"`
Address string `json:"address" bson:"address" yaml:"address" validate:"omitempty,ipv4"` Address string `json:"address" bson:"address" yaml:"address" validate:"omitempty,ipv4"`
Address6 string `json:"address6" bson:"address6" yaml:"address6" validate:"omitempty,ipv6"` Address6 string `json:"address6" bson:"address6" yaml:"address6" validate:"omitempty,ipv6"`
LocalAddress string `json:"localaddress" bson:"localaddress" yaml:"localaddress" validate:"omitempty,ip"` LocalAddress string `json:"localaddress" bson:"localaddress" yaml:"localaddress" validate:"omitempty,ip"`
LocalListenPort int32 `json:"locallistenport" bson:"locallistenport" yaml:"locallistenport" validate:"numeric,min=0,max=65535"` Name string `json:"name" bson:"name" yaml:"name" validate:"omitempty,max=62,in_charset"`
Name string `json:"name" bson:"name" yaml:"name" validate:"omitempty,max=62,in_charset"` NetworkSettings Network `json:"networksettings" bson:"networksettings" yaml:"networksettings" validate:"-"`
NetworkSettings Network `json:"networksettings" bson:"networksettings" yaml:"networksettings" validate:"-"` ListenPort int32 `json:"listenport" bson:"listenport" yaml:"listenport" validate:"omitempty,numeric,min=1024,max=65535"`
ListenPort int32 `json:"listenport" bson:"listenport" yaml:"listenport" validate:"omitempty,numeric,min=1024,max=65535"` LocalListenPort int32 `json:"locallistenport" bson:"locallistenport" yaml:"locallistenport" validate:"numeric,min=0,max=65535"`
PublicKey string `json:"publickey" bson:"publickey" yaml:"publickey" validate:"required,base64"` PublicKey string `json:"publickey" bson:"publickey" yaml:"publickey" validate:"required,base64"`
Endpoint string `json:"endpoint" bson:"endpoint" yaml:"endpoint" validate:"required,ip"` Endpoint string `json:"endpoint" bson:"endpoint" yaml:"endpoint" validate:"required,ip"`
PostUp string `json:"postup" bson:"postup" yaml:"postup"` PostUp string `json:"postup" bson:"postup" yaml:"postup"`
PostDown string `json:"postdown" bson:"postdown" yaml:"postdown"` PostDown string `json:"postdown" bson:"postdown" yaml:"postdown"`
AllowedIPs []string `json:"allowedips" bson:"allowedips" yaml:"allowedips"` AllowedIPs []string `json:"allowedips" bson:"allowedips" yaml:"allowedips"`
PersistentKeepalive int32 `json:"persistentkeepalive" bson:"persistentkeepalive" yaml:"persistentkeepalive" validate:"omitempty,numeric,max=1000"` PersistentKeepalive int32 `json:"persistentkeepalive" bson:"persistentkeepalive" yaml:"persistentkeepalive" validate:"omitempty,numeric,max=1000"`
IsHub string `json:"ishub" bson:"ishub" yaml:"ishub" validate:"checkyesorno"` IsHub string `json:"ishub" bson:"ishub" yaml:"ishub" validate:"checkyesorno"`
AccessKey string `json:"accesskey" bson:"accesskey" yaml:"accesskey"` AccessKey string `json:"accesskey" bson:"accesskey" yaml:"accesskey"`
Interface string `json:"interface" bson:"interface" yaml:"interface"` Interface string `json:"interface" bson:"interface" yaml:"interface"`
LastModified int64 `json:"lastmodified" bson:"lastmodified" yaml:"lastmodified"` LastModified int64 `json:"lastmodified" bson:"lastmodified" yaml:"lastmodified"`
ExpirationDateTime int64 `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime"` ExpirationDateTime int64 `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime"`
LastPeerUpdate int64 `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate"` LastPeerUpdate int64 `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate"`
LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"` LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"`
MacAddress string `json:"macaddress" bson:"macaddress" yaml:"macaddress" validate:"macaddress_unique"` MacAddress string `json:"macaddress" bson:"macaddress" yaml:"macaddress" validate:"macaddress_unique"`
Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"` Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"`
Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"` Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"`
IsRelayed string `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"` IsRelayed string `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"`
IsPending string `json:"ispending" bson:"ispending" yaml:"ispending"` IsPending string `json:"ispending" bson:"ispending" yaml:"ispending"`
IsRelay string `json:"isrelay" bson:"isrelay" yaml:"isrelay" validate:"checkyesorno"` IsRelay string `json:"isrelay" bson:"isrelay" yaml:"isrelay" validate:"checkyesorno"`
IsDocker string `json:"isdocker" bson:"isdocker" yaml:"isdocker" validate:"checkyesorno"` IsDocker string `json:"isdocker" bson:"isdocker" yaml:"isdocker" validate:"checkyesorno"`
IsK8S string `json:"isk8s" bson:"isk8s" yaml:"isk8s" validate:"checkyesorno"` IsK8S string `json:"isk8s" bson:"isk8s" yaml:"isk8s" validate:"checkyesorno"`
IsEgressGateway string `json:"isegressgateway" bson:"isegressgateway" yaml:"isegressgateway"` IsEgressGateway string `json:"isegressgateway" bson:"isegressgateway" yaml:"isegressgateway"`
IsIngressGateway string `json:"isingressgateway" bson:"isingressgateway" yaml:"isingressgateway"` IsIngressGateway string `json:"isingressgateway" bson:"isingressgateway" yaml:"isingressgateway"`
EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"` EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"`
RelayAddrs []string `json:"relayaddrs" bson:"relayaddrs" yaml:"relayaddrs"` RelayAddrs []string `json:"relayaddrs" bson:"relayaddrs" yaml:"relayaddrs"`
IngressGatewayRange string `json:"ingressgatewayrange" bson:"ingressgatewayrange" yaml:"ingressgatewayrange"` IngressGatewayRange string `json:"ingressgatewayrange" bson:"ingressgatewayrange" yaml:"ingressgatewayrange"`
IsStatic string `json:"isstatic" bson:"isstatic" yaml:"isstatic" validate:"checkyesorno"` IsStatic string `json:"isstatic" bson:"isstatic" yaml:"isstatic" validate:"checkyesorno"`
UDPHolePunch string `json:"udpholepunch" bson:"udpholepunch" yaml:"udpholepunch" validate:"checkyesorno"` UDPHolePunch string `json:"udpholepunch" bson:"udpholepunch" yaml:"udpholepunch" validate:"checkyesorno"`
//PullChanges string `json:"pullchanges" bson:"pullchanges" yaml:"pullchanges" validate:"checkyesorno"` DNSOn string `json:"dnson" bson:"dnson" yaml:"dnson" validate:"checkyesorno"`
DNSOn string `json:"dnson" bson:"dnson" yaml:"dnson" validate:"checkyesorno"` IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"`
// ** IsDualStack deprecated ** Action string `json:"action" bson:"action" yaml:"action"`
IsDualStack string `json:"isdualstack" bson:"isdualstack" yaml:"isdualstack" validate:"checkyesorno"` IsLocal string `json:"islocal" bson:"islocal" yaml:"islocal" validate:"checkyesorno"`
IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"` LocalRange string `json:"localrange" bson:"localrange" yaml:"localrange"`
Action string `json:"action" bson:"action" yaml:"action"` IPForwarding string `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"`
IsLocal string `json:"islocal" bson:"islocal" yaml:"islocal" validate:"checkyesorno"` OS string `json:"os" bson:"os" yaml:"os"`
LocalRange string `json:"localrange" bson:"localrange" yaml:"localrange"` MTU int32 `json:"mtu" bson:"mtu" yaml:"mtu"`
IPForwarding string `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"` Version string `json:"version" bson:"version" yaml:"version"`
OS string `json:"os" bson:"os" yaml:"os"` Server string `json:"server" bson:"server" yaml:"server"`
MTU int32 `json:"mtu" bson:"mtu" yaml:"mtu"` TrafficKeys TrafficKeys `json:"traffickeys" bson:"traffickeys" yaml:"traffickeys"`
Version string `json:"version" bson:"version" yaml:"version"`
Server string `json:"server" bson:"server" yaml:"server"`
TrafficKeys TrafficKeys `json:"traffickeys" bson:"traffickeys" yaml:"traffickeys"`
} }
// NodesArray - used for node sorting // NodesArray - used for node sorting
@@ -201,13 +198,6 @@ func (node *Node) SetDNSOnDefault() {
} }
} }
// Node.SetIsDualStackDefault - set is dual stack default status
func (node *Node) SetIsDualStackDefault() {
if node.IsDualStack == "" {
node.IsDualStack = "no"
}
}
// Node.SetIsServerDefault - sets node isserver default // Node.SetIsServerDefault - sets node isserver default
func (node *Node) SetIsServerDefault() { func (node *Node) SetIsServerDefault() {
if node.IsServer != "yes" { if node.IsServer != "yes" {
@@ -350,18 +340,12 @@ func (newNode *Node) Fill(currentNode *Node) {
if newNode.DNSOn == "" { if newNode.DNSOn == "" {
newNode.DNSOn = currentNode.DNSOn newNode.DNSOn = currentNode.DNSOn
} }
if newNode.IsDualStack == "" {
newNode.IsDualStack = currentNode.IsDualStack
}
if newNode.IsLocal == "" { if newNode.IsLocal == "" {
newNode.IsLocal = currentNode.IsLocal newNode.IsLocal = currentNode.IsLocal
} }
if newNode.IPForwarding == "" { if newNode.IPForwarding == "" {
newNode.IPForwarding = currentNode.IPForwarding newNode.IPForwarding = currentNode.IPForwarding
} }
//if newNode.Roaming == "" {
//newNode.Roaming = currentNode.Roaming
//}
if newNode.Action == "" { if newNode.Action == "" {
newNode.Action = currentNode.Action newNode.Action = currentNode.Action
} }

View File

@@ -144,12 +144,6 @@ func GetFlags(hostname string) []cli.Flag {
Value: "", Value: "",
Usage: "Sets endpoint to local address if 'yes'. Ignores if 'no'. Will retrieve from network if unset.", Usage: "Sets endpoint to local address if 'yes'. Ignores if 'no'. Will retrieve from network if unset.",
}, },
&cli.StringFlag{
Name: "isdualstack",
EnvVars: []string{"NETCLIENT_IS_DUALSTACK"},
Value: "",
Usage: "Sets ipv6 address if 'yes'. Ignores if 'no'. Will retrieve from network if unset.",
},
&cli.StringFlag{ &cli.StringFlag{
Name: "udpholepunch", Name: "udpholepunch",
EnvVars: []string{"NETCLIENT_UDP_HOLEPUNCH"}, EnvVars: []string{"NETCLIENT_UDP_HOLEPUNCH"},

View File

@@ -237,7 +237,6 @@ func GetCLIConfig(c *cli.Context) (ClientConfig, string, error) {
cfg.Node.DNSOn = c.String("dnson") cfg.Node.DNSOn = c.String("dnson")
cfg.Node.IsLocal = c.String("islocal") cfg.Node.IsLocal = c.String("islocal")
cfg.Node.IsStatic = c.String("isstatic") cfg.Node.IsStatic = c.String("isstatic")
cfg.Node.IsDualStack = c.String("isdualstack")
cfg.Node.PostUp = c.String("postup") cfg.Node.PostUp = c.String("postup")
cfg.Node.PostDown = c.String("postdown") cfg.Node.PostDown = c.String("postdown")
cfg.Node.ListenPort = int32(c.Int("port")) cfg.Node.ListenPort = int32(c.Int("port"))

View File

@@ -10,9 +10,9 @@ import (
func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool { func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool {
// single comparison statements // single comparison statements
if newNode.Endpoint != currentNode.Endpoint || if newNode.Endpoint != currentNode.Endpoint ||
newNode.LocalAddress != currentNode.LocalAddress ||
newNode.PublicKey != currentNode.PublicKey || newNode.PublicKey != currentNode.PublicKey ||
newNode.Address != currentNode.Address || newNode.Address != currentNode.Address ||
newNode.Address6 != currentNode.Address6 ||
newNode.IsEgressGateway != currentNode.IsEgressGateway || newNode.IsEgressGateway != currentNode.IsEgressGateway ||
newNode.IsIngressGateway != currentNode.IsIngressGateway || newNode.IsIngressGateway != currentNode.IsIngressGateway ||
newNode.IsRelay != currentNode.IsRelay || newNode.IsRelay != currentNode.IsRelay ||
@@ -27,12 +27,6 @@ func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool {
} }
// multi-comparison statements // multi-comparison statements
if newNode.IsDualStack == "yes" {
if newNode.Address6 != currentNode.Address6 {
return true
}
}
if newNode.IsEgressGateway == "yes" { if newNode.IsEgressGateway == "yes" {
if len(currentNode.EgressGatewayRanges) != len(newNode.EgressGatewayRanges) { if len(currentNode.EgressGatewayRanges) != len(newNode.EgressGatewayRanges) {
return true return true

View File

@@ -14,6 +14,7 @@ import (
"github.com/gravitl/netmaker/netclient/config" "github.com/gravitl/netmaker/netclient/config"
"github.com/gravitl/netmaker/netclient/local" "github.com/gravitl/netmaker/netclient/local"
"github.com/gravitl/netmaker/netclient/ncutils" "github.com/gravitl/netmaker/netclient/ncutils"
"github.com/gravitl/netmaker/netclient/server"
"golang.zx2c4.com/wireguard/wgctrl" "golang.zx2c4.com/wireguard/wgctrl"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes" "golang.zx2c4.com/wireguard/wgctrl/wgtypes"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
@@ -229,6 +230,10 @@ func SetWGConfig(network string, peerupdate bool) error {
servercfg := cfg.Server servercfg := cfg.Server
nodecfg := cfg.Node nodecfg := cfg.Node
peers, hasGateway, gateways, err := server.GetPeers(nodecfg.MacAddress, nodecfg.Network, servercfg.GRPCAddress, nodecfg.IsIngressGateway == "yes", nodecfg.IsServer == "yes")
if err != nil {
return err
}
privkey, err := RetrievePrivKey(network) privkey, err := RetrievePrivKey(network)
if err != nil { if err != nil {
return err return err

View File

@@ -88,9 +88,14 @@ func ApplyWithoutWGQuick(node *models.Node, ifacename string, confPath string) e
runcmds := strings.Split(node.PostUp, "; ") runcmds := strings.Split(node.PostUp, "; ")
_ = ncutils.RunCmds(runcmds, true) _ = ncutils.RunCmds(runcmds, true)
} }
if node.Address6 != "" && node.IsDualStack == "yes" { if node.Address6 != "" {
logger.Log(1, "adding address: ", node.Address6) logger.Log(1, "adding address: ", node.Address6)
_, _ = ncutils.RunCmd(ipExec+" address add dev "+ifacename+" "+node.Address6+"/64", true) netmaskArr := strings.Split(node.NetworkSettings.AddressRange6, "/")
var netmask = "64"
if len(netmaskArr) == 2 {
netmask = netmaskArr[1]
}
ncutils.RunCmd(ipExec+" address add dev "+ifacename+" "+node.Address6+"/"+netmask, true)
} }
return nil return nil
} }