|
@@ -167,9 +167,9 @@ func unsubscribeNode(client mqtt.Client, nodeCfg *config.ClientConfig) {
|
|
|
}
|
|
|
if token := client.Unsubscribe(fmt.Sprintf("peers/%s/%s", nodeCfg.Node.Network, nodeCfg.Node.ID)); token.WaitTimeout(mq.MQ_TIMEOUT*time.Second) && token.Error() != nil {
|
|
|
if token.Error() == nil {
|
|
|
- logger.Log(1, "network:", nodeCfg.Node.Network, "unable to unsubscribe from peer updates for node ", nodeCfg.Node.Name, "\n", "connection timeout")
|
|
|
+ logger.Log(1, "network:", nodeCfg.Node.Network, "unable to unsubscribe from peer updates for node", nodeCfg.Node.Name, "\n", "connection timeout")
|
|
|
} else {
|
|
|
- logger.Log(1, "network:", nodeCfg.Node.Network, "unable to unsubscribe from peer updates for node ", nodeCfg.Node.Name, "\n", token.Error().Error())
|
|
|
+ logger.Log(1, "network:", nodeCfg.Node.Network, "unable to unsubscribe from peer updates for node", nodeCfg.Node.Name, "\n", token.Error().Error())
|
|
|
}
|
|
|
ok = false
|
|
|
}
|
|
@@ -182,7 +182,7 @@ func unsubscribeNode(client mqtt.Client, nodeCfg *config.ClientConfig) {
|
|
|
// the client should subscribe to ALL nodes that exist on server locally
|
|
|
func messageQueue(ctx context.Context, wg *sync.WaitGroup, cfg *config.ClientConfig) {
|
|
|
defer wg.Done()
|
|
|
- logger.Log(0, "network:", cfg.Node.Network, "netclient message queue started for server: ", cfg.Server.Server)
|
|
|
+ logger.Log(0, "network:", cfg.Node.Network, "netclient message queue started for server:", cfg.Server.Server)
|
|
|
client, err := setupMQTT(cfg, false)
|
|
|
if err != nil {
|
|
|
logger.Log(0, "unable to connect to broker", cfg.Server.Server, err.Error())
|
|
@@ -190,7 +190,7 @@ func messageQueue(ctx context.Context, wg *sync.WaitGroup, cfg *config.ClientCon
|
|
|
}
|
|
|
defer client.Disconnect(250)
|
|
|
<-ctx.Done()
|
|
|
- logger.Log(0, "shutting down message queue for server ", cfg.Server.Server)
|
|
|
+ logger.Log(0, "shutting down message queue for server", cfg.Server.Server)
|
|
|
}
|
|
|
|
|
|
// NewTLSConf sets up tls configuration to connect to broker securely
|
|
@@ -199,7 +199,7 @@ func NewTLSConfig(server string) (*tls.Config, error) {
|
|
|
certpool := x509.NewCertPool()
|
|
|
ca, err := os.ReadFile(file)
|
|
|
if err != nil {
|
|
|
- logger.Log(0, "could not read CA file ", err.Error())
|
|
|
+ logger.Log(0, "could not read CA file", err.Error())
|
|
|
}
|
|
|
ok := certpool.AppendCertsFromPEM(ca)
|
|
|
if !ok {
|
|
@@ -207,7 +207,7 @@ func NewTLSConfig(server string) (*tls.Config, error) {
|
|
|
}
|
|
|
clientKeyPair, err := tls.LoadX509KeyPair(ncutils.GetNetclientServerPath(server)+ncutils.GetSeparator()+"client.pem", ncutils.GetNetclientPath()+ncutils.GetSeparator()+"client.key")
|
|
|
if err != nil {
|
|
|
- logger.Log(0, "could not read client cert/key ", err.Error())
|
|
|
+ logger.Log(0, "could not read client cert/key", err.Error())
|
|
|
return nil, err
|
|
|
}
|
|
|
certs := []tls.Certificate{clientKeyPair}
|
|
@@ -246,7 +246,7 @@ func setupMQTT(cfg *config.ClientConfig, publish bool) (mqtt.Client, error) {
|
|
|
if !publish {
|
|
|
networks, err := ncutils.GetSystemNetworks()
|
|
|
if err != nil {
|
|
|
- logger.Log(0, "error retriving networks ", err.Error())
|
|
|
+ logger.Log(0, "error retriving networks", err.Error())
|
|
|
}
|
|
|
for _, network := range networks {
|
|
|
var currNodeCfg config.ClientConfig
|