Browse Source

add turn config to host model

Abhishek Kondur 2 years ago
parent
commit
851fdbfee1
3 changed files with 14 additions and 8 deletions
  1. 2 0
      logic/peers.go
  2. 2 0
      models/host.go
  3. 10 8
      models/proxy.go

+ 2 - 0
logic/peers.go

@@ -97,6 +97,8 @@ func GetProxyUpdateForHost(ctx context.Context, host *models.Host) (models.Proxy
 					Proxy:            peerHost.ProxyEnabled,
 					Proxy:            peerHost.ProxyEnabled,
 					PublicListenPort: int32(GetPeerListenPort(peerHost)),
 					PublicListenPort: int32(GetPeerListenPort(peerHost)),
 					ProxyListenPort:  GetProxyListenPort(peerHost),
 					ProxyListenPort:  GetProxyListenPort(peerHost),
+					ShouldUseTurn:    peerHost.ShouldUseTurn,
+					TurnRelayAddr:    peerHost.TurnRelayAddr,
 				}
 				}
 			}
 			}
 
 

+ 2 - 0
models/host.go

@@ -54,6 +54,8 @@ type Host struct {
 	Interfaces       []Iface          `json:"interfaces" yaml:"interfaces"`
 	Interfaces       []Iface          `json:"interfaces" yaml:"interfaces"`
 	DefaultInterface string           `json:"defaultinterface" yaml:"defaultinterface"`
 	DefaultInterface string           `json:"defaultinterface" yaml:"defaultinterface"`
 	EndpointIP       net.IP           `json:"endpointip" yaml:"endpointip"`
 	EndpointIP       net.IP           `json:"endpointip" yaml:"endpointip"`
+	ShouldUseTurn    bool             `json:"should_use_turn" yaml:"should_use_turn"`
+	TurnRelayAddr    net.PacketConn   `json:"turn_relay_addr" yaml:"turn_relay_addr"`
 	ProxyEnabled     bool             `json:"proxy_enabled" yaml:"proxy_enabled"`
 	ProxyEnabled     bool             `json:"proxy_enabled" yaml:"proxy_enabled"`
 	ProxyEnabledSet  bool             `json:"proxy_enabled_updated" yaml:"proxy_enabled_updated"`
 	ProxyEnabledSet  bool             `json:"proxy_enabled_updated" yaml:"proxy_enabled_updated"`
 	IsDocker         bool             `json:"isdocker" yaml:"isdocker"`
 	IsDocker         bool             `json:"isdocker" yaml:"isdocker"`

+ 10 - 8
models/proxy.go

@@ -35,14 +35,16 @@ type RelayedConf struct {
 
 
 // PeerConf - struct for peer config in the network
 // PeerConf - struct for peer config in the network
 type PeerConf struct {
 type PeerConf struct {
-	Proxy            bool         `json:"proxy"`
-	PublicListenPort int32        `json:"public_listen_port"`
-	ProxyListenPort  int          `json:"proxy_listen_port"`
-	IsExtClient      bool         `json:"is_ext_client"`
-	Address          net.IP       `json:"address"`
-	ExtInternalIp    net.IP       `json:"ext_internal_ip"`
-	IsRelayed        bool         `json:"is_relayed"`
-	RelayedTo        *net.UDPAddr `json:"relayed_to"`
+	Proxy            bool           `json:"proxy"`
+	PublicListenPort int32          `json:"public_listen_port"`
+	ProxyListenPort  int            `json:"proxy_listen_port"`
+	IsExtClient      bool           `json:"is_ext_client"`
+	Address          net.IP         `json:"address"`
+	ExtInternalIp    net.IP         `json:"ext_internal_ip"`
+	IsRelayed        bool           `json:"is_relayed"`
+	RelayedTo        *net.UDPAddr   `json:"relayed_to"`
+	ShouldUseTurn    bool           `json:"should_use_turn"`
+	TurnRelayAddr    net.PacketConn `json:"turn_relay_addr"`
 }
 }
 
 
 // ProxyManagerPayload - struct for proxy manager payload
 // ProxyManagerPayload - struct for proxy manager payload