From dba954c5299a2ffbe144cddb7638479bd289756b Mon Sep 17 00:00:00 2001 From: afeiszli Date: Fri, 3 Mar 2023 10:37:04 -0500 Subject: [PATCH] add stunlist string to serverconfig --- config/config.go | 1 + servercfg/serverconf.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/config/config.go b/config/config.go index 77e67753..da3c52ca 100644 --- a/config/config.go +++ b/config/config.go @@ -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"` } diff --git a/servercfg/serverconf.go b/servercfg/serverconf.go index 0181ede5..5cbe1094 100644 --- a/servercfg/serverconf.go +++ b/servercfg/serverconf.go @@ -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 }