checkin logic updated

This commit is contained in:
Matthew R. Kasun
2022-02-15 15:40:38 -05:00
parent 6c583567d4
commit e8a897f342
6 changed files with 57 additions and 57 deletions

View File

@@ -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()

View File

@@ -70,7 +70,7 @@ type Node struct {
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"`
//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"`
@@ -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
}

View File

@@ -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")

View File

@@ -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 "+

View File

@@ -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)

View File

@@ -132,7 +132,7 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
MacAddress: cfg.Node.MacAddress,
AccessKey: cfg.Server.AccessKey,
IsStatic: cfg.Node.IsStatic,
Roaming: cfg.Node.Roaming,
//Roaming: cfg.Node.Roaming,
Network: cfg.Network,
ListenPort: cfg.Node.ListenPort,
PostUp: cfg.Node.PostUp,