Browse Source

add auto update config to server yaml

Anish Mukherjee 2 years ago
parent
commit
96d7b67822
2 changed files with 12 additions and 1 deletions
  1. 1 0
      config/config.go
  2. 11 1
      servercfg/serverconf.go

+ 1 - 0
config/config.go

@@ -40,6 +40,7 @@ type ServerConfig struct {
 	ServerBrokerEndpoint string    `yaml:"serverbrokerendpoint"`
 	BrokerType           string    `yaml:"brokertype"`
 	EmqxRestEndpoint     string    `yaml:"emqxrestendpoint"`
+	NetclientAutoUpdate  string    `yaml:"netclientautoupdate"`
 	MasterKey            string    `yaml:"masterkey"`
 	DNSKey               string    `yaml:"dnskey"`
 	AllowedOrigin        string    `yaml:"allowedorigin"`

+ 11 - 1
servercfg/serverconf.go

@@ -46,6 +46,11 @@ func GetServerConfig() config.ServerConfig {
 	cfg.StunPort = GetStunPort()
 	cfg.BrokerType = GetBrokerType()
 	cfg.EmqxRestEndpoint = GetEmqxRestEndpoint()
+	if AutoUpdateEnabled() {
+		cfg.NetclientAutoUpdate = "enabled"
+	} else {
+		cfg.NetclientAutoUpdate = "disabled"
+	}
 	if IsRestBackend() {
 		cfg.RestBackend = "on"
 	}
@@ -385,7 +390,12 @@ func GetVerbosity() int32 {
 // AutoUpdateEnabled returns a boolean indicating whether netclient auto update is enabled or disabled
 // default is enabled
 func AutoUpdateEnabled() bool {
-	return os.Getenv("NETCLIENT_AUTO_UPDATE") != "disabled"
+	if os.Getenv("NETCLIENT_AUTO_UPDATE") == "disabled" {
+		return false
+	} else if config.Config.Server.NetclientAutoUpdate == "disabled" {
+		return false
+	}
+	return true
 }
 
 // IsDNSMode - should it run with DNS