Browse Source

Upgrade golangci-lint for 1.42

tags/v1.0.10
9seconds 4 years ago
parent
commit
3e0880f6b4

+ 1
- 1
.github/workflows/ci.yaml View File

72
       - name: Run linter
72
       - name: Run linter
73
         uses: golangci/golangci-lint-action@v2
73
         uses: golangci/golangci-lint-action@v2
74
         with:
74
         with:
75
-          version: v1.37.1
75
+          version: v1.42.0
76
 
76
 
77
   docker:
77
   docker:
78
     name: Docker
78
     name: Docker

+ 1
- 1
Makefile View File

4
 
4
 
5
 CC_BINARIES  := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
5
 CC_BINARIES  := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
6
 
6
 
7
-GOLANGCI_LINT_VERSION := v1.37.1
7
+GOLANGCI_LINT_VERSION := v1.42.0
8
 
8
 
9
 VERSION_GO         := $(shell go version)
9
 VERSION_GO         := $(shell go version)
10
 VERSION_DATE       := $(shell date -Ru)
10
 VERSION_DATE       := $(shell date -Ru)

+ 30
- 30
config/config.go View File

79
 
79
 
80
 type Config struct {
80
 type Config struct {
81
 	Bind             *net.TCPAddr      `json:"bind"`
81
 	Bind             *net.TCPAddr      `json:"bind"`
82
-	PublicIPv4       *net.TCPAddr      `json:"public_ipv4"`
83
-	PublicIPv6       *net.TCPAddr      `json:"public_ipv6"`
84
-	StatsBind        *net.TCPAddr      `json:"stats_bind"`
85
-	StatsdAddr       *net.TCPAddr      `json:"stats_addr"`
86
-	StatsdTagsFormat *statsd.TagFormat `json:"statsd_tags_format"`
82
+	PublicIPv4       *net.TCPAddr      `json:"public_ipv4"`        // nolint: tagliatelle
83
+	PublicIPv6       *net.TCPAddr      `json:"public_ipv6"`        // nolint: tagliatelle
84
+	StatsBind        *net.TCPAddr      `json:"stats_bind"`         // nolint: tagliatelle
85
+	StatsdAddr       *net.TCPAddr      `json:"stats_addr"`         // nolint: tagliatelle
86
+	StatsdTagsFormat *statsd.TagFormat `json:"statsd_tags_format"` // nolint: tagliatelle
87
 
87
 
88
-	StatsNamespace string            `json:"stats_namespace"`
89
-	CloakHost      string            `json:"cloak_host"`
90
-	StatsdTags     map[string]string `json:"statsd_tags"`
88
+	StatsNamespace string            `json:"stats_namespace"` // nolint: tagliatelle
89
+	CloakHost      string            `json:"cloak_host"`      // nolint: tagliatelle
90
+	StatsdTags     map[string]string `json:"statsd_tags"`     // nolint: tagliatelle
91
 
91
 
92
-	WriteBuffer int `json:"write_buffer"`
93
-	ReadBuffer  int `json:"read_buffer"`
94
-	CloakPort   int `json:"cloak_port"`
92
+	WriteBuffer int `json:"write_buffer"` // nolint: tagliatelle
93
+	ReadBuffer  int `json:"read_buffer"`  // nolint: tagliatelle
94
+	CloakPort   int `json:"cloak_port"`   // nolint: tagliatelle
95
 
95
 
96
-	AntiReplayMaxSize int `json:"anti_replay_max_size"`
96
+	AntiReplayMaxSize int `json:"anti_replay_max_size"` // nolint: tagliatelle
97
 
97
 
98
-	MultiplexPerConnection int `json:"multiplex_per_connection"`
98
+	MultiplexPerConnection int `json:"multiplex_per_connection"` // nolint: tagliatelle
99
 
99
 
100
 	Debug      bool       `json:"debug"`
100
 	Debug      bool       `json:"debug"`
101
 	Verbose    bool       `json:"verbose"`
101
 	Verbose    bool       `json:"verbose"`
102
-	SecretMode SecretMode `json:"secret_mode"`
103
-	PreferIP   PreferIP   `json:"prefer_ip"`
104
-	NTPServers []string   `json:"ntp_servers"`
102
+	SecretMode SecretMode `json:"secret_mode"` // nolint: tagliatelle
103
+	PreferIP   PreferIP   `json:"prefer_ip"`   // nolint: tagliatelle
104
+	NTPServers []string   `json:"ntp_servers"` // nolint: tagliatelle
105
 
105
 
106
 	Secret []byte `json:"secret"`
106
 	Secret []byte `json:"secret"`
107
 	AdTag  []byte `json:"adtag"`
107
 	AdTag  []byte `json:"adtag"`
164
 	for _, opt := range options {
164
 	for _, opt := range options {
165
 		switch opt.Option {
165
 		switch opt.Option {
166
 		case OptionTypeDebug:
166
 		case OptionTypeDebug:
167
-			C.Debug = opt.Value.(bool)
167
+			C.Debug = opt.Value.(bool) // nolint: forcetypeassert
168
 		case OptionTypeVerbose:
168
 		case OptionTypeVerbose:
169
-			C.Verbose = opt.Value.(bool)
169
+			C.Verbose = opt.Value.(bool) // nolint: forcetypeassert
170
 		case OptionTypePreferIP:
170
 		case OptionTypePreferIP:
171
-			value := opt.Value.(string)
171
+			value := opt.Value.(string) // nolint: forcetypeassert
172
 			switch value {
172
 			switch value {
173
 			case "ipv4":
173
 			case "ipv4":
174
 				C.PreferIP = PreferIPv4
174
 				C.PreferIP = PreferIPv4
178
 				return fmt.Errorf("incorrect direct IP mode %s", value)
178
 				return fmt.Errorf("incorrect direct IP mode %s", value)
179
 			}
179
 			}
180
 		case OptionTypeBind:
180
 		case OptionTypeBind:
181
-			C.Bind = opt.Value.(*net.TCPAddr)
181
+			C.Bind = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
182
 		case OptionTypePublicIPv4:
182
 		case OptionTypePublicIPv4:
183
-			C.PublicIPv4 = opt.Value.(*net.TCPAddr)
183
+			C.PublicIPv4 = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
184
 			if C.PublicIPv4 == nil {
184
 			if C.PublicIPv4 == nil {
185
 				C.PublicIPv4 = &net.TCPAddr{}
185
 				C.PublicIPv4 = &net.TCPAddr{}
186
 			}
186
 			}
187
 		case OptionTypePublicIPv6:
187
 		case OptionTypePublicIPv6:
188
-			C.PublicIPv6 = opt.Value.(*net.TCPAddr)
188
+			C.PublicIPv6 = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
189
 			if C.PublicIPv6 == nil {
189
 			if C.PublicIPv6 == nil {
190
 				C.PublicIPv6 = &net.TCPAddr{}
190
 				C.PublicIPv6 = &net.TCPAddr{}
191
 			}
191
 			}
192
 		case OptionTypeStatsBind:
192
 		case OptionTypeStatsBind:
193
-			C.StatsBind = opt.Value.(*net.TCPAddr)
193
+			C.StatsBind = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
194
 		case OptionTypeStatsNamespace:
194
 		case OptionTypeStatsNamespace:
195
-			C.StatsNamespace = opt.Value.(string)
195
+			C.StatsNamespace = opt.Value.(string) // nolint: forcetypeassert
196
 		case OptionTypeStatsdAddress:
196
 		case OptionTypeStatsdAddress:
197
-			C.StatsdAddr = opt.Value.(*net.TCPAddr)
197
+			C.StatsdAddr = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
198
 		case OptionTypeStatsdTagsFormat:
198
 		case OptionTypeStatsdTagsFormat:
199
-			value := opt.Value.(string)
199
+			value := opt.Value.(string) // nolint: forcetypeassert
200
 			switch value {
200
 			switch value {
201
 			case "datadog":
201
 			case "datadog":
202
 				C.StatsdTagsFormat = statsd.TagFormatDatadog
202
 				C.StatsdTagsFormat = statsd.TagFormatDatadog
206
 				return fmt.Errorf("incorrect statsd tag %s", value)
206
 				return fmt.Errorf("incorrect statsd tag %s", value)
207
 			}
207
 			}
208
 		case OptionTypeStatsdTags:
208
 		case OptionTypeStatsdTags:
209
-			C.StatsdTags = opt.Value.(map[string]string)
209
+			C.StatsdTags = opt.Value.(map[string]string) // nolint: forcetypeassert
210
 		case OptionTypeWriteBufferSize:
210
 		case OptionTypeWriteBufferSize:
211
 			C.WriteBuffer = int(opt.Value.(units.Base2Bytes))
211
 			C.WriteBuffer = int(opt.Value.(units.Base2Bytes))
212
 		case OptionTypeReadBufferSize:
212
 		case OptionTypeReadBufferSize:
218
 		case OptionTypeMultiplexPerConnection:
218
 		case OptionTypeMultiplexPerConnection:
219
 			C.MultiplexPerConnection = int(opt.Value.(uint))
219
 			C.MultiplexPerConnection = int(opt.Value.(uint))
220
 		case OptionTypeNTPServers:
220
 		case OptionTypeNTPServers:
221
-			C.NTPServers = opt.Value.([]string)
221
+			C.NTPServers = opt.Value.([]string) // nolint: forcetypeassert
222
 			if len(C.NTPServers) == 0 {
222
 			if len(C.NTPServers) == 0 {
223
 				return errors.New("ntp server list is empty")
223
 				return errors.New("ntp server list is empty")
224
 			}
224
 			}
225
 		case OptionTypeSecret:
225
 		case OptionTypeSecret:
226
-			C.Secret = opt.Value.([]byte)
226
+			C.Secret = opt.Value.([]byte) // nolint: forcetypeassert
227
 		case OptionTypeAdtag:
227
 		case OptionTypeAdtag:
228
-			C.AdTag = opt.Value.([]byte)
228
+			C.AdTag = opt.Value.([]byte) // nolint: forcetypeassert
229
 		default:
229
 		default:
230
 			return fmt.Errorf("unknown tag %v", opt.Option)
230
 			return fmt.Errorf("unknown tag %v", opt.Option)
231
 		}
231
 		}

+ 1
- 1
config/global_ips.go View File

41
 		Timeout: ifconfigTimeout,
41
 		Timeout: ifconfigTimeout,
42
 		Transport: &http.Transport{
42
 		Transport: &http.Transport{
43
 			DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
43
 			DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
44
-				return dialer.DialContext(ctx, network, addr)
44
+				return dialer.DialContext(ctx, network, addr) // nolint: wrapcheck
45
 			},
45
 			},
46
 		},
46
 		},
47
 	}
47
 	}

