mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Add NewWebRTCPeer3E Initializer
This name includes [E]vent to reduce merge conflict with forward proxy change set.
This commit is contained in:
parent
9a7fcdec03
commit
36ca610d6b
1 changed files with 14 additions and 3 deletions
|
@ -36,13 +36,22 @@ type WebRTCPeer struct {
|
||||||
eventsLogger event.SnowflakeEventReceiver
|
eventsLogger event.SnowflakeEventReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWebRTCPeer constructs a WebRTC PeerConnection to a snowflake proxy.
|
func NewWebRTCPeer(config *webrtc.Configuration,
|
||||||
|
broker *BrokerChannel) (*WebRTCPeer, error) {
|
||||||
|
return NewWebRTCPeer3E(config, broker, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewWebRTCPeer3E constructs a WebRTC PeerConnection to a snowflake proxy.
|
||||||
//
|
//
|
||||||
// The creation of the peer handles the signaling to the Snowflake broker, including
|
// The creation of the peer handles the signaling to the Snowflake broker, including
|
||||||
// the exchange of SDP information, the creation of a PeerConnection, and the establishment
|
// the exchange of SDP information, the creation of a PeerConnection, and the establishment
|
||||||
// of a DataChannel to the Snowflake proxy.
|
// of a DataChannel to the Snowflake proxy.
|
||||||
func NewWebRTCPeer(config *webrtc.Configuration,
|
func NewWebRTCPeer3E(config *webrtc.Configuration,
|
||||||
broker *BrokerChannel) (*WebRTCPeer, error) {
|
broker *BrokerChannel, eventsLogger event.SnowflakeEventReceiver) (*WebRTCPeer, error) {
|
||||||
|
if eventsLogger == nil {
|
||||||
|
eventsLogger = event.NewSnowflakeEventDispatcher()
|
||||||
|
}
|
||||||
|
|
||||||
connection := new(WebRTCPeer)
|
connection := new(WebRTCPeer)
|
||||||
{
|
{
|
||||||
var buf [8]byte
|
var buf [8]byte
|
||||||
|
@ -59,6 +68,8 @@ func NewWebRTCPeer(config *webrtc.Configuration,
|
||||||
// Pipes remain the same even when DataChannel gets switched.
|
// Pipes remain the same even when DataChannel gets switched.
|
||||||
connection.recvPipe, connection.writePipe = io.Pipe()
|
connection.recvPipe, connection.writePipe = io.Pipe()
|
||||||
|
|
||||||
|
connection.eventsLogger = eventsLogger
|
||||||
|
|
||||||
err := connection.connect(config, broker)
|
err := connection.connect(config, broker)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
connection.Close()
|
connection.Close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue