fetch networks for checkin

This commit is contained in:
Matthew R. Kasun 2022-07-14 06:35:49 -04:00
parent cdc7ec7495
commit aa9be268f3

View file

@ -19,9 +19,6 @@ import (
"github.com/gravitl/netmaker/tls"
)
// pubNetworks hold the currently publishable networks
var pubNetworks []string
// Checkin -- go routine that checks for public or local ip changes, publishes changes
// if there are no updates, simply "pings" the server as a checkin
func Checkin(ctx context.Context, wg *sync.WaitGroup) {
@ -34,7 +31,15 @@ func Checkin(ctx context.Context, wg *sync.WaitGroup) {
return
//delay should be configuraable -> use cfg.Node.NetworkSettings.DefaultCheckInInterval ??
case <-time.After(time.Second * 60):
for _, network := range pubNetworks {
checkin()
}
}
}
func checkin() {
networks, _ := ncutils.GetSystemNetworks()
logger.Log(3, "checkin with server(s) for all networks")
for _, network := range networks {
var nodeCfg config.ClientConfig
nodeCfg.Network = network
nodeCfg.ReadConfig()
@ -79,8 +84,6 @@ func Checkin(ctx context.Context, wg *sync.WaitGroup) {
Hello(&nodeCfg)
checkCertExpiry(&nodeCfg)
}
}
}
}
// PublishNodeUpdates -- saves node and pushes changes to broker