+ 5
- 5
config/urls.go View File

8
 )
8
 )
9
 
9
 
10
 type URLs struct {
10
 type URLs struct {
11
-	TG        string `json:"tg_url"`
12
-	TMe       string `json:"tme_url"`
13
-	TGQRCode  string `json:"tg_qrcode"`
14
-	TMeQRCode string `json:"tme_qrcode"`
11
+	TG        string `json:"tg_url"`     // nolint: tagliatelle
12
+	TMe       string `json:"tme_url"`    // nolint: tagliatelle
13
+	TGQRCode  string `json:"tg_qrcode"`  // nolint: tagliatelle
14
+	TMeQRCode string `json:"tme_qrcode"` // nolint: tagliatelle
15
 }
15
 }
16
 
16
 
17
 type IPURLs struct {
17
 type IPURLs struct {
18
 	IPv4      *URLs  `json:"ipv4,omitempty"`
18
 	IPv4      *URLs  `json:"ipv4,omitempty"`
19
 	IPv6      *URLs  `json:"ipv6,omitempty"`
19
 	IPv6      *URLs  `json:"ipv6,omitempty"`
20
-	BotSecret string `json:"secret_for_mtproxybot"`
20
+	BotSecret string `json:"secret_for_mtproxybot"` // nolint: tagliatelle
21
 }
21
 }
