|
@@ -85,7 +85,6 @@ func GetServerConfig() config.ServerConfig {
|
|
|
cfg.FrontendURL = GetFrontendURL()
|
|
|
cfg.Telemetry = Telemetry()
|
|
|
cfg.Server = GetServer()
|
|
|
- cfg.StunList = GetStunListString()
|
|
|
cfg.Verbosity = GetVerbosity()
|
|
|
cfg.IsPro = "no"
|
|
|
if IsPro {
|
|
@@ -112,7 +111,6 @@ func GetServerInfo() models.ServerConfig {
|
|
|
cfg.Version = GetVersion()
|
|
|
cfg.IsPro = IsPro
|
|
|
cfg.StunPort = GetStunPort()
|
|
|
- cfg.StunList = GetStunList()
|
|
|
cfg.TurnDomain = GetTurnHost()
|
|
|
cfg.TurnPort = GetTurnPort()
|
|
|
cfg.UseTurn = IsUsingTurn()
|
|
@@ -223,46 +221,6 @@ func GetAPIPort() string {
|
|
|
return apiport
|
|
|
}
|
|
|
|
|
|
-// GetStunList - gets the stun servers
|
|
|
-func GetStunList() []models.StunServer {
|
|
|
- stunList := []models.StunServer{
|
|
|
- {
|
|
|
- Domain: "stun1.netmaker.io",
|
|
|
- Port: 3478,
|
|
|
- },
|
|
|
- {
|
|
|
- Domain: "stun2.netmaker.io",
|
|
|
- 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
|
|
|
-}
|
|
|
-
|
|
|
-// GetStunList - gets the stun servers w/o parsing to struct
|
|
|
-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
|
|
|
-}
|
|
|
-
|
|
|
// GetCoreDNSAddr - gets the core dns address
|
|
|
func GetCoreDNSAddr() string {
|
|
|
addr, _ := GetPublicIP()
|
|
@@ -784,33 +742,3 @@ func GetEnvironment() string {
|
|
|
}
|
|
|
return ""
|
|
|
}
|
|
|
-
|
|
|
-// parseStunList - turn string into slice of StunServers
|
|
|
-func parseStunList(stunString string) ([]models.StunServer, error) {
|
|
|
- var err error
|
|
|
- stunServers := []models.StunServer{}
|
|
|
- stuns := strings.Split(stunString, ",")
|
|
|
- if len(stuns) == 0 {
|
|
|
- return stunServers, errors.New("no stun servers provided")
|
|
|
- }
|
|
|
- for _, stun := range stuns {
|
|
|
- stun = strings.Trim(stun, " ")
|
|
|
- stunInfo := strings.Split(stun, ":")
|
|
|
- if len(stunInfo) != 2 {
|
|
|
- continue
|
|
|
- }
|
|
|
- port, err := strconv.Atoi(stunInfo[1])
|
|
|
- if err != nil || port == 0 {
|
|
|
- continue
|
|
|
- }
|
|
|
- stunServers = append(stunServers, models.StunServer{
|
|
|
- Domain: stunInfo[0],
|
|
|
- Port: port,
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
- if len(stunServers) == 0 {
|
|
|
- err = errors.New("no stun entries parsable")
|
|
|
- }
|
|
|
- return stunServers, err
|
|
|
-}
|