Remove config.Server.Debug

no longer required with move to logger.Log and it's verbosity
capabilities
This commit is contained in:
Matthew R. Kasun
2022-05-09 09:49:17 -04:00
parent 5d3274e48d
commit 501108b53d
8 changed files with 2 additions and 24 deletions

View File

@@ -61,7 +61,6 @@ type ServerConfig struct {
DisplayKeys string `yaml:"displaykeys"` DisplayKeys string `yaml:"displaykeys"`
AzureTenant string `yaml:"azuretenant"` AzureTenant string `yaml:"azuretenant"`
RCE string `yaml:"rce"` RCE string `yaml:"rce"`
Debug bool `yaml:"debug"`
Telemetry string `yaml:"telemetry"` Telemetry string `yaml:"telemetry"`
ManageIPTables string `yaml:"manageiptables"` ManageIPTables string `yaml:"manageiptables"`
PortForwardServices string `yaml:"portforwardservices"` PortForwardServices string `yaml:"portforwardservices"`

View File

@@ -33,7 +33,6 @@ server:
displaykeys: "" displaykeys: ""
azuretenant: "" azuretenant: ""
rce: "off" rce: "off"
debug: ""
telemetry: "" telemetry: ""
manageiptables: "off" manageiptables: "off"
portforwardservices: "" portforwardservices: ""

View File

@@ -11,7 +11,7 @@ import (
"github.com/gravitl/netmaker/netclient/ncutils" "github.com/gravitl/netmaker/netclient/ncutils"
) )
// DefaultHandler default message queue handler - only called when GetDebug == true // DefaultHandler default message queue handler -- NOT USED
func DefaultHandler(client mqtt.Client, msg mqtt.Message) { func DefaultHandler(client mqtt.Client, msg mqtt.Message) {
logger.Log(0, "MQTT Message: Topic: ", string(msg.Topic()), " Message: ", string(msg.Payload())) logger.Log(0, "MQTT Message: Topic: ", string(msg.Topic()), " Message: ", string(msg.Payload()))
} }

View File

@@ -31,12 +31,6 @@ func SetupMQTT(publish bool) mqtt.Client {
opts.SetWriteTimeout(time.Minute) opts.SetWriteTimeout(time.Minute)
opts.SetOnConnectHandler(func(client mqtt.Client) { opts.SetOnConnectHandler(func(client mqtt.Client) {
if !publish { if !publish {
if servercfg.GetDebug() {
if token := client.Subscribe("#", 2, mqtt.MessageHandler(DefaultHandler)); token.Wait() && token.Error() != nil {
client.Disconnect(240)
logger.Log(0, "default subscription failed")
}
}
if token := client.Subscribe("ping/#", 2, mqtt.MessageHandler(Ping)); token.Wait() && token.Error() != nil { if token := client.Subscribe("ping/#", 2, mqtt.MessageHandler(Ping)); token.Wait() && token.Error() != nil {
client.Disconnect(240) client.Disconnect(240)
logger.Log(0, "ping subscription failed") logger.Log(0, "ping subscription failed")

View File

@@ -18,7 +18,7 @@ func Join(cfg *config.ClientConfig, privateKey string) error {
var err error var err error
//join network //join network
err = functions.JoinNetwork(cfg, privateKey) err = functions.JoinNetwork(cfg, privateKey)
if err != nil && !cfg.DebugOn { if err != nil {
if !strings.Contains(err.Error(), "ALREADY_INSTALLED") { if !strings.Contains(err.Error(), "ALREADY_INSTALLED") {
logger.Log(1, "error installing: ", err.Error()) logger.Log(1, "error installing: ", err.Error())
err = functions.LeaveNetwork(cfg.Network, true) err = functions.LeaveNetwork(cfg.Network, true)

View File

@@ -28,7 +28,6 @@ type ClientConfig struct {
Network string `yaml:"network"` Network string `yaml:"network"`
Daemon string `yaml:"daemon"` Daemon string `yaml:"daemon"`
OperatingSystem string `yaml:"operatingsystem"` OperatingSystem string `yaml:"operatingsystem"`
DebugOn bool `yaml:"debugon"`
} }
// ServerConfig - struct for dealing with the server information for a netclient // ServerConfig - struct for dealing with the server information for a netclient

View File

@@ -114,13 +114,6 @@ func UpdateKeys(nodeCfg *config.ClientConfig, client mqtt.Client) error {
// sets MQ client subscriptions for a specific node config // sets MQ client subscriptions for a specific node config
// should be called for each node belonging to a given server // should be called for each node belonging to a given server
func setSubscriptions(client mqtt.Client, nodeCfg *config.ClientConfig) { func setSubscriptions(client mqtt.Client, nodeCfg *config.ClientConfig) {
if nodeCfg.DebugOn {
if token := client.Subscribe("#", 0, nil); token.Wait() && token.Error() != nil {
logger.Log(0, token.Error().Error())
return
}
logger.Log(0, "subscribed to all topics for debugging purposes")
}
if token := client.Subscribe(fmt.Sprintf("update/%s/%s", nodeCfg.Node.Network, nodeCfg.Node.ID), 0, mqtt.MessageHandler(NodeUpdate)); token.Wait() && token.Error() != nil { if token := client.Subscribe(fmt.Sprintf("update/%s/%s", nodeCfg.Node.Network, nodeCfg.Node.ID), 0, mqtt.MessageHandler(NodeUpdate)); token.Wait() && token.Error() != nil {
logger.Log(0, token.Error().Error()) logger.Log(0, token.Error().Error())
return return

View File

@@ -78,7 +78,6 @@ func GetServerConfig() config.ServerConfig {
} else { } else {
cfg.RCE = "off" cfg.RCE = "off"
} }
cfg.Debug = GetDebug()
cfg.Telemetry = Telemetry() cfg.Telemetry = Telemetry()
cfg.ManageIPTables = ManageIPTables() cfg.ManageIPTables = ManageIPTables()
services := strings.Join(GetPortForwardServiceList(), ",") services := strings.Join(GetPortForwardServiceList(), ",")
@@ -546,8 +545,3 @@ func GetAzureTenant() string {
func GetRce() bool { func GetRce() bool {
return os.Getenv("RCE") == "on" || config.Config.Server.RCE == "on" return os.Getenv("RCE") == "on" || config.Config.Server.RCE == "on"
} }
// GetDebug -- checks if debugging is enabled, off by default
func GetDebug() bool {
return os.Getenv("DEBUG") == "on" || config.Config.Server.Debug == true
}