Просмотр исходного кода

Update golangci-lint to 1.44.2

tags/v2.1.5^2
9seconds 4 лет назад
Родитель
Сommit
5282ca26f3

+ 1
- 1
.github/workflows/ci.yaml Просмотреть файл

83
       - name: Run linter
83
       - name: Run linter
84
         uses: golangci/golangci-lint-action@v2
84
         uses: golangci/golangci-lint-action@v2
85
         with:
85
         with:
86
-          version: v1.43.0
86
+          version: v1.44.2
87
 
87
 
88
   docker:
88
   docker:
89
     name: Docker
89
     name: Docker

+ 1
- 1
.golangci.toml Просмотреть файл

9
 
9
 
10
 [linters]
10
 [linters]
11
 enable-all = true
11
 enable-all = true
12
-disable = ["ireturn", "varnamelen", "gochecknoglobals", "gas", "goerr113", "exhaustivestruct"]
12
+disable = ["ireturn", "varnamelen", "gochecknoglobals", "gas", "goerr113", "exhaustivestruct", "containedctx"]

+ 1
- 1
Makefile Просмотреть файл

2
 IMAGE_NAME   := mtg
2
 IMAGE_NAME   := mtg
3
 APP_NAME     := $(IMAGE_NAME)
3
 APP_NAME     := $(IMAGE_NAME)
4
 
4
 
5
-GOLANGCI_LINT_VERSION := v1.43.0
5
+GOLANGCI_LINT_VERSION := v1.44.2
6
 
6
 
7
 VERSION_GO         := $(shell go version)
7
 VERSION_GO         := $(shell go version)
8
 VERSION_DATE       := $(shell date -Ru)
8
 VERSION_DATE       := $(shell date -Ru)

+ 3
- 3
internal/testlib/mtglib_network_mock.go Просмотреть файл

15
 func (m *MtglibNetworkMock) Dial(network, address string) (essentials.Conn, error) {
15
 func (m *MtglibNetworkMock) Dial(network, address string) (essentials.Conn, error) {
16
 	args := m.Called(network, address)
16
 	args := m.Called(network, address)
17
 
17
 
18
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
18
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
19
 }
19
 }
20
 
20
 
21
 func (m *MtglibNetworkMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
21
 func (m *MtglibNetworkMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
22
 	args := m.Called(ctx, network, address)
22
 	args := m.Called(ctx, network, address)
23
 
23
 
24
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
24
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
25
 }
25
 }
26
 
26
 
27
 func (m *MtglibNetworkMock) MakeHTTPClient(dialFunc func(ctx context.Context,
27
 func (m *MtglibNetworkMock) MakeHTTPClient(dialFunc func(ctx context.Context,
28
 	network, address string) (essentials.Conn, error)) *http.Client {
28
 	network, address string) (essentials.Conn, error)) *http.Client {
29
-	return m.Called(dialFunc).Get(0).(*http.Client)
29
+	return m.Called(dialFunc).Get(0).(*http.Client) // nolint: forcetypeassert
30
 }
30
 }

+ 2
- 2
internal/testlib/net_conn_mock.go Просмотреть файл

36
 }
36
 }
37
 
37
 
38
 func (n *EssentialsConnMock) LocalAddr() net.Addr {
38
 func (n *EssentialsConnMock) LocalAddr() net.Addr {
39
-	return n.Called().Get(0).(net.Addr)
39
+	return n.Called().Get(0).(net.Addr) // nolint: forcetypeassert
40
 }
40
 }
41
 
41
 
42
 func (n *EssentialsConnMock) RemoteAddr() net.Addr {
42
 func (n *EssentialsConnMock) RemoteAddr() net.Addr {
43
-	return n.Called().Get(0).(net.Addr)
43
+	return n.Called().Get(0).(net.Addr) // nolint: forcetypeassert
44
 }
44
 }
45
 
45
 
46
 func (n *EssentialsConnMock) SetDeadline(t time.Time) error {
46
 func (n *EssentialsConnMock) SetDeadline(t time.Time) error {

+ 1
- 1
mtglib/internal/faketls/pools.go Просмотреть файл

12
 }
12
 }
13
 
13
 
14
 func acquireBytesBuffer() *bytes.Buffer {
14
 func acquireBytesBuffer() *bytes.Buffer {
15
-	return bytesBufferPool.Get().(*bytes.Buffer)
15
+	return bytesBufferPool.Get().(*bytes.Buffer) // nolint: forcetypeassert
16
 }
16
 }
17
 
17
 
18
 func releaseBytesBuffer(b *bytes.Buffer) {
18
 func releaseBytesBuffer(b *bytes.Buffer) {

+ 1
- 1
mtglib/internal/faketls/record/pools.go Просмотреть файл

11
 }
11
 }
12
 
12
 
13
 func AcquireRecord() *Record {
13
 func AcquireRecord() *Record {
14
-	return recordPool.Get().(*Record)
14
+	return recordPool.Get().(*Record) // nolint: forcetypeassert
15
 }
15
 }
