|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+//go:build linux
|
|
|
2
|
+
|
|
|
3
|
+package network
|
|
|
4
|
+
|
|
|
5
|
+import (
|
|
|
6
|
+ "syscall"
|
|
|
7
|
+
|
|
|
8
|
+ "golang.org/x/sys/unix"
|
|
|
9
|
+)
|
|
|
10
|
+
|
|
|
11
|
+func setCongestionControl(conn syscall.RawConn) {
|
|
|
12
|
+ conn.Control(func(fd uintptr) { //nolint: errcheck
|
|
|
13
|
+ // BBR provides better throughput over lossy and high-latency links compared
|
|
|
14
|
+ // to the default cubic, which is especially beneficial for mobile and
|
|
|
15
|
+ // home internet clients. This is best-effort: silently ignored if the
|
|
|
16
|
+ // kernel does not have tcp_bbr available.
|
|
|
17
|
+ unix.SetsockoptString(int(fd), unix.IPPROTO_TCP, unix.TCP_CONGESTION, "bbr") //nolint: errcheck
|
|
|
18
|
+ })
|
|
|
19
|
+}
|