From 9016e6e79c957f257b4312705be4bc357dff0951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 8 Nov 2023 11:35:23 +0800 Subject: [PATCH] Ignore brutal server error in test --- go.mod | 2 +- go.sum | 4 ++-- server.go | 14 +++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 2af3c70..87a1449 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/hashicorp/yamux v0.1.1 - github.com/sagernet/sing v0.2.18-0.20231108032954-875ad36cc6d1 + github.com/sagernet/sing v0.2.18-0.20231108035335-eab64608b6ee github.com/sagernet/smux v0.0.0-20230312102458-337ec2a5af37 golang.org/x/net v0.17.0 golang.org/x/sys v0.14.0 diff --git a/go.sum b/go.sum index cb06a24..5379dc2 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk= -github.com/sagernet/sing v0.2.18-0.20231108032954-875ad36cc6d1 h1:HDOYNiGGK3/L7WyYIM8z86K7NEVQ6CiHWMOKAMdXv4w= -github.com/sagernet/sing v0.2.18-0.20231108032954-875ad36cc6d1/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= +github.com/sagernet/sing v0.2.18-0.20231108035335-eab64608b6ee h1:WkgVOU61KpojY71cRb5ZWGMimnaW/c8nF4x7o8SqBaw= +github.com/sagernet/sing v0.2.18-0.20231108035335-eab64608b6ee/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= github.com/sagernet/smux v0.0.0-20230312102458-337ec2a5af37 h1:HuE6xSwco/Xed8ajZ+coeYLmioq0Qp1/Z2zczFaV8as= github.com/sagernet/smux v0.0.0-20230312102458-337ec2a5af37/go.mod h1:3skNSftZDJWTGVtVaM2jfbce8qHnmH/AGDRe62iNOg0= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= diff --git a/server.go b/server.go index befe257..96ef43d 100644 --- a/server.go +++ b/server.go @@ -2,6 +2,7 @@ package mux import ( "context" + "github.com/sagernet/sing/common/debug" "net" "github.com/sagernet/sing/common/bufio" @@ -34,7 +35,7 @@ type ServiceOptions struct { } func NewService(options ServiceOptions) (*Service, error) { - if options.Brutal.Enabled && !BrutalAvailable { + if options.Brutal.Enabled && !BrutalAvailable && !debug.Enabled { return nil, E.New("TCP Brutal is only supported on Linux") } return &Service{ @@ -112,11 +113,14 @@ func (s *Service) newConnection(ctx context.Context, sessionConn net.Conn, strea } err = SetBrutalOptions(sessionConn, sendBPS) if err != nil { - err = WriteBrutalResponse(conn, 0, false, E.Cause(err, "enable TCP Brutal").Error()) - if err != nil { - return E.Cause(err, "write brutal response") + // ignore error in test + if !debug.Enabled { + err = WriteBrutalResponse(conn, 0, false, E.Cause(err, "enable TCP Brutal").Error()) + if err != nil { + return E.Cause(err, "write brutal response") + } + return nil } - return nil } err = WriteBrutalResponse(conn, s.brutal.ReceiveBPS, true, "") if err != nil {