diff --git a/dnstt-client/main.go b/dnstt-client/main.go index a2e8f77..1b4e672 100644 --- a/dnstt-client/main.go +++ b/dnstt-client/main.go @@ -153,6 +153,7 @@ func run(pubkey []byte, domain dns.Name, localAddr *net.TCPAddr, remoteAddr net. 0, // default resend 1, // nc=1 => congestion window off ) + conn.SetWindowSize(turbotunnel.QueueSize/2, turbotunnel.QueueSize/2) if rc := conn.SetMtu(mtu); !rc { panic(rc) } @@ -167,6 +168,7 @@ func run(pubkey []byte, domain dns.Name, localAddr *net.TCPAddr, remoteAddr net. smuxConfig := smux.DefaultConfig() smuxConfig.Version = 2 smuxConfig.KeepAliveTimeout = idleTimeout + smuxConfig.MaxStreamBuffer = 1 * 1024 * 1024 // default is 65536 sess, err := smux.Client(rw, smuxConfig) if err != nil { return fmt.Errorf("opening smux session: %v", err) diff --git a/dnstt-server/main.go b/dnstt-server/main.go index 8771fef..35a997e 100644 --- a/dnstt-server/main.go +++ b/dnstt-server/main.go @@ -241,6 +241,7 @@ func acceptStreams(conn *kcp.UDPSession, privkey []byte, upstream string) error smuxConfig := smux.DefaultConfig() smuxConfig.Version = 2 smuxConfig.KeepAliveTimeout = idleTimeout + smuxConfig.MaxStreamBuffer = 1 * 1024 * 1024 // default is 65536 sess, err := smux.Server(rw, smuxConfig) if err != nil { return err @@ -291,6 +292,7 @@ func acceptSessions(ln *kcp.Listener, privkey []byte, mtu int, upstream string) 0, // default resend 1, // nc=1 => congestion window off ) + conn.SetWindowSize(turbotunnel.QueueSize/2, turbotunnel.QueueSize/2) if rc := conn.SetMtu(mtu); !rc { panic(rc) } diff --git a/turbotunnel/consts.go b/turbotunnel/consts.go index db54589..5684bf7 100644 --- a/turbotunnel/consts.go +++ b/turbotunnel/consts.go @@ -6,7 +6,9 @@ package turbotunnel import "errors" -const queueSize = 64 +// QueueSize is the size of send and receive queues in QueuePacketConn and +// RemoteMap. +const QueueSize = 128 var errClosedPacketConn = errors.New("operation on closed connection") var errNotImplemented = errors.New("not implemented") diff --git a/turbotunnel/queuepacketconn.go b/turbotunnel/queuepacketconn.go index eb4df4b..6571de0 100644 --- a/turbotunnel/queuepacketconn.go +++ b/turbotunnel/queuepacketconn.go @@ -48,7 +48,7 @@ func NewQueuePacketConn(localAddr net.Addr, timeout time.Duration) *QueuePacketC return &QueuePacketConn{ remotes: NewRemoteMap(timeout), localAddr: localAddr, - recvQueue: make(chan taggedPacket, queueSize), + recvQueue: make(chan taggedPacket, QueueSize), closed: make(chan struct{}), } } diff --git a/turbotunnel/remotemap.go b/turbotunnel/remotemap.go index c679bfa..a3238e9 100644 --- a/turbotunnel/remotemap.go +++ b/turbotunnel/remotemap.go @@ -127,7 +127,7 @@ func (inner *remoteMapInner) Lookup(addr net.Addr, now time.Time) *remoteRecord record = &remoteRecord{ Addr: addr, LastSeen: now, - SendQueue: make(chan []byte, queueSize), + SendQueue: make(chan []byte, QueueSize), Stash: make(chan []byte, 1), } heap.Push(inner, record)