afeiszli 3 éve
szülő
commit
6e0aacfc82

+ 1 - 0
compose/docker-compose.contained.yml

@@ -33,6 +33,7 @@ services:
       DATABASE: "sqlite"
       NODE_ID: "netmaker-server-1"
       MQ_HOST: "mq"
+      MQ_PUBLIC_PORT: "8883"
       HOST_NETWORK: "off"
       VERBOSITY: "1"
       MANAGE_IPTABLES: "on"

+ 1 - 0
config/config.go

@@ -66,6 +66,7 @@ type ServerConfig struct {
 	PortForwardServices   string `yaml:"portforwardservices"`
 	HostNetwork           string `yaml:"hostnetwork"`
 	MQPort                string `yaml:"mqport"`
+	MQPublicPort          string `yaml:"mqpublicport"`
 	Server                string `yaml:"server"`
 }
 

+ 5 - 4
netclient/config/config.go

@@ -30,10 +30,11 @@ type ClientConfig struct {
 
 // ServerConfig - struct for dealing with the server information for a netclient
 type ServerConfig struct {
-	CoreDNSAddr string `yaml:"corednsaddr"`
-	AccessKey   string `yaml:"accesskey"`
-	Server      string `yaml:"server"`
-	API         string `yaml:"api"`
+	CoreDNSAddr  string `yaml:"corednsaddr"`
+	AccessKey    string `yaml:"accesskey"`
+	Server       string `yaml:"server"`
+	MQPublicPort string `yaml:"mqpublicport"`
+	API          string `yaml:"api"`
 }
 
 // RegisterRequest - struct for registation with netmaker server

+ 5 - 1
netclient/functions/daemon.go

@@ -208,7 +208,11 @@ func NewTLSConfig(server string) *tls.Config {
 func setupMQTT(cfg *config.ClientConfig, publish bool) (mqtt.Client, error) {
 	opts := mqtt.NewClientOptions()
 	server := cfg.Server.Server
-	opts.AddBroker("ssl://" + server + ":8883") // TODO get the appropriate port of the comms mq server
+	mqport := cfg.Server.MQPublicPort
+	if mqport == "" {
+		mqport = "8883"
+	}
+	opts.AddBroker("ssl://" + server + ":" + mqport) // TODO get the appropriate port of the comms mq server
 	opts.SetTLSConfig(NewTLSConfig(server))
 	opts.SetClientID(ncutils.MakeRandomString(23))
 	opts.SetDefaultPublishHandler(All)

+ 1 - 0
netclient/functions/join.go

@@ -169,6 +169,7 @@ func JoinNetwork(cfg *config.ClientConfig, privateKey string) error {
 		}
 	}
 	logger.Log(1, "node created on remote server...updating configs")
+
 	cfg.Node = node
 	logger.Log(1, "turn on UDP hole punching (dynamic port setting)? "+cfg.Node.UDPHolePunch)
 	if !manualPort && (cfg.Node.UDPHolePunch == "no") {

+ 14 - 1
servercfg/serverconf.go

@@ -35,6 +35,7 @@ func GetServerConfig() config.ServerConfig {
 	cfg.APIPort = GetAPIPort()
 	cfg.APIPort = GetAPIPort()
 	cfg.MQPort = GetMQPort()
+	cfg.MQPublicPort = GetMQPublicPort()
 	cfg.MasterKey = "(hidden)"
 	cfg.DNSKey = "(hidden)"
 	cfg.AllowedOrigin = GetAllowedOrigin()
@@ -205,6 +206,17 @@ func GetMQPort() string {
 	return mqport
 }
 
+// GetMQPort - gets the mq port
+func GetMQPublicPort() string {
+	mqport := "8883"
+	if os.Getenv("MQ_PUBLIC_PORT") != "" {
+		mqport = os.Getenv("MQ_PUBLIC_PORT")
+	} else if config.Config.Server.MQPublicPort != "" {
+		mqport = config.Config.Server.MQPublicPort
+	}
+	return mqport
+}
+
 // GetMessageQueueEndpoint - gets the message queue endpoint
 func GetMessageQueueEndpoint() string {
 	host, _ := GetPublicIP()
@@ -213,8 +225,9 @@ func GetMessageQueueEndpoint() string {
 	} else if config.Config.Server.MQHOST != "" {
 		host = config.Config.Server.MQHOST
 	}
+
 	//Do we want MQ port configurable???
-	return host + ":1883"
+	return host + GetMQPort()
 }
 
 // GetMasterKey - gets the configured master key of server