mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Ported snowflake client to work with pion/webrtc
Modified the snowflake client to use pion/webrtc as the webrtc library. This involved a few small changes to match function signatures as well as several larger ones: - OnNegotiationNeeded is no longer supported, so CreateOffer and SetLocalDescription have been moved to a go routine called after the other peer connection callbacks are set - We need our own deserialize/serialize functions - We need to use a SettingEngine in order to access the OnICEGatheringStateChange callback
This commit is contained in:
parent
0428797ea0
commit
b5c50b69d0
6 changed files with 146 additions and 76 deletions
|
@ -17,7 +17,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/keroserene/go-webrtc"
|
||||
"github.com/pion/webrtc"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -84,7 +84,7 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
|
|||
*webrtc.SessionDescription, error) {
|
||||
log.Println("Negotiating via BrokerChannel...\nTarget URL: ",
|
||||
bc.Host, "\nFront URL: ", bc.url.Host)
|
||||
data := bytes.NewReader([]byte(offer.Serialize()))
|
||||
data := bytes.NewReader([]byte(serializeSessionDescription(offer)))
|
||||
// Suffix with broker's client registration handler.
|
||||
clientURL := bc.url.ResolveReference(&url.URL{Path: "client"})
|
||||
request, err := http.NewRequest("POST", clientURL.String(), data)
|
||||
|
@ -107,7 +107,7 @@ func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
|
|||
if nil != err {
|
||||
return nil, err
|
||||
}
|
||||
answer := webrtc.DeserializeSessionDescription(string(body))
|
||||
answer := deserializeSessionDescription(string(body))
|
||||
return answer, nil
|
||||
|
||||
case http.StatusServiceUnavailable:
|
||||
|
@ -126,15 +126,18 @@ type WebRTCDialer struct {
|
|||
}
|
||||
|
||||
func NewWebRTCDialer(
|
||||
broker *BrokerChannel, iceServers IceServerList) *WebRTCDialer {
|
||||
config := webrtc.NewConfiguration(iceServers...)
|
||||
if nil == config {
|
||||
log.Println("Unable to prepare WebRTC configuration.")
|
||||
return nil
|
||||
broker *BrokerChannel, iceServers []webrtc.ICEServer) *WebRTCDialer {
|
||||
var config webrtc.Configuration
|
||||
if iceServers == nil {
|
||||
config = webrtc.Configuration{
|
||||
ICEServers: iceServers,
|
||||
}
|
||||
} else {
|
||||
config = webrtc.Configuration{}
|
||||
}
|
||||
return &WebRTCDialer{
|
||||
BrokerChannel: broker,
|
||||
webrtcConfig: config,
|
||||
webrtcConfig: &config,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue