additional checks for disconnected nodes

This commit is contained in:
Matthew R. Kasun
2022-09-22 15:22:21 -04:00
parent 02233c5d8f
commit 175bb94471
3 changed files with 45 additions and 37 deletions

View File

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

View File

@@ -94,12 +94,14 @@ func startGoRoutines(wg *sync.WaitGroup) context.CancelFunc {
cfg := config.ClientConfig{} cfg := config.ClientConfig{}
cfg.Network = network cfg.Network = network
cfg.ReadConfig() cfg.ReadConfig()
if cfg.Node.Connected == "yes" {
if err := wireguard.ApplyConf(&cfg.Node, cfg.Node.Interface, ncutils.GetNetclientPathSpecific()+cfg.Node.Interface+".conf"); err != nil { 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()) logger.Log(0, "failed to start ", cfg.Node.Interface, "wg interface", err.Error())
} }
if cfg.PublicIPService != "" { if cfg.PublicIPService != "" {
global_settings.PublicIPServices[network] = cfg.PublicIPService global_settings.PublicIPServices[network] = cfg.PublicIPService
} }
}
server := cfg.Server.Server server := cfg.Server.Server
if !serverSet[server] { if !serverSet[server] {

View File

@@ -69,6 +69,7 @@ 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.Connected == "yes" {
if nodeCfg.Node.IsStatic != "yes" { if nodeCfg.Node.IsStatic != "yes" {
extIP, err := ncutils.GetPublicIP(nodeCfg.Server.API) extIP, err := ncutils.GetPublicIP(nodeCfg.Server.API)
if err != nil { if err != nil {
@@ -107,6 +108,7 @@ func checkin(currentRun int) {
} }
} }
} }
}
//check version //check version
if nodeCfg.Node.Version != ncutils.Version { if nodeCfg.Node.Version != ncutils.Version {
nodeCfg.Node.Version = ncutils.Version nodeCfg.Node.Version = ncutils.Version