16
 
16
 
17
 func ReleaseRecord(r *Record) {
17
 func ReleaseRecord(r *Record) {

+ 2
- 2
mtglib/internal/obfuscated2/pools.go Просмотреть файл

21
 )
21
 )
22
 
22
 
23
 func acquireSha256Hasher() hash.Hash {
23
 func acquireSha256Hasher() hash.Hash {
24
-	return sha256HasherPool.Get().(hash.Hash)
24
+	return sha256HasherPool.Get().(hash.Hash) // nolint: forcetypeassert
25
 }
25
 }
26
 
26
 
27
 func releaseSha256Hasher(h hash.Hash) {
27
 func releaseSha256Hasher(h hash.Hash) {
30
 }
30
 }
31
 
31
 
32
 func acquireBytesBuffer() *bytes.Buffer {
32
 func acquireBytesBuffer() *bytes.Buffer {
33
-	return bytesBufferPool.Get().(*bytes.Buffer)
33
+	return bytesBufferPool.Get().(*bytes.Buffer) // nolint: forcetypeassert
34
 }
34
 }
35
 
35
 
36
 func releaseBytesBuffer(buf *bytes.Buffer) {
36
 func releaseBytesBuffer(buf *bytes.Buffer) {

+ 2
- 2
mtglib/internal/obfuscated2/server_handshake_test.go Просмотреть файл

69
 		Once().
69
 		Once().
70
 		Run(func(args mock.Arguments) {
70
 		Run(func(args mock.Arguments) {
71
 			message := make([]byte, len(messageToTelegram))
71
 			message := make([]byte, len(messageToTelegram))
72
-			suite.decryptor.XORKeyStream(message, args.Get(0).([]byte))
72
+			suite.decryptor.XORKeyStream(message, args.Get(0).([]byte)) // nolint: forcetypeassert
73
 			suite.Equal(messageToTelegram, message)
73
 			suite.Equal(messageToTelegram, message)
74
 		})
74
 		})
75
 
75
 
89
 		Run(func(args mock.Arguments) {
89
 		Run(func(args mock.Arguments) {
90
 			message := make([]byte, len(messageFromTelegram))
90
 			message := make([]byte, len(messageFromTelegram))
91
 			suite.encryptor.XORKeyStream(message, messageFromTelegram)
91
 			suite.encryptor.XORKeyStream(message, messageFromTelegram)
92
-			copy(args.Get(0).([]byte), message)
92
+			copy(args.Get(0).([]byte), message) // nolint: forcetypeassert
93
 		})
93
 		})
94
 
94
 
95
 	n, err := suite.proxyConn.Read(buffer)
95
 	n, err := suite.proxyConn.Read(buffer)

+ 1
- 1
mtglib/internal/relay/pools.go Просмотреть файл

11
 }
11
 }
12
 
12
 
13
 func acquireCopyBuffer() *[]byte {
13
 func acquireCopyBuffer() *[]byte {
14
-	return copyBufferPool.Get().(*[]byte)
14
+	return copyBufferPool.Get().(*[]byte) // nolint: forcetypeassert
15
 }
15
 }
16
 
16
 
17
 func releaseCopyBuffer(buf *[]byte) {
17
 func releaseCopyBuffer(buf *[]byte) {

+ 6
- 3
mtglib/proxy.go Просмотреть файл

106
 			}
106
 			}
107
 		}
107
 		}
108
 
108
 
109
-		ipAddr := conn.RemoteAddr().(*net.TCPAddr).IP
109
+		ipAddr := conn.RemoteAddr().(*net.TCPAddr).IP // nolint: forcetypeassert
110
 		logger := p.logger.BindStr("ip", ipAddr.String())
110
 		logger := p.logger.BindStr("ip", ipAddr.String())
111
 
111
 
112
 		if p.whitelist != nil && !p.whitelist.Contains(ipAddr) {
112
 		if p.whitelist != nil && !p.whitelist.Contains(ipAddr) {
255
 	}
255
 	}
256
 
256
 
257
 	p.eventStream.Send(ctx,
257
 	p.eventStream.Send(ctx,
258
-		NewEventConnectedToDC(ctx.streamID, conn.RemoteAddr().(*net.TCPAddr).IP, ctx.dc))
258
+		NewEventConnectedToDC(ctx.streamID,
259
+			conn.RemoteAddr().(*net.TCPAddr).IP, // nolint: forcetypeassert
260
+			ctx.dc),
261
+	)
259
 
262
 
260
 	return nil
263
 	return nil
261
 }
264
 }
316
 
319
 
317
 	pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
320
 	pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
318
 		func(arg interface{}) {
321
 		func(arg interface{}) {
319
-			proxy.ServeConn(arg.(essentials.Conn))
322
+			proxy.ServeConn(arg.(essentials.Conn)) // nolint: forcetypeassert
320
 		},
323
 		},
