mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-03 20:35:54 +02:00
ICE servers as URIs with auth.
This commit is contained in:
parent
0824c24bf6
commit
a1be9002f7
1 changed files with 30 additions and 0 deletions
|
@ -3,6 +3,7 @@ package webrtc
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -423,6 +424,35 @@ func (manager *WebRTCManagerCtx) apiConfiguration() *webrtc.Configuration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ICEServers := []webrtc.ICEServer{}
|
||||||
|
for _, server := range manager.config.ICEServers {
|
||||||
|
u, err := url.Parse(server)
|
||||||
|
|
||||||
|
// if it is not valid URL, just pass it down
|
||||||
|
if err != nil {
|
||||||
|
ICEServers = append(ICEServers, webrtc.ICEServer{
|
||||||
|
URLs: []string{server},
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var pwdInt interface{}
|
||||||
|
pwd, ok := u.User.Password()
|
||||||
|
if ok {
|
||||||
|
pwdInt = pwd
|
||||||
|
} else {
|
||||||
|
pwdInt = false
|
||||||
|
}
|
||||||
|
|
||||||
|
ICEServers = append(ICEServers, webrtc.ICEServer{
|
||||||
|
URLs: []string{
|
||||||
|
u.Scheme + ":" + u.Host + u.Path + "?" + u.RawQuery,
|
||||||
|
},
|
||||||
|
Username: u.User.Username(),
|
||||||
|
Credential: pwdInt,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return &webrtc.Configuration{
|
return &webrtc.Configuration{
|
||||||
ICEServers: []webrtc.ICEServer{
|
ICEServers: []webrtc.ICEServer{
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue