add stun to servercfg

This commit is contained in:
Abhishek Kondur 2022-10-26 10:53:57 +05:30
parent fb60c528e3
commit 1b92cb2442
6 changed files with 19 additions and 0 deletions

View file

@ -76,6 +76,7 @@ type ServerConfig struct {
LicenseValue string `yaml:"license_value"`
NetmakerAccountID string `yaml:"netmaker_account_id"`
IsEE string `yaml:"is_ee"`
StunPort string `yaml:"stun_port"`
}
// SQLConfig - Generic SQL Config

1
go.mod
View file

@ -100,5 +100,6 @@ require (
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gortc.io/stun v1.23.0 // indirect
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
)

2
go.sum
View file

@ -988,6 +988,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gortc.io/stun v1.23.0 h1:CpRQFjakCZMwVKTwInKbcCzlBklj62LGzD3NPdFyGrE=
gortc.io/stun v1.23.0/go.mod h1:XD5lpONVyjvV3BgOyJFNo0iv6R2oZB4L+weMqxts+zg=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 h1:oomkgU6VaQDsV6qZby2uz1Lap0eXmku8+2em3A/l700=
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2/go.mod h1:sUMDUKNB2ZcVjt92UnLy3cdGs+wDAcrPdV3JP6sVgA4=

View file

@ -25,6 +25,7 @@ import (
"github.com/gravitl/netmaker/netclient/ncutils"
"github.com/gravitl/netmaker/servercfg"
"github.com/gravitl/netmaker/serverctl"
stunserver "github.com/gravitl/netmaker/stun-server"
)
var version = "dev"
@ -170,6 +171,8 @@ func startControllers() {
if !servercfg.IsAgentBackend() && !servercfg.IsRestBackend() && !servercfg.IsMessageQueueBackend() {
logger.Log(0, "No Server Mode selected, so nothing is being served! Set Agent mode (AGENT_BACKEND) or Rest mode (REST_BACKEND) or MessageQueue (MESSAGEQUEUE_BACKEND) to 'true'.")
}
// starts the stun server
go stunserver.Start()
waitnetwork.Wait()
}

View file

@ -219,6 +219,7 @@ type ServerConfig struct {
MQPort string `yaml:"mqport"`
Server string `yaml:"server"`
Is_EE bool `yaml:"isee"`
StunPort string `yaml:"stun_port"`
}
// User.NameInCharset - returns if name is in charset below or not

View file

@ -107,6 +107,7 @@ func GetServerInfo() models.ServerConfig {
cfg.Version = GetVersion()
cfg.Server = GetServer()
cfg.Is_EE = Is_EE
cfg.StunPort = GetStunPort()
return cfg
}
@ -661,3 +662,13 @@ func GetNetmakerAccountID() string {
}
return netmakerAccountID
}
func GetStunPort() string {
port := "3478" //default
if os.Getenv("STUN_PORT") != "" {
port = os.Getenv("STUN_PORT")
} else if config.Config.Server.StunPort != "" {
port = config.Config.Server.StunPort
}
return port
}