Przeglądaj źródła

Linting

tags/v2.1.6^2
9seconds 4 lat temu
rodzic
commit
e0850869ba

+ 2
- 1
internal/cli/run_proxy.go Wyświetl plik

@@ -89,7 +89,8 @@ func makeAntiReplayCache(conf *config.Config) mtglib.AntiReplayCache {
89 89
 func makeIPBlocklist(conf config.ListConfig,
90 90
 	logger mtglib.Logger,
91 91
 	ntw mtglib.Network,
92
-	updateCallback ipblocklist.FireholUpdateCallback) (mtglib.IPBlocklist, error) {
92
+	updateCallback ipblocklist.FireholUpdateCallback,
93
+) (mtglib.IPBlocklist, error) {
93 94
 	if !conf.Enabled.Get(false) {
94 95
 		return ipblocklist.NewNoop(), nil
95 96
 	}

+ 2
- 1
internal/testlib/mtglib_network_mock.go Wyświetl plik

@@ -25,6 +25,7 @@ func (m *MtglibNetworkMock) DialContext(ctx context.Context, network, address st
25 25
 }
26 26
 
27 27
 func (m *MtglibNetworkMock) MakeHTTPClient(dialFunc func(ctx context.Context,
28
-	network, address string) (essentials.Conn, error)) *http.Client {
28
+	network, address string) (essentials.Conn, error),
29
+) *http.Client {
29 30
 	return m.Called(dialFunc).Get(0).(*http.Client) // nolint: forcetypeassert
30 31
 }

+ 6
- 3
ipblocklist/firehol.go Wyświetl plik

@@ -155,7 +155,8 @@ func (f *Firehol) update() {
155 155
 
156 156
 func (f *Firehol) updateFromFile(mutex sync.Locker,
157 157
 	ranger cidranger.Ranger,
158
-	scanner *bufio.Scanner) error {
158
+	scanner *bufio.Scanner,
159
+) error {
159 160
 	for scanner.Scan() {
160 161
 		text := scanner.Text()
161 162
 		text = fireholRegexpComment.ReplaceAllLiteralString(text, "")
@@ -216,7 +217,8 @@ func NewFirehol(logger mtglib.Logger, network mtglib.Network,
216 217
 	downloadConcurrency uint,
217 218
 	urls []string,
218 219
 	localFiles []string,
219
-	updateCallback FireholUpdateCallback) (*Firehol, error) {
220
+	updateCallback FireholUpdateCallback,
221
+) (*Firehol, error) {
220 222
 	blocklists := []files.File{}
221 223
 
222 224
 	for _, v := range localFiles {
@@ -245,7 +247,8 @@ func NewFirehol(logger mtglib.Logger, network mtglib.Network,
245 247
 func NewFireholFromFiles(logger mtglib.Logger,
246 248
 	downloadConcurrency uint,
247 249
 	blocklists []files.File,
248
-	updateCallback FireholUpdateCallback) (*Firehol, error) {
250
+	updateCallback FireholUpdateCallback,
251
+) (*Firehol, error) {
249 252
 	if downloadConcurrency == 0 {
250 253
 		downloadConcurrency = DefaultFireholDownloadConcurrency
251 254
 	}

+ 2
- 2
mtglib/internal/obfuscated2/client_handshake_fuzz_internal_test.go Wyświetl plik

@@ -7,10 +7,10 @@ import (
7 7
 	"github.com/stretchr/testify/require"
8 8
 )
9 9
 
10
-var FuzzClientHandshakeSecret = []byte{1,2,3}
10
+var FuzzClientHandshakeSecret = []byte{1, 2, 3}
11 11
 
12 12
 func FuzzClientHandshake(f *testing.F) {
13
-	f.Add([]byte{1,2,3})
13
+	f.Add([]byte{1, 2, 3})
14 14
 
15 15
 	f.Fuzz(func(t *testing.T, frame []byte) {
16 16
 		data := bytes.NewReader(frame)

+ 1
- 1
mtglib/internal/obfuscated2/init_test.go Wyświetl plik

@@ -127,7 +127,7 @@ func NewServerHandshakeTestData(t *testing.T) ServerHandshakeTestData {
127 127
 	return ServerHandshakeTestData{
128 128
 		connMock: connMock,
129 129
 		proxyConn: obfuscated2.Conn{
130
-			Conn: connMock,
130
+			Conn:      connMock,
131 131
 			Encryptor: handshakeEnc,
132 132
 			Decryptor: handshakeDec,
133 133
 		},

+ 1
- 1
mtglib/internal/obfuscated2/server_handshake_fuzz_internal_test.go Wyświetl plik

@@ -23,7 +23,7 @@ func FuzzServerGenerateHandshakeFrame(f *testing.F) {
23 23
 		assert.NotEqualValues(
24 24
 			t,
25 25
 			0,
26
-			frame.data[4] | frame.data[5] | frame.data[6] | frame.data[7])
26
+			frame.data[4]|frame.data[5]|frame.data[6]|frame.data[7])
27 27
 
28 28
 		assert.Equal(t, handshakeConnectionType, frame.connectionType())
29 29
 	})

+ 2
- 2
mtglib/internal/obfuscated2/server_handshake_fuzz_test.go Wyświetl plik

@@ -8,7 +8,7 @@ import (
8 8
 )
9 9
 
10 10
 func FuzzServerSend(f *testing.F) {
11
-	f.Add([]byte{1,2,3,4,5})
11
+	f.Add([]byte{1, 2, 3, 4, 5})
12 12
 
13 13
 	f.Fuzz(func(t *testing.T, data []byte) {
14 14
 		handshakeData := NewServerHandshakeTestData(t)
@@ -32,7 +32,7 @@ func FuzzServerSend(f *testing.F) {
32 32
 }
33 33
 
34 34
 func FuzzServerReceive(f *testing.F) {
35
-	f.Add([]byte{1,2,3,4,5})
35
+	f.Add([]byte{1, 2, 3, 4, 5})
36 36
 
37 37
 	f.Fuzz(func(t *testing.T, data []byte) {
38 38
 		handshakeData := NewServerHandshakeTestData(t)

+ 10
- 5
network/circuit_breaker.go Wyświetl plik

@@ -36,7 +36,8 @@ func (c *circuitBreakerDialer) Dial(network, address string) (essentials.Conn, e
36 36
 }
37 37
 
38 38
 func (c *circuitBreakerDialer) DialContext(ctx context.Context,
39
-	network, address string) (essentials.Conn, error) {
39
+	network, address string,
40
+) (essentials.Conn, error) {
40 41
 	switch atomic.LoadUint32(&c.state) {
41 42
 	case circuitBreakerStateClosed:
42 43
 		return c.doClosed(ctx, network, address)
@@ -48,7 +49,8 @@ func (c *circuitBreakerDialer) DialContext(ctx context.Context,
48 49
 }
49 50
 
50 51
 func (c *circuitBreakerDialer) doClosed(ctx context.Context,
51
-	network, address string) (essentials.Conn, error) {
52
+	network, address string,
53
+) (essentials.Conn, error) {
52 54
 	conn, err := c.Dialer.DialContext(ctx, network, address)
53 55
 
54 56
 	select {
@@ -80,7 +82,8 @@ func (c *circuitBreakerDialer) doClosed(ctx context.Context,
80 82
 }
81 83
 
82 84
 func (c *circuitBreakerDialer) doHalfOpened(ctx context.Context,
83
-	network, address string) (essentials.Conn, error) {
85
+	network, address string,
86
+) (essentials.Conn, error) {
84 87
 	if !atomic.CompareAndSwapUint32(&c.halfOpenAttempts, 0, 1) {
85 88
 		return nil, ErrCircuitBreakerOpened
86 89
 	}
@@ -174,14 +177,16 @@ func (c *circuitBreakerDialer) stopTimer(timerRef **time.Timer) {
174 177
 }
175 178
 
176 179
 func (c *circuitBreakerDialer) ensureTimer(timerRef **time.Timer,
177
-	timeout time.Duration, callback func()) {
180
+	timeout time.Duration, callback func(),
181
+) {
178 182
 	if *timerRef == nil {
179 183
 		*timerRef = time.AfterFunc(timeout, callback)
180 184
 	}
181 185
 }
182 186
 
183 187
 func newCircuitBreakerDialer(baseDialer Dialer,
184
-	openThreshold uint32, halfOpenTimeout, resetFailuresTimeout time.Duration) Dialer {
188
+	openThreshold uint32, halfOpenTimeout, resetFailuresTimeout time.Duration,
189
+) Dialer {
185 190
 	cb := &circuitBreakerDialer{
186 191
 		Dialer:               baseDialer,
187 192
 		stateMutexChan:       make(chan bool, 1),

+ 6
- 3
network/network.go Wyświetl plik

@@ -61,7 +61,8 @@ func (n *network) DialContext(ctx context.Context, protocol, address string) (es
61 61
 }
62 62
 
63 63
 func (n *network) MakeHTTPClient(dialFunc func(ctx context.Context,
64
-	network, address string) (essentials.Conn, error)) *http.Client {
64
+	network, address string) (essentials.Conn, error),
65
+) *http.Client {
65 66
 	if dialFunc == nil {
66 67
 		dialFunc = n.DialContext
67 68
 	}
@@ -123,7 +124,8 @@ func (n *network) dnsResolve(protocol, address string) ([]string, error) {
123 124
 // It brings simple DNS cache and DNS-Over-HTTPS when necessary.
124 125
 func NewNetwork(dialer Dialer,
125 126
 	userAgent, dohHostname string,
126
-	httpTimeout time.Duration) (mtglib.Network, error) {
127
+	httpTimeout time.Duration,
128
+) (mtglib.Network, error) {
127 129
 	switch {
128 130
 	case httpTimeout < 0:
129 131
 		return nil, fmt.Errorf("timeout should be positive number %s", httpTimeout)
@@ -146,7 +148,8 @@ func NewNetwork(dialer Dialer,
146 148
 
147 149
 func makeHTTPClient(userAgent string,
148 150
 	timeout time.Duration,
149
-	dialFunc func(ctx context.Context, network, address string) (essentials.Conn, error)) *http.Client {
151
+	dialFunc func(ctx context.Context, network, address string) (essentials.Conn, error),
152
+) *http.Client {
150 153
 	return &http.Client{
151 154
 		Timeout: timeout,
152 155
 		Transport: networkHTTPTransport{

+ 2
- 1
stats/statsd.go Wyświetl plik

@@ -171,7 +171,8 @@ func (s StatsdFactory) Make() events.Observer {
171 171
 //
172 172
 // Valid tagFormats are 'datadog', 'influxdb' and 'graphite'.
173 173
 func NewStatsd(address string, log logger.StdLikeLogger,
174
-	metricPrefix, tagFormat string) (StatsdFactory, error) {
174
+	metricPrefix, tagFormat string,
175
+) (StatsdFactory, error) {
175 176
 	options := []statsd.Option{
176 177
 		statsd.MetricPrefix(metricPrefix),
177 178
 		statsd.Logger(log),

Ładowanie…
Anuluj
Zapisz