mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 08:47:35 +08:00
send connected status on checkin
This commit is contained in:
@@ -3,7 +3,6 @@ package functions
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gravitl/netmaker/logger"
|
||||
"github.com/gravitl/netmaker/netclient/config"
|
||||
"github.com/gravitl/netmaker/netclient/ncutils"
|
||||
"github.com/gravitl/netmaker/netclient/wireguard"
|
||||
@@ -24,10 +23,6 @@ func Connect(network string) error {
|
||||
if err = wireguard.ApplyConf(&cfg.Node, cfg.Node.Interface, filePath); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := PublishNodeUpdate(cfg); err != nil {
|
||||
logger.Log(0, "network:", cfg.Node.Network, "could not publish connection change, it will likely get reverted")
|
||||
}
|
||||
|
||||
return config.ModNodeConfig(&cfg.Node)
|
||||
}
|
||||
|
||||
@@ -46,9 +41,5 @@ func Disconnect(network string) error {
|
||||
if err = wireguard.ApplyConf(&cfg.Node, cfg.Node.Interface, filePath); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := PublishNodeUpdate(cfg); err != nil {
|
||||
logger.Log(0, "network:", cfg.Node.Network, "could not publish connection change, it will likely get reverted")
|
||||
}
|
||||
|
||||
return config.ModNodeConfig(&cfg.Node)
|
||||
}
|
||||
|
@@ -123,7 +123,15 @@ func PublishNodeUpdate(nodeCfg *config.ClientConfig) error {
|
||||
|
||||
// Hello -- ping the broker to let server know node it's alive and well
|
||||
func Hello(nodeCfg *config.ClientConfig) {
|
||||
if err := publish(nodeCfg, fmt.Sprintf("ping/%s", nodeCfg.Node.ID), []byte(ncutils.Version), 0); err != nil {
|
||||
var checkin models.NodeCheckin
|
||||
checkin.Version = ncutils.Version
|
||||
checkin.Connected = nodeCfg.Node.Connected
|
||||
data, err := json.Marshal(checkin)
|
||||
if err != nil {
|
||||
logger.Log(0, "unable to marshal checkin data", err.Error())
|
||||
return
|
||||
}
|
||||
if err := publish(nodeCfg, fmt.Sprintf("ping/%s", nodeCfg.Node.ID), data, 0); err != nil {
|
||||
logger.Log(0, fmt.Sprintf("Network: %s error publishing ping, %v", nodeCfg.Node.Network, err))
|
||||
logger.Log(0, "running pull on "+nodeCfg.Node.Network+" to reconnect")
|
||||
_, err := Pull(nodeCfg.Node.Network, true)
|
||||
|
Reference in New Issue
Block a user