diff --git a/logic/nodes.go b/logic/nodes.go index 90f3c4bb..641fcd3c 100644 --- a/logic/nodes.go +++ b/logic/nodes.go @@ -396,7 +396,7 @@ func SetNodeDefaults(node *models.Node) { node.SetDefaultName() node.SetLastCheckIn() node.SetLastPeerUpdate() - node.SetRoamingDefault() + //node.SetRoamingDefault() node.SetPullChangesDefault() node.SetDefaultAction() node.SetIsServerDefault() diff --git a/models/node.go b/models/node.go index a0218941..2326b323 100644 --- a/models/node.go +++ b/models/node.go @@ -48,35 +48,35 @@ type Node struct { LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"` MacAddress string `json:"macaddress" bson:"macaddress" yaml:"macaddress" validate:"macaddress_unique"` // checkin interval is depreciated at the network level. Set on server with CHECKIN_INTERVAL - CheckInInterval int32 `json:"checkininterval" bson:"checkininterval" yaml:"checkininterval"` - Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"` - Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"` - IsRelayed string `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"` - IsPending string `json:"ispending" bson:"ispending" yaml:"ispending"` - IsRelay string `json:"isrelay" bson:"isrelay" yaml:"isrelay" validate:"checkyesorno"` - IsDocker string `json:"isdocker" bson:"isdocker" yaml:"isdocker" validate:"checkyesorno"` - IsK8S string `json:"isk8s" bson:"isk8s" yaml:"isk8s" validate:"checkyesorno"` - IsEgressGateway string `json:"isegressgateway" bson:"isegressgateway" yaml:"isegressgateway"` - IsIngressGateway string `json:"isingressgateway" bson:"isingressgateway" yaml:"isingressgateway"` - EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"` - RelayAddrs []string `json:"relayaddrs" bson:"relayaddrs" yaml:"relayaddrs"` - IngressGatewayRange string `json:"ingressgatewayrange" bson:"ingressgatewayrange" yaml:"ingressgatewayrange"` - IsStatic string `json:"isstatic" bson:"isstatic" yaml:"isstatic" 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"` - IsDualStack string `json:"isdualstack" bson:"isdualstack" yaml:"isdualstack" validate:"checkyesorno"` - IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"` - Action string `json:"action" bson:"action" yaml:"action"` - IsLocal string `json:"islocal" bson:"islocal" yaml:"islocal" validate:"checkyesorno"` - LocalRange string `json:"localrange" bson:"localrange" yaml:"localrange"` - Roaming string `json:"roaming" bson:"roaming" yaml:"roaming" validate:"checkyesorno"` - IPForwarding string `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"` - OS string `json:"os" bson:"os" yaml:"os"` - MTU int32 `json:"mtu" bson:"mtu" yaml:"mtu"` - Version string `json:"version" bson:"version" yaml:"version"` - ExcludedAddrs []string `json:"excludedaddrs" bson:"excludedaddrs" yaml:"excludedaddrs"` - TrafficKeys TrafficKeys `json:"traffickeys" bson:"traffickeys" yaml:"traffickeys"` + CheckInInterval int32 `json:"checkininterval" bson:"checkininterval" yaml:"checkininterval"` + Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"` + Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"` + IsRelayed string `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"` + IsPending string `json:"ispending" bson:"ispending" yaml:"ispending"` + IsRelay string `json:"isrelay" bson:"isrelay" yaml:"isrelay" validate:"checkyesorno"` + IsDocker string `json:"isdocker" bson:"isdocker" yaml:"isdocker" validate:"checkyesorno"` + IsK8S string `json:"isk8s" bson:"isk8s" yaml:"isk8s" validate:"checkyesorno"` + IsEgressGateway string `json:"isegressgateway" bson:"isegressgateway" yaml:"isegressgateway"` + IsIngressGateway string `json:"isingressgateway" bson:"isingressgateway" yaml:"isingressgateway"` + EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"` + RelayAddrs []string `json:"relayaddrs" bson:"relayaddrs" yaml:"relayaddrs"` + IngressGatewayRange string `json:"ingressgatewayrange" bson:"ingressgatewayrange" yaml:"ingressgatewayrange"` + IsStatic string `json:"isstatic" bson:"isstatic" yaml:"isstatic" 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"` + IsDualStack string `json:"isdualstack" bson:"isdualstack" yaml:"isdualstack" validate:"checkyesorno"` + IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"` + Action string `json:"action" bson:"action" yaml:"action"` + IsLocal string `json:"islocal" bson:"islocal" yaml:"islocal" validate:"checkyesorno"` + LocalRange string `json:"localrange" bson:"localrange" yaml:"localrange"` + //Roaming string `json:"roaming" bson:"roaming" yaml:"roaming" validate:"checkyesorno"` + IPForwarding string `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"` + OS string `json:"os" bson:"os" yaml:"os"` + MTU int32 `json:"mtu" bson:"mtu" yaml:"mtu"` + Version string `json:"version" bson:"version" yaml:"version"` + ExcludedAddrs []string `json:"excludedaddrs" bson:"excludedaddrs" yaml:"excludedaddrs"` + TrafficKeys TrafficKeys `json:"traffickeys" bson:"traffickeys" yaml:"traffickeys"` } // NodesArray - used for node sorting @@ -161,11 +161,11 @@ func (node *Node) SetDefaultAction() { } // Node.SetRoamingDefault - sets default roaming status -func (node *Node) SetRoamingDefault() { - if node.Roaming == "" { - node.Roaming = "yes" - } -} +//func (node *Node) SetRoamingDefault() { +// if node.Roaming == "" { +// node.Roaming = "yes" +// } +//} // Node.SetPullChangesDefault - sets default pull changes status func (node *Node) SetPullChangesDefault() { @@ -371,9 +371,9 @@ func (newNode *Node) Fill(currentNode *Node) { if newNode.PullChanges == "" { newNode.PullChanges = currentNode.PullChanges } - if newNode.Roaming == "" { - newNode.Roaming = currentNode.Roaming - } + //if newNode.Roaming == "" { + //newNode.Roaming = currentNode.Roaming + //} if newNode.Action == "" { newNode.Action = currentNode.Action } diff --git a/netclient/config/config.go b/netclient/config/config.go index 5e21f1c6..66efcac2 100644 --- a/netclient/config/config.go +++ b/netclient/config/config.go @@ -228,7 +228,7 @@ func GetCLIConfig(c *cli.Context) (ClientConfig, string, error) { cfg.Node.LocalAddress = c.String("localaddress") cfg.Node.Address = c.String("address") cfg.Node.Address6 = c.String("addressIPV6") - cfg.Node.Roaming = c.String("roaming") + //cfg.Node.Roaming = c.String("roaming") cfg.Node.DNSOn = c.String("dnson") cfg.Node.IsLocal = c.String("islocal") cfg.Node.IsStatic = c.String("isstatic") diff --git a/netclient/functions/checkin.go b/netclient/functions/checkin.go index f72cd1b8..6b8b7ed4 100644 --- a/netclient/functions/checkin.go +++ b/netclient/functions/checkin.go @@ -28,11 +28,11 @@ func isDeleteError(err error) bool { func checkIP(node *models.Node, servercfg config.ServerConfig, cliconf config.ClientConfig, network string) bool { ipchange := false var err error - if node.Roaming == "yes" && node.IsStatic != "yes" { + if node.IsStatic != "yes" { if node.IsLocal == "no" { extIP, err := ncutils.GetPublicIP() if err != nil { - ncutils.PrintLog("error encountered checking ip addresses: "+err.Error(), 1) + ncutils.PrintLog("error encountered checking public ip addresses: "+err.Error(), 1) } if node.Endpoint != extIP && extIP != "" { ncutils.PrintLog("endpoint has changed from "+ @@ -43,7 +43,7 @@ func checkIP(node *models.Node, servercfg config.ServerConfig, cliconf config.Cl } intIP, err := getPrivateAddr() if err != nil { - ncutils.PrintLog("error encountered checking ip addresses: "+err.Error(), 1) + ncutils.PrintLog("error encountered checking private ip addresses: "+err.Error(), 1) } if node.LocalAddress != intIP && intIP != "" { ncutils.PrintLog("local Address has changed from "+ @@ -52,10 +52,10 @@ func checkIP(node *models.Node, servercfg config.ServerConfig, cliconf config.Cl node.LocalAddress = intIP ipchange = true } - } else { + } else if node.IsLocal == "yes" && node.LocalRange != "" { localIP, err := ncutils.GetLocalIP(node.LocalRange) if err != nil { - ncutils.PrintLog("error encountered checking ip addresses: "+err.Error(), 1) + ncutils.PrintLog("error encountered checking local ip addresses: "+err.Error(), 1) } if node.Endpoint != localIP && localIP != "" { ncutils.PrintLog("endpoint has changed from "+ diff --git a/netclient/functions/daemon.go b/netclient/functions/daemon.go index 27be60fa..a371444b 100644 --- a/netclient/functions/daemon.go +++ b/netclient/functions/daemon.go @@ -436,10 +436,10 @@ func Checkin(ctx context.Context, wg *sync.WaitGroup, cfg *config.ClientConfig, // ncutils.Log("Checkin running") //read latest config cfg.ReadConfig() - if cfg.Node.Roaming == "yes" && cfg.Node.IsStatic != "yes" { + if cfg.Node.IsStatic != "yes" { extIP, err := ncutils.GetPublicIP() if err != nil { - ncutils.PrintLog("error encountered checking ip addresses: "+err.Error(), 1) + ncutils.PrintLog("error encountered checking public ip addresses: "+err.Error(), 1) } if cfg.Node.Endpoint != extIP && extIP != "" { ncutils.PrintLog("endpoint has changed from "+cfg.Node.Endpoint+" to "+extIP, 1) @@ -450,7 +450,7 @@ func Checkin(ctx context.Context, wg *sync.WaitGroup, cfg *config.ClientConfig, } intIP, err := getPrivateAddr() if err != nil { - ncutils.PrintLog("error encountered checking ip addresses: "+err.Error(), 1) + ncutils.PrintLog("error encountered checking private ip addresses: "+err.Error(), 1) } if cfg.Node.LocalAddress != intIP && intIP != "" { ncutils.PrintLog("local Address has changed from "+cfg.Node.LocalAddress+" to "+intIP, 1) @@ -459,10 +459,10 @@ func Checkin(ctx context.Context, wg *sync.WaitGroup, cfg *config.ClientConfig, ncutils.Log("could not publish local address change") } } - } else { + } else if cfg.Node.IsLocal == "yes" && cfg.Node.LocalRange != "" { localIP, err := ncutils.GetLocalIP(cfg.Node.LocalRange) if err != nil { - ncutils.PrintLog("error encountered checking ip addresses: "+err.Error(), 1) + ncutils.PrintLog("error encountered checking local ip addresses: "+err.Error(), 1) } if cfg.Node.Endpoint != localIP && localIP != "" { ncutils.PrintLog("endpoint has changed from "+cfg.Node.Endpoint+" to "+localIP, 1) diff --git a/netclient/functions/join.go b/netclient/functions/join.go index 8e67c814..9bfe6aa9 100644 --- a/netclient/functions/join.go +++ b/netclient/functions/join.go @@ -125,14 +125,14 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error { cfg.Node.Name = formatName(cfg.Node) // differentiate between client/server here var node = models.Node{ - Password: cfg.Node.Password, - Address: cfg.Node.Address, - Address6: cfg.Node.Address6, - ID: cfg.Node.ID, - MacAddress: cfg.Node.MacAddress, - AccessKey: cfg.Server.AccessKey, - IsStatic: cfg.Node.IsStatic, - Roaming: cfg.Node.Roaming, + Password: cfg.Node.Password, + Address: cfg.Node.Address, + Address6: cfg.Node.Address6, + ID: cfg.Node.ID, + MacAddress: cfg.Node.MacAddress, + AccessKey: cfg.Server.AccessKey, + IsStatic: cfg.Node.IsStatic, + //Roaming: cfg.Node.Roaming, Network: cfg.Network, ListenPort: cfg.Node.ListenPort, PostUp: cfg.Node.PostUp,