22
 
22
 
23
 func GetURLs() (urls IPURLs) {
23
 func GetURLs() (urls IPURLs) {

+ 1
- 1
hub/hub.go View File

18
 }
18
 }
19
 
19
 
20
 func (h *hub) getMux(req *protocol.TelegramRequest) *mux {
20
 func (h *hub) getMux(req *protocol.TelegramRequest) *mux {
21
-	var key int32 = 32767 + int32(req.ClientProtocol.DC()) + 100000*int32(req.ClientProtocol.ConnectionProtocol())
21
+	key := 32767 + int32(req.ClientProtocol.DC()) + 100000*int32(req.ClientProtocol.ConnectionProtocol())
22
 
22
 
23
 	h.mutex.RLock()
23
 	h.mutex.RLock()
24
 	m, ok := h.muxes[key]
24
 	m, ok := h.muxes[key]

+ 5
- 5
obfuscated2/client_protocol.go View File

45
 	}
45
 	}
46
 
46
 
47
 	decHasher := sha256.New()
47
 	decHasher := sha256.New()
48
-	decHasher.Write(fm.Key())        // nolint: errcheck
49
-	decHasher.Write(config.C.Secret) // nolint: errcheck
48
+	decHasher.Write(fm.Key())
49
+	decHasher.Write(config.C.Secret)
50
 	decryptor := utils.MakeStreamCipher(decHasher.Sum(nil), fm.IV())
