add turn port to server config

This commit is contained in:
Abhishek Kondur 2023-04-06 11:30:53 +04:00
parent f54ae9ae8f
commit 5153c471d8
4 changed files with 18 additions and 1 deletions

View file

@ -31,6 +31,7 @@ services:
DEFAULT_PROXY_MODE: "off"
TURN_SERVER_HOST: "turn.NETMAKER_BASE_DOMAIN"
TURN_SERVER_API_HOST: "https://api.turn.NETMAKER_BASE_DOMAIN"
TURN_PORT: "3479"
ports:
- "3478:3478/udp"
netmaker-ui:

View file

@ -242,6 +242,7 @@ type ServerConfig struct {
TrafficKey []byte `yaml:"traffickey"`
TurnDomain string `yaml:"turn_domain"`
TurnApiDomain string `yaml:"turn_api_domain"`
TurnPort int `yaml:"turn_port"`
}
// User.NameInCharset - returns if name is in charset below or not

View file

@ -104,6 +104,7 @@ func GetServerInfo() models.ServerConfig {
cfg.StunList = GetStunList()
cfg.TurnDomain = GetTurnHost()
cfg.TurnApiDomain = GetTurnApiHost()
cfg.TurnPort = GetTurnPort()
return cfg
}
@ -649,6 +650,20 @@ func GetStunPort() int {
return port
}
// GetTurnPort - Get the port to run the turn server on
func GetTurnPort() int {
port := 3479 //default
if os.Getenv("TURN_PORT") != "" {
portInt, err := strconv.Atoi(os.Getenv("TURN_PORT"))
if err == nil {
port = portInt
}
} else if config.Config.Server.TurnPort != 0 {
port = config.Config.Server.TurnPort
}
return port
}
// IsProxyEnabled - is proxy on or off
func IsProxyEnabled() bool {
var enabled = false //default

View file

@ -16,7 +16,7 @@ func Init(r *gin.Engine) *gin.Engine {
func registerRoutes(r *gin.RouterGroup) {
r.POST("/host/register", host.Register)
r.DELETE("/host/unregister", host.Remove)
r.DELETE("/host/deregister", host.Remove)
r.GET("/status", status)
}