Sfoglia il codice sorgente

Merge pull request #199 from 9seconds/update-lint

Update golangci-lint to 1.41.1
tags/v2.1.0^2
Sergey Arkhipov 4 anni fa
parent
commit
bd39fa63cb
Nessun account collegato all'indirizzo email del committer

+ 1
- 1
.github/workflows/ci.yaml Vedi File

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

+ 1
- 1
Makefile Vedi File

2
 IMAGE_NAME   := mtg
2
 IMAGE_NAME   := mtg
3
 APP_NAME     := $(IMAGE_NAME)
3
 APP_NAME     := $(IMAGE_NAME)
4
 
4
 
5
-GOLANGCI_LINT_VERSION := v1.40.1
5
+GOLANGCI_LINT_VERSION := v1.41.1
6
 
6
 
7
 VERSION_GO         := $(shell go version)
7
 VERSION_GO         := $(shell go version)
8
 VERSION_DATE       := $(shell date -Ru)
8
 VERSION_DATE       := $(shell date -Ru)

+ 1
- 1
internal/cli/run_proxy.go Vedi File

115
 }
115
 }
116
 
116
 
117
 func makeEventStream(conf *config.Config, logger mtglib.Logger) (mtglib.EventStream, error) {
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
 	if conf.Stats.StatsD.Enabled.Get(false) {
120
 	if conf.Stats.StatsD.Enabled.Get(false) {
121
 		statsdFactory, err := stats.NewStatsd(
121
 		statsdFactory, err := stats.NewStatsd(

+ 2
- 5
internal/cli/simple_run.go Vedi File

34
 		return fmt.Errorf("incorrect secret: %w", err)
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
 		return fmt.Errorf("incorrect concurrency: %w", err)
38
 		return fmt.Errorf("incorrect concurrency: %w", err)
39
 	}
39
 	}
40
 
40
 
46
 		return fmt.Errorf("incorrect prefer-ip: %w", err)
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
 		return fmt.Errorf("incorrect domain-fronting-port: %w", err)
50
 		return fmt.Errorf("incorrect domain-fronting-port: %w", err)
51
 	}
51
 	}
52
 
52
 
72
 
72
 
73
 	conf.Debug.Value = s.Debug
73
 	conf.Debug.Value = s.Debug
74
 	conf.Defense.AntiReplay.Enabled.Value = true
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
 	if err := conf.Validate(); err != nil {
76
 	if err := conf.Validate(); err != nil {
80
 		return fmt.Errorf("invalid result configuration: %w", err)
77
 		return fmt.Errorf("invalid result configuration: %w", err)

+ 2
- 2
internal/config/type_concurrency.go Vedi File

10
 }
10
 }
11
 
11
 
12
 func (t *TypeConcurrency) Set(value string) error {
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
 	if err != nil {
14
 	if err != nil {
15
 		return fmt.Errorf("value is not uint (%s): %w", value, err)
15
 		return fmt.Errorf("value is not uint (%s): %w", value, err)
16
 	}
16
 	}
41
 }
41
 }
42
 
42
 
43
 func (t TypeConcurrency) String() string {
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 Vedi File

12
 }
12
 }
13
 
13
 
14
 func (t *TypeErrorRate) Set(value string) error {
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
 	if err != nil {
16
 	if err != nil {
17
 		return fmt.Errorf("value is not a float (%s): %w", value, err)
17
 		return fmt.Errorf("value is not a float (%s): %w", value, err)
18
 	}
18
 	}
43
 }
43
 }
44
 
44
 
45
 func (t TypeErrorRate) String() string {
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 Vedi File

18
 		return fmt.Errorf("incorrect host:port value (%v): %w", value, err)
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
 	if err != nil {
22
 	if err != nil {
23
 		return fmt.Errorf("incorrect port number (%v): %w", value, err)
23
 		return fmt.Errorf("incorrect port number (%v): %w", value, err)
24
 	}
24
 	}

+ 1
- 1
internal/config/type_port.go Vedi File

10
 }
10
 }
11
 
11
 
12
 func (t *TypePort) Set(value string) error {
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
 	if err != nil {
14
 	if err != nil {
15
 		return fmt.Errorf("incorrect port number (%v): %w", value, err)
15
 		return fmt.Errorf("incorrect port number (%v): %w", value, err)
16
 	}
16
 	}

+ 2
- 2
ipblocklist/firehol.go Vedi File

119
 }
119
 }
120
 
120
 
121
 func (f *Firehol) containsIPv4(addr net.IP) bool {
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
 	if ok, _, err := f.treeV4.FindDeepestTag(ip); ok && err == nil {
124
 	if ok, _, err := f.treeV4.FindDeepestTag(ip); ok && err == nil {
125
 		return true
125
 		return true
129
 }
129
 }
130
 
130
 
131
 func (f *Firehol) containsIPv6(addr net.IP) bool {
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
 	if ok, _, err := f.treeV6.FindDeepestTag(ip); ok && err == nil {
134
 	if ok, _, err := f.treeV6.FindDeepestTag(ip); ok && err == nil {
135
 		return true
135
 		return true

+ 1
- 1
network/proxy_dialer.go Vedi File

16
 	)
16
 	)
17
 
17
 
18
 	if param := params.Get("open_threshold"); param != "" {
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
 			openThreshold = uint32(intNum)
20
 			openThreshold = uint32(intNum)
21
 		}
21
 		}
22
 	}
22
 	}

+ 2
- 3
stats/prometheus.go Vedi File

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

Loading…
Annulla
Salva