Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go and manually put together TURN TLS for twilio #1

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions adapters/twilio/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ type TwilioResponse struct {
func (d *Driver) GetIceServers() (iceServers []webrtc.ICEServer, err error) {
client := &http.Client{}

if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Error("Error forming http request URL")
return nil, err
}
req, err := http.NewRequest("POST", d.Config.RequestUrl, nil)
req.SetBasicAuth(d.Config.HttpUsername, d.Config.HttpPassword)

Expand Down Expand Up @@ -79,6 +73,8 @@ func (d *Driver) GetIceServers() (iceServers []webrtc.ICEServer, err error) {
responseServers := TwilioResponse{}
json.Unmarshal([]byte(responseData), &responseServers)

tempTurnHost := ""

for _, r := range responseServers.IceServers {

info, err := stun.ParseURI(r.URL)
Expand All @@ -91,6 +87,10 @@ func (d *Driver) GetIceServers() (iceServers []webrtc.ICEServer, err error) {
continue
}

if (info.Scheme == stun.SchemeTypeTURN) {
tempTurnHost = info.Host
}

s := webrtc.ICEServer{
URLs: []string{r.URL},
}
Expand All @@ -104,5 +104,21 @@ func (d *Driver) GetIceServers() (iceServers []webrtc.ICEServer, err error) {
iceServers = append(iceServers, s)
}



//apparently if you go and make a tls turn uri it will work
s := webrtc.ICEServer{
URLs: []string{"turns:" + tempTurnHost + ":5349?transport=tcp"},
}

if responseServers.Username != "" {
s.Username = responseServers.Username
}
if responseServers.Password != "" {
s.Credential = responseServers.Password
}

iceServers = append(iceServers, s)

return iceServers, nil
}
Loading