50
 	decryptor := utils.MakeStreamCipher(decHasher.Sum(nil), fm.IV())
51
 
51
 
52
 	invertedFrame := fm.Invert()
52
 	invertedFrame := fm.Invert()
53
 	encHasher := sha256.New()
53
 	encHasher := sha256.New()
54
-	encHasher.Write(invertedFrame.Key()) // nolint: errcheck
55
-	encHasher.Write(config.C.Secret)     // nolint: errcheck
54
+	encHasher.Write(invertedFrame.Key())
55
+	encHasher.Write(config.C.Secret)
56
 	encryptor := utils.MakeStreamCipher(encHasher.Sum(nil), invertedFrame.IV())
56
 	encryptor := utils.MakeStreamCipher(encHasher.Sum(nil), invertedFrame.IV())
57
 
57
 
58
 	decryptedFrame := Frame{}
58
 	decryptedFrame := Frame{}
106
 }
106
 }
107
 
107
 
108
 func (h handshakeReader) Read(p []byte) (int, error) {
108
 func (h handshakeReader) Read(p []byte) (int, error) {
109
-	return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout)
109
+	return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout) // nolint: wrapcheck
110
 }
110
 }
111
 
111
 
112
 func MakeClientProtocol() protocol.ClientProtocol {
112
 func MakeClientProtocol() protocol.ClientProtocol {

+ 3
- 6
proxy/direct.go View File

4
 	"io"
4
 	"io"
5
 	"sync"
5
 	"sync"
6
 
6
 
7
-	"github.com/9seconds/mtg/conntypes"
8
 	"github.com/9seconds/mtg/obfuscated2"
7
 	"github.com/9seconds/mtg/obfuscated2"
9
 	"github.com/9seconds/mtg/protocol"
8
 	"github.com/9seconds/mtg/protocol"
10
 	"go.uber.org/zap"
9
 	"go.uber.org/zap"
18
 		return err // nolint: wrapcheck
17
 		return err // nolint: wrapcheck
19
 	}
18
 	}
20
 
19
 
21
-	telegramConn := telegramConnRaw.(conntypes.StreamReadWriteCloser)
22
-
23
-	defer telegramConn.Close()
20
+	defer telegramConnRaw.Close()
24
 
21
 
25
 	wg := &sync.WaitGroup{}
22
 	wg := &sync.WaitGroup{}
26
 	wg.Add(2)
23
 	wg.Add(2)
27
 
24
 
28
-	go directPipe(telegramConn, request.ClientConn, wg, request.Logger)
25
+	go directPipe(telegramConnRaw, request.ClientConn, wg, request.Logger)
29
 
26
 
30
-	go directPipe(request.ClientConn, telegramConn, wg, request.Logger)
27
+	go directPipe(request.ClientConn, telegramConnRaw, wg, request.Logger)
31
 
28
 
32
 	wg.Wait()
29
 	wg.Wait()
33
 
30
 

+ 2
- 2
tlstypes/server_hello.go View File

49
 	packet := buf.Bytes()
49
 	packet := buf.Bytes()
50
 
50
 
51
 	mac := hmac.New(sha256.New, config.C.Secret)
51
 	mac := hmac.New(sha256.New, config.C.Secret)
52
-	mac.Write(s.clientHello.Random[:]) // nolint: errcheck
53
-	mac.Write(packet)                  // nolint: errcheck
52
+	mac.Write(s.clientHello.Random[:])
53
+	mac.Write(packet)
54
 	copy(packet[11:], mac.Sum(nil))
