add turn config to server config

This commit is contained in:
Abhishek Kondur 2023-03-22 11:09:50 +04:00
parent cafdfa70c1
commit 91b4d237c8
2 changed files with 6 additions and 7 deletions

View file

@ -1,7 +1,6 @@
package models
import (
"net"
"strings"
jwt "github.com/golang-jwt/jwt/v4"
@ -233,7 +232,8 @@ type ServerConfig struct {
StunPort int `yaml:"stun_port"`
StunList []StunServer `yaml:"stun_list"`
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

View file

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