Browse Source

add turn config to server config

Abhishek Kondur 2 years ago
parent
commit
91b4d237c8
2 changed files with 6 additions and 7 deletions
  1. 2 2
      models/structs.go
  2. 4 5
      servercfg/serverconf.go

+ 2 - 2
models/structs.go

@@ -1,7 +1,6 @@
 package models
 package models
 
 
 import (
 import (
-	"net"
 	"strings"
 	"strings"
 
 
 	jwt "github.com/golang-jwt/jwt/v4"
 	jwt "github.com/golang-jwt/jwt/v4"
@@ -233,7 +232,8 @@ type ServerConfig struct {
 	StunPort    int          `yaml:"stun_port"`
 	StunPort    int          `yaml:"stun_port"`
 	StunList    []StunServer `yaml:"stun_list"`
 	StunList    []StunServer `yaml:"stun_list"`
 	TrafficKey  []byte       `yaml:"traffickey"`
 	TrafficKey  []byte       `yaml:"traffickey"`
-	TurnServer  *net.UDPAddr `yaml:"turn_server"`
+	TurnDomain  string       `yaml:"turn_domain"`
+	TurnPort    int          `yaml:"turn_port"`
 }
 }
 
 
 // User.NameInCharset - returns if name is in charset below or not
 // User.NameInCharset - returns if name is in charset below or not

+ 4 - 5
servercfg/serverconf.go

@@ -2,9 +2,7 @@ package servercfg
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"fmt"
 	"io"
 	"io"
-	"net"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
 	"strconv"
 	"strconv"
@@ -104,7 +102,8 @@ func GetServerInfo() models.ServerConfig {
 	cfg.Is_EE = Is_EE
 	cfg.Is_EE = Is_EE
 	cfg.StunPort = GetStunPort()
 	cfg.StunPort = GetStunPort()
 	cfg.StunList = GetStunList()
 	cfg.StunList = GetStunList()
-	cfg.TurnServer, _ = net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", GetTurnHost(), GetTurnPort()))
+	cfg.TurnDomain = GetTurnHost()
+	cfg.TurnPort = GetTurnPort()
 	return cfg
 	return cfg
 }
 }
 
 
@@ -183,11 +182,11 @@ func GetAPIPort() string {
 // GetStunList - gets the stun servers
 // GetStunList - gets the stun servers
 func GetStunList() []models.StunServer {
 func GetStunList() []models.StunServer {
 	stunList := []models.StunServer{
 	stunList := []models.StunServer{
-		models.StunServer{
+		{
 			Domain: "stun1.netmaker.io",
 			Domain: "stun1.netmaker.io",
 			Port:   3478,
 			Port:   3478,
 		},
 		},
-		models.StunServer{
+		{
 			Domain: "stun2.netmaker.io",
 			Domain: "stun2.netmaker.io",
 			Port:   3478,
 			Port:   3478,
 		},
 		},