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 5b1580c
Showing 1 changed file with 9 additions and 5 deletions.
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 5b1580c

Please sign in to comment.