mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 14:54:01 +03:00
Merge pull request #199 from 9seconds/update-lint
Update golangci-lint to 1.41.1
This commit is contained in:
@@ -70,7 +70,7 @@ jobs:
|
|||||||
- name: Run linter
|
- name: Run linter
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
with:
|
with:
|
||||||
version: v1.40.1
|
version: v1.41.1
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
name: Docker
|
name: Docker
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|||||||
IMAGE_NAME := mtg
|
IMAGE_NAME := mtg
|
||||||
APP_NAME := $(IMAGE_NAME)
|
APP_NAME := $(IMAGE_NAME)
|
||||||
|
|
||||||
GOLANGCI_LINT_VERSION := v1.40.1
|
GOLANGCI_LINT_VERSION := v1.41.1
|
||||||
|
|
||||||
VERSION_GO := $(shell go version)
|
VERSION_GO := $(shell go version)
|
||||||
VERSION_DATE := $(shell date -Ru)
|
VERSION_DATE := $(shell date -Ru)
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ func makeIPBlocklist(conf *config.Config, logger mtglib.Logger, ntw mtglib.Netwo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeEventStream(conf *config.Config, logger mtglib.Logger) (mtglib.EventStream, error) {
|
func makeEventStream(conf *config.Config, logger mtglib.Logger) (mtglib.EventStream, error) {
|
||||||
factories := make([]events.ObserverFactory, 0, 2)
|
factories := make([]events.ObserverFactory, 0, 2) // nolint: gomnd
|
||||||
|
|
||||||
if conf.Stats.StatsD.Enabled.Get(false) {
|
if conf.Stats.StatsD.Enabled.Get(false) {
|
||||||
statsdFactory, err := stats.NewStatsd(
|
statsdFactory, err := stats.NewStatsd(
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { // nolint: cyclop
|
|||||||
return fmt.Errorf("incorrect secret: %w", err)
|
return fmt.Errorf("incorrect secret: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := conf.Concurrency.Set(strconv.FormatUint(s.Concurrency, 10)); err != nil {
|
if err := conf.Concurrency.Set(strconv.FormatUint(s.Concurrency, 10)); err != nil { // nolint: gomnd
|
||||||
return fmt.Errorf("incorrect concurrency: %w", err)
|
return fmt.Errorf("incorrect concurrency: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { // nolint: cyclop
|
|||||||
return fmt.Errorf("incorrect prefer-ip: %w", err)
|
return fmt.Errorf("incorrect prefer-ip: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := conf.DomainFrontingPort.Set(strconv.FormatUint(s.DomainFrontingPort, 10)); err != nil {
|
if err := conf.DomainFrontingPort.Set(strconv.FormatUint(s.DomainFrontingPort, 10)); err != nil { // nolint: gomnd
|
||||||
return fmt.Errorf("incorrect domain-fronting-port: %w", err)
|
return fmt.Errorf("incorrect domain-fronting-port: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +72,6 @@ func (s *SimpleRun) Run(cli *CLI, version string) error { // nolint: cyclop
|
|||||||
|
|
||||||
conf.Debug.Value = s.Debug
|
conf.Debug.Value = s.Debug
|
||||||
conf.Defense.AntiReplay.Enabled.Value = true
|
conf.Defense.AntiReplay.Enabled.Value = true
|
||||||
conf.Defense.Blocklist.Enabled.Value = false
|
|
||||||
conf.Stats.StatsD.Enabled.Value = false
|
|
||||||
conf.Stats.Prometheus.Enabled.Value = false
|
|
||||||
|
|
||||||
if err := conf.Validate(); err != nil {
|
if err := conf.Validate(); err != nil {
|
||||||
return fmt.Errorf("invalid result configuration: %w", err)
|
return fmt.Errorf("invalid result configuration: %w", err)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ type TypeConcurrency struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeConcurrency) Set(value string) error {
|
func (t *TypeConcurrency) Set(value string) error {
|
||||||
concurrencyValue, err := strconv.ParseUint(value, 10, 64)
|
concurrencyValue, err := strconv.ParseUint(value, 10, 16) // nolint: gomnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("value is not uint (%s): %w", value, err)
|
return fmt.Errorf("value is not uint (%s): %w", value, err)
|
||||||
}
|
}
|
||||||
@@ -41,5 +41,5 @@ func (t TypeConcurrency) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t TypeConcurrency) String() string {
|
func (t TypeConcurrency) String() string {
|
||||||
return strconv.FormatUint(uint64(t.Value), 10)
|
return strconv.FormatUint(uint64(t.Value), 10) // nolint: gomnd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type TypeErrorRate struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeErrorRate) Set(value string) error {
|
func (t *TypeErrorRate) Set(value string) error {
|
||||||
parsedValue, err := strconv.ParseFloat(value, 64)
|
parsedValue, err := strconv.ParseFloat(value, 64) // nolint: gomnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("value is not a float (%s): %w", value, err)
|
return fmt.Errorf("value is not a float (%s): %w", value, err)
|
||||||
}
|
}
|
||||||
@@ -43,5 +43,5 @@ func (t TypeErrorRate) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t TypeErrorRate) String() string {
|
func (t TypeErrorRate) String() string {
|
||||||
return strconv.FormatFloat(t.Value, 'f', -1, 64)
|
return strconv.FormatFloat(t.Value, 'f', -1, 64) // nolint: gomnd
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func (t *TypeHostPort) Set(value string) error {
|
|||||||
return fmt.Errorf("incorrect host:port value (%v): %w", value, err)
|
return fmt.Errorf("incorrect host:port value (%v): %w", value, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
portValue, err := strconv.ParseUint(port, 10, 16)
|
portValue, err := strconv.ParseUint(port, 10, 16) // nolint: gomnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("incorrect port number (%v): %w", value, err)
|
return fmt.Errorf("incorrect port number (%v): %w", value, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ type TypePort struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypePort) Set(value string) error {
|
func (t *TypePort) Set(value string) error {
|
||||||
portValue, err := strconv.ParseUint(value, 10, 16)
|
portValue, err := strconv.ParseUint(value, 10, 16) // nolint: gomnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("incorrect port number (%v): %w", value, err)
|
return fmt.Errorf("incorrect port number (%v): %w", value, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ func (f *Firehol) Run(updateEach time.Duration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Firehol) containsIPv4(addr net.IP) bool {
|
func (f *Firehol) containsIPv4(addr net.IP) bool {
|
||||||
ip := patricia.NewIPv4AddressFromBytes(addr, 32)
|
ip := patricia.NewIPv4AddressFromBytes(addr, 32) // nolint: gomnd
|
||||||
|
|
||||||
if ok, _, err := f.treeV4.FindDeepestTag(ip); ok && err == nil {
|
if ok, _, err := f.treeV4.FindDeepestTag(ip); ok && err == nil {
|
||||||
return true
|
return true
|
||||||
@@ -129,7 +129,7 @@ func (f *Firehol) containsIPv4(addr net.IP) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Firehol) containsIPv6(addr net.IP) bool {
|
func (f *Firehol) containsIPv6(addr net.IP) bool {
|
||||||
ip := patricia.NewIPv6Address(addr, 128)
|
ip := patricia.NewIPv6Address(addr, 128) // nolint: gomnd
|
||||||
|
|
||||||
if ok, _, err := f.treeV6.FindDeepestTag(ip); ok && err == nil {
|
if ok, _, err := f.treeV6.FindDeepestTag(ip); ok && err == nil {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func newProxyDialer(baseDialer Dialer, proxyURL *url.URL) Dialer {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if param := params.Get("open_threshold"); param != "" {
|
if param := params.Get("open_threshold"); param != "" {
|
||||||
if intNum, err := strconv.ParseUint(param, 10, 32); err == nil {
|
if intNum, err := strconv.ParseUint(param, 10, 32); err == nil { // nolint: gomnd
|
||||||
openThreshold = uint32(intNum)
|
openThreshold = uint32(intNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -119,11 +119,10 @@ func (p prometheusProcessor) EventReplayAttack(_ mtglib.EventReplayAttack) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p prometheusProcessor) Shutdown() {
|
func (p prometheusProcessor) Shutdown() {
|
||||||
for _, v := range p.streams {
|
for k, v := range p.streams {
|
||||||
releaseStreamInfo(v)
|
releaseStreamInfo(v)
|
||||||
|
delete(p.streams, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.streams = make(map[string]*streamInfo)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrometheusFactory is a factory of events.Observers which collect
|
// PrometheusFactory is a factory of events.Observers which collect
|
||||||
|
|||||||
Reference in New Issue
Block a user