Add UDP Like transport mode to snowflake

This commit is contained in:
Shelikhoo 2023-12-12 14:43:30 +00:00 committed by WofWca
parent fa122efb61
commit 457c4fbf15
8 changed files with 275 additions and 5 deletions

View file

@ -339,6 +339,16 @@ func newSession(snowflakes SnowflakeCollector) (net.PacketConn, *smux.Session, e
return nil, errors.New("handler: Received invalid Snowflake")
}
log.Println("---- Handler: snowflake assigned ----")
log.Printf("activeTransportMode = %c \n", conn.activeTransportMode)
if conn.activeTransportMode == 'u' {
packetIDConn := newPacketClientIDConn(clientID, conn)
packetConnWrapper := &packetConnWrapper{
ReadWriter: packetIDConn,
remoteAddr: dummyAddr{},
localAddr: dummyAddr{},
}
return packetConnWrapper, nil
}
// Send the magic Turbo Tunnel token.
_, err := conn.Write(turbotunnel.Token[:])
if err != nil {
@ -363,7 +373,7 @@ func newSession(snowflakes SnowflakeCollector) (net.PacketConn, *smux.Session, e
return nil, nil, err
}
// Permit coalescing the payloads of consecutive sends.
conn.SetStreamMode(true)
conn.SetStreamMode(false)
// Set the maximum send and receive window sizes to a high number
// Removes KCP bottlenecks: https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40026
conn.SetWindowSize(WindowSize, WindowSize)