mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-04 16:33:49 +08:00
remove stunlist (#2572)
This commit is contained in:
@@ -74,7 +74,6 @@ type ServerConfig struct {
|
|||||||
NetmakerTenantID string `yaml:"netmaker_tenant_id"`
|
NetmakerTenantID string `yaml:"netmaker_tenant_id"`
|
||||||
IsPro string `yaml:"is_ee" json:"IsEE"`
|
IsPro string `yaml:"is_ee" json:"IsEE"`
|
||||||
StunPort int `yaml:"stun_port"`
|
StunPort int `yaml:"stun_port"`
|
||||||
StunList string `yaml:"stun_list"`
|
|
||||||
TurnServer string `yaml:"turn_server"`
|
TurnServer string `yaml:"turn_server"`
|
||||||
TurnApiServer string `yaml:"turn_api_server"`
|
TurnApiServer string `yaml:"turn_api_server"`
|
||||||
TurnPort int `yaml:"turn_port"`
|
TurnPort int `yaml:"turn_port"`
|
||||||
|
@@ -248,23 +248,22 @@ type NodeJoinResponse struct {
|
|||||||
|
|
||||||
// ServerConfig - struct for dealing with the server information for a netclient
|
// ServerConfig - struct for dealing with the server information for a netclient
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
CoreDNSAddr string `yaml:"corednsaddr"`
|
CoreDNSAddr string `yaml:"corednsaddr"`
|
||||||
API string `yaml:"api"`
|
API string `yaml:"api"`
|
||||||
APIPort string `yaml:"apiport"`
|
APIPort string `yaml:"apiport"`
|
||||||
DNSMode string `yaml:"dnsmode"`
|
DNSMode string `yaml:"dnsmode"`
|
||||||
Version string `yaml:"version"`
|
Version string `yaml:"version"`
|
||||||
MQPort string `yaml:"mqport"`
|
MQPort string `yaml:"mqport"`
|
||||||
MQUserName string `yaml:"mq_username"`
|
MQUserName string `yaml:"mq_username"`
|
||||||
MQPassword string `yaml:"mq_password"`
|
MQPassword string `yaml:"mq_password"`
|
||||||
Server string `yaml:"server"`
|
Server string `yaml:"server"`
|
||||||
Broker string `yaml:"broker"`
|
Broker string `yaml:"broker"`
|
||||||
IsPro bool `yaml:"isee" json:"Is_EE"`
|
IsPro bool `yaml:"isee" json:"Is_EE"`
|
||||||
StunPort int `yaml:"stun_port"`
|
StunPort int `yaml:"stun_port"`
|
||||||
StunList []StunServer `yaml:"stun_list"`
|
TrafficKey []byte `yaml:"traffickey"`
|
||||||
TrafficKey []byte `yaml:"traffickey"`
|
TurnDomain string `yaml:"turn_domain"`
|
||||||
TurnDomain string `yaml:"turn_domain"`
|
TurnPort int `yaml:"turn_port"`
|
||||||
TurnPort int `yaml:"turn_port"`
|
UseTurn bool `yaml:"use_turn"`
|
||||||
UseTurn bool `yaml:"use_turn"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// User.NameInCharset - returns if name is in charset below or not
|
// User.NameInCharset - returns if name is in charset below or not
|
||||||
@@ -290,12 +289,6 @@ type JoinData struct {
|
|||||||
Key string `json:"key" yaml:"key"`
|
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
|
// HookDetails - struct to hold hook info
|
||||||
type HookDetails struct {
|
type HookDetails struct {
|
||||||
Hook func() error
|
Hook func() error
|
||||||
|
@@ -85,7 +85,6 @@ func GetServerConfig() config.ServerConfig {
|
|||||||
cfg.FrontendURL = GetFrontendURL()
|
cfg.FrontendURL = GetFrontendURL()
|
||||||
cfg.Telemetry = Telemetry()
|
cfg.Telemetry = Telemetry()
|
||||||
cfg.Server = GetServer()
|
cfg.Server = GetServer()
|
||||||
cfg.StunList = GetStunListString()
|
|
||||||
cfg.Verbosity = GetVerbosity()
|
cfg.Verbosity = GetVerbosity()
|
||||||
cfg.IsPro = "no"
|
cfg.IsPro = "no"
|
||||||
if IsPro {
|
if IsPro {
|
||||||
@@ -112,7 +111,6 @@ func GetServerInfo() models.ServerConfig {
|
|||||||
cfg.Version = GetVersion()
|
cfg.Version = GetVersion()
|
||||||
cfg.IsPro = IsPro
|
cfg.IsPro = IsPro
|
||||||
cfg.StunPort = GetStunPort()
|
cfg.StunPort = GetStunPort()
|
||||||
cfg.StunList = GetStunList()
|
|
||||||
cfg.TurnDomain = GetTurnHost()
|
cfg.TurnDomain = GetTurnHost()
|
||||||
cfg.TurnPort = GetTurnPort()
|
cfg.TurnPort = GetTurnPort()
|
||||||
cfg.UseTurn = IsUsingTurn()
|
cfg.UseTurn = IsUsingTurn()
|
||||||
@@ -223,46 +221,6 @@ func GetAPIPort() string {
|
|||||||
return apiport
|
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
|
// GetCoreDNSAddr - gets the core dns address
|
||||||
func GetCoreDNSAddr() string {
|
func GetCoreDNSAddr() string {
|
||||||
addr, _ := GetPublicIP()
|
addr, _ := GetPublicIP()
|
||||||
@@ -784,33 +742,3 @@ func GetEnvironment() string {
|
|||||||
}
|
}
|
||||||
return ""
|
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
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user