close #237, add linux bbr

This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent 986c9c2eda
commit 825d60c7d4
3 changed files with 13 additions and 1 deletions

View File

@@ -27,6 +27,8 @@ users = [ {user = "a684455c-b14f-11ea-bf0d-42010aaa0004"} , {user = "a684455c-b1
# extra.tls_rejectUnknownSni = true # 这个开启了的话,防御效果更佳, 不过, 这要求你有真实证书
#sockopt.bbr = true #用户空间的bbr拥塞控制, 仅限linux, see issue #237
[[listen]]
tag = "my_ws1"
protocol = "vlesss"

View File

@@ -9,6 +9,7 @@ import (
type Sockopt struct {
TProxy bool `toml:"tproxy"` //only linux
Somark int `toml:"mark"` //only linux
BBR bool `toml:"bbr"` //only linux
Device string `toml:"device"`
//fastopen 不予支持, 因为自己客户端在重重网关之下不可能让层层网关都支持tcp fast open

View File

@@ -1,9 +1,10 @@
package netLayer
import (
"syscall"
"go.uber.org/zap"
"golang.org/x/sys/unix"
"syscall"
"github.com/e1732a364fed/v2ray_simple/utils"
)
@@ -29,6 +30,14 @@ func SetSockOpt(fd int, sockopt *Sockopt, isudp bool, isipv6 bool) {
bindToDevice(fd, sockopt.Device)
}
if sockopt.BBR {
if err := syscall.SetsockoptString(fd, syscall.SOL_TCP, syscall.TCP_CONGESTION, "bbr"); err != nil {
if ce := utils.CanLogErr("bbr failed"); ce != nil {
ce.Write(zap.Error(err))
}
}
}
}
func bindToDevice(fd int, device string) {