Quellcode durchsuchen

Update to go 1.19

tags/v1.0.12
9seconds vor 3 Jahren
Ursprung
Commit
f48156814b
60 geänderte Dateien mit 260 neuen und 260 gelöschten Zeilen
  1. 2
    2
      .github/workflows/ci.yaml
  2. 11
    1
      .golangci.toml
  3. 1
    1
      Dockerfile
  4. 1
    1
      Makefile
  5. 2
    2
      cli/proxy.go
  6. 2
    2
      cli/utils.go
  7. 37
    37
      config/config.go
  8. 4
    5
      config/global_ips.go
  9. 7
    6
      config/urls.go
  10. 2
    2
      faketls/client_protocol.go
  11. 2
    2
      faketls/cloak.go
  12. 5
    2
      go.mod
  13. 10
    0
      go.sum
  14. 2
    2
      hub/connection.go
  15. 1
    1
      hub/hub.go
  16. 0
    5
      main.go
  17. 1
    1
      mtproto/protocol.go
  18. 1
    1
      mtproto/rpc/handshake_response.go
  19. 4
    4
      mtproto/rpc/nonce_request.go
  20. 1
    1
      mtproto/rpc/nonce_response.go
  21. 2
    2
      mtproto/rpc/proxy_flags.go
  22. 1
    1
      mtproto/rpc/proxy_response.go
  23. 1
    1
      ntp/ntp.go
  24. 7
    5
      obfuscated2/client_protocol.go
  25. 3
    3
      obfuscated2/frame.go
  26. 8
    7
      obfuscated2/telegram_protocol.go
  27. 2
    2
      proxy/direct.go
  28. 1
    1
      proxy/middle.go
  29. 2
    2
      stats/stats.go
  30. 4
    4
      stats/stats_statsd.go
  31. 6
    6
      telegram/api/addresses.go
  32. 3
    4
      telegram/api/api.go
  33. 3
    3
      telegram/api/secret.go
  34. 2
    2
      telegram/base.go
  35. 14
    14
      tlstypes/consts.go
  36. 3
    3
      tlstypes/handshake.go
  37. 7
    5
      tlstypes/record.go
  38. 8
    8
      tlstypes/server_hello.go
  39. 1
    1
      utils/init_tcp.go
  40. 4
    3
      utils/read_full.go
  41. 1
    1
      utils/reverse_bytes.go
  42. 0
    25
      utils/rlimit.go
  43. 2
    2
      utils/uint24.go
  44. 18
    16
      wrappers/packet/mtproto_frame.go
  45. 4
    4
      wrappers/packetack/client_abridged.go
  46. 3
    3
      wrappers/packetack/client_intermediate.go
  47. 3
    3
      wrappers/packetack/client_intermediate_secure.go
  48. 2
    2
      wrappers/packetack/proxy.go
  49. 3
    3
      wrappers/rwc/ping.go
  50. 3
    3
      wrappers/stream/blockcipher.go
  51. 1
    1
      wrappers/stream/buffered_reader.go
  52. 6
    6
      wrappers/stream/conn.go
  53. 5
    5
      wrappers/stream/ctx.go
  54. 4
    4
      wrappers/stream/faketls.go
  55. 3
    3
      wrappers/stream/mtproto_cipher.go
  56. 4
    4
      wrappers/stream/obfuscated2.go
  57. 5
    5
      wrappers/stream/rewind.go
  58. 5
    5
      wrappers/stream/stats_telegram.go
  59. 5
    5
      wrappers/stream/stats_traffic.go
  60. 5
    5
      wrappers/stream/timeout.go

+ 2
- 2
.github/workflows/ci.yaml Datei anzeigen

@@ -30,7 +30,7 @@ jobs:
30 30
     strategy:
31 31
       matrix:
32 32
         go_version:
33
-          - ^1.18
33
+          - ^1.19
34 34
     steps:
35 35
       - name: Checkout
36 36
         uses: actions/checkout@v2
@@ -70,7 +70,7 @@ jobs:
70 70
       - name: Run linter
71 71
         uses: golangci/golangci-lint-action@v2
72 72
         with:
73
-          version: v1.45.0
73
+          version: v1.48.0
74 74
 
75 75
   docker:
76 76
     name: Docker

+ 11
- 1
.golangci.toml Datei anzeigen

@@ -9,4 +9,14 @@ format = "colored-line-number"
9 9
 
10 10
 [linters]
11 11
 enable-all = true
12
-disable = ["thelper", "ireturn", "varnamelen", "gochecknoglobals", "gas", "goerr113", "exhaustivestruct", "containedctx"]
12
+disable = [
13
+    "containedctx",
14
+    "exhaustivestruct",
15
+    "exhaustruct",
16
+    "gas",
17
+    "gochecknoglobals",
18
+    "goerr113",
19
+    "ireturn",
20
+    "thelper",
21
+    "varnamelen",
22
+]

+ 1
- 1
Dockerfile Datei anzeigen

@@ -1,7 +1,7 @@
1 1
 ###############################################################################
2 2
 # BUILD STAGE
3 3
 
4
-FROM golang:1.18-alpine AS build
4
+FROM golang:1.19-alpine AS build
5 5
 
6 6
 RUN set -x \
7 7
   && apk --no-cache --update add \

+ 1
- 1
Makefile Datei anzeigen

@@ -2,7 +2,7 @@ ROOT_DIR     := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2 2
 IMAGE_NAME   := mtg
3 3
 APP_NAME     := $(IMAGE_NAME)
4 4
 
5
-GOLANGCI_LINT_VERSION := v1.45.0
5
+GOLANGCI_LINT_VERSION := v1.48.0
6 6
 
7 7
 VERSION_GO         := $(shell go version)
8 8
 VERSION_DATE       := $(shell date -Ru)

+ 2
- 2
cli/proxy.go Datei anzeigen

@@ -19,7 +19,7 @@ import (
19 19
 	"go.uber.org/zap/zapcore"
20 20
 )
21 21
 
