change stun port to int type

This commit is contained in:
Abhishek Kondur 2022-12-08 21:45:32 +05:30
parent 3bf78fe638
commit 79aa9893dc
3 changed files with 9 additions and 6 deletions

View file

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

View file

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

View file

@ -692,11 +692,14 @@ func GetNetmakerAccountID() string {
return netmakerAccountID
}
func GetStunPort() string {
port := "3478" //default
func GetStunPort() int {
port := 3478 //default
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
}
return port