diff --git a/controllers/hosts.go b/controllers/hosts.go index 145743b7..ede7d53c 100644 --- a/controllers/hosts.go +++ b/controllers/hosts.go @@ -124,9 +124,6 @@ func pull(w http.ResponseWriter, r *http.Request) { return } serverConf := servercfg.GetServerInfo() - if servercfg.GetBrokerType() == servercfg.EmqxBrokerType { - serverConf.MQUserName = hostID - } key, keyErr := logic.RetrievePublicTrafficKey() if keyErr != nil { logger.Log(0, "error retrieving key:", keyErr.Error()) diff --git a/servercfg/serverconf.go b/servercfg/serverconf.go index 7c5397dc..31f854a9 100644 --- a/servercfg/serverconf.go +++ b/servercfg/serverconf.go @@ -117,8 +117,13 @@ func GetRacAutoDisable() bool { func GetServerInfo() models.ServerConfig { var cfg models.ServerConfig cfg.Server = GetServer() - cfg.MQUserName = GetMqUserName() - cfg.MQPassword = GetMqPassword() + if GetBrokerType() == EmqxBrokerType { + cfg.MQUserName = "HOST_ID" + cfg.MQPassword = "HOST_PASS" + } else { + cfg.MQUserName = GetMqUserName() + cfg.MQPassword = GetMqPassword() + } cfg.API = GetAPIConnString() cfg.CoreDNSAddr = GetCoreDNSAddr() cfg.APIPort = GetAPIPort()