54
 	copy(packet[11:], mac.Sum(nil))
55
 
55
 
56
 	return packet
56
 	return packet

+ 1
- 1
utils/init_tcp.go View File

6
 )
6
 )
7
 
7
 
8
 func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
8
 func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
9
-	tcpConn := conn.(*net.TCPConn)
9
+	tcpConn := conn.(*net.TCPConn) // nolint: forcetypeassert
10
 
10
 
11
 	if err := tcpConn.SetNoDelay(true); err != nil {
11
 	if err := tcpConn.SetNoDelay(true); err != nil {
12
 		return fmt.Errorf("cannot set TCP_NO_DELAY: %w", err)
12
 		return fmt.Errorf("cannot set TCP_NO_DELAY: %w", err)

+ 1
- 0
utils/rlimit.go View File

1
+//go:build !windows
1
 // +build !windows
2
 // +build !windows
2
 
3
 
3
 package utils
4
 package utils

+ 1
- 0
utils/rlimit_windows.go View File

1
+//go:build windows
1
 // +build windows
2
 // +build windows
2
 
3
 
3
 package utils
4
 package utils

+ 1
- 0
utils/signal_context.go View File

1
+//go:build !windows
1
 // +build !windows
2
 // +build !windows
2
 
3
 
3
 package utils
4
 package utils

+ 1
- 0
utils/signal_context_windows.go View File

1
+//go:build windows
1
 // +build windows
2
 // +build windows
2
 
3
 
3
 package utils
4
 package utils

+ 1
- 1
wrappers/packet/mtproto_frame.go View File

136
 }
136
 }
137
 
137
 
138
 func (w *wrapperMtprotoFrame) Close() error {
138
 func (w *wrapperMtprotoFrame) Close() error {
139
-	return w.parent.Close()
139
+	return w.parent.Close() // nolint: wrapcheck
140
 }
140
 }
141
 
141
 
142
 func (w *wrapperMtprotoFrame) Conn() net.Conn {
142
 func (w *wrapperMtprotoFrame) Conn() net.Conn {

+ 1
- 1
wrappers/packetack/client_abridged.go View File

104
 }
104
 }
105
 
105
 
106
 func (w *wrapperClientAbridged) Close() error {
106
 func (w *wrapperClientAbridged) Close() error {
107
-	return w.parent.Close()
107
+	return w.parent.Close() // nolint: wrapcheck
108
 }
108
 }
109
 
109
 
110
 func (w *wrapperClientAbridged) Conn() net.Conn {
110
 func (w *wrapperClientAbridged) Conn() net.Conn {

+ 1
- 1
wrappers/packetack/client_intermediate.go View File

63
 }
63
 }
64
 
64
 
65
 func (w *wrapperClientIntermediate) Close() error {
65
 func (w *wrapperClientIntermediate) Close() error {
66
-	return w.parent.Close()
66
+	return w.parent.Close() // nolint: wrapcheck
67
 }
67
 }
68
 
68
 
69
 func (w *wrapperClientIntermediate) Conn() net.Conn {
69
 func (w *wrapperClientIntermediate) Conn() net.Conn {

+ 1
- 1
wrappers/packetack/proxy.go View File

46
 	buf.Grow(len(packet))
46
 	buf.Grow(len(packet))
47
 	buf.Write(packet)
47
 	buf.Write(packet)
48
 
48
 
49
-	return w.proxy.Write(buf.Bytes())
49
+	return w.proxy.Write(buf.Bytes()) // nolint: wrapcheck
50
 }
50
 }
51
 
51
 
52
 func (w *wrapperProxy) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {
52
 func (w *wrapperProxy) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {

+ 1
- 1
wrappers/rwc/ping.go View File

36
 }
36
 }
37
 
37
 
38
 func (w *wrapperPing) Close() error {
38
 func (w *wrapperPing) Close() error {
39
-	return w.parent.Close()
39
+	return w.parent.Close() // nolint: wrapcheck
40
 }
40
 }
41
 
41
 
42
 func NewPing(ctx context.Context, parent io.ReadWriteCloser, channelPing chan<- struct{}) io.ReadWriteCloser {
42
 func NewPing(ctx context.Context, parent io.ReadWriteCloser, channelPing chan<- struct{}) io.ReadWriteCloser {

+ 3
- 3
wrappers/stream/blockcipher.go View File

26
 		return 0, err
26
 		return 0, err
27
 	}
27
 	}
