From e1864377c2f8fdcd9f3f58b60f956c05ee0bc913 Mon Sep 17 00:00:00 2001 From: 9seconds Date: Mon, 17 May 2021 14:00:11 +0300 Subject: [PATCH] Update golangci-lint to 1.40.1 --- .github/workflows/ci.yaml | 2 +- Makefile | 2 +- internal/cli/access.go | 8 +-- internal/config/config.go | 64 +++++++++---------- internal/config/type_prefer_ip.go | 15 ++++- internal/config/type_statsd_tag_format.go | 10 ++- mtglib/internal/faketls/client_hello_test.go | 4 +- mtglib/internal/faketls/init.go | 28 ++++++-- mtglib/internal/faketls/record/init.go | 20 +++++- .../client-hello-bad-fa2e46cdb33e2a1b.json | 4 +- .../client-hello-ok-19dfe38384b9884b.json | 6 +- .../client-hello-ok-48f8a72a56f3174a.json | 6 +- .../client-hello-ok-651054256093c6cd.json | 6 +- .../client-hello-ok-79d01ef18a9d2621.json | 6 +- .../client-hello-ok-7a5569f05b118145.json | 6 +- .../internal/obfuscated2/handshake_frame.go | 2 + mtglib/proxy_test.go | 2 +- mtglib/secret.go | 2 +- network/init.go | 10 ++- network/network_test.go | 4 +- stats/init.go | 16 ++++- 21 files changed, 147 insertions(+), 76 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 34d76a4..3590ed3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -70,7 +70,7 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v2 with: - version: v1.39.0 + version: v1.40.1 docker: name: Docker diff --git a/Makefile b/Makefile index edba1fe..1455961 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) IMAGE_NAME := mtg APP_NAME := $(IMAGE_NAME) -GOLANGCI_LINT_VERSION := v1.39.0 +GOLANGCI_LINT_VERSION := v1.40.1 VERSION_GO := $(shell go version) VERSION_DATE := $(shell date -Ru) diff --git a/internal/cli/access.go b/internal/cli/access.go index 57083cc..15e6bfa 100644 --- a/internal/cli/access.go +++ b/internal/cli/access.go @@ -26,10 +26,10 @@ type accessResponse struct { type accessResponseURLs struct { IP net.IP `json:"ip"` Port uint `json:"port"` - TgURL string `json:"tg_url"` - TgQrCode string `json:"tg_qrcode"` - TmeURL string `json:"tme_url"` - TmeQrCode string `json:"tme_qrcode"` + TgURL string `json:"tg_url"` // nolint: tagliatelle + TgQrCode string `json:"tg_qrcode"` // nolint: tagliatelle + TmeURL string `json:"tme_url"` // nolint: tagliatelle + TmeQrCode string `json:"tme_qrcode"` // nolint: tagliatelle } type Access struct { diff --git a/internal/config/config.go b/internal/config/config.go index a634c7b..c8e88d3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -12,23 +12,23 @@ import ( type Config struct { Debug bool `json:"debug"` Secret mtglib.Secret `json:"secret"` - BindTo TypeHostPort `json:"bind-to"` - TCPBuffer TypeBytes `json:"tcp-buffer"` - PreferIP TypePreferIP `json:"prefer-ip"` - DomainFrontingPort TypePort `json:"domain-fronting-port"` - TolerateTimeSkewness TypeDuration `json:"tolerate-time-skewness"` + BindTo TypeHostPort `json:"bindTo"` + TCPBuffer TypeBytes `json:"tcpBuffer"` + PreferIP TypePreferIP `json:"preferIp"` + DomainFrontingPort TypePort `json:"domainFrontingPort"` + TolerateTimeSkewness TypeDuration `json:"tolerateTimeSkewness"` Concurrency uint `json:"concurrency"` Defense struct { AntiReplay struct { Enabled bool `json:"enabled"` - MaxSize TypeBytes `json:"max-size"` - ErrorRate TypeErrorRate `json:"error-rate"` - } `json:"anti-replay"` + MaxSize TypeBytes `json:"maxSize"` + ErrorRate TypeErrorRate `json:"errorRate"` + } `json:"antiReplay"` Blocklist struct { Enabled bool `json:"enabled"` - DownloadConcurrency uint `json:"download-concurrency"` + DownloadConcurrency uint `json:"downloadConcurrency"` URLs []TypeBlocklistURI `json:"urls"` - UpdateEach TypeDuration `json:"update-each"` + UpdateEach TypeDuration `json:"updateEach"` } `json:"blocklist"` } `json:"defense"` Network struct { @@ -37,21 +37,21 @@ type Config struct { HTTP TypeDuration `json:"http"` Idle TypeDuration `json:"idle"` } `json:"timeout"` - DOHIP TypeIP `json:"doh-ip"` + DOHIP TypeIP `json:"dohIp"` Proxies []TypeURL `json:"proxies"` } `json:"network"` Stats struct { StatsD struct { Enabled bool `json:"enabled"` Address TypeHostPort `json:"address"` - MetricPrefix TypeMetricPrefix `json:"metric-prefix"` - TagFormat TypeStatsdTagFormat `json:"tag-format"` + MetricPrefix TypeMetricPrefix `json:"metricPrefix"` + TagFormat TypeStatsdTagFormat `json:"tagFormat"` } `json:"statsd"` Prometheus struct { Enabled bool `json:"enabled"` - BindTo TypeHostPort `json:"bind-to"` - HTTPPath TypeHTTPPath `json:"http-path"` - MetricPrefix TypeMetricPrefix `json:"metric-prefix"` + BindTo TypeHostPort `json:"bindTo"` + HTTPPath TypeHTTPPath `json:"httpPath"` + MetricPrefix TypeMetricPrefix `json:"metricPrefix"` } `json:"prometheus"` } `json:"stats"` } @@ -84,23 +84,23 @@ func (c *Config) String() string { type configRaw struct { Debug bool `toml:"debug" json:"debug,omitempty"` Secret string `toml:"secret" json:"secret"` - BindTo string `toml:"bind-to" json:"bind-to"` - TCPBuffer string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"` - PreferIP string `toml:"prefer-ip" json:"prefer-ip,omitempty"` - DomainFrontingPort uint `toml:"domain-fronting-port" json:"domain-fronting-port,omitempty"` - TolerateTimeSkewness string `toml:"tolerate-time-skewness" json:"tolerate-time-skewness,omitempty"` + BindTo string `toml:"bind-to" json:"bindTo"` + TCPBuffer string `toml:"tcp-buffer" json:"tcpBuffer,omitempty"` + PreferIP string `toml:"prefer-ip" json:"preferIp,omitempty"` + DomainFrontingPort uint `toml:"domain-fronting-port" json:"domainFrontingPort,omitempty"` + TolerateTimeSkewness string `toml:"tolerate-time-skewness" json:"tolerateTimeSkewness,omitempty"` Concurrency uint `toml:"concurrency" json:"concurrency,omitempty"` Defense struct { AntiReplay struct { Enabled bool `toml:"enabled" json:"enabled,omitempty"` - MaxSize string `toml:"max-size" json:"max-size,omitempty"` - ErrorRate float64 `toml:"error-rate" json:"error-rate,omitempty"` - } `toml:"anti-replay" json:"anti-replay,omitempty"` + MaxSize string `toml:"max-size" json:"maxSize,omitempty"` + ErrorRate float64 `toml:"error-rate" json:"errorRate,omitempty"` + } `toml:"anti-replay" json:"antiReplay,omitempty"` Blocklist struct { Enabled bool `toml:"enabled" json:"enabled,omitempty"` - DownloadConcurrency uint `toml:"download-concurrency" json:"download-concurrency,omitempty"` + DownloadConcurrency uint `toml:"download-concurrency" json:"downloadConcurrency,omitempty"` URLs []string `toml:"urls" json:"urls,omitempty"` - UpdateEach string `toml:"update-each" json:"update-each,omitempty"` + UpdateEach string `toml:"update-each" json:"updateEach,omitempty"` } `toml:"blocklist" json:"blocklist,omitempty"` } `toml:"defense" json:"defense,omitempty"` Network struct { @@ -109,21 +109,21 @@ type configRaw struct { HTTP string `toml:"http" json:"http,omitempty"` Idle string `toml:"idle" json:"idle,omitempty"` } `toml:"timeout" json:"timeout,omitempty"` - DOHIP string `toml:"doh-ip" json:"doh-ip,omitempty"` + DOHIP string `toml:"doh-ip" json:"dohIp,omitempty"` Proxies []string `toml:"proxies" json:"proxies,omitempty"` } `toml:"network" json:"network,omitempty"` Stats struct { StatsD struct { Enabled bool `toml:"enabled" json:"enabled,omitempty"` Address string `toml:"address" json:"address,omitempty"` - MetricPrefix string `toml:"metric-prefix" json:"metric-prefix,omitempty"` - TagFormat string `toml:"tag-format" json:"tag-format,omitempty"` + MetricPrefix string `toml:"metric-prefix" json:"metricPrefix,omitempty"` + TagFormat string `toml:"tag-format" json:"tagFormat,omitempty"` } `toml:"statsd" json:"statsd,omitempty"` Prometheus struct { Enabled bool `toml:"enabled" json:"enabled,omitempty"` - BindTo string `toml:"bind-to" json:"bind-to,omitempty"` - HTTPPath string `toml:"http-path" json:"http-path,omitempty"` - MetricPrefix string `toml:"metric-prefix" json:"metric-prefix,omitempty"` + BindTo string `toml:"bind-to" json:"bindTo,omitempty"` + HTTPPath string `toml:"http-path" json:"httpPath,omitempty"` + MetricPrefix string `toml:"metric-prefix" json:"metricPrefix,omitempty"` } `toml:"prometheus" json:"prometheus,omitempty"` } `toml:"stats" json:"stats,omitempty"` } diff --git a/internal/config/type_prefer_ip.go b/internal/config/type_prefer_ip.go index 3d150d4..0b30e82 100644 --- a/internal/config/type_prefer_ip.go +++ b/internal/config/type_prefer_ip.go @@ -6,10 +6,21 @@ import ( ) const ( + // TypePreferIPPreferIPv4 states that you prefer to use IPv4 addresses + // but IPv6 is also possible. TypePreferIPPreferIPv4 = "prefer-ipv4" + + // TypePreferIPPreferIPv6 states that you prefer to use IPv6 addresses + // but IPv4 is also possible. TypePreferIPPreferIPv6 = "prefer-ipv6" - TypePreferOnlyIPv4 = "only-ipv4" - TypePreferOnlyIPv6 = "only-ipv6" + + // TypePreferOnlyIPv4 states that you prefer to use IPv4 addresses + // only. + TypePreferOnlyIPv4 = "only-ipv4" + + // TypePreferOnlyIPv6 states that you prefer to use IPv6 addresses + // only. + TypePreferOnlyIPv6 = "only-ipv6" ) type TypePreferIP struct { diff --git a/internal/config/type_statsd_tag_format.go b/internal/config/type_statsd_tag_format.go index 7903b0c..51ed34b 100644 --- a/internal/config/type_statsd_tag_format.go +++ b/internal/config/type_statsd_tag_format.go @@ -6,8 +6,16 @@ import ( ) const ( + // TypeStatsdTagFormatInfluxdb defines a tag format compatible with + // InfluxDB. TypeStatsdTagFormatInfluxdb = "influxdb" - TypeStatsdTagFormatDatadog = "datadog" + + // TypeStatsdTagFormatDatadog defines a tag format compatible with + // DataDog. + TypeStatsdTagFormatDatadog = "datadog" + + // TypeStatsdTagFormatGraphite defines a tag format compatible with + // Graphite. TypeStatsdTagFormatGraphite = "graphite" ) diff --git a/mtglib/internal/faketls/client_hello_test.go b/mtglib/internal/faketls/client_hello_test.go index 4d5ad53..7c9446e 100644 --- a/mtglib/internal/faketls/client_hello_test.go +++ b/mtglib/internal/faketls/client_hello_test.go @@ -18,9 +18,9 @@ import ( type ClientHelloSnapshot struct { Time int `json:"time"` Random string `json:"random"` - SessionID string `json:"session-id"` + SessionID string `json:"sessionId"` Host string `json:"host"` - CipherSuite int `json:"cipher-suite"` + CipherSuite int `json:"cipherSuite"` Full string `json:"full"` } diff --git a/mtglib/internal/faketls/init.go b/mtglib/internal/faketls/init.go index 5bbf6f3..3a305a5 100644 --- a/mtglib/internal/faketls/init.go +++ b/mtglib/internal/faketls/init.go @@ -6,25 +6,43 @@ import ( ) const ( + // RandomLen defines a size of the random digest in TLS Hellos. RandomLen = 32 - ClientHelloRandomOffset = 6 - ClientHelloSessionIDOffset = ClientHelloRandomOffset + RandomLen - ClientHelloMinLen = 4 + // ClientHelloRandomOffset is an offset in ClientHello record where + // random digest is started. + ClientHelloRandomOffset = 6 + // ClientHelloSessionIDOffset is an offset in ClientHello record where + // SessionID is started. + ClientHelloSessionIDOffset = ClientHelloRandomOffset + RandomLen + + // ClientHelloMinLen is a minimal possible length of + // ClientHello record. + ClientHelloMinLen = 4 + + // WelcomePacketRandomOffset is an offset of random in ServerHello + // packet (including record envelope). WelcomePacketRandomOffset = 11 + // HandshakeTypeClient is a value representing a client handshake. HandshakeTypeClient = 0x01 + + // HandshakeTypeServer is a value representing a server handshake. HandshakeTypeServer = 0x02 + // ChangeCipherValue is a value representing a change cipher + // specification record. ChangeCipherValue = 0x01 + // ExtensionSNI is a value for TLS extension 'SNI'. ExtensionSNI = 0x00 ) var ( - ErrBadDigest = errors.New("bad digest") - ErrAntiReplayAttack = errors.New("antireplay attack was detected") + // ErrBadDigest is returned if given TLS Client Hello mismatches with a + // derived one. + ErrBadDigest = errors.New("bad digest") serverHelloSuffix = []byte{ 0x00, // no compression diff --git a/mtglib/internal/faketls/record/init.go b/mtglib/internal/faketls/record/init.go index 0ea3b5f..9195113 100644 --- a/mtglib/internal/faketls/record/init.go +++ b/mtglib/internal/faketls/record/init.go @@ -7,9 +7,18 @@ const TLSMaxRecordSize = 65535 // max uint16 type Type uint8 const ( + // TypeChangeCipherSpec defines a byte value of the TLS record when a + // peer wants to change a specifications of the chosen cipher. TypeChangeCipherSpec Type = 0x14 - TypeHandshake Type = 0x16 - TypeApplicationData Type = 0x17 + + // TypeHandshake defines a byte value of the TLS record when a peer + // initiates a new TLS connection and wants to make a handshake + // ceremony. + TypeHandshake Type = 0x16 + + // TypeApplicationData defines a byte value of the TLS record when a + // peer sends an user data, not a control frames. + TypeApplicationData Type = 0x17 ) func (t Type) String() string { @@ -37,9 +46,16 @@ func (t Type) Valid() error { type Version uint16 const ( + // Version10 defines a TLS1.0. Version10 Version = 769 // 0x03 0x01 + + // Version11 defines a TLS1.1. Version11 Version = 770 // 0x03 0x02 + + // Version12 defines a TLS1.2. Version12 Version = 771 // 0x03 0x03 + + // Version13 defines a TLS1.3. Version13 Version = 772 // 0x03 0x04 ) diff --git a/mtglib/internal/faketls/testdata/client-hello-bad-fa2e46cdb33e2a1b.json b/mtglib/internal/faketls/testdata/client-hello-bad-fa2e46cdb33e2a1b.json index 046a122..68bfd38 100644 --- a/mtglib/internal/faketls/testdata/client-hello-bad-fa2e46cdb33e2a1b.json +++ b/mtglib/internal/faketls/testdata/client-hello-bad-fa2e46cdb33e2a1b.json @@ -1,8 +1,8 @@ { "time": 1617181365, "random": "XvCPc3aAbHbhRLv0kUmy6BfPZOGvsused5/HNsKXEPs=", - "session-id": "St2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4=", + "sessionId": "St2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4=", "host": "storage.googleapis.com", - "cipher-suite": 4867, + "cipherSuite": 4867, "full": "AQAB/AMDXvCPc3aAbHbhRLv0kUmy6BfPZOGvsused5/HNsKXEPsgSt2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCACq4ANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFANAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAgB/7oLx9JElIALsLJS91H2QNyU1H0osKwIUelVndsLyIALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" } diff --git a/mtglib/internal/faketls/testdata/client-hello-ok-19dfe38384b9884b.json b/mtglib/internal/faketls/testdata/client-hello-ok-19dfe38384b9884b.json index 0a47b92..097df60 100644 --- a/mtglib/internal/faketls/testdata/client-hello-ok-19dfe38384b9884b.json +++ b/mtglib/internal/faketls/testdata/client-hello-ok-19dfe38384b9884b.json @@ -1,8 +1,8 @@ { "time": 1617181365, "random": "XvCPc3aAbHbhRLv0kUmy6BfPZOGvsused5/HNsKXEPs=", - "session-id": "St2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4=", + "sessionId": "St2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4=", "host": "storage.googleapis.com", - "cipher-suite": 4867, + "cipherSuite": 4867, "full": "AQAB/AMDXvCPc3aAbHbhRLv0kUmy6BfPZOGvsused5/HNsKXEPsgSt2BZ2uHMFn3B2trD1jfdtpjoJOOg6JBeLhFcyCMCq4ANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAgB/7oLx9JElIALsLJS91H2QNyU1H0osKwIUelVndsLyIALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" -} \ No newline at end of file +} diff --git a/mtglib/internal/faketls/testdata/client-hello-ok-48f8a72a56f3174a.json b/mtglib/internal/faketls/testdata/client-hello-ok-48f8a72a56f3174a.json index adc7cc7..f4fe585 100644 --- a/mtglib/internal/faketls/testdata/client-hello-ok-48f8a72a56f3174a.json +++ b/mtglib/internal/faketls/testdata/client-hello-ok-48f8a72a56f3174a.json @@ -1,8 +1,8 @@ { "time": 1617181352, "random": "oYEu33jl+zQbUKMtQbV1OHB0gXIM2y2aq9iY0QX12os=", - "session-id": "FGqA3ZFYrSlj//xl7lammNn64K9/MK2mQ3HJUGvP+8g=", + "sessionId": "FGqA3ZFYrSlj//xl7lammNn64K9/MK2mQ3HJUGvP+8g=", "host": "storage.googleapis.com", - "cipher-suite": 4867, + "cipherSuite": 4867, "full": "AQAB/AMDoYEu33jl+zQbUKMtQbV1OHB0gXIM2y2aq9iY0QX12osgFGqA3ZFYrSlj//xl7lammNn64K9/MK2mQ3HJUGvP+8gANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAga6CocpFP8Qd4YCFR9pkaCr97po2ALj0P5nI9Nnb3UWMALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" -} \ No newline at end of file +} diff --git a/mtglib/internal/faketls/testdata/client-hello-ok-651054256093c6cd.json b/mtglib/internal/faketls/testdata/client-hello-ok-651054256093c6cd.json index c5165fb..432f170 100644 --- a/mtglib/internal/faketls/testdata/client-hello-ok-651054256093c6cd.json +++ b/mtglib/internal/faketls/testdata/client-hello-ok-651054256093c6cd.json @@ -1,8 +1,8 @@ { "time": 1617181352, "random": "5V5sSprk/tFIgy+x1BeKNGhLlFkqfggLpgN7GYOA1ro=", - "session-id": "jxr4d6PXPDk+Lwx3WUp9wvj8TGlOxEdrRJ0ydyJ9+H8=", + "sessionId": "jxr4d6PXPDk+Lwx3WUp9wvj8TGlOxEdrRJ0ydyJ9+H8=", "host": "storage.googleapis.com", - "cipher-suite": 4867, + "cipherSuite": 4867, "full": "AQAB/AMD5V5sSprk/tFIgy+x1BeKNGhLlFkqfggLpgN7GYOA1rogjxr4d6PXPDk+Lwx3WUp9wvj8TGlOxEdrRJ0ydyJ9+H8ANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAgrulAaqUdKeVYM0F+pu6on/h6LBpOyzOKG4xFIKcoFk4ALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" -} \ No newline at end of file +} diff --git a/mtglib/internal/faketls/testdata/client-hello-ok-79d01ef18a9d2621.json b/mtglib/internal/faketls/testdata/client-hello-ok-79d01ef18a9d2621.json index a642fec..0faafd8 100644 --- a/mtglib/internal/faketls/testdata/client-hello-ok-79d01ef18a9d2621.json +++ b/mtglib/internal/faketls/testdata/client-hello-ok-79d01ef18a9d2621.json @@ -1,8 +1,8 @@ { "time": 1617181365, "random": "8xljlOhkDlkafEF5vu3e1r3fWvh8AX548wC3hLZ3szQ=", - "session-id": "00uvDYKnFyZFKyf3HlLwWGCOyeHsPFiU5UZ+Fs5pDAU=", + "sessionId": "00uvDYKnFyZFKyf3HlLwWGCOyeHsPFiU5UZ+Fs5pDAU=", "host": "storage.googleapis.com", - "cipher-suite": 4867, + "cipherSuite": 4867, "full": "AQAB/AMD8xljlOhkDlkafEF5vu3e1r3fWvh8AX548wC3hLZ3szQg00uvDYKnFyZFKyf3HlLwWGCOyeHsPFiU5UZ+Fs5pDAUANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAg/9P7140NtKzjyDwBf99mOy1+FjRPAPHTNQ9WxHOKpV4ALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" -} \ No newline at end of file +} diff --git a/mtglib/internal/faketls/testdata/client-hello-ok-7a5569f05b118145.json b/mtglib/internal/faketls/testdata/client-hello-ok-7a5569f05b118145.json index 5b803da..7bd1122 100644 --- a/mtglib/internal/faketls/testdata/client-hello-ok-7a5569f05b118145.json +++ b/mtglib/internal/faketls/testdata/client-hello-ok-7a5569f05b118145.json @@ -1,8 +1,8 @@ { "time": 1617181352, "random": "zja3MLZ8WGSfsQRtPV75+tY6gbK3zKPi1Sy7SBBafg4=", - "session-id": "qPut2yMqXa9zGLII/872SQ3d4Tfqo0uoDb7tpkRfBnA=", + "sessionId": "qPut2yMqXa9zGLII/872SQ3d4Tfqo0uoDb7tpkRfBnA=", "host": "storage.googleapis.com", - "cipher-suite": 4867, + "cipherSuite": 4867, "full": "AQAB/AMDzja3MLZ8WGSfsQRtPV75+tY6gbK3zKPi1Sy7SBBafg4gqPut2yMqXa9zGLII/872SQ3d4Tfqo0uoDb7tpkRfBnAANBMDEwETAsAswCvAJMAjwArACcypwDDAL8AowCfAFMATzKgAnQCcAD0APAA1AC/ACMASAAoBAAF//wEAAQAAAAAbABkAABZzdG9yYWdlLmdvb2dsZWFwaXMuY29tABcAAAANABgAFgQDCAQEAQUDAgMIBQgFBQEIBgYBAgEABQAFAQAAAAAzdAAAABIAAAAQADAALgJoMgVoMi0xNgVoMi0xNQVoMi0xNAhzcGR5LzMuMQZzcGR5LzMIaHR0cC8xLjEACwACAQAAMwAmACQAHQAgXviLRAqAYJ8xOLdlcsUhldI4Xl0g/s9+y2Qrd8raPEgALQACAQEAKwAJCAMEAwMDAgMBAAoACgAIAB0AFwAYABkAFQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" -} \ No newline at end of file +} diff --git a/mtglib/internal/obfuscated2/handshake_frame.go b/mtglib/internal/obfuscated2/handshake_frame.go index fff548f..4a8e156 100644 --- a/mtglib/internal/obfuscated2/handshake_frame.go +++ b/mtglib/internal/obfuscated2/handshake_frame.go @@ -1,6 +1,8 @@ package obfuscated2 const ( + // DefaultDC defines a number of the default DC to use. This value used + // only if a value from obfuscated2 handshake frame is 0 (default). DefaultDC = 2 handshakeFrameLen = 64 diff --git a/mtglib/proxy_test.go b/mtglib/proxy_test.go index d97b8e7..59963c6 100644 --- a/mtglib/proxy_test.go +++ b/mtglib/proxy_test.go @@ -166,7 +166,7 @@ func (suite *ProxyTestSuite) TestHTTPSRequest() { jsonStruct := struct { Headers struct { - TraceID string `json:"X-Amzn-Trace-Id"` + TraceID string `json:"X-Amzn-Trace-Id"` // nolint: tagliatelle } `json:"headers"` }{} diff --git a/mtglib/secret.go b/mtglib/secret.go index d9c1ff3..49fd106 100644 --- a/mtglib/secret.go +++ b/mtglib/secret.go @@ -56,7 +56,7 @@ func (s Secret) MarshalText() ([]byte, error) { return nil, nil } -// MarshalText is to support text.Unmarshaller interface. +// UnmarshalText is to support text.Unmarshaller interface. func (s *Secret) UnmarshalText(data []byte) error { text := string(data) if text == "" { diff --git a/network/init.go b/network/init.go index 0dc9660..b53f37c 100644 --- a/network/init.go +++ b/network/init.go @@ -53,8 +53,14 @@ const ( // // When circuit breaker is closed, it clears an error states each // ProxyDialerResetFailuresTimeout. - ProxyDialerOpenThreshold = 5 - ProxyDialerHalfOpenTimeout = time.Minute + ProxyDialerOpenThreshold = 5 + + // ProxyDialerHalfOpenTimeout defines a halfopen timeout for circuit + // breaker. + ProxyDialerHalfOpenTimeout = time.Minute + + // ProxyDialerResetFailuresTimeout defines a timeout for resetting a + // failure. ProxyDialerResetFailuresTimeout = 10 * time.Second // DefaultDOHHostname defines a default IP address for DOH host. diff --git a/network/network_test.go b/network/network_test.go index 86b5f0c..891c614 100644 --- a/network/network_test.go +++ b/network/network_test.go @@ -42,7 +42,7 @@ func (suite *NetworkTestSuite) TestLocalHTTPRequest() { jsonStruct := struct { Headers struct { - UserAgent []string `json:"User-Agent"` + UserAgent []string `json:"User-Agent"` // nolint: tagliatelle } `json:"headers"` }{} @@ -67,7 +67,7 @@ func (suite *NetworkTestSuite) TestRealHTTPRequest() { jsonStruct := struct { Headers struct { - UserAgent string `json:"User-Agent"` + UserAgent string `json:"User-Agent"` // nolint: tagliatelle } `json:"headers"` }{} diff --git a/stats/init.go b/stats/init.go index 3a2bae7..2154c60 100644 --- a/stats/init.go +++ b/stats/init.go @@ -90,8 +90,12 @@ const ( MetricReplayAttacks = "replay_attacks" // TagIPFamily defines a name of the 'ip_family' tag and all values. - TagIPFamily = "ip_family" + TagIPFamily = "ip_family" + + // TagIPFamilyIPv4 defines a value of 'ip_family' of IPv4. TagIPFamilyIPv4 = "ipv4" + + // TagIPFamilyIPv6 defines a value of 'ip_family' of IPv6. TagIPFamilyIPv6 = "ipv6" // TagTelegramIP defines a name of the 'telegram_ip' tag. @@ -101,7 +105,13 @@ const ( TagDC = "dc" // TagDirection defines a name of the 'direction' tag. - TagDirection = "direction" - TagDirectionToClient = "to_client" + TagDirection = "direction" + + // TagDirectionToClient defines that traffic is sent from Telegram to a + // client. + TagDirectionToClient = "to_client" + + // TagDirectionFromClient defines that traffic is sent from a client to + // Telegram. TagDirectionFromClient = "from_client" )