Cosmetic changes from dev-snowflake-udp-rebase-extradata.

https://gitlab.torproject.org/shelikhoo/snowflake/-/tree/dev-snowflake-udp-rebase-extradata
commit 59b76dc68d2ee0383c2acd91cb0f44edc46af939
This commit is contained in:
David Fifield 2024-08-01 21:37:09 +00:00
parent a93b4859c7
commit ee5f815f60
4 changed files with 11 additions and 9 deletions

View file

@ -7,15 +7,15 @@ import (
"crypto/tls" "crypto/tls"
"errors" "errors"
"fmt" "fmt"
"net/url"
"log" "log"
"net/http" "net/http"
"net/url"
"sync" "sync"
"time" "time"
"github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3"
utls "github.com/refraction-networking/utls" utls "github.com/refraction-networking/utls"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/certs" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/certs"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/messages" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/messages"
@ -125,7 +125,8 @@ func newBrokerChannelFromConfig(config ClientConfig) (*BrokerChannel, error) {
// Negotiate uses a RendezvousMethod to send the client's WebRTC SDP offer // Negotiate uses a RendezvousMethod to send the client's WebRTC SDP offer
// and receive a snowflake proxy WebRTC SDP answer in return. // and receive a snowflake proxy WebRTC SDP answer in return.
func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) ( func (bc *BrokerChannel) Negotiate(offer *webrtc.SessionDescription) (
*webrtc.SessionDescription, error) { *webrtc.SessionDescription, error,
) {
// Ideally, we could specify an `RTCIceTransportPolicy` that would handle // Ideally, we could specify an `RTCIceTransportPolicy` that would handle
// this for us. However, "public" was removed from the draft spec. // this for us. However, "public" was removed from the draft spec.
// See https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration#RTCIceTransportPolicy_enum // See https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration#RTCIceTransportPolicy_enum
@ -201,7 +202,8 @@ func NewWebRTCDialerWithEvents(broker *BrokerChannel, iceServers []webrtc.ICESer
// NewWebRTCDialerWithEventsAndProxy constructs a new WebRTCDialer. // NewWebRTCDialerWithEventsAndProxy constructs a new WebRTCDialer.
func NewWebRTCDialerWithEventsAndProxy(broker *BrokerChannel, iceServers []webrtc.ICEServer, max int, func NewWebRTCDialerWithEventsAndProxy(broker *BrokerChannel, iceServers []webrtc.ICEServer, max int,
eventLogger event.SnowflakeEventReceiver, proxy *url.URL) *WebRTCDialer { eventLogger event.SnowflakeEventReceiver, proxy *url.URL,
) *WebRTCDialer {
config := webrtc.Configuration{ config := webrtc.Configuration{
ICEServers: iceServers, ICEServers: iceServers,
} }

View file

@ -16,8 +16,8 @@ import (
"syscall" "syscall"
pt "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib" pt "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/goptlib"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/ptutil/safelog" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/ptutil/safelog"
sf "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/client/lib" sf "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/client/lib"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/proxy" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/proxy"

View file

@ -43,6 +43,7 @@ import (
"github.com/pion/ice/v2" "github.com/pion/ice/v2"
"github.com/pion/transport/v2/stdnet" "github.com/pion/transport/v2/stdnet"
"github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/event"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/messages" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/messages"
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/namematcher" "gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/namematcher"

View file

@ -55,7 +55,7 @@ const (
// WindowSize is the number of packets in the send and receive window of a KCP connection. // WindowSize is the number of packets in the send and receive window of a KCP connection.
WindowSize = 65535 WindowSize = 65535
// StreamSize controls the maximum amount of in flight data between a client and server. // StreamSize controls the maximum amount of in flight data between a client and server.
StreamSize = 1048576 //1MB StreamSize = 1048576 // 1MB
) )
// Transport is a structure with methods that conform to the Go PT v2.1 API // Transport is a structure with methods that conform to the Go PT v2.1 API
@ -66,7 +66,6 @@ type Transport struct {
// NewSnowflakeServer returns a new server-side Transport for Snowflake. // NewSnowflakeServer returns a new server-side Transport for Snowflake.
func NewSnowflakeServer(getCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)) *Transport { func NewSnowflakeServer(getCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)) *Transport {
return &Transport{getCertificate: getCertificate} return &Transport{getCertificate: getCertificate}
} }
@ -164,7 +163,6 @@ func (t *Transport) Listen(addr net.Addr, numKCPInstances int) (*SnowflakeListen
} }
return listener, nil return listener, nil
} }
type SnowflakeListener struct { type SnowflakeListener struct {
@ -182,7 +180,7 @@ type SnowflakeListener struct {
func (l *SnowflakeListener) Accept() (net.Conn, error) { func (l *SnowflakeListener) Accept() (net.Conn, error) {
select { select {
case <-l.closed: case <-l.closed:
//channel has been closed, no longer accepting connections // channel has been closed, no longer accepting connections
return nil, io.ErrClosedPipe return nil, io.ErrClosedPipe
case conn := <-l.queue: case conn := <-l.queue:
return conn, nil return conn, nil
@ -304,6 +302,7 @@ func (conn *SnowflakeClientConn) SetDeadline(t time.Time) error { return conn.st
func (conn *SnowflakeClientConn) SetReadDeadline(t time.Time) error { func (conn *SnowflakeClientConn) SetReadDeadline(t time.Time) error {
return conn.stream.SetReadDeadline(t) return conn.stream.SetReadDeadline(t)
} }
func (conn *SnowflakeClientConn) SetWriteDeadline(t time.Time) error { func (conn *SnowflakeClientConn) SetWriteDeadline(t time.Time) error {
return conn.stream.SetWriteDeadline(t) return conn.stream.SetWriteDeadline(t)
} }