add auto update config to server yaml

This commit is contained in:
Anish Mukherjee 2023-03-21 18:05:04 +05:30
parent 1032eb86c5
commit 96d7b67822
2 changed files with 12 additions and 1 deletions

View file

@ -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"`

View file

@ -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