Bladeren bron

Update golangci-lint to 1.40.1

tags/v2.1.0^2
9seconds 5 jaren geleden
bovenliggende
commit
e1864377c2

+ 1
- 1
.github/workflows/ci.yaml Bestand weergeven

@@ -70,7 +70,7 @@ jobs:
70 70
       - name: Run linter
71 71
         uses: golangci/golangci-lint-action@v2
72 72
         with:
73
-          version: v1.39.0
73
+          version: v1.40.1
74 74
 
75 75
   docker:
76 76
     name: Docker

+ 1
- 1
Makefile Bestand weergeven

@@ -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.39.0
5
+GOLANGCI_LINT_VERSION := v1.40.1
6 6
 
7 7
 VERSION_GO         := $(shell go version)
8 8
 VERSION_DATE       := $(shell date -Ru)

+ 4
- 4
internal/cli/access.go Bestand weergeven

@@ -26,10 +26,10 @@ type accessResponse struct {
26 26
 type accessResponseURLs struct {
27 27
 	IP        net.IP `json:"ip"`
28 28
 	Port      uint   `json:"port"`
29
-	TgURL     string `json:"tg_url"`
30
-	TgQrCode  string `json:"tg_qrcode"`
31
-	TmeURL    string `json:"tme_url"`
32
-	TmeQrCode string `json:"tme_qrcode"`
29
+	TgURL     string `json:"tg_url"`     // nolint: tagliatelle
30
+	TgQrCode  string `json:"tg_qrcode"`  // nolint: tagliatelle
31
+	TmeURL    string `json:"tme_url"`    // nolint: tagliatelle
32
+	TmeQrCode string `json:"tme_qrcode"` // nolint: tagliatelle
33 33
 }
34 34
 
35 35
 type Access struct {

+ 32
- 32
internal/config/config.go Bestand weergeven

@@ -12,23 +12,23 @@ import (
12 12
 type Config struct {
13 13
 	Debug                bool          `json:"debug"`
14 14
 	Secret               mtglib.Secret `json:"secret"`
15
-	BindTo               TypeHostPort  `json:"bind-to"`
16
-	TCPBuffer            TypeBytes     `json:"tcp-buffer"`
17
-	PreferIP             TypePreferIP  `json:"prefer-ip"`
18
-	DomainFrontingPort   TypePort      `json:"domain-fronting-port"`
19
-	TolerateTimeSkewness TypeDuration  `json:"tolerate-time-skewness"`
15
+	BindTo               TypeHostPort  `json:"bindTo"`
16
+	TCPBuffer            TypeBytes     `json:"tcpBuffer"`
17
+	PreferIP             TypePreferIP  `json:"preferIp"`
18
+	DomainFrontingPort   TypePort      `json:"domainFrontingPort"`
19
+	TolerateTimeSkewness TypeDuration  `json:"tolerateTimeSkewness"`
20 20
 	Concurrency          uint          `json:"concurrency"`
21 21
 	Defense              struct {
22 22
 		AntiReplay struct {
23 23
 			Enabled   bool          `json:"enabled"`
24
-			MaxSize   TypeBytes     `json:"max-size"`
25
-			ErrorRate TypeErrorRate `json:"error-rate"`
26
-		} `json:"anti-replay"`
24
+			MaxSize   TypeBytes     `json:"maxSize"`
25
+			ErrorRate TypeErrorRate `json:"errorRate"`
26
+		} `json:"antiReplay"`
27 27
 		Blocklist struct {
28 28
 			Enabled             bool               `json:"enabled"`
29
-			DownloadConcurrency uint               `json:"download-concurrency"`
29
+			DownloadConcurrency uint               `json:"downloadConcurrency"`
30 30
 			URLs                []TypeBlocklistURI `json:"urls"`
31
-			UpdateEach          TypeDuration       `json:"update-each"`
31
+			UpdateEach          TypeDuration       `json:"updateEach"`
32 32
 		} `json:"blocklist"`
33 33
 	} `json:"defense"`
34 34
 	Network struct {
@@ -37,21 +37,21 @@ type Config struct {
37 37
 			HTTP TypeDuration `json:"http"`
38 38
 			Idle TypeDuration `json:"idle"`
39 39
 		} `json:"timeout"`
40
-		DOHIP   TypeIP    `json:"doh-ip"`
40
+		DOHIP   TypeIP    `json:"dohIp"`
41 41
 		Proxies []TypeURL `json:"proxies"`
42 42
 	} `json:"network"`
43 43
 	Stats struct {
44 44
 		StatsD struct {
45 45
 			Enabled      bool                `json:"enabled"`
46 46
 			Address      TypeHostPort        `json:"address"`
47
-			MetricPrefix TypeMetricPrefix    `json:"metric-prefix"`
48
-			TagFormat    TypeStatsdTagFormat `json:"tag-format"`
47
+			MetricPrefix TypeMetricPrefix    `json:"metricPrefix"`
48
+			TagFormat    TypeStatsdTagFormat `json:"tagFormat"`
49 49
 		} `json:"statsd"`
50 50
 		Prometheus struct {
51 51
 			Enabled      bool             `json:"enabled"`
52
-			BindTo       TypeHostPort     `json:"bind-to"`
53
-			HTTPPath     TypeHTTPPath     `json:"http-path"`
54
-			MetricPrefix TypeMetricPrefix `json:"metric-prefix"`
52
+			BindTo       TypeHostPort     `json:"bindTo"`
53
+			HTTPPath     TypeHTTPPath     `json:"httpPath"`
54
+			MetricPrefix TypeMetricPrefix `json:"metricPrefix"`
55 55
 		} `json:"prometheus"`
56 56
 	} `json:"stats"`
57 57
 }
@@ -84,23 +84,23 @@ func (c *Config) String() string {
84 84
 type configRaw struct {
85 85
 	Debug                bool   `toml:"debug" json:"debug,omitempty"`
86 86
 	Secret               string `toml:"secret" json:"secret"`
87
-	BindTo               string `toml:"bind-to" json:"bind-to"`
88
-	TCPBuffer            string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"`
89
-	PreferIP             string `toml:"prefer-ip" json:"prefer-ip,omitempty"`
90
-	DomainFrontingPort   uint   `toml:"domain-fronting-port" json:"domain-fronting-port,omitempty"`
91
-	TolerateTimeSkewness string `toml:"tolerate-time-skewness" json:"tolerate-time-skewness,omitempty"`
87
+	BindTo               string `toml:"bind-to" json:"bindTo"`
88
+	TCPBuffer            string `toml:"tcp-buffer" json:"tcpBuffer,omitempty"`
89
+	PreferIP             string `toml:"prefer-ip" json:"preferIp,omitempty"`
90
+	DomainFrontingPort   uint   `toml:"domain-fronting-port" json:"domainFrontingPort,omitempty"`
91
+	TolerateTimeSkewness string `toml:"tolerate-time-skewness" json:"tolerateTimeSkewness,omitempty"`
92 92
 	Concurrency          uint   `toml:"concurrency" json:"concurrency,omitempty"`
93 93
 	Defense              struct {
94 94
 		AntiReplay struct {
95 95
 			Enabled   bool    `toml:"enabled" json:"enabled,omitempty"`
96
-			MaxSize   string  `toml:"max-size" json:"max-size,omitempty"`
97
-			ErrorRate float64 `toml:"error-rate" json:"error-rate,omitempty"`
98
-		} `toml:"anti-replay" json:"anti-replay,omitempty"`
96
+			MaxSize   string  `toml:"max-size" json:"maxSize,omitempty"`
97
+			ErrorRate float64 `toml:"error-rate" json:"errorRate,omitempty"`
98
+		} `toml:"anti-replay" json:"antiReplay,omitempty"`
99 99
 		Blocklist struct {
100 100
 			Enabled             bool     `toml:"enabled" json:"enabled,omitempty"`
101
-			DownloadConcurrency uint     `toml:"download-concurrency" json:"download-concurrency,omitempty"`
101
+			DownloadConcurrency uint     `toml:"download-concurrency" json:"downloadConcurrency,omitempty"`
102 102
 			URLs                []string `toml:"urls" json:"urls,omitempty"`
103
-			UpdateEach          string   `toml:"update-each" json:"update-each,omitempty"`
103
+			UpdateEach          string   `toml:"update-each" json:"updateEach,omitempty"`
104 104
 		} `toml:"blocklist" json:"blocklist,omitempty"`
105 105
 	} `toml:"defense" json:"defense,omitempty"`
106 106
 	Network struct {
@@ -109,21 +109,21 @@ type configRaw struct {
109 109
 			HTTP string `toml:"http" json:"http,omitempty"`
110 110
 			Idle string `toml:"idle" json:"idle,omitempty"`
111 111
 		} `toml:"timeout" json:"timeout,omitempty"`
112
-		DOHIP   string   `toml:"doh-ip" json:"doh-ip,omitempty"`
112
+		DOHIP   string   `toml:"doh-ip" json:"dohIp,omitempty"`
113 113
 		Proxies []string `toml:"proxies" json:"proxies,omitempty"`
114 114
 	} `toml:"network" json:"network,omitempty"`
115 115
 	Stats struct {
116 116
 		StatsD struct {
117 117
 			Enabled      bool   `toml:"enabled" json:"enabled,omitempty"`
118 118
 			Address      string `toml:"address" json:"address,omitempty"`
119
-			MetricPrefix string `toml:"metric-prefix" json:"metric-prefix,omitempty"`
120
-			TagFormat    string `toml:"tag-format" json:"tag-format,omitempty"`
119
+			MetricPrefix string `toml:"metric-prefix" json:"metricPrefix,omitempty"`
120
+			TagFormat    string `toml:"tag-format" json:"tagFormat,omitempty"`
121 121
 		} `toml:"statsd" json:"statsd,omitempty"`
122 122
 		Prometheus struct {
123 123
 			Enabled      bool   `toml:"enabled" json:"enabled,omitempty"`
124
-			BindTo       string `toml:"bind-to" json:"bind-to,omitempty"`
125
-			HTTPPath     string `toml:"http-path" json:"http-path,omitempty"`
126
-			MetricPrefix string `toml:"metric-prefix" json:"metric-prefix,omitempty"`
124
+			BindTo       string `toml:"bind-to" json:"bindTo,omitempty"`
125
+			HTTPPath     string `toml:"http-path" json:"httpPath,omitempty"`
126
+			MetricPrefix string `toml:"metric-prefix" json:"metricPrefix,omitempty"`
127 127
 		} `toml:"prometheus" json:"prometheus,omitempty"`
128 128
 	} `toml:"stats" json:"stats,omitempty"`
129 129
 }

+ 13
- 2
internal/config/type_prefer_ip.go Bestand weergeven

@@ -6,10 +6,21 @@ import (
6 6
 )
7 7
 
8 8
 const (
9
+	// TypePreferIPPreferIPv4 states that you prefer to use IPv4 addresses
10
+	// but IPv6 is also possible.
9 11
 	TypePreferIPPreferIPv4 = "prefer-ipv4"
12
+
13
+	// TypePreferIPPreferIPv6 states that you prefer to use IPv6 addresses
14
+	// but IPv4 is also possible.
10 15
 	TypePreferIPPreferIPv6 = "prefer-ipv6"
11
-	TypePreferOnlyIPv4     = "only-ipv4"
12
-	TypePreferOnlyIPv6     = "only-ipv6"
16
+
17
+	// TypePreferOnlyIPv4 states that you prefer to use IPv4 addresses
18
+	// only.
19
+	TypePreferOnlyIPv4 = "only-ipv4"
20
+
21
+	// TypePreferOnlyIPv6 states that you prefer to use IPv6 addresses
22
+	// only.
23
+	TypePreferOnlyIPv6 = "only-ipv6"
13 24
 )
14 25
 
15 26
 type TypePreferIP struct {

+ 9
- 1
internal/config/type_statsd_tag_format.go Bestand weergeven

@@ -6,8 +6,16 @@ import (
6 6
 )
7 7
 
8 8
 const (
9
+	// TypeStatsdTagFormatInfluxdb defines a tag format compatible with
10
+	// InfluxDB.
9 11
 	TypeStatsdTagFormatInfluxdb = "influxdb"
10
-	TypeStatsdTagFormatDatadog  = "datadog"
12
+
13
+	// TypeStatsdTagFormatDatadog defines a tag format compatible with
14
+	// DataDog.
15
+	TypeStatsdTagFormatDatadog = "datadog"
16
+
17
+	// TypeStatsdTagFormatGraphite defines a tag format compatible with
18
+	// Graphite.
11 19
 	TypeStatsdTagFormatGraphite = "graphite"
12 20
 )
13 21
 

+ 2
- 2
mtglib/internal/faketls/client_hello_test.go Bestand weergeven

@@ -18,9 +18,9 @@ import (
18 18
 type ClientHelloSnapshot struct {
19 19
 	Time        int    `json:"time"`
20 20
 	Random      string `json:"random"`
21
-	SessionID   string `json:"session-id"`
21
+	SessionID   string `json:"sessionId"`
22 22
 	Host        string `json:"host"`
23
-	CipherSuite int    `json:"cipher-suite"`
23
+	CipherSuite int    `json:"cipherSuite"`
24 24
 	Full        string `json:"full"`
25 25
 }
26 26
 

+ 22
- 4
mtglib/internal/faketls/init.go Bestand weergeven

@@ -6,25 +6,43 @@ import (
6 6
 )
7 7
 
8 8
 const (
9
+	// RandomLen defines a size of the random digest in TLS Hellos.
9 10
 	RandomLen = 32
10 11
 
11
-	ClientHelloRandomOffset    = 6
12
+	// ClientHelloRandomOffset is an offset in ClientHello record where
13
+	// random digest is started.
14
+	ClientHelloRandomOffset = 6
15
+
16
+	// ClientHelloSessionIDOffset is an offset in ClientHello record where
17
+	// SessionID is started.
12 18
 	ClientHelloSessionIDOffset = ClientHelloRandomOffset + RandomLen
13
-	ClientHelloMinLen          = 4
14 19
 
20
+	// ClientHelloMinLen is a minimal possible length of
21
+	// ClientHello record.
22
+	ClientHelloMinLen = 4
23
+
24
+	// WelcomePacketRandomOffset is an offset of random in ServerHello
25
+	// packet (including record envelope).
15 26
 	WelcomePacketRandomOffset = 11
16 27
 
28
+	// HandshakeTypeClient is a value representing a client handshake.
17 29
 	HandshakeTypeClient = 0x01
30
+
31
+	// HandshakeTypeServer is a value representing a server handshake.
18 32
 	HandshakeTypeServer = 0x02
19 33
 
34
+	// ChangeCipherValue is a value representing a change cipher
35
+	// specification record.
20 36
 	ChangeCipherValue = 0x01
21 37
 
38
+	// ExtensionSNI is a value for TLS extension 'SNI'.
22 39
 	ExtensionSNI = 0x00
23 40
 )
24 41
 
25 42
 var (
26
-	ErrBadDigest        = errors.New("bad digest")
27
-	ErrAntiReplayAttack = errors.New("antireplay attack was detected")
43
+	// ErrBadDigest is returned if given TLS Client Hello mismatches with a
44
+	// derived one.
45
+	ErrBadDigest = errors.New("bad digest")
28 46
 
29 47
 	serverHelloSuffix = []byte{
30 48
 		0x00,       // no compression

+ 18
- 2
mtglib/internal/faketls/record/init.go Bestand weergeven

@@ -7,9 +7,18 @@ const TLSMaxRecordSize = 65535 // max uint16
7 7
 type Type uint8
8 8
 
9 9
 const (
10
+	// TypeChangeCipherSpec defines a byte value of the TLS record when a
11
+	// peer wants to change a specifications of the chosen cipher.
10 12
 	TypeChangeCipherSpec Type = 0x14
11
-	TypeHandshake        Type = 0x16
12
-	TypeApplicationData  Type = 0x17
13
+
14
+	// TypeHandshake defines a byte value of the TLS record when a peer
15
+	// initiates a new TLS connection and wants to make a handshake
16
+	// ceremony.
17
+	TypeHandshake Type = 0x16
18
+
19
+	// TypeApplicationData defines a byte value of the TLS record when a
20
+	// peer sends an user data, not a control frames.
21
+	TypeApplicationData Type = 0x17
13 22
 )
14 23
 
15 24
 func (t Type) String() string {
@@ -37,9 +46,16 @@ func (t Type) Valid() error {
37 46
 type Version uint16
38 47
 
39 48
 const (
49
+	// Version10 defines a TLS1.0.
40 50
 	Version10 Version = 769 // 0x03 0x01
51
+
52
+	// Version11 defines a TLS1.1.
41 53
 	Version11 Version = 770 // 0x03 0x02
54
+
55
+	// Version12 defines a TLS1.2.
42 56
 	Version12 Version = 771 // 0x03 0x03
57
+
58
+	// Version13 defines a TLS1.3.
43 59
 	Version13 Version = 772 // 0x03 0x04
44 60
 )
45 61
 

+ 2
- 2
mtglib/internal/faketls/testdata/client-hello-bad-fa2e46cdb33e2a1b.json Bestand weergeven

@@ -1,8 +1,8 @@
1 1
 {
2 2
   "time": 1617181365,
3 3
   "random": "XvCPc3aAbHbhRLv0kUmy6BfPZOGvsused5/HNsKXEPs=",
4
-  "session-id": "St2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4=",
4
+  "sessionId": "St2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4=",
5 5
   "host": "storage.googleapis.com",
6
-  "cipher-suite": 4867,
6
+  "cipherSuite": 4867,
7 7
   "full": "AQAB/AMDXvCPc3aAbHbhRLv0kUmy6BfPZOGvsused5/HNsKXEPsgSt2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCACq4ANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFANAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAgB/7oLx9JElIALsLJS91H2QNyU1H0osKwIUelVndsLyIALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
8 8
 }

+ 3
- 3
mtglib/internal/faketls/testdata/client-hello-ok-19dfe38384b9884b.json Bestand weergeven

@@ -1,8 +1,8 @@
1 1
 {
2 2
   "time": 1617181365,
3 3
   "random": "XvCPc3aAbHbhRLv0kUmy6BfPZOGvsused5/HNsKXEPs=",
4
-  "session-id": "St2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4=",
4
+  "sessionId": "St2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4=",
5 5
   "host": "storage.googleapis.com",
6
-  "cipher-suite": 4867,
6
+  "cipherSuite": 4867,
7 7
   "full": "AQAB/AMDXvCPc3aAbHbhRLv0kUmy6BfPZOGvsused5/HNsKXEPsgSt2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4ANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAgB/7oLx9JElIALsLJS91H2QNyU1H0osKwIUelVndsLyIALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
8
-}
8
+}

+ 3
- 3
mtglib/internal/faketls/testdata/client-hello-ok-48f8a72a56f3174a.json Bestand weergeven

@@ -1,8 +1,8 @@
1 1
 {
2 2
   "time": 1617181352,
3 3
   "random": "oYEu33jl+zQbUKMtQbV1OHB0gXIM2y2aq9iY0QX12os=",
4
-  "session-id": "FGqA3ZFYrSlj//xl7lammNn64K9/MK2mQ3HJUGvP+8g=",
4
+  "sessionId": "FGqA3ZFYrSlj//xl7lammNn64K9/MK2mQ3HJUGvP+8g=",
5 5
   "host": "storage.googleapis.com",
6
-  "cipher-suite": 4867,
6
+  "cipherSuite": 4867,
7 7
   "full": "AQAB/AMDoYEu33jl+zQbUKMtQbV1OHB0gXIM2y2aq9iY0QX12osgFGqA3ZFYrSlj//xl7lammNn64K9/MK2mQ3HJUGvP+8gANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAga6CocpFP8Qd4YCFR9pkaCr97po2ALj0P5nI9Nnb3UWMALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
8
-}
8
+}

+ 3
- 3
mtglib/internal/faketls/testdata/client-hello-ok-651054256093c6cd.json Bestand weergeven

@@ -1,8 +1,8 @@
1 1
 {
2 2
   "time": 1617181352,
3 3
   "random": "5V5sSprk/tFIgy+x1BeKNGhLlFkqfggLpgN7GYOA1ro=",
4
-  "session-id": "jxr4d6PXPDk+Lwx3WUp9wvj8TGlOxEdrRJ0ydyJ9+H8=",
4
+  "sessionId": "jxr4d6PXPDk+Lwx3WUp9wvj8TGlOxEdrRJ0ydyJ9+H8=",
5 5
   "host": "storage.googleapis.com",
6
-  "cipher-suite": 4867,
6
+  "cipherSuite": 4867,
7 7
   "full": "AQAB/AMD5V5sSprk/tFIgy+x1BeKNGhLlFkqfggLpgN7GYOA1rogjxr4d6PXPDk+Lwx3WUp9wvj8TGlOxEdrRJ0ydyJ9+H8ANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAgrulAaqUdKeVYM0F+pu6on/h6LBpOyzOKG4xFIKcoFk4ALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
8
-}
8
+}

+ 3
- 3
mtglib/internal/faketls/testdata/client-hello-ok-79d01ef18a9d2621.json Bestand weergeven

@@ -1,8 +1,8 @@
1 1
 {
2 2
   "time": 1617181365,
3 3
   "random": "8xljlOhkDlkafEF5vu3e1r3fWvh8AX548wC3hLZ3szQ=",
4
-  "session-id": "00uvDYKnFyZFKyf3HlLwWGCOyeHsPFiU5UZ+Fs5pDAU=",
4
+  "sessionId": "00uvDYKnFyZFKyf3HlLwWGCOyeHsPFiU5UZ+Fs5pDAU=",
5 5
   "host": "storage.googleapis.com",
6
-  "cipher-suite": 4867,
6
+  "cipherSuite": 4867,
7 7
   "full": "AQAB/AMD8xljlOhkDlkafEF5vu3e1r3fWvh8AX548wC3hLZ3szQg00uvDYKnFyZFKyf3HlLwWGCOyeHsPFiU5UZ+Fs5pDAUANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAg/9P7140NtKzjyDwBf99mOy1+FjRPAPHTNQ9WxHOKpV4ALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
8
-}
8
+}

+ 3
- 3
mtglib/internal/faketls/testdata/client-hello-ok-7a5569f05b118145.json Bestand weergeven

@@ -1,8 +1,8 @@
1 1
 {
2 2
   "time": 1617181352,
3 3
   "random": "zja3MLZ8WGSfsQRtPV75+tY6gbK3zKPi1Sy7SBBafg4=",
4
-  "session-id": "qPut2yMqXa9zGLII/872SQ3d4Tfqo0uoDb7tpkRfBnA=",
4
+  "sessionId": "qPut2yMqXa9zGLII/872SQ3d4Tfqo0uoDb7tpkRfBnA=",
5 5
   "host": "storage.googleapis.com",
6
-  "cipher-suite": 4867,
6
+  "cipherSuite": 4867,
7 7
   "full": "AQAB/AMDzja3MLZ8WGSfsQRtPV75+tY6gbK3zKPi1Sy7SBBafg4gqPut2yMqXa9zGLII/872SQ3d4Tfqo0uoDb7tpkRfBnAANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAgXviLRAqAYJ8xOLdlcsUhldI4Xl0g/s9+y2Qrd8raPEgALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
8
-}
8
+}

+ 2
- 0
mtglib/internal/obfuscated2/handshake_frame.go Bestand weergeven

@@ -1,6 +1,8 @@
1 1
 package obfuscated2
2 2
 
3 3
 const (
4
+	// DefaultDC defines a number of the default DC to use. This value used
5
+	// only if a value from obfuscated2 handshake frame is 0 (default).
4 6
 	DefaultDC = 2
5 7
 
6 8
 	handshakeFrameLen = 64

+ 1
- 1
mtglib/proxy_test.go Bestand weergeven

@@ -166,7 +166,7 @@ func (suite *ProxyTestSuite) TestHTTPSRequest() {
166 166
 
167 167
 	jsonStruct := struct {
168 168
 		Headers struct {
169
-			TraceID string `json:"X-Amzn-Trace-Id"`
169
+			TraceID string `json:"X-Amzn-Trace-Id"` // nolint: tagliatelle
170 170
 		} `json:"headers"`
171 171
 	}{}
172 172
 

+ 1
- 1
mtglib/secret.go Bestand weergeven

@@ -56,7 +56,7 @@ func (s Secret) MarshalText() ([]byte, error) {
56 56
 	return nil, nil
57 57
 }
58 58
 
59
-// MarshalText is to support text.Unmarshaller interface.
59
+// UnmarshalText is to support text.Unmarshaller interface.
60 60
 func (s *Secret) UnmarshalText(data []byte) error {
61 61
 	text := string(data)
62 62
 	if text == "" {

+ 8
- 2
network/init.go Bestand weergeven

@@ -53,8 +53,14 @@ const (
53 53
 	//
54 54
 	// When circuit breaker is closed, it clears an error states each
55 55
 	// ProxyDialerResetFailuresTimeout.
56
-	ProxyDialerOpenThreshold        = 5
57
-	ProxyDialerHalfOpenTimeout      = time.Minute
56
+	ProxyDialerOpenThreshold = 5
57
+
58
+	// ProxyDialerHalfOpenTimeout defines a halfopen timeout for circuit
59
+	// breaker.
60
+	ProxyDialerHalfOpenTimeout = time.Minute
61
+
62
+	// ProxyDialerResetFailuresTimeout defines a timeout for resetting a
63
+	// failure.
58 64
 	ProxyDialerResetFailuresTimeout = 10 * time.Second
59 65
 
60 66
 	// DefaultDOHHostname defines a default IP address for DOH host.

+ 2
- 2
network/network_test.go Bestand weergeven

@@ -42,7 +42,7 @@ func (suite *NetworkTestSuite) TestLocalHTTPRequest() {
42 42
 
43 43
 	jsonStruct := struct {
44 44
 		Headers struct {
45
-			UserAgent []string `json:"User-Agent"`
45
+			UserAgent []string `json:"User-Agent"` // nolint: tagliatelle
46 46
 		} `json:"headers"`
47 47
 	}{}
48 48
 
@@ -67,7 +67,7 @@ func (suite *NetworkTestSuite) TestRealHTTPRequest() {
67 67
 
68 68
 	jsonStruct := struct {
69 69
 		Headers struct {
70
-			UserAgent string `json:"User-Agent"`
70
+			UserAgent string `json:"User-Agent"` // nolint: tagliatelle
71 71
 		} `json:"headers"`
72 72
 	}{}
73 73
 

+ 13
- 3
stats/init.go Bestand weergeven

@@ -90,8 +90,12 @@ const (
90 90
 	MetricReplayAttacks = "replay_attacks"
91 91
 
92 92
 	// TagIPFamily defines a name of the 'ip_family' tag and all values.
93
-	TagIPFamily     = "ip_family"
93
+	TagIPFamily = "ip_family"
94
+
95
+	// TagIPFamilyIPv4 defines a value of 'ip_family' of IPv4.
94 96
 	TagIPFamilyIPv4 = "ipv4"
97
+
98
+	// TagIPFamilyIPv6 defines a value of 'ip_family' of IPv6.
95 99
 	TagIPFamilyIPv6 = "ipv6"
96 100
 
97 101
 	// TagTelegramIP defines a name of the 'telegram_ip' tag.
@@ -101,7 +105,13 @@ const (
101 105
 	TagDC = "dc"
102 106
 
103 107
 	// TagDirection defines a name of the 'direction' tag.
104
-	TagDirection           = "direction"
105
-	TagDirectionToClient   = "to_client"
108
+	TagDirection = "direction"
109
+
110
+	// TagDirectionToClient defines that traffic is sent from Telegram to a
111
+	// client.
112
+	TagDirectionToClient = "to_client"
113
+
114
+	// TagDirectionFromClient defines that traffic is sent from a client to
115
+	// Telegram.
106 116
 	TagDirectionFromClient = "from_client"
107 117
 )

Laden…
Annuleren
Opslaan