mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 08:54:02 +03:00
Update to the latest golangci-lint
This commit is contained in:
+17
-18
@@ -1,22 +1,21 @@
|
||||
# https://golangci-lint.run/docs/configuration/file/
|
||||
|
||||
version = 2
|
||||
|
||||
[run]
|
||||
concurrency = 4
|
||||
deadline = "2m"
|
||||
tests = true
|
||||
skip-dirs = ["vendor"]
|
||||
|
||||
[output]
|
||||
format = "colored-line-number"
|
||||
|
||||
[linters]
|
||||
enable-all = true
|
||||
disable = [
|
||||
"containedctx",
|
||||
"exhaustivestruct",
|
||||
"exhaustruct",
|
||||
"gas",
|
||||
"gochecknoglobals",
|
||||
"goerr113",
|
||||
"ireturn",
|
||||
"thelper",
|
||||
"varnamelen",
|
||||
]
|
||||
# [linters]
|
||||
# enable-all = true
|
||||
# disable = [
|
||||
# "containedctx",
|
||||
# "exhaustivestruct",
|
||||
# "exhaustruct",
|
||||
# "gas",
|
||||
# "gochecknoglobals",
|
||||
# "goerr113",
|
||||
# "ireturn",
|
||||
# "thelper",
|
||||
# "varnamelen",
|
||||
# ]
|
||||
|
||||
@@ -10,6 +10,11 @@ sources = ["**/*.go", "go.mod", "go.sum"]
|
||||
outputs = ["mtg"]
|
||||
run = "go build"
|
||||
|
||||
[tasks.lint]
|
||||
description = "Run linter"
|
||||
tools.golangci-lint = "latest"
|
||||
run = "golangci-lint run"
|
||||
|
||||
[tasks.test]
|
||||
description = "Run tests"
|
||||
run = "go test -v ./..."
|
||||
|
||||
@@ -42,7 +42,7 @@ func NewStableBloomFilter(byteSize uint, errorRate float64) mtglib.AntiReplayCac
|
||||
errorRate = DefaultStableBloomFilterErrorRate
|
||||
}
|
||||
|
||||
sf := boom.NewDefaultStableBloomFilter(byteSize*8, errorRate) //nolint: gomnd
|
||||
sf := boom.NewDefaultStableBloomFilter(byteSize*8, errorRate)
|
||||
sf.SetHash(xxhash.New64())
|
||||
|
||||
return &stableBloomFilter{
|
||||
|
||||
@@ -61,7 +61,7 @@ func (a *Access) Run(cli *CLI, version string) error {
|
||||
}
|
||||
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(2) //nolint: gomnd
|
||||
wg.Add(2)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@@ -129,7 +129,7 @@ func (a *Access) getIP(ntw mtglib.Network, protocol string) net.IP {
|
||||
|
||||
defer func() {
|
||||
io.Copy(io.Discard, resp.Body) //nolint: errcheck
|
||||
resp.Body.Close()
|
||||
resp.Body.Close() //nolint: errcheck
|
||||
}()
|
||||
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
|
||||
@@ -164,7 +164,7 @@ func makeIPAllowlist(conf config.ListConfig,
|
||||
}
|
||||
|
||||
func makeEventStream(conf *config.Config, logger mtglib.Logger) (mtglib.EventStream, error) {
|
||||
factories := make([]events.ObserverFactory, 0, 2) //nolint: gomnd
|
||||
factories := make([]events.ObserverFactory, 0, 2)
|
||||
|
||||
if conf.Stats.StatsD.Enabled.Get(false) {
|
||||
statsdFactory, err := stats.NewStatsd(
|
||||
@@ -271,7 +271,7 @@ func runProxy(conf *config.Config, version string) error { //nolint: funlen
|
||||
go proxy.Serve(listener) //nolint: errcheck
|
||||
|
||||
<-ctx.Done()
|
||||
listener.Close()
|
||||
listener.Close() //nolint: errcheck
|
||||
proxy.Shutdown()
|
||||
|
||||
return nil
|
||||
|
||||
@@ -35,7 +35,7 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop,funle
|
||||
return fmt.Errorf("incorrect secret: %w", err)
|
||||
}
|
||||
|
||||
if err := conf.Concurrency.Set(strconv.FormatUint(s.Concurrency, 10)); err != nil { //nolint: gomnd
|
||||
if err := conf.Concurrency.Set(strconv.FormatUint(s.Concurrency, 10)); err != nil {
|
||||
return fmt.Errorf("incorrect concurrency: %w", err)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { //nolint: cyclop,funle
|
||||
return fmt.Errorf("incorrect prefer-ip: %w", err)
|
||||
}
|
||||
|
||||
if err := conf.DomainFrontingPort.Set(strconv.FormatUint(s.DomainFrontingPort, 10)); err != nil { //nolint: gomnd
|
||||
if err := conf.DomainFrontingPort.Set(strconv.FormatUint(s.DomainFrontingPort, 10)); err != nil {
|
||||
return fmt.Errorf("incorrect domain-fronting-port: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ type TypeConcurrency struct {
|
||||
}
|
||||
|
||||
func (t *TypeConcurrency) Set(value string) error {
|
||||
concurrencyValue, err := strconv.ParseUint(value, 10, 16) //nolint: gomnd
|
||||
concurrencyValue, err := strconv.ParseUint(value, 10, 16)
|
||||
if err != nil {
|
||||
return fmt.Errorf("value is not uint (%s): %w", value, err)
|
||||
}
|
||||
@@ -41,5 +41,5 @@ func (t TypeConcurrency) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (t TypeConcurrency) String() string {
|
||||
return strconv.FormatUint(uint64(t.Value), 10) //nolint: gomnd
|
||||
return strconv.FormatUint(uint64(t.Value), 10)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ type TypeErrorRate struct {
|
||||
}
|
||||
|
||||
func (t *TypeErrorRate) Set(value string) error {
|
||||
parsedValue, err := strconv.ParseFloat(value, 64) //nolint: gomnd
|
||||
parsedValue, err := strconv.ParseFloat(value, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("value is not a float (%s): %w", value, err)
|
||||
}
|
||||
@@ -43,5 +43,5 @@ func (t TypeErrorRate) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (t TypeErrorRate) String() string {
|
||||
return strconv.FormatFloat(t.Value, 'f', -1, 64) //nolint: gomnd
|
||||
return strconv.FormatFloat(t.Value, 'f', -1, 64)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func (t *TypeHostPort) Set(value string) error {
|
||||
return fmt.Errorf("incorrect host:port value (%v): %w", value, err)
|
||||
}
|
||||
|
||||
portValue, err := strconv.ParseUint(port, 10, 16) //nolint: gomnd
|
||||
portValue, err := strconv.ParseUint(port, 10, 16)
|
||||
if err != nil {
|
||||
return fmt.Errorf("incorrect port number (%v): %w", value, err)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ type TypePort struct {
|
||||
}
|
||||
|
||||
func (t *TypePort) Set(value string) error {
|
||||
portValue, err := strconv.ParseUint(value, 10, 16) //nolint: gomnd
|
||||
portValue, err := strconv.ParseUint(value, 10, 16)
|
||||
if err != nil {
|
||||
return fmt.Errorf("incorrect port number (%v): %w", value, err)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func captureOutput(filefp **os.File, callback func()) string {
|
||||
|
||||
callback()
|
||||
|
||||
writer.Close()
|
||||
writer.Close() //nolint: errcheck
|
||||
<-closeChan
|
||||
|
||||
return strings.TrimSpace(buf.String())
|
||||
|
||||
@@ -18,7 +18,7 @@ func (l Listener) Accept() (net.Conn, error) {
|
||||
}
|
||||
|
||||
if err := network.SetClientSocketOptions(conn, 0); err != nil {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
|
||||
return nil, fmt.Errorf("cannot set TCP options: %w", err)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func (h httpFile) Open(ctx context.Context) (io.ReadCloser, error) {
|
||||
if err != nil {
|
||||
if response != nil {
|
||||
io.Copy(io.Discard, response.Body) //nolint: errcheck
|
||||
response.Body.Close()
|
||||
response.Body.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("cannot get url %s: %w", h.url, err)
|
||||
|
||||
@@ -77,7 +77,7 @@ func (suite *HTTPTestSuite) TestOk() {
|
||||
readCloser, err := file.Open(suite.ctx)
|
||||
suite.NoError(err)
|
||||
|
||||
defer readCloser.Close()
|
||||
defer readCloser.Close() //nolint: errcheck
|
||||
|
||||
data, err := io.ReadAll(readCloser)
|
||||
suite.NoError(err)
|
||||
|
||||
@@ -19,8 +19,8 @@ import (
|
||||
var (
|
||||
fireholRegexpComment = regexp.MustCompile(`\s*#.*?$`)
|
||||
|
||||
fireholIPv4DefaultCIDR = net.CIDRMask(32, 32) //nolint: gomnd
|
||||
fireholIPv6DefaultCIDR = net.CIDRMask(128, 128) //nolint: gomnd
|
||||
fireholIPv4DefaultCIDR = net.CIDRMask(32, 32)
|
||||
fireholIPv6DefaultCIDR = net.CIDRMask(128, 128)
|
||||
)
|
||||
|
||||
// FireholUpdateCallback defines a signature of the callback that has to be
|
||||
@@ -130,7 +130,7 @@ func (f *Firehol) update() {
|
||||
return
|
||||
}
|
||||
|
||||
defer fileContent.Close()
|
||||
defer fileContent.Close() //nolint: errcheck
|
||||
|
||||
if err := f.updateFromFile(mutex, ranger, bufio.NewScanner(fileContent)); err != nil {
|
||||
logger.WarningError("update has failed", err)
|
||||
|
||||
@@ -35,7 +35,7 @@ func (suite *FireholTestSuite) SetupSuite() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer filefp.Close()
|
||||
defer filefp.Close() //nolint: errcheck
|
||||
|
||||
io.Copy(w, filefp) //nolint: errcheck
|
||||
})
|
||||
|
||||
@@ -56,7 +56,7 @@ func ParseClientHello(secret, handshake []byte) (ClientHello, error) {
|
||||
if len(handshake)-4 != int(handshakeLength) {
|
||||
return hello,
|
||||
fmt.Errorf("incorrect handshake size. manifested=%d, real=%d",
|
||||
handshakeLength, len(handshake)-4) //nolint: gomnd
|
||||
handshakeLength, len(handshake)-4)
|
||||
}
|
||||
|
||||
copy(hello.Random[:], handshake[ClientHelloRandomOffset:])
|
||||
@@ -100,7 +100,7 @@ func parseSessionID(hello *ClientHello, handshake []byte) {
|
||||
}
|
||||
|
||||
func parseCipherSuite(hello *ClientHello, handshake []byte) {
|
||||
cipherSuiteOffset := ClientHelloSessionIDOffset + len(hello.SessionID) + 3 //nolint: gomnd
|
||||
cipherSuiteOffset := ClientHelloSessionIDOffset + len(hello.SessionID) + 3
|
||||
hello.CipherSuite = binary.BigEndian.Uint16(handshake[cipherSuiteOffset : cipherSuiteOffset+2])
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func SendWelcomePacket(writer io.Writer, secret []byte, clientHello ClientHello)
|
||||
rec.Type = record.TypeApplicationData
|
||||
rec.Version = record.Version12
|
||||
|
||||
if _, err := io.CopyN(&rec.Payload, rand.Reader, int64(1024+mrand.Intn(3092))); err != nil { //nolint: gomnd
|
||||
if _, err := io.CopyN(&rec.Payload, rand.Reader, int64(1024+mrand.Intn(3092))); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ type handshakeFrame struct {
|
||||
}
|
||||
|
||||
func (h *handshakeFrame) dc() int {
|
||||
idx := int16(h.data[handshakeFrameOffsetDC]) | int16(h.data[handshakeFrameOffsetDC+1])<<8 //nolint: gomnd, lll // little endian for int16 is here
|
||||
idx := int16(h.data[handshakeFrameOffsetDC]) | int16(h.data[handshakeFrameOffsetDC+1])<<8 //nolint: lll // little endian for int16 is here
|
||||
|
||||
switch {
|
||||
case idx > 0:
|
||||
|
||||
@@ -47,12 +47,12 @@ func generateServerHanshakeFrame() serverHandshakeFrame {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if frame.data[0] == 0xef { //nolint: gomnd // taken from tg sources
|
||||
if frame.data[0] == 0xef { // taken from tg sources
|
||||
continue
|
||||
}
|
||||
|
||||
switch binary.LittleEndian.Uint32(frame.data[:4]) {
|
||||
case 0x44414548, 0x54534f50, 0x20544547, 0x4954504f, 0xeeeeeeee: //nolint: gomnd // taken from tg sources
|
||||
case 0x44414548, 0x54534f50, 0x20544547, 0x4954504f, 0xeeeeeeee: // taken from tg sources
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ import (
|
||||
)
|
||||
|
||||
func Relay(ctx context.Context, log Logger, telegramConn, clientConn essentials.Conn) {
|
||||
defer telegramConn.Close()
|
||||
defer clientConn.Close()
|
||||
defer telegramConn.Close() //nolint: errcheck
|
||||
defer clientConn.Close() //nolint: errcheck
|
||||
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
telegramConn.Close()
|
||||
clientConn.Close()
|
||||
telegramConn.Close() //nolint: errcheck
|
||||
clientConn.Close() //nolint: errcheck
|
||||
}()
|
||||
|
||||
closeChan := make(chan struct{})
|
||||
|
||||
+3
-3
@@ -110,7 +110,7 @@ func (p *Proxy) Serve(listener net.Listener) error {
|
||||
logger := p.logger.BindStr("ip", ipAddr.String())
|
||||
|
||||
if !p.allowlist.Contains(ipAddr) {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
logger.Info("ip was rejected by allowlist")
|
||||
p.eventStream.Send(p.ctx, NewEventIPAllowlisted(ipAddr))
|
||||
|
||||
@@ -118,7 +118,7 @@ func (p *Proxy) Serve(listener net.Listener) error {
|
||||
}
|
||||
|
||||
if p.blocklist.Contains(ipAddr) {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
logger.Info("ip was blacklisted")
|
||||
p.eventStream.Send(p.ctx, NewEventIPBlocklisted(ipAddr))
|
||||
|
||||
@@ -235,7 +235,7 @@ func (p *Proxy) doTelegramCall(ctx *streamContext) error {
|
||||
|
||||
encryptor, decryptor, err := obfuscated2.ServerHandshake(conn)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
|
||||
return fmt.Errorf("cannot perform obfuscated2 handshake: %w", err)
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (suite *ProxyTestSuite) SetupSuite() {
|
||||
|
||||
func (suite *ProxyTestSuite) TearDownSuite() {
|
||||
if suite.listener != nil {
|
||||
suite.listener.Close()
|
||||
suite.listener.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
if suite.p != nil {
|
||||
@@ -177,7 +177,7 @@ func (suite *ProxyTestSuite) TestHTTPSRequest() {
|
||||
resp, err := client.Get(addr) //nolint: noctx
|
||||
suite.NoError(err)
|
||||
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint: errcheck
|
||||
|
||||
suite.Equal(http.StatusOK, resp.StatusCode)
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ func (s *Secret) Set(text string) error {
|
||||
return fmt.Errorf("incorrect secret format: %w", err)
|
||||
}
|
||||
|
||||
if len(decoded) < 2 { //nolint: gomnd // we need at least 1 byte here
|
||||
if len(decoded) < 2 { // we need at least 1 byte here
|
||||
return fmt.Errorf("secret is truncated, length=%d", len(decoded))
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,11 @@ func (s *streamContext) Close() {
|
||||
s.ctxCancel()
|
||||
|
||||
if s.clientConn != nil {
|
||||
s.clientConn.Close()
|
||||
s.clientConn.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
if s.telegramConn != nil {
|
||||
s.telegramConn.Close()
|
||||
s.telegramConn.Close() //nolint: errcheck
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ func (suite *StreamContextTestSuite) SetupSuite() {
|
||||
|
||||
func (suite *StreamContextTestSuite) SetupTest() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctx = context.WithValue(ctx, "key", "value") //nolint: golint, staticcheck
|
||||
ctx = context.WithValue(ctx, "key", "value") //nolint: staticcheck
|
||||
|
||||
suite.ctxCancel = cancel
|
||||
suite.connMock = &testlib.EssentialsConnMock{}
|
||||
|
||||
@@ -56,7 +56,7 @@ func (c *circuitBreakerDialer) doClosed(ctx context.Context,
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
return nil, ctx.Err() //nolint: wrapcheck
|
||||
@@ -93,7 +93,7 @@ func (c *circuitBreakerDialer) doHalfOpened(ctx context.Context,
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
return nil, ctx.Err() //nolint: wrapcheck
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ func (d *defaultDialer) DialContext(ctx context.Context, network, address string
|
||||
|
||||
// we do not need to call to end user. End users call us.
|
||||
if err := SetServerSocketOptions(conn, 0); err != nil {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
|
||||
return nil, fmt.Errorf("cannot set socket options: %w", err)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func (suite *DefaultDialerTestSuite) TestConnectOk() {
|
||||
suite.NoError(err)
|
||||
suite.NotNil(conn)
|
||||
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
func (suite *DefaultDialerTestSuite) TestHTTPRequest() {
|
||||
@@ -59,7 +59,7 @@ func (suite *DefaultDialerTestSuite) TestHTTPRequest() {
|
||||
|
||||
resp, err := httpClient.Get(suite.MakeURL("/get")) //nolint: noctx
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
suite.NoError(err)
|
||||
|
||||
@@ -78,7 +78,7 @@ func (suite *Socks5ServerTestSuite) SetupSuite() {
|
||||
}
|
||||
|
||||
func (suite *Socks5ServerTestSuite) TearDownSuite() {
|
||||
suite.socks5Listener.Close()
|
||||
suite.socks5Listener.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
func (suite *Socks5ServerTestSuite) MakeSocks5URL(user, password string) *url.URL {
|
||||
|
||||
@@ -75,7 +75,7 @@ func (suite *LoadBalancedSocks5TestSuite) TestCannotDial() {
|
||||
func (suite *LoadBalancedSocks5TestSuite) TestDialOk() {
|
||||
resp, err := suite.httpClient.Get(suite.MakeURL("/get")) //nolint: noctx
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
suite.NoError(err)
|
||||
|
||||
@@ -34,7 +34,7 @@ func (suite *NetworkTestSuite) TestLocalHTTPRequest() {
|
||||
resp, err := client.Get(suite.httpServer.URL + "/headers") //nolint: noctx
|
||||
suite.NoError(err)
|
||||
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint: errcheck
|
||||
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
suite.NoError(err)
|
||||
@@ -59,7 +59,7 @@ func (suite *NetworkTestSuite) TestRealHTTPRequest() {
|
||||
resp, err := client.Get("https://httpbin.org/headers") //nolint: noctx
|
||||
suite.NoError(err)
|
||||
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint: errcheck
|
||||
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
suite.NoError(err)
|
||||
|
||||
@@ -16,7 +16,7 @@ func newProxyDialer(baseDialer Dialer, proxyURL *url.URL) Dialer {
|
||||
)
|
||||
|
||||
if param := params.Get("open_threshold"); param != "" {
|
||||
if intNum, err := strconv.ParseUint(param, 10, 32); err == nil { //nolint: gomnd
|
||||
if intNum, err := strconv.ParseUint(param, 10, 32); err == nil {
|
||||
openThreshold = uint32(intNum)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ func setSocketReuseAddrPort(conn syscall.RawConn) error {
|
||||
var err error
|
||||
|
||||
conn.Control(func(fd uintptr) { //nolint: errcheck
|
||||
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1) //nolint: nosnakecase
|
||||
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("cannot set SO_REUSEADDR: %w", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1) //nolint: nosnakecase
|
||||
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("cannot set SO_REUSEPORT: %w", err)
|
||||
}
|
||||
|
||||
+2
-2
@@ -36,13 +36,13 @@ func (s socks5Dialer) DialContext(ctx context.Context, network, address string)
|
||||
}
|
||||
|
||||
if err := s.handshake(conn); err != nil {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
|
||||
return nil, fmt.Errorf("cannot perform a handshake: %w", err)
|
||||
}
|
||||
|
||||
if err := s.connect(conn, address); err != nil {
|
||||
conn.Close()
|
||||
conn.Close() //nolint: errcheck
|
||||
|
||||
return nil, fmt.Errorf("cannot connect to a destination host %s: %w", address, err)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func (suite *Socks5TestSuite) TestRequestFailed() {
|
||||
|
||||
resp, err := httpClient.Get(suite.MakeURL("/get")) //nolint: noctx
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
suite.Error(err)
|
||||
@@ -48,7 +48,7 @@ func (suite *Socks5TestSuite) TestRequestOk() {
|
||||
|
||||
resp, err := httpClient.Get(suite.MakeURL("/get")) //nolint: noctx
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
suite.NoError(err)
|
||||
|
||||
@@ -30,7 +30,7 @@ func (suite *PrometheusTestSuite) Get() (string, error) {
|
||||
return "", err //nolint: wrapcheck
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint: errcheck
|
||||
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
@@ -51,7 +51,7 @@ func (suite *PrometheusTestSuite) SetupTest() {
|
||||
func (suite *PrometheusTestSuite) TearDownTest() {
|
||||
suite.prometheus.Shutdown()
|
||||
suite.NoError(suite.factory.Close())
|
||||
suite.httpListener.Close()
|
||||
suite.httpListener.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
func (suite *PrometheusTestSuite) TestTelegramPath() {
|
||||
|
||||
@@ -100,8 +100,8 @@ func (suite *StatsdTestSuite) SetupTest() {
|
||||
|
||||
func (suite *StatsdTestSuite) TearDownTest() {
|
||||
suite.statsd.Shutdown()
|
||||
suite.factory.Close()
|
||||
suite.statsdServer.Close()
|
||||
suite.factory.Close() //nolint: errcheck
|
||||
suite.statsdServer.Close() //nolint: errcheck
|
||||
}
|
||||
|
||||
func (suite *StatsdTestSuite) TestTelegramPath() {
|
||||
|
||||
Reference in New Issue
Block a user