add kcp setting adjustment SNOWFLAKE_TEST_KCP_FAST3MODE

This commit is contained in:
Shelikhoo 2023-12-19 14:59:45 +00:00 committed by WofWca
parent 93d303b47b
commit ad5edd3f01
2 changed files with 18 additions and 0 deletions

View file

@ -32,6 +32,7 @@ import (
"math/rand"
"net"
"net/url"
"os"
"strings"
"time"
@ -385,6 +386,14 @@ func newSession(snowflakes SnowflakeCollector) (net.PacketConn, *smux.Session, e
0, // default resend
1, // nc=1 => congestion window off
)
if os.Getenv("SNOWFLAKE_TEST_KCP_FAST3MODE") == "1" {
conn.SetNoDelay(
1,
10,
2,
1,
)
}
// On the KCP connection we overlay an smux session and stream.
smuxConfig := smux.DefaultConfig()
smuxConfig.Version = 2

View file

@ -41,6 +41,7 @@ import (
"log"
"net"
"net/http"
"os"
"sync"
"time"
@ -265,6 +266,14 @@ func (l *SnowflakeListener) acceptSessions(ln *kcp.Listener) error {
0, // default resend
1, // nc=1 => congestion window off
)
if os.Getenv("SNOWFLAKE_TEST_KCP_FAST3MODE") == "1" {
conn.SetNoDelay(
1,
10,
2,
1,
)
}
go func() {
defer conn.Close()
err := l.acceptStreams(conn)