add stunlist string to serverconfig

This commit is contained in:
afeiszli 2023-03-03 10:37:04 -05:00
parent bf8a5bbc69
commit dba954c529
2 changed files with 20 additions and 0 deletions

View file

@ -72,6 +72,7 @@ type ServerConfig struct {
NetmakerAccountID string `yaml:"netmaker_account_id"`
IsEE string `yaml:"is_ee"`
StunPort int `yaml:"stun_port"`
StunList string `yaml:"stun_list"`
Proxy string `yaml:"proxy"`
}

View file

@ -73,6 +73,7 @@ func GetServerConfig() config.ServerConfig {
cfg.FrontendURL = GetFrontendURL()
cfg.Telemetry = Telemetry()
cfg.Server = GetServer()
cfg.StunList = GetStunListString()
cfg.Verbosity = GetVerbosity()
cfg.IsEE = "no"
if Is_EE {
@ -188,12 +189,30 @@ func GetStunList() []models.StunServer {
Port: 3478,
},
}
parsed := false
if os.Getenv("STUN_LIST") != "" {
stuns, err := parseStunList(os.Getenv("STUN_LIST"))
if err == nil {
parsed = true
stunList = stuns
}
}
if !parsed && config.Config.Server.StunList != "" {
stuns, err := parseStunList(config.Config.Server.StunList)
if err == nil {
stunList = stuns
}
}
return stunList
}
func GetStunListString() string {
stunList := "stun1.netmaker.io:3478,stun2.netmaker.io:3478"
if os.Getenv("STUN_LIST") != "" {
stunList = os.Getenv("STUN_LIST")
} else if config.Config.Server.StunList != "" {
stunList = config.Config.Server.StunList
}
return stunList
}