defaulting to udp transport

This commit is contained in:
Roland Osborne 2024-05-31 23:36:44 -07:00
parent 3318048ce3
commit cd801a7679
2 changed files with 16 additions and 3 deletions

View File

@ -69,6 +69,8 @@ func AddCall(w http.ResponseWriter, r *http.Request) {
calleeToken := hex.EncodeToString(calleeBin); calleeToken := hex.EncodeToString(calleeBin);
bridgeRelay.AddBridge(account.ID, callId, cardId, callerToken, calleeToken); bridgeRelay.AddBridge(account.ID, callId, cardId, callerToken, calleeToken);
turn := getDefaultIce(ice);
// create response // create response
call := Call{ call := Call{
Id: callId, Id: callId,
@ -77,10 +79,11 @@ func AddCall(w http.ResponseWriter, r *http.Request) {
CalleeToken: calleeToken, CalleeToken: calleeToken,
Ice: ice, Ice: ice,
IceService: iceService, IceService: iceService,
IceURL: ice[len(ice)-1].URLs, IceURL: turn.URLs,
IceUsername: ice[len(ice)-1].Username, IceUsername: turn.Username,
IcePassword: ice[len(ice)-1].Credential, IcePassword: turn.Credential,
KeepAlive: BridgeKeepAlive, KeepAlive: BridgeKeepAlive,
} }
WriteResponse(w, call); WriteResponse(w, call);
} }

View File

@ -5,6 +5,7 @@ import (
"net/http" "net/http"
"errors" "errors"
"bytes" "bytes"
"strings"
) )
func getIce(service bool, urls string, username string, credential string) ([]IceURL, error) { func getIce(service bool, urls string, username string, credential string) ([]IceURL, error) {
@ -45,3 +46,12 @@ func getIce(service bool, urls string, username string, credential string) ([]Ic
}, nil }, nil
} }
func getDefaultIce(ice []IceURL) IceURL, error {
for _, url := range ice {
if strings.HasSuffix(url.URLs, "?transport=udp") {
return url
}
}
return ice[0];
}