Skip to content

Commit

Permalink
Prioritize TURN servers according to they relay protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
jmelancongen committed Nov 22, 2023
1 parent 1c68365 commit f7a98e2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions candidate_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ func NewCandidateRelay(config *CandidateRelayConfig) (*CandidateRelay, error) {
}, nil
}

func (c *CandidateRelay) LocalPreference() uint16 {
relayPreference := uint16(0)
switch c.relayProtocol {
case "tls":
case "dtls":
relayPreference = 2
case tcp:
relayPreference = 1
case udp:
default:
relayPreference = 0
}

return c.candidateBase.LocalPreference() + relayPreference
}

// RelayProtocol returns the protocol used between the endpoint and the relay server.
func (c *CandidateRelay) RelayProtocol() string {
return c.relayProtocol
Expand Down

0 comments on commit f7a98e2

Please sign in to comment.