28
 
28
 
29
-	return w.parent.Write(encrypted)
29
+	return w.parent.Write(encrypted) // nolint: wrapcheck
30
 }
30
 }
31
 
31
 
32
 func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
32
 func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
35
 		return 0, err
35
 		return 0, err
36
 	}
36
 	}
37
 
37
 
38
-	return w.parent.WriteTimeout(encrypted, timeout)
38
+	return w.parent.WriteTimeout(encrypted, timeout) // nolint: wrapcheck
39
 }
39
 }
40
 
40
 
41
 func (w *wrapperBlockCipher) encrypt(p []byte) ([]byte, error) {
41
 func (w *wrapperBlockCipher) encrypt(p []byte) ([]byte, error) {
50
 }
50
 }
51
 
51
 
52
 func (w *wrapperBlockCipher) Close() error {
52
 func (w *wrapperBlockCipher) Close() error {
53
-	return w.parent.Close()
53
+	return w.parent.Close() // nolint: wrapcheck
54
 }
54
 }
55
 
55
 
56
 func (w *wrapperBlockCipher) Conn() net.Conn {
56
 func (w *wrapperBlockCipher) Conn() net.Conn {

+ 1
- 1
wrappers/stream/buffered_reader.go View File

33
 
33
 
34
 func (b *bufferedReader) flush(p []byte) (int, error) {
34
 func (b *bufferedReader) flush(p []byte) (int, error) {
35
 	if b.buf.Len() > len(p) {
35
 	if b.buf.Len() > len(p) {
36
-		return b.buf.Read(p)
36
+		return b.buf.Read(p) // nolint: wrapcheck
37
 	}
37
 	}
38
 
38
 
39
 	sizeToReturn := b.buf.Len()
39
 	sizeToReturn := b.buf.Len()

+ 1
- 1
wrappers/stream/conn.go View File

70
 func (w *wrapperConn) Close() error {
70
 func (w *wrapperConn) Close() error {
71
 	w.logger.Debugw("Close connection")
71
 	w.logger.Debugw("Close connection")
72
 
72
 
73
-	return w.parent.Close()
73
+	return w.parent.Close() // nolint: wrapcheck
74
 }
74
 }
75
 
75
 
76
 func (w *wrapperConn) Conn() net.Conn {
76
 func (w *wrapperConn) Conn() net.Conn {

+ 5
- 5
wrappers/stream/ctx.go View File

23
 
23
 
24
 		return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
24
 		return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
25
 	default:
25
 	default:
26
-		return w.parent.WriteTimeout(p, timeout)
26
+		return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
27
 	}
27
 	}
28
 }
28
 }
29
 
29
 
34
 
34
 
35
 		return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
35
 		return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
36
 	default:
36
 	default:
37
-		return w.parent.Write(p)
37
+		return w.parent.Write(p) // nolint: wrapcheck
38
 	}
38
 	}
39
 }
39
 }
40
 
40
 
45
 
45
 
46
 		return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
46
 		return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
47
 	default:
47
 	default:
48
-		return w.parent.ReadTimeout(p, timeout)
48
+		return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
49
 	}
49
 	}
50
 }
50
 }
51
 
51
 
56
 
56
 
57
 		return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
57
 		return 0, fmt.Errorf("cannot write because context was closed: %w", w.ctx.Err())
58
 	default:
58
 	default:
59
-		return w.parent.Read(p)
59
+		return w.parent.Read(p) // nolint: wrapcheck
60
 	}
60
 	}
61
 }
61
 }
62
 
62
 
63
 func (w *wrapperCtx) Close() error {
63
 func (w *wrapperCtx) Close() error {
64
 	w.cancel()
64
 	w.cancel()
65
 
65
 
66
-	return w.parent.Close()
66
+	return w.parent.Close() // nolint: wrapcheck
67
 }
67
 }
68
 
68
 
