mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Parse ICE servers with pion/ice library function
This commit is contained in:
parent
b443e99417
commit
a6a18c1a9b
2 changed files with 19 additions and 5 deletions
|
@ -37,6 +37,7 @@ import (
|
|||
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/event"
|
||||
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/nat"
|
||||
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/turbotunnel"
|
||||
"github.com/pion/ice/v2"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/xtaci/kcp-go/v5"
|
||||
"github.com/xtaci/smux"
|
||||
|
@ -269,8 +270,16 @@ func parseIceServers(addresses []string) []webrtc.ICEServer {
|
|||
}
|
||||
for _, url := range addresses {
|
||||
url = strings.TrimSpace(url)
|
||||
|
||||
// add default port, other sanity checks
|
||||
parsedURL, err := ice.ParseURL(url)
|
||||
if err != nil {
|
||||
log.Printf("Warning: Parsing ICE server %v resulted in error: %v, skipping", url, err)
|
||||
continue
|
||||
}
|
||||
|
||||
servers = append(servers, webrtc.ICEServer{
|
||||
URLs: []string{url},
|
||||
URLs: []string{parsedURL.String()},
|
||||
})
|
||||
}
|
||||
return servers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue