Skip to content

Commit

Permalink
Ignore brutal server error in test
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Nov 8, 2023
1 parent e9cf54c commit 9016e6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
14 changes: 9 additions & 5 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mux

import (
"context"

Check failure on line 4 in server.go

View workflow job for this annotation

GitHub Actions / Build

File is not `gofumpt`-ed (gofumpt)
"github.com/sagernet/sing/common/debug"

Check failure on line 5 in server.go

View workflow job for this annotation

GitHub Actions / Build

File is not `gci`-ed with --skip-generated -s standard -s prefix(github.com/sagernet/) -s default --custom-order (gci)
"net"

Check failure on line 6 in server.go

View workflow job for this annotation

GitHub Actions / Build

File is not `gofumpt`-ed (gofumpt)

"github.com/sagernet/sing/common/bufio"

Check failure on line 8 in server.go

View workflow job for this annotation

GitHub Actions / Build

File is not `gci`-ed with --skip-generated -s standard -s prefix(github.com/sagernet/) -s default --custom-order (gci)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9016e6e

Please sign in to comment.