diff --git a/config/config.go b/config/config.go index 20a55b253..2ebcc1af9 100644 --- a/config/config.go +++ b/config/config.go @@ -74,7 +74,6 @@ type ServerConfig struct { NetmakerTenantID string `yaml:"netmaker_tenant_id"` IsPro string `yaml:"is_ee" json:"IsEE"` StunPort int `yaml:"stun_port"` - StunList string `yaml:"stun_list"` TurnServer string `yaml:"turn_server"` TurnApiServer string `yaml:"turn_api_server"` TurnPort int `yaml:"turn_port"` diff --git a/models/structs.go b/models/structs.go index eed8f4478..bf8605730 100644 --- a/models/structs.go +++ b/models/structs.go @@ -248,23 +248,22 @@ type NodeJoinResponse struct { // ServerConfig - struct for dealing with the server information for a netclient type ServerConfig struct { - CoreDNSAddr string `yaml:"corednsaddr"` - API string `yaml:"api"` - APIPort string `yaml:"apiport"` - DNSMode string `yaml:"dnsmode"` - Version string `yaml:"version"` - MQPort string `yaml:"mqport"` - MQUserName string `yaml:"mq_username"` - MQPassword string `yaml:"mq_password"` - Server string `yaml:"server"` - Broker string `yaml:"broker"` - IsPro bool `yaml:"isee" json:"Is_EE"` - StunPort int `yaml:"stun_port"` - StunList []StunServer `yaml:"stun_list"` - TrafficKey []byte `yaml:"traffickey"` - TurnDomain string `yaml:"turn_domain"` - TurnPort int `yaml:"turn_port"` - UseTurn bool `yaml:"use_turn"` + CoreDNSAddr string `yaml:"corednsaddr"` + API string `yaml:"api"` + APIPort string `yaml:"apiport"` + DNSMode string `yaml:"dnsmode"` + Version string `yaml:"version"` + MQPort string `yaml:"mqport"` + MQUserName string `yaml:"mq_username"` + MQPassword string `yaml:"mq_password"` + Server string `yaml:"server"` + Broker string `yaml:"broker"` + IsPro bool `yaml:"isee" json:"Is_EE"` + StunPort int `yaml:"stun_port"` + TrafficKey []byte `yaml:"traffickey"` + TurnDomain string `yaml:"turn_domain"` + TurnPort int `yaml:"turn_port"` + UseTurn bool `yaml:"use_turn"` } // User.NameInCharset - returns if name is in charset below or not @@ -290,12 +289,6 @@ type JoinData struct { Key string `json:"key" yaml:"key"` } -// StunServer - struct to hold data required for using stun server -type StunServer struct { - Domain string `json:"domain" yaml:"domain"` - Port int `json:"port" yaml:"port"` -} - // HookDetails - struct to hold hook info type HookDetails struct { Hook func() error diff --git a/servercfg/serverconf.go b/servercfg/serverconf.go index c0b2341cf..8d8380438 100644 --- a/servercfg/serverconf.go +++ b/servercfg/serverconf.go @@ -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 -}