321
 		ants.WithLogger(opts.getLogger("ants")),
324
 		ants.WithLogger(opts.getLogger("ants")),
322
 		ants.WithNonblocking(true))
325
 		ants.WithNonblocking(true))

+ 1
- 1
mtglib/stream_context.go Просмотреть файл

49
 }
49
 }
50
 
50
 
51
 func (s *streamContext) ClientIP() net.IP {
51
 func (s *streamContext) ClientIP() net.IP {
52
-	return s.clientConn.RemoteAddr().(*net.TCPAddr).IP
52
+	return s.clientConn.RemoteAddr().(*net.TCPAddr).IP // nolint: forcetypeassert
53
 }
53
 }
54
 
54
 
55
 func newStreamContext(ctx context.Context, logger Logger, clientConn essentials.Conn) *streamContext {
55
 func newStreamContext(ctx context.Context, logger Logger, clientConn essentials.Conn) *streamContext {

+ 1
- 1
network/default.go Просмотреть файл

36
 		return nil, fmt.Errorf("cannot set socket options: %w", err)
36
 		return nil, fmt.Errorf("cannot set socket options: %w", err)
37
 	}
37
 	}
38
 
38
 
39
-	return conn.(essentials.Conn), nil
39
+	return conn.(essentials.Conn), nil // nolint: forcetypeassert
40
 }
40
 }
41
 
41
 
42
 // NewDefaultDialer build a new dialer which dials bypassing proxies
42
 // NewDefaultDialer build a new dialer which dials bypassing proxies

+ 2
- 2
network/init_internal_test.go Просмотреть файл

14
 func (d *DialerMock) Dial(network, address string) (essentials.Conn, error) {
14
 func (d *DialerMock) Dial(network, address string) (essentials.Conn, error) {
15
 	args := d.Called(network, address)
15
 	args := d.Called(network, address)
16
 
16
 
17
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
17
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
18
 }
18
 }
19
 
19
 
20
 func (d *DialerMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
20
 func (d *DialerMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
21
 	args := d.Called(ctx, network, address)
21
 	args := d.Called(ctx, network, address)
22
 
22
 
23
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
23
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
24
 }
24
 }

+ 2
- 2
network/init_test.go Просмотреть файл

22
 func (d *DialerMock) Dial(network, address string) (essentials.Conn, error) {
22
 func (d *DialerMock) Dial(network, address string) (essentials.Conn, error) {
23
 	args := d.Called(network, address)
23
 	args := d.Called(network, address)
24
 
24
 
25
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
25
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
26
 }
26
 }
27
 
27
 
28
 func (d *DialerMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
28
 func (d *DialerMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
29
 	args := d.Called(ctx, network, address)
29
 	args := d.Called(ctx, network, address)
30
 
30
 
31
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
31
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
32
 }
32
 }
33
 
33
 
34
 type HTTPServerTestSuite struct {
34
 type HTTPServerTestSuite struct {

+ 2
- 2
network/sockopts.go Просмотреть файл

10
 //
10
 //
11
 // bufferSize setting is deprecated and ignored.
11
 // bufferSize setting is deprecated and ignored.
12
 func SetClientSocketOptions(conn net.Conn, bufferSize int) error {
12
 func SetClientSocketOptions(conn net.Conn, bufferSize int) error {
13
-	return setCommonSocketOptions(conn.(*net.TCPConn))
13
+	return setCommonSocketOptions(conn.(*net.TCPConn)) // nolint: forcetypeassert
14
 }
14
 }
15
 
15
 
16
 // SetServerSocketOptions tunes a TCP socket that represents a connection to
16
 // SetServerSocketOptions tunes a TCP socket that represents a connection to
17
 // remote server like Telegram or fronting domain (but not end user).
17
 // remote server like Telegram or fronting domain (but not end user).
18
 func SetServerSocketOptions(conn net.Conn, bufferSize int) error {
18
 func SetServerSocketOptions(conn net.Conn, bufferSize int) error {
19
-	return setCommonSocketOptions(conn.(*net.TCPConn))
19
+	return setCommonSocketOptions(conn.(*net.TCPConn)) // nolint: forcetypeassert
20
 }
20
 }
21
 
21
 
22
 func setCommonSocketOptions(conn *net.TCPConn) error {
22
 func setCommonSocketOptions(conn *net.TCPConn) error {

+ 1
- 1
stats/pools.go Просмотреть файл

11
 }
11
 }
12
 
12
 
13
 func acquireStreamInfo() *streamInfo {
13
 func acquireStreamInfo() *streamInfo {
14
-	return streamInfoPool.Get().(*streamInfo)
14
+	return streamInfoPool.Get().(*streamInfo) // nolint: forcetypeassert
15
 }
15
 }
16
 
16
 
17
 func releaseStreamInfo(info *streamInfo) {
17
 func releaseStreamInfo(info *streamInfo) {

Загрузка…
Отмена
Сохранить