69
 func (w *wrapperCtx) Conn() net.Conn {
69
 func (w *wrapperCtx) Conn() net.Conn {

+ 3
- 3
wrappers/stream/faketls.go View File

20
 
20
 
21
 func (w *wrapperFakeTLS) Write(p []byte) (int, error) {
21
 func (w *wrapperFakeTLS) Write(p []byte) (int, error) {
22
 	return w.write(p, func(b []byte) (int, error) {
22
 	return w.write(p, func(b []byte) (int, error) {
23
-		return w.parent.Write(b)
23
+		return w.parent.Write(b) // nolint: wrapcheck
24
 	})
24
 	})
25
 }
25
 }
26
 
26
 
30
 	return w.write(p, func(b []byte) (int, error) {
30
 	return w.write(p, func(b []byte) (int, error) {
31
 		elapsed := time.Since(startTime)
31
 		elapsed := time.Since(startTime)
32
 		if elapsed > timeout {
32
 		if elapsed > timeout {
33
-			return w.parent.WriteTimeout(b, timeout-elapsed)
33
+			return w.parent.WriteTimeout(b, timeout-elapsed) // nolint: wrapcheck
34
 		}
34
 		}
35
 
35
 
36
 		return 0, errors.New("timeout")
36
 		return 0, errors.New("timeout")
73
 }
73
 }
74
 
74
 
75
 func (w *wrapperFakeTLS) Close() error {
75
 func (w *wrapperFakeTLS) Close() error {
76
-	return w.parent.Close()
76
+	return w.parent.Close() // nolint: wrapcheck
77
 }
77
 }
78
 
78
 
79
 func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
79
 func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {

+ 3
- 3
wrappers/stream/obfuscated2.go View File

48
 
48
 
49
 	w.encryptor.XORKeyStream(buf, buf)
49
 	w.encryptor.XORKeyStream(buf, buf)
50
 
50
 
51
-	return w.parent.WriteTimeout(buf, timeout)
51
+	return w.parent.WriteTimeout(buf, timeout) // nolint: wrapcheck
52
 }
52
 }
53
 
53
 
54
 func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
54
 func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
60
 
60
 
61
 	w.encryptor.XORKeyStream(buf, buf)
61
 	w.encryptor.XORKeyStream(buf, buf)
62
 
62
 
63
-	return w.parent.Write(buf)
63
+	return w.parent.Write(buf) // nolint: wrapcheck
64
 }
64
 }
65
 
65
 
66
 func (w *wrapperObfuscated2) Conn() net.Conn {
66
 func (w *wrapperObfuscated2) Conn() net.Conn {
80
 }
80
 }
81
 
81
 
82
 func (w *wrapperObfuscated2) Close() error {
82
 func (w *wrapperObfuscated2) Close() error {
83
-	return w.parent.Close()
83
+	return w.parent.Close() // nolint: wrapcheck
84
 }
84
 }
85
 
85
 
86
 func NewObfuscated2(socket conntypes.StreamReadWriteCloser,
86
 func NewObfuscated2(socket conntypes.StreamReadWriteCloser,

+ 5
- 5
wrappers/stream/rewind.go View File

24
 }
24
 }
25
 
25
 
26
 func (w *wrapperRewind) Write(p []byte) (int, error) {
26
 func (w *wrapperRewind) Write(p []byte) (int, error) {
27
-	return w.parent.Write(p)
27
+	return w.parent.Write(p) // nolint: wrapcheck
28
 }
28
 }
29
 
29
 
30
 func (w *wrapperRewind) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
30
 func (w *wrapperRewind) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
31
-	return w.parent.WriteTimeout(p, timeout)
31
+	return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
32
 }
32
 }
33
 
33
 
34
 func (w *wrapperRewind) Read(p []byte) (int, error) {
34
 func (w *wrapperRewind) Read(p []byte) (int, error) {
35
 	w.mutex.Lock()
35
 	w.mutex.Lock()
36
 	defer w.mutex.Unlock()
36
 	defer w.mutex.Unlock()
37
 
37
 
38
-	return w.activeReader.Read(p)
38
+	return w.activeReader.Read(p) // nolint: wrapcheck
39
 }
39
 }
40
 
40
 
41
 func (w *wrapperRewind) ReadTimeout(p []byte, _ time.Duration) (int, error) {
41
 func (w *wrapperRewind) ReadTimeout(p []byte, _ time.Duration) (int, error) {
42
 	w.mutex.Lock()
42
 	w.mutex.Lock()
43
 	defer w.mutex.Unlock()
43
 	defer w.mutex.Unlock()
44
 
44
 
45
-	return w.activeReader.Read(p)
45
+	return w.activeReader.Read(p) // nolint: wrapcheck
46
 }
46
 }
