Browse Source

change stun port to int type

Abhishek Kondur 2 years ago
parent
commit
79aa9893dc
3 changed files with 9 additions and 6 deletions
  1. 1 1
      config/config.go
  2. 1 1
      models/structs.go
  3. 7 4
      servercfg/serverconf.go

+ 1 - 1
config/config.go

@@ -77,7 +77,7 @@ type ServerConfig struct {
 	LicenseValue          string `yaml:"license_value"`
 	LicenseValue          string `yaml:"license_value"`
 	NetmakerAccountID     string `yaml:"netmaker_account_id"`
 	NetmakerAccountID     string `yaml:"netmaker_account_id"`
 	IsEE                  string `yaml:"is_ee"`
 	IsEE                  string `yaml:"is_ee"`
-	StunPort              string `yaml:"stun_port"`
+	StunPort              int    `yaml:"stun_port"`
 	StunHost              string `yaml:"stun_host"`
 	StunHost              string `yaml:"stun_host"`
 	Proxy                 string `yaml:"proxy"`
 	Proxy                 string `yaml:"proxy"`
 }
 }

+ 1 - 1
models/structs.go

@@ -222,7 +222,7 @@ type ServerConfig struct {
 	Server      string `yaml:"server"`
 	Server      string `yaml:"server"`
 	Broker      string `yaml:"broker"`
 	Broker      string `yaml:"broker"`
 	Is_EE       bool   `yaml:"isee"`
 	Is_EE       bool   `yaml:"isee"`
-	StunPort    string `yaml:"stun_port"`
+	StunPort    int    `yaml:"stun_port"`
 	StunHost    string `yaml:"stun_host"`
 	StunHost    string `yaml:"stun_host"`
 }
 }
 
 

+ 7 - 4
servercfg/serverconf.go

@@ -692,11 +692,14 @@ func GetNetmakerAccountID() string {
 	return netmakerAccountID
 	return netmakerAccountID
 }
 }
 
 
-func GetStunPort() string {
-	port := "3478" //default
+func GetStunPort() int {
+	port := 3478 //default
 	if os.Getenv("STUN_PORT") != "" {
 	if os.Getenv("STUN_PORT") != "" {
-		port = os.Getenv("STUN_PORT")
-	} else if config.Config.Server.StunPort != "" {
+		portInt, err := strconv.Atoi(os.Getenv("STUN_PORT"))
+		if err == nil {
+			port = portInt
+		}
+	} else if config.Config.Server.StunPort != 0 {
 		port = config.Config.Server.StunPort
 		port = config.Config.Server.StunPort
 	}
 	}
 	return port
 	return port