aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorCecylia Bocovich <cohosh@torproject.org>2021-07-14 14:42:17 -0400
committerCecylia Bocovich <cohosh@torproject.org>2021-08-10 15:38:11 -0400
commite6715cb4ee3e577c83bb4edc40fcc5018ac70bb7 (patch)
tree9cf1410bf91a618dd350d9bdc52cdbb92fe26412 /server
parentb203a75c41df5fca3b4b8bd41e7c98d0360f1575 (diff)
downloadsnowflake-e6715cb4ee3e577c83bb4edc40fcc5018ac70bb7.tar.gz
snowflake-e6715cb4ee3e577c83bb4edc40fcc5018ac70bb7.zip
Increase smux and QueuePacketConn buffer sizes
This should increase the maximum amount of inflight data and hopefully the performance of Snowflake, especially for clients geographically distant from proxies and the server.
Diffstat (limited to 'server')
-rw-r--r--server/lib/snowflake.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/server/lib/snowflake.go b/server/lib/snowflake.go
index 48c6d9e..aa1872f 100644
--- a/server/lib/snowflake.go
+++ b/server/lib/snowflake.go
@@ -16,6 +16,11 @@ import (
"golang.org/x/net/http2"
)
+const (
+ WindowSize = 65535
+ StreamSize = 1048576 //1MB
+)
+
// Transport is a structure with methods that conform to the Go PT v2.1 API
// https://github.com/Pluggable-Transports/Pluggable-Transports-spec/blob/master/releases/PTSpecV2.1/Pluggable%20Transport%20Specification%20v2.1%20-%20Go%20Transport%20API.pdf
type Transport struct {
@@ -168,6 +173,7 @@ func (l *SnowflakeListener) acceptStreams(conn *kcp.UDPSession) error {
smuxConfig := smux.DefaultConfig()
smuxConfig.Version = 2
smuxConfig.KeepAliveTimeout = 10 * time.Minute
+ smuxConfig.MaxStreamBuffer = StreamSize
sess, err := smux.Server(conn, smuxConfig)
if err != nil {
return err
@@ -201,7 +207,7 @@ func (l *SnowflakeListener) acceptSessions(ln *kcp.Listener) error {
conn.SetStreamMode(true)
// 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(65535, 65535)
+ conn.SetWindowSize(WindowSize, WindowSize)
// Disable the dynamic congestion window (limit only by the
// maximum of local and remote static windows).
conn.SetNoDelay(