47
 
47
 
48
 func (w *wrapperRewind) Conn() net.Conn {
48
 func (w *wrapperRewind) Conn() net.Conn {
64
 func (w *wrapperRewind) Close() error {
64
 func (w *wrapperRewind) Close() error {
65
 	w.buf.Reset()
65
 	w.buf.Reset()
66
 
66
 
67
-	return w.parent.Close()
67
+	return w.parent.Close() // nolint: wrapcheck
68
 }
68
 }
69
 
69
 
70
 func (w *wrapperRewind) Rewind() {
70
 func (w *wrapperRewind) Rewind() {

+ 4
- 4
wrappers/stream/stats_telegram.go View File

17
 }
17
 }
18
 
18
 
19
 func (w *wrapperTelegramStats) Write(p []byte) (int, error) {
19
 func (w *wrapperTelegramStats) Write(p []byte) (int, error) {
20
-	return w.parent.Write(p)
20
+	return w.parent.Write(p) // nolint: wrapcheck
21
 }
21
 }
22
 
22
 
23
 func (w *wrapperTelegramStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
23
 func (w *wrapperTelegramStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
24
-	return w.parent.WriteTimeout(p, timeout)
24
+	return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
25
 }
25
 }
26
 
26
 
27
 func (w *wrapperTelegramStats) Read(p []byte) (int, error) {
27
 func (w *wrapperTelegramStats) Read(p []byte) (int, error) {
28
-	return w.parent.Read(p)
28
+	return w.parent.Read(p) // nolint: wrapcheck
29
 }
29
 }
30
 
30
 
31
 func (w *wrapperTelegramStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
31
 func (w *wrapperTelegramStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
32
-	return w.parent.ReadTimeout(p, timeout)
32
+	return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
33
 }
33
 }
34
 
34
 
35
 func (w *wrapperTelegramStats) Conn() net.Conn {
35
 func (w *wrapperTelegramStats) Conn() net.Conn {

+ 1
- 1
wrappers/stream/stats_traffic.go View File

58
 }
58
 }
59
 
59
 
60
 func (w *wrapperTrafficStats) Close() error {
60
 func (w *wrapperTrafficStats) Close() error {
61
-	return w.parent.Close()
61
+	return w.parent.Close() // nolint: wrapcheck
62
 }
62
 }
63
 
63
 
64
 func NewTrafficStats(parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
64
 func NewTrafficStats(parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {

+ 5
- 5
wrappers/stream/timeout.go View File

18
 }
18
 }
19
 
19
 
20
 func (w *wrapperTimeout) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
20
 func (w *wrapperTimeout) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
21
-	return w.parent.WriteTimeout(p, timeout)
21
+	return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
22
 }
22
 }
23
 
23
 
24
 func (w *wrapperTimeout) Write(p []byte) (int, error) {
24
 func (w *wrapperTimeout) Write(p []byte) (int, error) {
25
-	return w.parent.WriteTimeout(p, timeoutWrite)
25
+	return w.parent.WriteTimeout(p, timeoutWrite) // nolint: wrapcheck
26
 }
26
 }
27
 
27
 
28
 func (w *wrapperTimeout) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
28
 func (w *wrapperTimeout) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
29
-	return w.parent.ReadTimeout(p, timeout)
29
+	return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
30
 }
30
 }
31
 
31
 
32
 func (w *wrapperTimeout) Read(p []byte) (int, error) {
32
 func (w *wrapperTimeout) Read(p []byte) (int, error) {
33
-	return w.parent.ReadTimeout(p, timeoutRead)
33
+	return w.parent.ReadTimeout(p, timeoutRead) // nolint: wrapcheck
34
 }
34
 }
35
 
35
 
36
 func (w *wrapperTimeout) Close() error {
36
 func (w *wrapperTimeout) Close() error {
37
-	return w.parent.Close()
37
+	return w.parent.Close() // nolint: wrapcheck
38
 }
38
 }
39
 
39
 
40
 func (w *wrapperTimeout) Conn() net.Conn {
40
 func (w *wrapperTimeout) Conn() net.Conn {

Loading…
Cancel
Save