22
-func Proxy() error { // nolint: funlen,cyclop
22
+func Proxy() error { //nolint: funlen,cyclop
23 23
 	ctx := utils.GetSignalContext()
24 24
 
25 25
 	atom := zap.NewAtomicLevel()
@@ -41,7 +41,7 @@ func Proxy() error { // nolint: funlen,cyclop
41 41
 	))
42 42
 
43 43
 	zap.ReplaceGlobals(logger)
44
-	defer logger.Sync() // nolint: errcheck
44
+	defer logger.Sync() //nolint: errcheck
45 45
 
46 46
 	if err := config.InitPublicAddress(ctx); err != nil {
47 47
 		Fatal(err)

+ 2
- 2
cli/utils.go Datei anzeigen

@@ -9,7 +9,7 @@ import (
9 9
 
10 10
 func Fatal(arg interface{}) {
11 11
 	if value, ok := arg.(error); ok {
12
-		arg = fmt.Errorf("fatal error: %+v", value) // nolint: errorlint
12
+		arg = fmt.Errorf("fatal error: %+v", value) //nolint: errorlint
13 13
 	}
14 14
 
15 15
 	PrintStderr(arg)
@@ -21,7 +21,7 @@ func PrintStderr(args ...interface{}) {
21 21
 }
22 22
 
23 23
 func PrintStdout(args ...interface{}) {
24
-	fmt.Println(args...) // nolint: forbidigo
24
+	fmt.Println(args...) //nolint: forbidigo
25 25
 }
26 26
 
27 27
 func PrintJSONStderr(data interface{}) {

+ 37
- 37
config/config.go Datei anzeigen

@@ -79,29 +79,29 @@ const (
79 79
 
80 80
 type Config struct {
81 81
 	Bind             *net.TCPAddr      `json:"bind"`
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
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"` // nolint: tagliatelle
89
-	CloakHost      string            `json:"cloak_host"`      // nolint: tagliatelle
90
-	StatsdTags     map[string]string `json:"statsd_tags"`     // nolint: tagliatelle
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"` // nolint: tagliatelle
93
-	ReadBuffer  int `json:"read_buffer"`  // nolint: tagliatelle
94
-	CloakPort   int `json:"cloak_port"`   // nolint: tagliatelle
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"` // nolint: tagliatelle
96
+	AntiReplayMaxSize int `json:"anti_replay_max_size"` //nolint: tagliatelle
97 97
 
98
-	MultiplexPerConnection int `json:"multiplex_per_connection"` // nolint: tagliatelle
98
+	MultiplexPerConnection int `json:"multiplex_per_connection"` //nolint: tagliatelle
99 99
 
100 100
 	Debug      bool       `json:"debug"`
101 101
 	Verbose    bool       `json:"verbose"`
102
-	SecretMode SecretMode `json:"secret_mode"` // nolint: tagliatelle
103
-	PreferIP   PreferIP   `json:"prefer_ip"`   // nolint: tagliatelle
104
-	NTPServers []string   `json:"ntp_servers"` // nolint: tagliatelle
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 106
 	Secret []byte `json:"secret"`
107 107
 	AdTag  []byte `json:"adtag"`
@@ -146,7 +146,7 @@ func (c *Config) adjustProxyValue(value int) int {
146 146
 
147 147
 	fvalue := float64(value)
148 148
 
149
-	newValue := fvalue * 2 * math.Log(float64(c.MultiplexPerConnection)) // nolint: gomnd
149
+	newValue := fvalue * 2 * math.Log(float64(c.MultiplexPerConnection)) //nolint: gomnd
150 150
 	newValue = math.Ceil(newValue)
151 151
 	newValue = math.Max(fvalue, newValue)
152 152
 
@@ -160,15 +160,15 @@ type Opt struct {
160 160
 
161 161
 var C = Config{}
162 162
 
163
-func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
163
+func Init(options ...Opt) error { //nolint: gocyclo, funlen, cyclop
164 164
 	for _, opt := range options {
165 165
 		switch opt.Option {
166 166
 		case OptionTypeDebug:
167
-			C.Debug = opt.Value.(bool) // nolint: forcetypeassert
167
+			C.Debug = opt.Value.(bool) //nolint: forcetypeassert
168 168
 		case OptionTypeVerbose:
169
-			C.Verbose = opt.Value.(bool) // nolint: forcetypeassert
169
+			C.Verbose = opt.Value.(bool) //nolint: forcetypeassert
170 170
 		case OptionTypePreferIP:
171
-			value := opt.Value.(string) // nolint: forcetypeassert
171
+			value := opt.Value.(string) //nolint: forcetypeassert
172 172
 			switch value {
173 173
 			case "ipv4":
174 174
 				C.PreferIP = PreferIPv4
@@ -178,25 +178,25 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
178 178
 				return fmt.Errorf("incorrect direct IP mode %s", value)
179 179
 			}
180 180
 		case OptionTypeBind:
181
-			C.Bind = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
181
+			C.Bind = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
182 182
 		case OptionTypePublicIPv4:
183
-			C.PublicIPv4 = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
183
+			C.PublicIPv4 = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
184 184
 			if C.PublicIPv4 == nil {
185 185
 				C.PublicIPv4 = &net.TCPAddr{}
186 186
 			}
187 187
 		case OptionTypePublicIPv6:
188
-			C.PublicIPv6 = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
188
+			C.PublicIPv6 = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
189 189
 			if C.PublicIPv6 == nil {
190 190
 				C.PublicIPv6 = &net.TCPAddr{}
191 191
 			}
192 192
 		case OptionTypeStatsBind:
193
-			C.StatsBind = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
193
+			C.StatsBind = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
194 194
 		case OptionTypeStatsNamespace:
195
-			C.StatsNamespace = opt.Value.(string) // nolint: forcetypeassert
195
+			C.StatsNamespace = opt.Value.(string) //nolint: forcetypeassert
196 196
 		case OptionTypeStatsdAddress:
197
-			C.StatsdAddr = opt.Value.(*net.TCPAddr) // nolint: forcetypeassert
197
+			C.StatsdAddr = opt.Value.(*net.TCPAddr) //nolint: forcetypeassert
198 198
 		case OptionTypeStatsdTagsFormat:
199
-			value := opt.Value.(string) // nolint: forcetypeassert
199
+			value := opt.Value.(string) //nolint: forcetypeassert
200 200
 			switch value {
201 201
 			case "datadog":
202 202
 				C.StatsdTagsFormat = statsd.TagFormatDatadog
@@ -206,26 +206,26 @@ func Init(options ...Opt) error { // nolint: gocyclo, funlen, cyclop
206 206
 				return fmt.Errorf("incorrect statsd tag %s", value)
207 207
 			}
208 208
 		case OptionTypeStatsdTags:
209
-			C.StatsdTags = opt.Value.(map[string]string) // nolint: forcetypeassert
209
+			C.StatsdTags = opt.Value.(map[string]string) //nolint: forcetypeassert
210 210
 		case OptionTypeWriteBufferSize:
211
-			C.WriteBuffer = int(opt.Value.(units.Base2Bytes)) // nolint: forcetypeassert
211
+			C.WriteBuffer = int(opt.Value.(units.Base2Bytes)) //nolint: forcetypeassert
212 212
 		case OptionTypeReadBufferSize:
213
-			C.ReadBuffer = int(opt.Value.(units.Base2Bytes)) // nolint: forcetypeassert
213
+			C.ReadBuffer = int(opt.Value.(units.Base2Bytes)) //nolint: forcetypeassert
214 214
 		case OptionTypeCloakPort:
215
-			C.CloakPort = int(opt.Value.(uint16)) // nolint: forcetypeassert
215
+			C.CloakPort = int(opt.Value.(uint16)) //nolint: forcetypeassert
216 216
 		case OptionTypeAntiReplayMaxSize:
217
-			C.AntiReplayMaxSize = int(opt.Value.(units.Base2Bytes)) // nolint: forcetypeassert
217
+			C.AntiReplayMaxSize = int(opt.Value.(units.Base2Bytes)) //nolint: forcetypeassert
218 218
 		case OptionTypeMultiplexPerConnection:
219
-			C.MultiplexPerConnection = int(opt.Value.(uint)) // nolint: forcetypeassert
219
+			C.MultiplexPerConnection = int(opt.Value.(uint)) //nolint: forcetypeassert
220 220
 		case OptionTypeNTPServers:
221
-			C.NTPServers = opt.Value.([]string) // nolint: forcetypeassert
221
+			C.NTPServers = opt.Value.([]string) //nolint: forcetypeassert
222 222
 			if len(C.NTPServers) == 0 {
223 223
 				return errors.New("ntp server list is empty")
224 224
 			}
225 225
 		case OptionTypeSecret:
226
-			C.Secret = opt.Value.([]byte) // nolint: forcetypeassert
226
+			C.Secret = opt.Value.([]byte) //nolint: forcetypeassert
227 227
 		case OptionTypeAdtag:
228
-			C.AdTag = opt.Value.([]byte) // nolint: forcetypeassert
228
+			C.AdTag = opt.Value.([]byte) //nolint: forcetypeassert
229 229
 		default:
230 230
 			return fmt.Errorf("unknown tag %v", opt.Option)
231 231
 		}

+ 4
- 5
config/global_ips.go Datei anzeigen

@@ -4,7 +4,6 @@ import (
4 4
 	"context"
5 5
 	"fmt"
6 6
 	"io"
7
-	"io/ioutil"
8 7
 	"net"
9 8
 	"net/http"
10 9
 	"strings"
@@ -41,12 +40,12 @@ func fetchIP(ctx context.Context, network string) (net.IP, error) {
41 40
 		Timeout: ifconfigTimeout,
42 41
 		Transport: &http.Transport{
43 42
 			DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
44
-				return dialer.DialContext(ctx, network, addr) // nolint: wrapcheck
43
+				return dialer.DialContext(ctx, network, addr) //nolint: wrapcheck
45 44
 			},
46 45
 		},
47 46
 	}
48 47
 
49
-	req, err := http.NewRequest("GET", ifconfigAddress, nil)
48
+	req, err := http.NewRequest(http.MethodGet, ifconfigAddress, nil)
50 49
 	if err != nil {
51 50
 		return nil, fmt.Errorf("cannot create a request: %w", err)
52 51
 	}
@@ -54,7 +53,7 @@ func fetchIP(ctx context.Context, network string) (net.IP, error) {
54 53
 	resp, err := client.Do(req.WithContext(ctx))
55 54
 	if err != nil {
56 55
 		if resp != nil {
57
-			io.Copy(ioutil.Discard, resp.Body) // nolint: errcheck
56
+			io.Copy(io.Discard, resp.Body) //nolint: errcheck
58 57
 		}
59 58
 
60 59
 		return nil, fmt.Errorf("cannot perform a request: %w", err)
@@ -62,7 +61,7 @@ func fetchIP(ctx context.Context, network string) (net.IP, error) {
62 61
 
63 62
 	defer resp.Body.Close()
64 63
 
65
-	respDataBytes, err := ioutil.ReadAll(resp.Body)
64
+	respDataBytes, err := io.ReadAll(resp.Body)
66 65
 	if err != nil {
67 66
 		return nil, fmt.Errorf("cannot read response body: %w", err)
68 67
 	}

+ 7
- 6
config/urls.go Datei anzeigen

@@ -8,20 +8,21 @@ import (
8 8
 )
9 9
 
10 10
 type URLs struct {
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
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 17
 type IPURLs struct {
18 18
 	IPv4      *URLs  `json:"ipv4,omitempty"`
19 19
 	IPv6      *URLs  `json:"ipv6,omitempty"`
20
-	BotSecret string `json:"secret_for_mtproxybot"` // nolint: tagliatelle
20
+	BotSecret string `json:"secret_for_mtproxybot"` //nolint: tagliatelle
21 21
 }
22 22
 
23
-func GetURLs() (urls IPURLs) {
23
+func GetURLs() IPURLs {
24 24
 	secret := ""
25
+	urls := IPURLs{}
25 26
 
26 27
 	switch C.SecretMode {
27 28
 	case SecretModeSimple:

+ 2
- 2
faketls/client_protocol.go Datei anzeigen

@@ -52,10 +52,10 @@ func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conn
52 52
 
53 53
 	conn, err := c.ClientProtocol.Handshake(conn)
54 54
 	if err != nil {
55
-		return nil, err // nolint: wrapcheck
55
+		return nil, err //nolint: wrapcheck
56 56
 	}
57 57
 
58
-	return conn, err // nolint: wrapcheck
58
+	return conn, err //nolint: wrapcheck
59 59
 }
60 60
 
61 61
 func (c *ClientProtocol) tlsHandshake(conn io.ReadWriter) error {

+ 2
- 2
faketls/cloak.go Datei anzeigen

@@ -26,7 +26,7 @@ func cloak(one, another io.ReadWriteCloser) {
26 26
 	another = rwc.NewPing(ctx, another, channelPing)
27 27
 	wg := &sync.WaitGroup{}
28 28
 
29
-	wg.Add(2) // nolint: gomnd
29
+	wg.Add(2) //nolint: gomnd
30 30
 
31 31
 	go cloakPipe(one, another, wg)
32 32
 
@@ -69,5 +69,5 @@ func cloak(one, another io.ReadWriteCloser) {
69 69
 func cloakPipe(one io.Writer, another io.Reader, wg *sync.WaitGroup) {
70 70
 	defer wg.Done()
71 71
 
72
-	io.Copy(one, another) // nolint: errcheck
72
+	io.Copy(one, another) //nolint: errcheck
73 73
 }

+ 5
- 2
go.mod Datei anzeigen

@@ -14,8 +14,8 @@ require (
14 14
 	go.uber.org/multierr v1.8.0 // indirect
15 15
 	go.uber.org/zap v1.21.0
16 16
 	golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
17
-	golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
18
-	golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8
17
+	golang.org/x/net v0.0.0-20220809012201-f428fae20770 // indirect
18
+	golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664
19 19
 	google.golang.org/protobuf v1.27.1 // indirect
20 20
 	gopkg.in/alecthomas/kingpin.v2 v2.2.6
21 21
 )
@@ -27,5 +27,8 @@ require (
27 27
 	github.com/golang/protobuf v1.5.2 // indirect
28 28
 	github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
29 29
 	github.com/prometheus/client_model v0.2.0 // indirect
30
+	github.com/yuin/goldmark v1.4.13 // indirect
30 31
 	go.uber.org/atomic v1.9.0 // indirect
32
+	golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
33
+	golang.org/x/tools v0.1.12 // indirect
31 34
 )

+ 10
- 0
go.sum Datei anzeigen

@@ -208,6 +208,8 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
208 208
 github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
209 209
 github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
210 210
 github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
211
+github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
212
+github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
211 213
 go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
212 214
 go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
213 215
 go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
@@ -262,6 +264,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
262 264
 golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
263 265
 golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
264 266
 golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
267
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
268
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
265 269
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
266 270
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
267 271
 golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -294,6 +298,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
294 298
 golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
295 299
 golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
296 300
 golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
301
+golang.org/x/net v0.0.0-20220809012201-f428fae20770 h1:dIi4qVdvjZEjiMDv7vhokAZNGnz3kepwuXqFKYDdDMs=
302
+golang.org/x/net v0.0.0-20220809012201-f428fae20770/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
297 303
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
298 304
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
299 305
 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -351,6 +357,8 @@ golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBc
351 357
 golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
352 358
 golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
353 359
 golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
360
+golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
361
+golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
354 362
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
355 363
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
356 364
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -402,6 +410,8 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
402 410
 golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
403 411
 golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
404 412
 golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
413
+golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
414
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
405 415
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
406 416
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
407 417
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

+ 2
- 2
hub/connection.go Datei anzeigen

@@ -30,7 +30,7 @@ type connection struct {
30 30
 	channelConnDetach chan conntypes.ConnID
31 31
 }
32 32
 
33
-func (c *connection) run() { // nolint: cyclop
33
+func (c *connection) run() { //nolint: cyclop
34 34
 	defer c.Close()
35 35
 
36 36
 	ttl := time.NewTimer(connectionTTL)
@@ -148,7 +148,7 @@ func newConnection(req *protocol.TelegramRequest) (*connection, error) {
148 148
 		return nil, fmt.Errorf("cannot create a new connection: %w", err)
149 149
 	}
150 150
 
151
-	id := rand.Int() // nolint: gosec
151
+	id := rand.Int() //nolint: gosec
152 152
 	rv := &connection{
153 153
 		conn: conn,
154 154
 		id:   id,

+ 1
- 1
hub/hub.go Datei anzeigen

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

+ 0
- 5
main.go Datei anzeigen

@@ -9,7 +9,6 @@ import (
9 9
 
10 10
 	"github.com/9seconds/mtg/cli"
11 11
 	"github.com/9seconds/mtg/config"
12
-	"github.com/9seconds/mtg/utils"
13 12
 	kingpin "gopkg.in/alecthomas/kingpin.v2"
14 13
 )
15 14
 
@@ -128,10 +127,6 @@ func main() {
128 127
 	app.Version(getVersion())
129 128
 	app.HelpFlag.Short('h')
130 129
 
131
-	if err := utils.SetLimits(); err != nil {
132
-		cli.Fatal(err)
133
-	}
134
-
135 130
 	switch kingpin.MustParse(app.Parse(os.Args[1:])) {
136 131
 	case generateSecretCommand.FullCommand():
137 132
 		cli.Generate(*generateSecretType, *generateCloakHost)

+ 1
- 1
mtproto/protocol.go Datei anzeigen

@@ -51,7 +51,7 @@ func doRPCNonceRequest(conn conntypes.BasePacketWriter) (*rpc.NonceRequest, erro
51 51
 	}
52 52
 
53 53
 	if err := conn.Write(rpcNonceReq.Bytes()); err != nil {
54
-		return nil, err // nolint: wrapcheck
54
+		return nil, err //nolint: wrapcheck
55 55
 	}
56 56
 
57 57
 	return rpcNonceReq, nil

+ 1
- 1
mtproto/rpc/handshake_response.go Datei anzeigen

@@ -41,7 +41,7 @@ func (r *HandshakeResponse) Valid() error {
41 41
 // NewHandshakeResponse constructs new handshake response from the given
42 42
 // data.
43 43
 func NewHandshakeResponse(data []byte) (*HandshakeResponse, error) {
44
-	if len(data) != 32 { // nolint: gomnd
44
+	if len(data) != 32 { //nolint: gomnd
45 45
 		return nil, fmt.Errorf("incorrect handshake response length %d", len(data))
46 46
 	}
47 47
 

+ 4
- 4
mtproto/rpc/nonce_request.go Datei anzeigen

@@ -29,9 +29,9 @@ func (r *NonceRequest) Bytes() []byte {
29 29
 
30 30
 // NewNonceRequest builds new none request based on proxy secret.
31 31
 func NewNonceRequest(proxySecret []byte) (*NonceRequest, error) {
32
-	nonce := make([]byte, 16)      // nolint: gomnd
33
-	keySelector := make([]byte, 4) // nolint: gomnd
34
-	cryptoTS := make([]byte, 4)    // nolint: gomnd
32
+	nonce := make([]byte, 16)      //nolint: gomnd
33
+	keySelector := make([]byte, 4) //nolint: gomnd
34
+	cryptoTS := make([]byte, 4)    //nolint: gomnd
35 35
 
36 36
 	if _, err := rand.Read(nonce); err != nil {
37 37
 		return nil, fmt.Errorf("cannot generate nonce: %w", err)
@@ -39,7 +39,7 @@ func NewNonceRequest(proxySecret []byte) (*NonceRequest, error) {
39 39
 
40 40
 	copy(keySelector, proxySecret)
41 41
 	// 256 ^ 4 - do not know how to name
42
-	timestamp := time.Now().Truncate(time.Second).Unix() % 4294967296 // nolint: gomnd
42
+	timestamp := time.Now().Truncate(time.Second).Unix() % 4294967296 //nolint: gomnd
43 43
 	binary.LittleEndian.PutUint32(cryptoTS, uint32(timestamp))
44 44
 
45 45
 	return &NonceRequest{

+ 1
- 1
mtproto/rpc/nonce_response.go Datei anzeigen

@@ -44,7 +44,7 @@ func (r *NonceResponse) Valid(req *NonceRequest) error {
44 44
 
45 45
 // NewNonceResponse build new nonce response based on the given data.
46 46
 func NewNonceResponse(data []byte) (*NonceResponse, error) {
47
-	if len(data) != 32 { // nolint: gomnd
47
+	if len(data) != 32 { //nolint: gomnd
48 48
 		return nil, fmt.Errorf("unexpected message length %d", len(data))
49 49
 	}
50 50
 

+ 2
- 2
mtproto/rpc/proxy_flags.go Datei anzeigen

@@ -21,14 +21,14 @@ const (
21 21
 var ProxyRequestFlagsEncryptedPrefix [8]byte
22 22
 
23 23
 func (r ProxyRequestFlags) Bytes() []byte {
24
-	converted := make([]byte, 4) // nolint: gomnd
24
+	converted := make([]byte, 4) //nolint: gomnd
25 25
 	binary.LittleEndian.PutUint32(converted, uint32(r))
26 26
 
27 27
 	return converted
28 28
 }
29 29
 
30 30
 func (r ProxyRequestFlags) String() string {
31
-	flags := make([]string, 0, 7) // nolint: gomnd
31
+	flags := make([]string, 0, 7) //nolint: gomnd
32 32
 
33 33
 	if r&ProxyRequestFlagsHasAdTag != 0 {
34 34
 		flags = append(flags, "HAS_AD_TAG")

+ 1
- 1
mtproto/rpc/proxy_response.go Datei anzeigen

@@ -24,7 +24,7 @@ type ProxyResponse struct {
24 24
 func ParseProxyResponse(packet conntypes.Packet) (*ProxyResponse, error) {
25 25
 	var response ProxyResponse
26 26
 
27
-	if len(packet) < 4 { // nolint: gomnd
27
+	if len(packet) < 4 { //nolint: gomnd
28 28
 		return nil, fmt.Errorf("incorrect packet length: %d", len(packet))
29 29
 	}
30 30
 

+ 1
- 1
ntp/ntp.go Datei anzeigen

@@ -14,7 +14,7 @@ const autoUpdatePeriod = time.Minute
14 14
 
15 15
 // Fetch fetches the data on time drift.
16 16
 func Fetch() (time.Duration, error) {
17
-	url := config.C.NTPServers[rand.Intn(len(config.C.NTPServers))] // nolint: gosec
17
+	url := config.C.NTPServers[rand.Intn(len(config.C.NTPServers))] //nolint: gosec
18 18
 
19 19
 	resp, err := ntp.Query(url)
20 20
 	if err != nil {

+ 7
- 5
obfuscated2/client_protocol.go Datei anzeigen

@@ -93,12 +93,14 @@ func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conn
93 93
 	return stream.NewObfuscated2(socket, encryptor, decryptor), nil
94 94
 }
95 95
 
96
-func (c *ClientProtocol) ReadFrame(socket conntypes.StreamReader) (fm Frame, err error) {
97
-	if _, err = io.ReadFull(handshakeReader{socket}, fm.Bytes()); err != nil {
98
-		err = fmt.Errorf("cannot extract obfuscated2 frame: %w", err)
96
+func (c *ClientProtocol) ReadFrame(socket conntypes.StreamReader) (Frame, error) {
97
+	fm := Frame{}
98
+
99
+	if _, err := io.ReadFull(handshakeReader{socket}, fm.Bytes()); err != nil {
100
+		return fm, fmt.Errorf("cannot extract obfuscated2 frame: %w", err)
99 101
 	}
100 102
 
101
-	return
103
+	return fm, nil
102 104
 }
103 105
 
104 106
 type handshakeReader struct {
@@ -106,7 +108,7 @@ type handshakeReader struct {
106 108
 }
107 109
 
108 110
 func (h handshakeReader) Read(p []byte) (int, error) {
109
-	return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout) // nolint: wrapcheck
111
+	return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout) //nolint: wrapcheck
110 112
 }
111 113
 
112 114
 func MakeClientProtocol() protocol.ClientProtocol {

+ 3
- 3
obfuscated2/frame.go Datei anzeigen

@@ -44,11 +44,11 @@ func (f *Frame) Unique() []byte {
44 44
 	return f.data[frameOffsetFirst:frameOffsetDC]
45 45
 }
46 46
 
47
-func (f *Frame) Invert() (nf Frame) {
48
-	nf = *f
47
+func (f *Frame) Invert() Frame {
48
+	nf := *f
49 49
 	for i := 0; i < frameLenKey+frameLenIV; i++ {
50 50
 		nf.data[frameOffsetFirst+i] = f.data[frameOffsetIV-1-i]
51 51
 	}
52 52
 
53
-	return
53
+	return nf
54 54
 }

+ 8
- 7
obfuscated2/telegram_protocol.go Datei anzeigen

@@ -39,7 +39,8 @@ func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.StreamReadWriteC
39 39
 	return stream.NewObfuscated2(conn, encryptor, decryptor), nil
40 40
 }
41 41
 
42
-func generateFrame(cp protocol.ClientProtocol) (fm Frame) {
42
+func generateFrame(cp protocol.ClientProtocol) Frame {
43
+	fm := Frame{}
43 44
 	data := fm.Bytes()
44 45
 
45 46
 	for {
@@ -47,22 +48,22 @@ func generateFrame(cp protocol.ClientProtocol) (fm Frame) {
47 48
 			continue
48 49
 		}
49 50
 
50
-		if data[0] == 0xef { // nolint: gomnd
51
+		if data[0] == 0xef { //nolint: gomnd
51 52
 			continue
52 53
 		}
53 54
 
54
-		val := (uint32(data[3]) << 24) | (uint32(data[2]) << 16) | (uint32(data[1]) << 8) | uint32(data[0])        // nolint: gomnd, lll
55
-		if val == 0x44414548 || val == 0x54534f50 || val == 0x20544547 || val == 0x4954504f || val == 0xeeeeeeee { // nolint: lll
55
+		val := (uint32(data[3]) << 24) | (uint32(data[2]) << 16) | (uint32(data[1]) << 8) | uint32(data[0])        //nolint: gomnd, lll
56
+		if val == 0x44414548 || val == 0x54534f50 || val == 0x20544547 || val == 0x4954504f || val == 0xeeeeeeee { //nolint: lll
56 57
 			continue
57 58
 		}
58 59
 
59
-		val = (uint32(data[7]) << 24) | (uint32(data[6]) << 16) | (uint32(data[5]) << 8) | uint32(data[4]) // nolint: gomnd
60
-		if val == 0x00000000 {                                                                             // nolint: gomnd
60
+		val = (uint32(data[7]) << 24) | (uint32(data[6]) << 16) | (uint32(data[5]) << 8) | uint32(data[4]) //nolint: gomnd
61
+		if val == 0x00000000 {                                                                             //nolint: gomnd
61 62
 			continue
62 63
 		}
63 64
 
64 65
 		copy(fm.Magic(), cp.ConnectionType().Tag())
65 66
 
66
-		return
67
+		return fm
67 68
 	}
68 69
 }

+ 2
- 2
proxy/direct.go Datei anzeigen

@@ -14,13 +14,13 @@ const directPipeBufferSize = 1024
14 14
 func directConnection(request *protocol.TelegramRequest) error {
15 15
 	telegramConnRaw, err := obfuscated2.TelegramProtocol(request)
16 16
 	if err != nil {
17
-		return err // nolint: wrapcheck
17
+		return err //nolint: wrapcheck
18 18
 	}
19 19
 
20 20
 	defer telegramConnRaw.Close()
21 21
 
22 22
 	wg := &sync.WaitGroup{}
23
-	wg.Add(2) // nolint: gomnd
23
+	wg.Add(2) //nolint: gomnd
24 24
 
25 25
 	go directPipe(telegramConnRaw, request.ClientConn, wg, request.Logger)
26 26
 

+ 1
- 1
proxy/middle.go Datei anzeigen

@@ -32,7 +32,7 @@ func middleConnection(request *protocol.TelegramRequest) {
32 32
 	}
33 33
 
34 34
 	wg := &sync.WaitGroup{}
35
-	wg.Add(2) // nolint: gomnd
35
+	wg.Add(2) //nolint: gomnd
36 36
 
37 37
 	go middlePipe(telegramConn, clientConn, wg, request.Logger)
38 38
 

+ 2
- 2
stats/stats.go Datei anzeigen

@@ -28,11 +28,11 @@ func Init(ctx context.Context) error {
28 28
 		Handler: mux,
29 29
 	}
30 30
 
31
-	go srv.Serve(listener) // nolint: errcheck
31
+	go srv.Serve(listener) //nolint: errcheck
32 32
 
33 33
 	go func() {
34 34
 		<-ctx.Done()
35
-		srv.Shutdown(context.Background()) // nolint: errcheck, contextcheck
35
+		srv.Shutdown(context.Background()) //nolint: errcheck
36 36
 	}()
37 37
 
38 38
 	Stats = multiStats(stats)

+ 4
- 4
stats/stats_statsd.go Datei anzeigen

@@ -83,7 +83,7 @@ func (s *statsStatsd) ClientDisconnected(connectionType conntypes.ConnectionType
83 83
 }
84 84
 
85 85
 func (s *statsStatsd) changeConnections(connectionType conntypes.ConnectionType, addr *net.TCPAddr, increment int64) {
86
-	tags := make([]*statsStatsdTag, 0, 2) // nolint: gomnd
86
+	tags := make([]*statsStatsdTag, 0, 2) //nolint: gomnd
87 87
 
88 88
 	switch connectionType {
89 89
 	case conntypes.ConnectionTypeAbridged:
@@ -172,7 +172,7 @@ func (s *statsStatsd) initGauge(metric, key string, tags []statsd.Tag) {
172 172
 		s.seenMutex.RUnlock()
173 173
 
174 174
 		return
175
-	} else { // nolint: golint,revive
175
+	} else { //nolint: golint,revive
176 176
 		s.seenMutex.RUnlock()
177 177
 	}
178 178
 
@@ -194,8 +194,8 @@ func newStatsStatsd() Interface {
194 194
 	return &statsStatsd{
195 195
 		seen: make(map[string]struct{}),
196 196
 		client: statsd.NewClient(config.C.StatsdAddr.String(),
197
-			statsd.SendLoopCount(2),                  // nolint: gomnd
198
-			statsd.ReconnectInterval(10*time.Second), // nolint: gomnd
197
+			statsd.SendLoopCount(2),                  //nolint: gomnd
198
+			statsd.ReconnectInterval(10*time.Second), //nolint: gomnd
199 199
 			statsd.Logger(logger),
200 200
 			statsd.MetricPrefix(prefix),
201 201
 			statsd.TagStyle(config.C.StatsdTagsFormat),

+ 6
- 6
telegram/api/addresses.go Datei anzeigen

@@ -12,8 +12,8 @@ import (
12 12
 )
13 13
 
14 14
 const (
15
-	addressesURLV4 = "https://core.telegram.org/getProxyConfig"   // nolint: gas
16
-	addressesURLV6 = "https://core.telegram.org/getProxyConfigV6" // nolint: gas
15
+	addressesURLV4 = "https://core.telegram.org/getProxyConfig"   //nolint: gas
16
+	addressesURLV6 = "https://core.telegram.org/getProxyConfigV6" //nolint: gas
17 17
 )
18 18
 
19 19
 var addressesProxyForSplitter = regexp.MustCompile(`\s+`)
@@ -74,12 +74,12 @@ func getAddresses(url string) (map[conntypes.DC][]string, conntypes.DC, error) {
74 74
 }
75 75
 
76 76
 func addressesParseProxyFor(text string) (string, conntypes.DC, error) {
77
-	chunks := addressesProxyForSplitter.Split(text, 3) // nolint: gomnd
77
+	chunks := addressesProxyForSplitter.Split(text, 3) //nolint: gomnd
78 78
 	if len(chunks) != 3 || chunks[0] != "proxy_for" {
79 79
 		return "", 0, fmt.Errorf("incorrect config %s", text)
80 80
 	}
81 81
 
82
-	dc, err := strconv.ParseInt(chunks[1], 10, 16) // nolint: gomnd
82
+	dc, err := strconv.ParseInt(chunks[1], 10, 16) //nolint: gomnd
83 83
 	if err != nil {
84 84
 		return "", 0, fmt.Errorf("incorrect config '%s': %w", text, err)
85 85
 	}
@@ -93,14 +93,14 @@ func addressesParseProxyFor(text string) (string, conntypes.DC, error) {
93 93
 }
94 94
 
95 95
 func addressesParseDefault(text string) (conntypes.DC, error) {
96
-	chunks := addressesProxyForSplitter.Split(text, 2) // nolint: gomnd
96
+	chunks := addressesProxyForSplitter.Split(text, 2) //nolint: gomnd
97 97
 	if len(chunks) != 2 || chunks[0] != "default" {
98 98
 		return 0, fmt.Errorf("incorrect config '%s'", text)
99 99
 	}
100 100
 
101 101
 	dcString := strings.TrimRight(chunks[1], ";")
102 102
 
103
-	dc, err := strconv.ParseInt(dcString, 10, 16) // nolint: gomnd
103
+	dc, err := strconv.ParseInt(dcString, 10, 16) //nolint: gomnd
104 104
 	if err != nil {
105 105
 		return 0, fmt.Errorf("incorrect config '%s': %w", text, err)
106 106
 	}

+ 3
- 4
telegram/api/api.go Datei anzeigen

@@ -4,7 +4,6 @@ import (
4 4
 	"context"
5 5
 	"fmt"
6 6
 	"io"
7
-	"io/ioutil"
8 7
 	"net/http"
9 8
 	"time"
10 9
 )
@@ -22,7 +21,7 @@ func request(url string) (io.ReadCloser, error) {
22 21
 	ctx, cancel := context.WithTimeout(context.Background(), apiHTTPTimeout)
23 22
 	defer cancel()
24 23
 
25
-	req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
24
+	req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
26 25
 	if err != nil {
27 26
 		panic(err)
28 27
 	}
@@ -33,12 +32,12 @@ func request(url string) (io.ReadCloser, error) {
33 32
 	resp, err := httpClient.Do(req)
34 33
 	if err != nil {
35 34
 		if resp != nil {
36
-			io.Copy(ioutil.Discard, resp.Body) // nolint: errcheck
35
+			io.Copy(io.Discard, resp.Body) //nolint: errcheck
37 36
 			resp.Body.Close()
38 37
 		}
39 38
 
40 39
 		return nil, fmt.Errorf("cannot perform a request: %w", err)
41 40
 	}
42 41
 
43
-	return resp.Body, err // nolint: wrapcheck
42
+	return resp.Body, err //nolint: wrapcheck
44 43
 }

+ 3
- 3
telegram/api/secret.go Datei anzeigen

@@ -2,10 +2,10 @@ package api
2 2
 
3 3
 import (
4 4
 	"fmt"
5
-	"io/ioutil"
5
+	"io"
6 6
 )
7 7
 
8
-const secretURL = "https://core.telegram.org/getProxySecret" // nolint: gas
8
+const secretURL = "https://core.telegram.org/getProxySecret" //nolint: gas
9 9
 
10 10
 func Secret() ([]byte, error) {
11 11
 	resp, err := request(secretURL)
@@ -15,7 +15,7 @@ func Secret() ([]byte, error) {
15 15
 
16 16
 	defer resp.Close()
17 17
 
18
-	secret, err := ioutil.ReadAll(resp)
18
+	secret, err := io.ReadAll(resp)
19 19
 	if err != nil {
20 20
 		return nil, fmt.Errorf("cannot read response: %w", err)
21 21
 	}

+ 2
- 2
telegram/base.go Datei anzeigen

@@ -51,7 +51,7 @@ func (b *baseTelegram) dial(dc conntypes.DC,
51 51
 }
52 52
 
53 53
 func (b *baseTelegram) getAddresses(dc conntypes.DC, protocol conntypes.ConnectionProtocol) []string {
54
-	addresses := make([]string, 0, 2) // nolint: gomnd
54
+	addresses := make([]string, 0, 2) //nolint: gomnd
55 55
 	protos := []conntypes.ConnectionProtocol{
56 56
 		conntypes.ConnectionProtocolIPv6,
57 57
 		conntypes.ConnectionProtocolIPv4,
@@ -86,7 +86,7 @@ func (b *baseTelegram) chooseAddress(addresses map[conntypes.DC][]string,
86 86
 	case len(addrs) == 1:
87 87
 		return addrs[0]
88 88
 	case len(addrs) > 1:
89
-		return addrs[rand.Intn(len(addrs))] // nolint: gosec
89
+		return addrs[rand.Intn(len(addrs))] //nolint: gosec
90 90
 	}
91 91
 
92 92
 	return ""

+ 14
- 14
tlstypes/consts.go Datei anzeigen

@@ -20,22 +20,22 @@ const (
20 20
 type CipherSuiteType uint8
21 21
 
22 22
 const (
23
-	CipherSuiteType_TLS_AES_128_GCM_SHA256       CipherSuiteType = iota // nolint: stylecheck,golint,revive
24
-	CipherSuiteType_TLS_AES_256_GCM_SHA384                              // nolint: stylecheck,golint,revive
25
-	CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256                        // nolint: stylecheck,golint,revive
23
+	CipherSuiteType_TLS_AES_128_GCM_SHA256       CipherSuiteType = iota //nolint: stylecheck,golint,revive,nosnakecase
24
+	CipherSuiteType_TLS_AES_256_GCM_SHA384                              //nolint: stylecheck,golint,revive,nosnakecase
25
+	CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256                        //nolint: stylecheck,golint,revive,nosnakecase
26 26
 )
27 27
 
28 28
 func (c CipherSuiteType) Bytes() []byte {
29 29
 	switch c {
30
-	case CipherSuiteType_TLS_AES_128_GCM_SHA256:
31
-		return CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes
32
-	case CipherSuiteType_TLS_AES_256_GCM_SHA384:
33
-		return CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes
34
-	case CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256:
35
-		return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes
30
+	case CipherSuiteType_TLS_AES_128_GCM_SHA256: //nolint: nosnakecase
31
+		return CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes //nolint: nosnakecase
32
+	case CipherSuiteType_TLS_AES_256_GCM_SHA384: //nolint: nosnakecase
33
+		return CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes //nolint: nosnakecase
34
+	case CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256: //nolint: nosnakecase
35
+		return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes //nolint: nosnakecase
36 36
 	}
37 37
 
38
-	return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes
38
+	return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes //nolint: nosnakecase
39 39
 }
40 40
 
41 41
 type Version uint8
@@ -69,9 +69,9 @@ var (
69 69
 	Version12Bytes = []byte{0x03, 0x03}
70 70
 	Version13Bytes = []byte{0x03, 0x04}
71 71
 
72
-	CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes       = []byte{0x13, 0x01} // nolint: stylecheck,golint,revive
73
-	CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes       = []byte{0x13, 0x02} // nolint: stylecheck,golint,revive
74
-	CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes = []byte{0x13, 0x03} // nolint: stylecheck,golint,revive
72
+	CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes       = []byte{0x13, 0x01} //nolint: stylecheck,golint,revive,nosnakecase
73
+	CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes       = []byte{0x13, 0x02} //nolint: stylecheck,golint,revive,nosnakecase
74
+	CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes = []byte{0x13, 0x03} //nolint: stylecheck,golint,revive,nosnakecase
75 75
 )
76 76
 
77 77
 type Byter interface {
@@ -82,7 +82,7 @@ type Byter interface {
82 82
 type RawBytes []byte
83 83
 
84 84
 func (r RawBytes) WriteBytes(writer io.Writer) {
85
-	writer.Write(r) // nolint: errcheck
85
+	writer.Write(r) //nolint: errcheck
86 86
 }
87 87
 
88 88
 func (r RawBytes) Len() int {

+ 3
- 3
tlstypes/handshake.go Datei anzeigen

@@ -18,7 +18,7 @@ type Handshake struct {
18 18
 func (h *Handshake) WriteBytes(writer io.Writer) {
19 19
 	packetBuf := bytes.Buffer{}
20 20
 
21
-	writer.Write([]byte{byte(h.Type)}) // nolint: errcheck
21
+	writer.Write([]byte{byte(h.Type)}) //nolint: errcheck
22 22
 
23 23
 	packetBuf.Write(h.Version.Bytes())
24 24
 	packetBuf.Write(h.Random[:])
@@ -30,8 +30,8 @@ func (h *Handshake) WriteBytes(writer io.Writer) {
30 30
 	sizeUint24Bytes := sizeUint24[:]
31 31
 	sizeUint24Bytes[0], sizeUint24Bytes[2] = sizeUint24Bytes[2], sizeUint24Bytes[0]
32 32
 
33
-	writer.Write(sizeUint24Bytes) // nolint: errcheck
34
-	packetBuf.WriteTo(writer)     // nolint: errcheck
33
+	writer.Write(sizeUint24Bytes) //nolint: errcheck
34
+	packetBuf.WriteTo(writer)     //nolint: errcheck
35 35
 }
36 36
 
37 37
 func (h *Handshake) Len() int {

+ 7
- 5
tlstypes/record.go Datei anzeigen

@@ -16,9 +16,9 @@ type Record struct {
16 16
 }
17 17
 
18 18
 func (r Record) WriteBytes(writer io.Writer) {
19
-	writer.Write([]byte{byte(r.Type)})                           // nolint: errcheck
20
-	writer.Write(r.Version.Bytes())                              // nolint: errcheck
21
-	binary.Write(writer, binary.BigEndian, uint16(r.Data.Len())) // nolint: errcheck
19
+	writer.Write([]byte{byte(r.Type)})                           //nolint: errcheck
20
+	writer.Write(r.Version.Bytes())                              //nolint: errcheck
21
+	binary.Write(writer, binary.BigEndian, uint16(r.Data.Len())) //nolint: errcheck
22 22
 	r.Data.WriteBytes(writer)
23 23
 }
24 24
 
@@ -65,7 +65,9 @@ func ReadRecord(reader io.Reader) (Record, error) {
65 65
 	return rec, nil
66 66
 }
67 67
 
68
-func MakeRecords(raw []byte) (arr []Record) {
68
+func MakeRecords(raw []byte) []Record {
69
+	var arr []Record
70
+
69 71
 	for len(raw) > 0 {
70 72
 		chunkSize := recordMaxChunkSize
71 73
 		if chunkSize > len(raw) {
@@ -80,5 +82,5 @@ func MakeRecords(raw []byte) (arr []Record) {
80 82
 		raw = raw[chunkSize:]
81 83
 	}
82 84
 
83
-	return
85
+	return arr
84 86
 }

+ 8
- 8
tlstypes/server_hello.go Datei anzeigen

@@ -36,8 +36,8 @@ func (s ServerHello) WelcomePacket() []byte {
36 36
 	}
37 37
 	recChangeCipher.WriteBytes(buf)
38 38
 
39
-	hostCert := make([]byte, 1024+mrand.Intn(3092)) // nolint: gosec, gomnd
40
-	rand.Read(hostCert)                             // nolint: errcheck
39
+	hostCert := make([]byte, 1024+mrand.Intn(3092)) //nolint: gosec, gomnd
40
+	rand.Read(hostCert)                             //nolint: errcheck
41 41
 
42 42
 	recData := Record{
43 43
 		Type:    RecordTypeApplicationData,
@@ -66,8 +66,8 @@ func NewServerHello(clientHello *ClientHello) *ServerHello {
66 66
 	rv.SessionID = make([]byte, len(clientHello.SessionID))
67 67
 	copy(rv.SessionID, clientHello.SessionID)
68 68
 
69
-	tail := bytes.NewBuffer(CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes)
70
-	tail.WriteByte(0x00) // nolint: gomnd // no compression
69
+	tail := bytes.NewBuffer(CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes) //nolint: nosnakecase
70
+	tail.WriteByte(0x00)                                                  //nolint: gomnd // no compression
71 71
 	makeTLSExtensions(tail)
72 72
 	rv.Tail = RawBytes(tail.Bytes())
73 73
 
@@ -75,7 +75,7 @@ func NewServerHello(clientHello *ClientHello) *ServerHello {
75 75
 }
76 76
 
77 77
 func makeTLSExtensions(buf io.Writer) {
78
-	buf.Write([]byte{ // nolint: errcheck
78
+	buf.Write([]byte{ //nolint: errcheck
79 79
 		0x00, 0x2e, // 46 bytes of data
80 80
 		0x00, 0x33, // Extension - Key Share
81 81
 		0x00, 0x24, // 36 bytes
@@ -85,11 +85,11 @@ func makeTLSExtensions(buf io.Writer) {
85 85
 
86 86
 	var scalar [32]byte
87 87
 
88
-	rand.Read(scalar[:]) // nolint: errcheck
88
+	rand.Read(scalar[:]) //nolint: errcheck
89 89
 	curve, _ := curve25519.X25519(scalar[:], curve25519.Basepoint)
90
-	buf.Write(curve) // nolint: errcheck
90
+	buf.Write(curve) //nolint: errcheck
91 91
 
92
-	buf.Write([]byte{ // nolint: errcheck
92
+	buf.Write([]byte{ //nolint: errcheck
93 93
 		0x00, 0x2b, // Extension - Supported Versions
94 94
 		0x00, 0x02, // 2 bytes are following
95 95
 		0x03, 0x04, // TLS 1.3

+ 1
- 1
utils/init_tcp.go Datei anzeigen

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

+ 4
- 3
utils/read_full.go Datei anzeigen

@@ -4,14 +4,15 @@ import "io"
4 4
 
5 5
 const readFullBufferSize = 1024 + 1 // +1 because telegram opreates with blocks mod 4
6 6
 
7
-func ReadFull(src io.Reader) (rv []byte, err error) {
7
+func ReadFull(src io.Reader) ([]byte, error) {
8 8
 	buf := make([]byte, readFullBufferSize)
9 9
 	n := readFullBufferSize
10
+	rv := []byte{}
10 11
 
11 12
 	for n == len(buf) {
12
-		n, err = src.Read(buf)
13
+		n, err := src.Read(buf)
13 14
 		if err != nil {
14
-			return nil, err // nolint: wrapcheck
15
+			return nil, err //nolint: wrapcheck
15 16
 		}
16 17
 
17 18
 		rv = append(rv, buf[:n]...)

+ 1
- 1
utils/reverse_bytes.go Datei anzeigen

@@ -6,7 +6,7 @@ func ReverseBytes(data []byte) []byte {
6 6
 	rv := make([]byte, dataLen)
7 7
 	rv[dataLen/2] = data[dataLen/2]
8 8
 
9
-	for i := dataLen/2 - 1; i >= 0; i-- { // nolint: gomnd
9
+	for i := dataLen/2 - 1; i >= 0; i-- { //nolint: gomnd
10 10
 		opp := dataLen - i - 1
11 11
 		rv[i], rv[opp] = data[opp], data[i]
12 12
 	}

+ 0
- 25
utils/rlimit.go Datei anzeigen

@@ -1,25 +0,0 @@
1
-//go:build !windows
2
-// +build !windows
3
-
4
-package utils
5
-
6
-import (
7
-	"fmt"
8
-
9
-	"golang.org/x/sys/unix"
10
-)
11
-
12
-func SetLimits() error {
13
-	rLimit := unix.Rlimit{}
14
-	if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rLimit); err != nil {
15
-		return fmt.Errorf("cannot get rlimit: %w", err)
16
-	}
17
-
18
-	rLimit.Cur = rLimit.Max
19
-
20
-	if err := unix.Setrlimit(unix.RLIMIT_NOFILE, &rLimit); err != nil {
21
-		return fmt.Errorf("cannot set rlimit: %w", err)
22
-	}
23
-
24
-	return nil
25
-}

+ 2
- 2
utils/uint24.go Datei anzeigen

@@ -3,9 +3,9 @@ package utils
3 3
 type Uint24 [3]byte
4 4
 
5 5
 func ToUint24(number uint32) Uint24 {
6
-	return Uint24{byte(number), byte(number >> 8), byte(number >> 16)} // nolint: gomnd
6
+	return Uint24{byte(number), byte(number >> 8), byte(number >> 16)} //nolint: gomnd
7 7
 }
8 8
 
9 9
 func FromUint24(number Uint24) uint32 {
10
-	return uint32(number[0]) + (uint32(number[1]) << 8) + (uint32(number[2]) << 16) // nolint: gomnd
10
+	return uint32(number[0]) + (uint32(number[1]) << 8) + (uint32(number[2]) << 16) //nolint: gomnd
11 11
 }

+ 18
- 16
wrappers/packet/mtproto_frame.go Datei anzeigen

@@ -7,7 +7,6 @@ import (
7 7
 	"fmt"
8 8
 	"hash/crc32"
9 9
 	"io"
10
-	"io/ioutil"
11 10
 	"net"
12 11
 
13 12
 	"github.com/9seconds/mtg/conntypes"
@@ -28,11 +27,14 @@ var mtprotoFramePadding = []byte{0x04, 0x00, 0x00, 0x00}
28 27
 //
29 28
 // MSGLEN is the length of the message + len of seqno and msglen.
30 29
 // SEQNO is the number of frame in the receive/send sequence. If client
31
-//   sends a message with SeqNo 18, it has to receive message with SeqNo 18.
30
+//
31
+//	sends a message with SeqNo 18, it has to receive message with SeqNo 18.
32
+//
32 33
 // MSG is the data which has to be written
33 34
 // CRC32 is the CRC32 checksum of MSGLEN + SEQNO + MSG
34 35
 // PADDING is custom padding schema to complete frame length to such that
35
-//    len(frame) % 16 == 0
36
+//
37
+//	len(frame) % 16 == 0
36 38
 type wrapperMtprotoFrame struct {
37 39
 	parent     conntypes.StreamReadWriteCloser
38 40
 	logger     *zap.SugaredLogger
@@ -40,7 +42,7 @@ type wrapperMtprotoFrame struct {
40 42
 	writeSeqNo int32
41 43
 }
42 44
 
43
-func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { // nolint: funlen, cyclop
45
+func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { //nolint: funlen, cyclop
44 46
 	buf := &bytes.Buffer{}
45 47
 
46 48
 	sum := crc32.NewIEEE()
@@ -50,7 +52,7 @@ func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { // nolint: funl
50 52
 		buf.Reset()
51 53
 		sum.Reset()
52 54
 
53
-		if _, err := io.CopyN(writer, w.parent, 4); err != nil { // nolint: gomnd
55
+		if _, err := io.CopyN(writer, w.parent, 4); err != nil { //nolint: gomnd
54 56
 			return nil, fmt.Errorf("cannot read frame padding: %w", err)
55 57
 		}
56 58
 
@@ -72,23 +74,23 @@ func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { // nolint: funl
72 74
 
73 75
 	buf.Reset()
74 76
 
75
-	if _, err := io.CopyN(writer, w.parent, int64(messageLength)-4-4); err != nil { // nolint: gomnd
77
+	if _, err := io.CopyN(writer, w.parent, int64(messageLength)-4-4); err != nil { //nolint: gomnd
76 78
 		return nil, fmt.Errorf("cannot read the message frame: %w", err)
77 79
 	}
78 80
 
79 81
 	var seqNo int32
80 82
 
81
-	binary.Read(buf, binary.LittleEndian, &seqNo) // nolint: errcheck
83
+	binary.Read(buf, binary.LittleEndian, &seqNo) //nolint: errcheck
82 84
 
83 85
 	if seqNo != w.readSeqNo {
84 86
 		return nil, fmt.Errorf("unexpected sequence number %d (wait for %d)", seqNo, w.readSeqNo)
85 87
 	}
86 88
 
87
-	data, _ := ioutil.ReadAll(buf)
89
+	data, _ := io.ReadAll(buf)
88 90
 	buf.Reset()
89 91
 	// write to buf, not to writer. This is because we are going to fetch
90 92
 	// crc32 checksum.
91
-	if _, err := io.CopyN(buf, w.parent, 4); err != nil { // nolint: gomnd
93
+	if _, err := io.CopyN(buf, w.parent, 4); err != nil { //nolint: gomnd
92 94
 		return nil, fmt.Errorf("cannot read checksum: %w", err)
93 95
 	}
94 96
 
@@ -109,18 +111,18 @@ func (w *wrapperMtprotoFrame) Read() (conntypes.Packet, error) { // nolint: funl
109 111
 }
110 112
 
111 113
 func (w *wrapperMtprotoFrame) Write(p conntypes.Packet) error {
112
-	messageLength := 4 + 4 + len(p) + 4 // nolint: gomnd
114
+	messageLength := 4 + 4 + len(p) + 4 //nolint: gomnd
113 115
 	paddingLength := (aes.BlockSize - messageLength%aes.BlockSize) % aes.BlockSize
114 116
 
115 117
 	buf := &bytes.Buffer{}
116 118
 
117
-	binary.Write(buf, binary.LittleEndian, uint32(messageLength)) // nolint: errcheck
118
-	binary.Write(buf, binary.LittleEndian, w.writeSeqNo)          // nolint: errcheck
119
+	binary.Write(buf, binary.LittleEndian, uint32(messageLength)) //nolint: errcheck
120
+	binary.Write(buf, binary.LittleEndian, w.writeSeqNo)          //nolint: errcheck
119 121
 	buf.Write(p)
120 122
 
121 123
 	checksum := crc32.ChecksumIEEE(buf.Bytes())
122
-	binary.Write(buf, binary.LittleEndian, checksum)              // nolint: errcheck
123
-	buf.Write(bytes.Repeat(mtprotoFramePadding, paddingLength/4)) // nolint: gomnd
124
+	binary.Write(buf, binary.LittleEndian, checksum)              //nolint: errcheck
125
+	buf.Write(bytes.Repeat(mtprotoFramePadding, paddingLength/4)) //nolint: gomnd
124 126
 
125 127
 	w.logger.Debugw("Write MTProto frame",
126 128
 		"length", len(p),
@@ -132,11 +134,11 @@ func (w *wrapperMtprotoFrame) Write(p conntypes.Packet) error {
132 134
 
133 135
 	_, err := w.parent.Write(buf.Bytes())
134 136
 
135
-	return err // nolint: wrapcheck
137
+	return err //nolint: wrapcheck
136 138
 }
137 139
 
138 140
 func (w *wrapperMtprotoFrame) Close() error {
139
-	return w.parent.Close() // nolint: wrapcheck
141
+	return w.parent.Close() //nolint: wrapcheck
140 142
 }
141 143
 
142 144
 func (w *wrapperMtprotoFrame) Conn() net.Conn {

+ 4
- 4
wrappers/packetack/client_abridged.go Datei anzeigen

@@ -39,9 +39,9 @@ func (w *wrapperClientAbridged) Read(acks *conntypes.ConnectionAcks) (conntypes.
39 39
 	}
40 40
 
41 41
 	if msgLength == clientAbridgedSmallPacketLength {
42
-		buf.Grow(3) // nolint: gomnd
42
+		buf.Grow(3) //nolint: gomnd
43 43
 
44
-		if _, err := io.CopyN(&buf, w.parent, 3); err != nil { // nolint: gomnd
44
+		if _, err := io.CopyN(&buf, w.parent, 3); err != nil { //nolint: gomnd
45 45
 			return nil, fmt.Errorf("cannot read correct message length: %w", err)
46 46
 		}
47 47
 
@@ -75,7 +75,7 @@ func (w *wrapperClientAbridged) Write(packet conntypes.Packet, acks *conntypes.C
75 75
 		return nil
76 76
 	}
77 77
 
78
-	packetLength := len(packet) / 4 // nolint: gomnd
78
+	packetLength := len(packet) / 4 //nolint: gomnd
79 79
 
80 80
 	switch {
81 81
 	case packetLength < clientAbridgedSmallPacketLength:
@@ -104,7 +104,7 @@ func (w *wrapperClientAbridged) Write(packet conntypes.Packet, acks *conntypes.C
104 104
 }
105 105
 
106 106
 func (w *wrapperClientAbridged) Close() error {
107
-	return w.parent.Close() // nolint: wrapcheck
107
+	return w.parent.Close() //nolint: wrapcheck
108 108
 }
109 109
 
110 110
 func (w *wrapperClientAbridged) Conn() net.Conn {

+ 3
- 3
wrappers/packetack/client_intermediate.go Datei anzeigen

@@ -20,9 +20,9 @@ type wrapperClientIntermediate struct {
20 20
 func (w *wrapperClientIntermediate) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {
21 21
 	buf := bytes.Buffer{}
22 22
 
23
-	buf.Grow(4) // nolint: gomnd
23
+	buf.Grow(4) //nolint: gomnd
24 24
 
25
-	if _, err := io.CopyN(&buf, w.parent, 4); err != nil { // nolint: gomnd
25
+	if _, err := io.CopyN(&buf, w.parent, 4); err != nil { //nolint: gomnd
26 26
 		return nil, fmt.Errorf("cannot read message length: %w", err)
27 27
 	}
28 28
 
@@ -63,7 +63,7 @@ func (w *wrapperClientIntermediate) Write(packet conntypes.Packet, acks *conntyp
63 63
 }
64 64
 
65 65
 func (w *wrapperClientIntermediate) Close() error {
66
-	return w.parent.Close() // nolint: wrapcheck
66
+	return w.parent.Close() //nolint: wrapcheck
67 67
 }
68 68
 
69 69
 func (w *wrapperClientIntermediate) Conn() net.Conn {

+ 3
- 3
wrappers/packetack/client_intermediate_secure.go Datei anzeigen

@@ -20,7 +20,7 @@ func (w *wrapperClientIntermediateSecure) Read(acks *conntypes.ConnectionAcks) (
20 20
 		return nil, err
21 21
 	}
22 22
 
23
-	length := len(data) - (len(data) % 4) // nolint: gomnd
23
+	length := len(data) - (len(data) % 4) //nolint: gomnd
24 24
 
25 25
 	return data[:length], nil
26 26
 }
@@ -35,11 +35,11 @@ func (w *wrapperClientIntermediateSecure) Write(packet conntypes.Packet, acks *c
35 35
 	}
36 36
 
37 37
 	buf := &bytes.Buffer{}
38
-	paddingLength := rand.Intn(4) // nolint: gosec, gomnd
38
+	paddingLength := rand.Intn(4) //nolint: gosec, gomnd
39 39
 
40 40
 	buf.Grow(4 + len(packet) + paddingLength)
41 41
 
42
-	binary.Write(buf, binary.LittleEndian, uint32(len(packet)+paddingLength)) // nolint: errcheck
42
+	binary.Write(buf, binary.LittleEndian, uint32(len(packet)+paddingLength)) //nolint: errcheck
43 43
 	buf.Write(packet)
44 44
 	buf.Write(make([]byte, paddingLength))
45 45
 

+ 2
- 2
wrappers/packetack/proxy.go Datei anzeigen

@@ -42,11 +42,11 @@ func (w *wrapperProxy) Write(packet conntypes.Packet, acks *conntypes.Connection
42 42
 	buf.Write(rpc.ProxyRequestProxyTag)
43 43
 	buf.WriteByte(byte(len(config.C.AdTag)))
44 44
 	buf.Write(config.C.AdTag)
45
-	buf.Write(make([]byte, (4-buf.Len()%4)%4)) // nolint: gomnd
45
+	buf.Write(make([]byte, (4-buf.Len()%4)%4)) //nolint: gomnd
46 46
 	buf.Grow(len(packet))
47 47
 	buf.Write(packet)
48 48
 
49
-	return w.proxy.Write(buf.Bytes()) // nolint: wrapcheck
49
+	return w.proxy.Write(buf.Bytes()) //nolint: wrapcheck
50 50
 }
51 51
 
52 52
 func (w *wrapperProxy) Read(acks *conntypes.ConnectionAcks) (conntypes.Packet, error) {

+ 3
- 3
wrappers/rwc/ping.go Datei anzeigen

@@ -20,7 +20,7 @@ func (w *wrapperPing) Read(p []byte) (int, error) {
20 20
 		}
21 21
 	}
22 22
 
23
-	return n, err // nolint: wrapcheck
23
+	return n, err //nolint: wrapcheck
24 24
 }
25 25
 
26 26
 func (w *wrapperPing) Write(p []byte) (int, error) {
@@ -32,11 +32,11 @@ func (w *wrapperPing) Write(p []byte) (int, error) {
32 32
 		}
33 33
 	}
34 34
 
35
-	return n, err // nolint: wrapcheck
35
+	return n, err //nolint: wrapcheck
36 36
 }
37 37
 
38 38
 func (w *wrapperPing) Close() error {
39
-	return w.parent.Close() // nolint: wrapcheck
39
+	return w.parent.Close() //nolint: wrapcheck
40 40
 }
41 41
 
42 42
 func NewPing(ctx context.Context, parent io.ReadWriteCloser, channelPing chan<- struct{}) io.ReadWriteCloser {

+ 3
- 3
wrappers/stream/blockcipher.go Datei anzeigen

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

+ 1
- 1
wrappers/stream/buffered_reader.go Datei anzeigen

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

+ 6
- 6
wrappers/stream/conn.go Datei anzeigen

@@ -43,7 +43,7 @@ func (w *wrapperConn) Write(p []byte) (int, error) {
43 43
 		w.Close()
44 44
 	}
45 45
 
46
-	return n, err // nolint: wrapcheck
46
+	return n, err //nolint: wrapcheck
47 47
 }
48 48
 
49 49
 func (w *wrapperConn) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
@@ -64,13 +64,13 @@ func (w *wrapperConn) Read(p []byte) (int, error) {
64 64
 		w.Close()
65 65
 	}
66 66
 
67
-	return n, err // nolint: wrapcheck
67
+	return n, err //nolint: wrapcheck
68 68
 }
69 69
 
70 70
 func (w *wrapperConn) Close() error {
71 71
 	w.logger.Debugw("Close connection")
72 72
 
73
-	return w.parent.Close() // nolint: wrapcheck
73
+	return w.parent.Close() //nolint: wrapcheck
74 74
 }
75 75
 
76 76
 func (w *wrapperConn) Conn() net.Conn {
@@ -93,9 +93,9 @@ func newConn(parent net.Conn,
93 93
 	connID conntypes.ConnID,
94 94
 	purpose connPurpose,
95 95
 ) conntypes.StreamReadWriteCloser {
96
-	localAddr := *parent.LocalAddr().(*net.TCPAddr) // nolint: forcetypeassert
96
+	localAddr := *parent.LocalAddr().(*net.TCPAddr) //nolint: forcetypeassert
97 97
 
98
-	if parent.RemoteAddr().(*net.TCPAddr).IP.To4() != nil { // nolint: forcetypeassert
98
+	if parent.RemoteAddr().(*net.TCPAddr).IP.To4() != nil { //nolint: forcetypeassert
99 99
 		if config.C.PublicIPv4.IP != nil {
100 100
 			localAddr.IP = config.C.PublicIPv4.IP
101 101
 		}
@@ -118,7 +118,7 @@ func newConn(parent net.Conn,
118 118
 		parent:     parent,
119 119
 		connID:     connID,
120 120
 		logger:     logger,
121
-		remoteAddr: parent.RemoteAddr().(*net.TCPAddr), // nolint: forcetypeassert
121
+		remoteAddr: parent.RemoteAddr().(*net.TCPAddr), //nolint: forcetypeassert
122 122
 		localAddr:  &localAddr,
123 123
 	}
124 124
 }

+ 5
- 5
wrappers/stream/ctx.go Datei anzeigen

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

+ 4
- 4
wrappers/stream/faketls.go Datei anzeigen

@@ -20,7 +20,7 @@ type wrapperFakeTLS struct {
20 20
 
21 21
 func (w *wrapperFakeTLS) Write(p []byte) (int, error) {
22 22
 	return w.write(p, func(b []byte) (int, error) {
23
-		return w.parent.Write(b) // nolint: wrapcheck
23
+		return w.parent.Write(b) //nolint: wrapcheck
24 24
 	})
25 25
 }
26 26
 
@@ -30,7 +30,7 @@ func (w *wrapperFakeTLS) WriteTimeout(p []byte, timeout time.Duration) (int, err
30 30
 	return w.write(p, func(b []byte) (int, error) {
31 31
 		elapsed := time.Since(startTime)
32 32
 		if elapsed > timeout {
33
-			return w.parent.WriteTimeout(b, timeout-elapsed) // nolint: wrapcheck
33
+			return w.parent.WriteTimeout(b, timeout-elapsed) //nolint: wrapcheck
34 34
 		}
35 35
 
36 36
 		return 0, errors.New("timeout")
@@ -73,7 +73,7 @@ func (w *wrapperFakeTLS) RemoteAddr() *net.TCPAddr {
73 73
 }
74 74
 
75 75
 func (w *wrapperFakeTLS) Close() error {
76
-	return w.parent.Close() // nolint: wrapcheck
76
+	return w.parent.Close() //nolint: wrapcheck
77 77
 }
78 78
 
79 79
 func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {
@@ -85,7 +85,7 @@ func NewFakeTLS(socket conntypes.StreamReadWriteCloser) conntypes.StreamReadWrit
85 85
 		for {
86 86
 			rec, err := tlstypes.ReadRecord(faketls.parent)
87 87
 			if err != nil {
88
-				return nil, err // nolint: wrapcheck
88
+				return nil, err //nolint: wrapcheck
89 89
 			}
90 90
 
91 91
 			switch rec.Type {

+ 3
- 3
wrappers/stream/mtproto_cipher.go Datei anzeigen

@@ -100,11 +100,11 @@ func mtprotoDeriveKeys(purpose mtprotoCipherPurpose,
100 100
 	message.Write(req.Nonce)
101 101
 
102 102
 	data := message.Bytes()
103
-	md5sum := md5.Sum(data[1:]) // nolint: gas
104
-	sha1sum := sha1.Sum(data)   // nolint: gosec
103
+	md5sum := md5.Sum(data[1:]) //nolint: gas
104
+	sha1sum := sha1.Sum(data)   //nolint: gosec
105 105
 
106 106
 	key := append(md5sum[:12], sha1sum[:]...)
107
-	iv := md5.Sum(data[2:]) // nolint: gas
107
+	iv := md5.Sum(data[2:]) //nolint: gas
108 108
 
109 109
 	return key, iv[:]
110 110
 }

+ 4
- 4
wrappers/stream/obfuscated2.go Datei anzeigen

@@ -31,7 +31,7 @@ func (w *wrapperObfuscated2) ReadTimeout(p []byte, timeout time.Duration) (int,
31 31
 func (w *wrapperObfuscated2) Read(p []byte) (int, error) {
32 32
 	n, err := w.parent.Read(p)
33 33
 	if err != nil {
34
-		return n, err // nolint: wrapcheck
34
+		return n, err //nolint: wrapcheck
35 35
 	}
36 36
 
37 37
 	w.decryptor.XORKeyStream(p, p[:n])
@@ -48,7 +48,7 @@ func (w *wrapperObfuscated2) WriteTimeout(p []byte, timeout time.Duration) (int,
48 48
 
49 49
 	w.encryptor.XORKeyStream(buf, buf)
50 50
 
51
-	return w.parent.WriteTimeout(buf, timeout) // nolint: wrapcheck
51
+	return w.parent.WriteTimeout(buf, timeout) //nolint: wrapcheck
52 52
 }
53 53
 
54 54
 func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
@@ -60,7 +60,7 @@ func (w *wrapperObfuscated2) Write(p []byte) (int, error) {
60 60
 
61 61
 	w.encryptor.XORKeyStream(buf, buf)
62 62
 
63
-	return w.parent.Write(buf) // nolint: wrapcheck
63
+	return w.parent.Write(buf) //nolint: wrapcheck
64 64
 }
65 65
 
66 66
 func (w *wrapperObfuscated2) Conn() net.Conn {
@@ -80,7 +80,7 @@ func (w *wrapperObfuscated2) RemoteAddr() *net.TCPAddr {
80 80
 }
81 81
 
82 82
 func (w *wrapperObfuscated2) Close() error {
83
-	return w.parent.Close() // nolint: wrapcheck
83
+	return w.parent.Close() //nolint: wrapcheck
84 84
 }
85 85
 
86 86
 func NewObfuscated2(socket conntypes.StreamReadWriteCloser,

+ 5
- 5
wrappers/stream/rewind.go Datei anzeigen

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

+ 5
- 5
wrappers/stream/stats_telegram.go Datei anzeigen

@@ -17,19 +17,19 @@ type wrapperTelegramStats struct {
17 17
 }
18 18
 
19 19
 func (w *wrapperTelegramStats) Write(p []byte) (int, error) {
20
-	return w.parent.Write(p) // nolint: wrapcheck
20
+	return w.parent.Write(p) //nolint: wrapcheck
21 21
 }
22 22
 
23 23
 func (w *wrapperTelegramStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
24
-	return w.parent.WriteTimeout(p, timeout) // nolint: wrapcheck
24
+	return w.parent.WriteTimeout(p, timeout) //nolint: wrapcheck
25 25
 }
26 26
 
27 27
 func (w *wrapperTelegramStats) Read(p []byte) (int, error) {
28
-	return w.parent.Read(p) // nolint: wrapcheck
28
+	return w.parent.Read(p) //nolint: wrapcheck
29 29
 }
30 30
 
31 31
 func (w *wrapperTelegramStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
32
-	return w.parent.ReadTimeout(p, timeout) // nolint: wrapcheck
32
+	return w.parent.ReadTimeout(p, timeout) //nolint: wrapcheck
33 33
 }
34 34
 
35 35
 func (w *wrapperTelegramStats) Conn() net.Conn {
@@ -56,7 +56,7 @@ func (w *wrapperTelegramStats) Close() error {
56 56
 		stats.Stats.TelegramDisconnected(w.dc, w.RemoteAddr())
57 57
 	})
58 58
 
59
-	return err // nolint: wrapcheck
59
+	return err //nolint: wrapcheck
60 60
 }
61 61
 
62 62
 func NewTelegramStats(dc conntypes.DC, parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {

+ 5
- 5
wrappers/stream/stats_traffic.go Datei anzeigen

@@ -17,28 +17,28 @@ func (w *wrapperTrafficStats) Write(p []byte) (int, error) {
17 17
 	n, err := w.parent.Write(p)
18 18
 	stats.Stats.EgressTraffic(n)
19 19
 
20
-	return n, err // nolint: wrapcheck
20
+	return n, err //nolint: wrapcheck
21 21
 }
22 22
 
23 23
 func (w *wrapperTrafficStats) WriteTimeout(p []byte, timeout time.Duration) (int, error) {
24 24
 	n, err := w.parent.WriteTimeout(p, timeout)
25 25
 	stats.Stats.EgressTraffic(n)
26 26
 
27
-	return n, err // nolint: wrapcheck
27
+	return n, err //nolint: wrapcheck
28 28
 }
29 29
 
30 30
 func (w *wrapperTrafficStats) Read(p []byte) (int, error) {
31 31
 	n, err := w.parent.Read(p)
32 32
 	stats.Stats.IngressTraffic(n)
33 33
 
34
-	return n, err // nolint: wrapcheck
34
+	return n, err //nolint: wrapcheck
35 35
 }
36 36
 
37 37
 func (w *wrapperTrafficStats) ReadTimeout(p []byte, timeout time.Duration) (int, error) {
38 38
 	n, err := w.parent.ReadTimeout(p, timeout)
39 39
 	stats.Stats.IngressTraffic(n)
40 40
 
41
-	return n, err // nolint: wrapcheck
41
+	return n, err //nolint: wrapcheck
42 42
 }
43 43
 
44 44
 func (w *wrapperTrafficStats) Conn() net.Conn {
@@ -58,7 +58,7 @@ func (w *wrapperTrafficStats) RemoteAddr() *net.TCPAddr {
58 58
 }
59 59
 
60 60
 func (w *wrapperTrafficStats) Close() error {
61
-	return w.parent.Close() // nolint: wrapcheck
61
+	return w.parent.Close() //nolint: wrapcheck
62 62
 }
63 63
 
64 64
 func NewTrafficStats(parent conntypes.StreamReadWriteCloser) conntypes.StreamReadWriteCloser {

+ 5
- 5
wrappers/stream/timeout.go Datei anzeigen

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

Laden…
Abbrechen
Speichern