mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 17:29:15 +08:00
additional checks for disconnected nodes
This commit is contained in:
@@ -61,6 +61,10 @@ func GetPeerUpdate(node *models.Node) (models.PeerUpdate, error) {
|
|||||||
if node.NetworkSettings.IsPointToSite == "yes" && node.IsHub == "no" && peer.IsHub == "no" {
|
if node.NetworkSettings.IsPointToSite == "yes" && node.IsHub == "no" && peer.IsHub == "no" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if node.Connected != "yes" {
|
||||||
|
//skip unconnected nodes
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// if the node is not a server, set the endpoint
|
// if the node is not a server, set the endpoint
|
||||||
var setEndpoint = !(node.IsServer == "yes")
|
var setEndpoint = !(node.IsServer == "yes")
|
||||||
|
@@ -94,11 +94,13 @@ func startGoRoutines(wg *sync.WaitGroup) context.CancelFunc {
|
|||||||
cfg := config.ClientConfig{}
|
cfg := config.ClientConfig{}
|
||||||
cfg.Network = network
|
cfg.Network = network
|
||||||
cfg.ReadConfig()
|
cfg.ReadConfig()
|
||||||
if err := wireguard.ApplyConf(&cfg.Node, cfg.Node.Interface, ncutils.GetNetclientPathSpecific()+cfg.Node.Interface+".conf"); err != nil {
|
if cfg.Node.Connected == "yes" {
|
||||||
logger.Log(0, "failed to start ", cfg.Node.Interface, "wg interface", err.Error())
|
if err := wireguard.ApplyConf(&cfg.Node, cfg.Node.Interface, ncutils.GetNetclientPathSpecific()+cfg.Node.Interface+".conf"); err != nil {
|
||||||
}
|
logger.Log(0, "failed to start ", cfg.Node.Interface, "wg interface", err.Error())
|
||||||
if cfg.PublicIPService != "" {
|
}
|
||||||
global_settings.PublicIPServices[network] = cfg.PublicIPService
|
if cfg.PublicIPService != "" {
|
||||||
|
global_settings.PublicIPServices[network] = cfg.PublicIPService
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server := cfg.Server.Server
|
server := cfg.Server.Server
|
||||||
|
@@ -69,41 +69,43 @@ func checkin(currentRun int) {
|
|||||||
// defaults to iptables for now, may need another default for non-Linux OSes
|
// defaults to iptables for now, may need another default for non-Linux OSes
|
||||||
nodeCfg.Node.FirewallInUse = models.FIREWALL_IPTABLES
|
nodeCfg.Node.FirewallInUse = models.FIREWALL_IPTABLES
|
||||||
}
|
}
|
||||||
if nodeCfg.Node.IsStatic != "yes" {
|
if nodeCfg.Node.Connected == "yes" {
|
||||||
extIP, err := ncutils.GetPublicIP(nodeCfg.Server.API)
|
if nodeCfg.Node.IsStatic != "yes" {
|
||||||
if err != nil {
|
extIP, err := ncutils.GetPublicIP(nodeCfg.Server.API)
|
||||||
logger.Log(1, "error encountered checking public ip addresses: ", err.Error())
|
if err != nil {
|
||||||
}
|
logger.Log(1, "error encountered checking public ip addresses: ", err.Error())
|
||||||
if nodeCfg.Node.Endpoint != extIP && extIP != "" {
|
|
||||||
logger.Log(1, "network:", nodeCfg.Node.Network, "endpoint has changed from ", nodeCfg.Node.Endpoint, " to ", extIP)
|
|
||||||
nodeCfg.Node.Endpoint = extIP
|
|
||||||
if err := PublishNodeUpdate(&nodeCfg); err != nil {
|
|
||||||
logger.Log(0, "network:", nodeCfg.Node.Network, "could not publish endpoint change")
|
|
||||||
}
|
}
|
||||||
}
|
if nodeCfg.Node.Endpoint != extIP && extIP != "" {
|
||||||
intIP, err := getPrivateAddr()
|
logger.Log(1, "network:", nodeCfg.Node.Network, "endpoint has changed from ", nodeCfg.Node.Endpoint, " to ", extIP)
|
||||||
if err != nil {
|
nodeCfg.Node.Endpoint = extIP
|
||||||
logger.Log(1, "network:", nodeCfg.Node.Network, "error encountered checking private ip addresses: ", err.Error())
|
if err := PublishNodeUpdate(&nodeCfg); err != nil {
|
||||||
}
|
logger.Log(0, "network:", nodeCfg.Node.Network, "could not publish endpoint change")
|
||||||
if nodeCfg.Node.LocalAddress != intIP && intIP != "" {
|
}
|
||||||
logger.Log(1, "network:", nodeCfg.Node.Network, "local Address has changed from ", nodeCfg.Node.LocalAddress, " to ", intIP)
|
|
||||||
nodeCfg.Node.LocalAddress = intIP
|
|
||||||
if err := PublishNodeUpdate(&nodeCfg); err != nil {
|
|
||||||
logger.Log(0, "Network: ", nodeCfg.Node.Network, " could not publish local address change")
|
|
||||||
}
|
}
|
||||||
}
|
intIP, err := getPrivateAddr()
|
||||||
_ = UpdateLocalListenPort(&nodeCfg)
|
if err != nil {
|
||||||
|
logger.Log(1, "network:", nodeCfg.Node.Network, "error encountered checking private ip addresses: ", err.Error())
|
||||||
|
}
|
||||||
|
if nodeCfg.Node.LocalAddress != intIP && intIP != "" {
|
||||||
|
logger.Log(1, "network:", nodeCfg.Node.Network, "local Address has changed from ", nodeCfg.Node.LocalAddress, " to ", intIP)
|
||||||
|
nodeCfg.Node.LocalAddress = intIP
|
||||||
|
if err := PublishNodeUpdate(&nodeCfg); err != nil {
|
||||||
|
logger.Log(0, "Network: ", nodeCfg.Node.Network, " could not publish local address change")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ = UpdateLocalListenPort(&nodeCfg)
|
||||||
|
|
||||||
} else if nodeCfg.Node.IsLocal == "yes" && nodeCfg.Node.LocalRange != "" {
|
} else if nodeCfg.Node.IsLocal == "yes" && nodeCfg.Node.LocalRange != "" {
|
||||||
localIP, err := ncutils.GetLocalIP(nodeCfg.Node.LocalRange)
|
localIP, err := ncutils.GetLocalIP(nodeCfg.Node.LocalRange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log(1, "network:", nodeCfg.Node.Network, "error encountered checking local ip addresses: ", err.Error())
|
logger.Log(1, "network:", nodeCfg.Node.Network, "error encountered checking local ip addresses: ", err.Error())
|
||||||
}
|
}
|
||||||
if nodeCfg.Node.Endpoint != localIP && localIP != "" {
|
if nodeCfg.Node.Endpoint != localIP && localIP != "" {
|
||||||
logger.Log(1, "network:", nodeCfg.Node.Network, "endpoint has changed from "+nodeCfg.Node.Endpoint+" to ", localIP)
|
logger.Log(1, "network:", nodeCfg.Node.Network, "endpoint has changed from "+nodeCfg.Node.Endpoint+" to ", localIP)
|
||||||
nodeCfg.Node.Endpoint = localIP
|
nodeCfg.Node.Endpoint = localIP
|
||||||
if err := PublishNodeUpdate(&nodeCfg); err != nil {
|
if err := PublishNodeUpdate(&nodeCfg); err != nil {
|
||||||
logger.Log(0, "network:", nodeCfg.Node.Network, "could not publish localip change")
|
logger.Log(0, "network:", nodeCfg.Node.Network, "could not publish localip change")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user