Browse Source

add turn port to server config

Abhishek Kondur 2 years ago
parent
commit
5153c471d8
4 changed files with 18 additions and 1 deletions
  1. 1 0
      compose/docker-compose.yml
  2. 1 0
      models/structs.go
  3. 15 0
      servercfg/serverconf.go
  4. 1 1
      turnserver/src/routes/routes.go

+ 1 - 0
compose/docker-compose.yml

@@ -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:

+ 1 - 0
models/structs.go

@@ -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

+ 15 - 0
servercfg/serverconf.go

@@ -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

+ 1 - 1
turnserver/src/routes/routes.go

@@ -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)
 }