Kaynağa Gözat

Update code to the latest golangci-lint

tags/v2.1.0^2
9seconds 4 yıl önce
ebeveyn
işleme
eaa757b6d0

+ 1
- 1
internal/cli/run_proxy.go Dosyayı Görüntüle

@@ -115,7 +115,7 @@ func makeIPBlocklist(conf *config.Config, logger mtglib.Logger, ntw mtglib.Netwo
115 115
 }
116 116
 
117 117
 func makeEventStream(conf *config.Config, logger mtglib.Logger) (mtglib.EventStream, error) {
118
-	factories := make([]events.ObserverFactory, 0, 2)
118
+	factories := make([]events.ObserverFactory, 0, 2) // nolint: gomnd
119 119
 
120 120
 	if conf.Stats.StatsD.Enabled.Get(false) {
121 121
 		statsdFactory, err := stats.NewStatsd(

+ 2
- 5
internal/cli/simple_run.go Dosyayı Görüntüle

@@ -34,7 +34,7 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { // nolint: cyclop
34 34
 		return fmt.Errorf("incorrect secret: %w", err)
35 35
 	}
36 36
 
37
-	if err := conf.Concurrency.Set(strconv.FormatUint(s.Concurrency, 10)); err != nil {
37
+	if err := conf.Concurrency.Set(strconv.FormatUint(s.Concurrency, 10)); err != nil { // nolint: gomnd
38 38
 		return fmt.Errorf("incorrect concurrency: %w", err)
39 39
 	}
40 40
 
@@ -46,7 +46,7 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { // nolint: cyclop
46 46
 		return fmt.Errorf("incorrect prefer-ip: %w", err)
47 47
 	}
48 48
 
49
-	if err := conf.DomainFrontingPort.Set(strconv.FormatUint(s.DomainFrontingPort, 10)); err != nil {
49
+	if err := conf.DomainFrontingPort.Set(strconv.FormatUint(s.DomainFrontingPort, 10)); err != nil { // nolint: gomnd
50 50
 		return fmt.Errorf("incorrect domain-fronting-port: %w", err)
51 51
 	}
52 52
 
@@ -72,9 +72,6 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { // nolint: cyclop
72 72
 
73 73
 	conf.Debug.Value = s.Debug
74 74
 	conf.Defense.AntiReplay.Enabled.Value = true
75
-	conf.Defense.Blocklist.Enabled.Value = false
76
-	conf.Stats.StatsD.Enabled.Value = false
77
-	conf.Stats.Prometheus.Enabled.Value = false
78 75
 
79 76
 	if err := conf.Validate(); err != nil {
80 77
 		return fmt.Errorf("invalid result configuration: %w", err)

+ 2
- 2
internal/config/type_concurrency.go Dosyayı Görüntüle

@@ -10,7 +10,7 @@ type TypeConcurrency struct {
10 10
 }
11 11
 
12 12
 func (t *TypeConcurrency) Set(value string) error {
13
-	concurrencyValue, err := strconv.ParseUint(value, 10, 64)
13
+	concurrencyValue, err := strconv.ParseUint(value, 10, 16) // nolint: gomnd
14 14
 	if err != nil {
15 15
 		return fmt.Errorf("value is not uint (%s): %w", value, err)
16 16
 	}
@@ -41,5 +41,5 @@ func (t TypeConcurrency) MarshalJSON() ([]byte, error) {
41 41
 }
42 42
 
43 43
 func (t TypeConcurrency) String() string {
44
-	return strconv.FormatUint(uint64(t.Value), 10)
44
+	return strconv.FormatUint(uint64(t.Value), 10) // nolint: gomnd
45 45
 }

+ 2
- 2
internal/config/type_error_rate.go Dosyayı Görüntüle

@@ -12,7 +12,7 @@ type TypeErrorRate struct {
12 12
 }
13 13
 
14 14
 func (t *TypeErrorRate) Set(value string) error {
15
-	parsedValue, err := strconv.ParseFloat(value, 64)
15
+	parsedValue, err := strconv.ParseFloat(value, 64) // nolint: gomnd
16 16
 	if err != nil {
17 17
 		return fmt.Errorf("value is not a float (%s): %w", value, err)
18 18
 	}
@@ -43,5 +43,5 @@ func (t TypeErrorRate) MarshalJSON() ([]byte, error) {
43 43
 }
44 44
 
45 45
 func (t TypeErrorRate) String() string {
46
-	return strconv.FormatFloat(t.Value, 'f', -1, 64)
46
+	return strconv.FormatFloat(t.Value, 'f', -1, 64) // nolint: gomnd
47 47
 }

+ 1
- 1
internal/config/type_hostport.go Dosyayı Görüntüle

@@ -18,7 +18,7 @@ func (t *TypeHostPort) Set(value string) error {
18 18
 		return fmt.Errorf("incorrect host:port value (%v): %w", value, err)
19 19
 	}
20 20
 
21
-	portValue, err := strconv.ParseUint(port, 10, 16)
21
+	portValue, err := strconv.ParseUint(port, 10, 16) // nolint: gomnd
22 22
 	if err != nil {
23 23
 		return fmt.Errorf("incorrect port number (%v): %w", value, err)
24 24
 	}

+ 1
- 1
internal/config/type_port.go Dosyayı Görüntüle

@@ -10,7 +10,7 @@ type TypePort struct {
10 10
 }
11 11
 
12 12
 func (t *TypePort) Set(value string) error {
13
-	portValue, err := strconv.ParseUint(value, 10, 16)
13
+	portValue, err := strconv.ParseUint(value, 10, 16) // nolint: gomnd
14 14
 	if err != nil {
15 15
 		return fmt.Errorf("incorrect port number (%v): %w", value, err)
16 16
 	}

+ 2
- 2
ipblocklist/firehol.go Dosyayı Görüntüle

@@ -119,7 +119,7 @@ func (f *Firehol) Run(updateEach time.Duration) {
119 119
 }
120 120
 
121 121
 func (f *Firehol) containsIPv4(addr net.IP) bool {
122
-	ip := patricia.NewIPv4AddressFromBytes(addr, 32)
122
+	ip := patricia.NewIPv4AddressFromBytes(addr, 32) // nolint: gomnd
123 123
 
124 124
 	if ok, _, err := f.treeV4.FindDeepestTag(ip); ok && err == nil {
125 125
 		return true
@@ -129,7 +129,7 @@ func (f *Firehol) containsIPv4(addr net.IP) bool {
129 129
 }
130 130
 
131 131
 func (f *Firehol) containsIPv6(addr net.IP) bool {
132
-	ip := patricia.NewIPv6Address(addr, 128)
132
+	ip := patricia.NewIPv6Address(addr, 128) // nolint: gomnd
133 133
 
134 134
 	if ok, _, err := f.treeV6.FindDeepestTag(ip); ok && err == nil {
135 135
 		return true

+ 1
- 1
network/proxy_dialer.go Dosyayı Görüntüle

@@ -16,7 +16,7 @@ func newProxyDialer(baseDialer Dialer, proxyURL *url.URL) Dialer {
16 16
 	)
17 17
 
18 18
 	if param := params.Get("open_threshold"); param != "" {
19
-		if intNum, err := strconv.ParseUint(param, 10, 32); err == nil {
19
+		if intNum, err := strconv.ParseUint(param, 10, 32); err == nil { // nolint: gomnd
20 20
 			openThreshold = uint32(intNum)
21 21
 		}
22 22
 	}

+ 2
- 3
stats/prometheus.go Dosyayı Görüntüle

@@ -119,11 +119,10 @@ func (p prometheusProcessor) EventReplayAttack(_ mtglib.EventReplayAttack) {
119 119
 }
120 120
 
121 121
 func (p prometheusProcessor) Shutdown() {
122
-	for _, v := range p.streams {
122
+	for k, v := range p.streams {
123 123
 		releaseStreamInfo(v)
124
+		delete(p.streams, k)
124 125
 	}
125
-
126
-	p.streams = make(map[string]*streamInfo)
127 126
 }
128 127
 
129 128
 // PrometheusFactory is a factory of events.Observers which collect

Loading…
İptal
Kaydet