Remove WebRTCPeer.activeTransportMode.

Make "u" mode the assumed default. The WebRTC data channel protocol
contains just the hex clientID.
This commit is contained in:
David Fifield 2024-08-02 02:58:59 +00:00 committed by WofWca
parent 568a0999d2
commit 490502691d
3 changed files with 13 additions and 82 deletions

View file

@ -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