mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 14:11:23 -04:00
Remove WebRTCPeer.activeTransportMode.
Make "u" mode the assumed default. The WebRTC data channel protocol contains just the hex clientID.
This commit is contained in:
parent
568a0999d2
commit
490502691d
3 changed files with 13 additions and 82 deletions
|
@ -331,11 +331,6 @@ func parseIceServers(addresses []string) []webrtc.ICEServer {
|
|||
// over. The net.PacketConn successively connects through Snowflake proxies
|
||||
// pulled from snowflakes.
|
||||
func newSession(snowflakes SnowflakeCollector, clientIDCandid turbotunnel.ClientID) (net.PacketConn, *smux.Session, error) {
|
||||
clientID := turbotunnel.NewClientID()
|
||||
if clientIDCandid != (turbotunnel.ClientID{}) {
|
||||
clientID = clientIDCandid
|
||||
}
|
||||
|
||||
// We build a persistent KCP session on a sequence of ephemeral WebRTC
|
||||
// connections. This dialContext tells RedialPacketConn how to get a new
|
||||
// WebRTC connection when the previous one dies. Inside each WebRTC
|
||||
|
@ -349,26 +344,12 @@ func newSession(snowflakes SnowflakeCollector, clientIDCandid turbotunnel.Client
|
|||
return nil, errors.New("handler: Received invalid Snowflake")
|
||||
}
|
||||
log.Println("---- Handler: snowflake assigned ----")
|
||||
log.Printf("activeTransportMode = %c \n", conn.activeTransportMode)
|
||||
if conn.activeTransportMode == 'u' {
|
||||
packetConnWrapper := &packetConnWrapper{
|
||||
ReadWriter: conn,
|
||||
remoteAddr: dummyAddr{},
|
||||
localAddr: dummyAddr{},
|
||||
}
|
||||
return packetConnWrapper, nil
|
||||
packetConnWrapper := &packetConnWrapper{
|
||||
ReadWriter: conn,
|
||||
remoteAddr: dummyAddr{},
|
||||
localAddr: dummyAddr{},
|
||||
}
|
||||
// Send the magic Turbo Tunnel token.
|
||||
_, err := conn.Write(turbotunnel.Token[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Send ClientID prefix.
|
||||
_, err = conn.Write(clientID[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newEncapsulationPacketConn(dummyAddr{}, dummyAddr{}, conn), nil
|
||||
return packetConnWrapper, nil
|
||||
}
|
||||
pconn := turbotunnel.NewRedialPacketConn(dummyAddr{}, dummyAddr{}, dialContext)
|
||||
|
||||
|
|
|
@ -46,8 +46,7 @@ type WebRTCPeer struct {
|
|||
eventsLogger event.SnowflakeEventReceiver
|
||||
proxy *url.URL
|
||||
|
||||
activeTransportMode byte
|
||||
clientID turbotunnel.ClientID
|
||||
clientID turbotunnel.ClientID
|
||||
}
|
||||
|
||||
// Deprecated: Use NewWebRTCPeerWithNatPolicyAndEventsAndProxy Instead.
|
||||
|
@ -212,7 +211,6 @@ func (c *WebRTCPeer) connect(
|
|||
) error {
|
||||
log.Println(c.id, " connecting...")
|
||||
|
||||
c.activeTransportMode = 'u'
|
||||
err := c.preparePeerConnection(config, broker.keepLocalAddresses)
|
||||
localDescription := c.pc.LocalDescription()
|
||||
c.eventsLogger.OnNewSnowflakeEvent(event.EventOnOfferCreated{
|
||||
|
@ -318,18 +316,13 @@ func (c *WebRTCPeer) preparePeerConnection(
|
|||
log.Printf("NewPeerConnection ERROR: %s", err)
|
||||
return err
|
||||
}
|
||||
ordered := true
|
||||
var maxRetransmission *uint16
|
||||
if c.activeTransportMode == 'u' {
|
||||
ordered = false
|
||||
maxRetransmissionVal := uint16(0)
|
||||
maxRetransmission = &maxRetransmissionVal
|
||||
}
|
||||
protocol := fmt.Sprintf("%c %s", c.activeTransportMode, c.clientID.String())
|
||||
ordered := false
|
||||
var maxRetransmission uint16 = 0
|
||||
protocol := fmt.Sprintf("%s", c.clientID.String())
|
||||
dataChannelOptions := &webrtc.DataChannelInit{
|
||||
Ordered: &ordered,
|
||||
Protocol: &protocol,
|
||||
MaxRetransmits: maxRetransmission,
|
||||
MaxRetransmits: &maxRetransmission,
|
||||
}
|
||||
// We must create the data channel before creating an offer
|
||||
// https://github.com/pion/webrtc/wiki/Release-WebRTC@v3.0.0#a-data-channel-is-no-longer-implicitly-created-with-a-peerconnection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue