From f68b195306167fdea5f878feb6bea2aeef4a769d Mon Sep 17 00:00:00 2001 From: 9seconds Date: Thu, 24 Jan 2019 08:15:56 +0300 Subject: [PATCH] Update golangci-lint --- .golangci.toml | 1 + Makefile | 12 ++---------- README.md | 4 ++-- main.go | 4 +--- mtproto/rpc/rpc.go | 9 ++------- obfuscated2/frame_test.go | 6 +++--- stats/server.go | 2 +- wrappers/streamcipher_pool.go | 6 ++---- 8 files changed, 14 insertions(+), 30 deletions(-) diff --git a/.golangci.toml b/.golangci.toml index 0ada8a9..5e59f5d 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -10,3 +10,4 @@ format = "colored-line-number" [linters] enable-all = true +disable = ["gochecknoglobals"] diff --git a/Makefile b/Makefile index c001a39..9aad579 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ APP_NAME := $(IMAGE_NAME) CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}") -GOLANGCI_LINT_VERSION := v1.11.2 +GOLANGCI_LINT_VERSION := v1.13 VERSION_GO := $(shell go version) VERSION_DATE := $(shell date -Ru) @@ -59,10 +59,6 @@ test: vendor lint: vendor @$(MOD_OFF) golangci-lint run -.PHONY: critic -critic: vendor - @$(MOD_OFF) gocritic check-project "$(ROOT_DIR)" - .PHONY: clean clean: @git clean -xfd && \ @@ -74,13 +70,9 @@ docker: @docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)" .PHONY: prepare -prepare: install-lint install-critic +prepare: install-lint .PHONY: install-lint install-lint: @curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \ | $(MOD_OFF) bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION) - -.PHONY: install-critic -install-critic: - @$(MOD_OFF) go get -u github.com/go-critic/go-critic/... diff --git a/README.md b/README.md index 82c825f..38ee12d 100644 --- a/README.md +++ b/README.md @@ -226,13 +226,13 @@ This tool will listen on port 3128 by default with the given secret. # One-line runner ```console -docker run --name mtg --restart=unless-stopped -p 3128:3128 -q 3129:3129 -d nineseconds/mtg:stable $(openssl rand -hex 16) +docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable $(openssl rand -hex 16) ``` or in secret mode: ```console -docker run --name mtg --restart=unless-stopped -p 3128:3128 -q 3129:3129 -d nineseconds/mtg:stable dd$(openssl rand -hex 16) +docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable dd$(openssl rand -hex 16) ``` You will have this tool up and running on port 3128. Now curl diff --git a/main.go b/main.go index 7f1c76f..3303e3f 100644 --- a/main.go +++ b/main.go @@ -138,13 +138,11 @@ var ( adtag = app.Arg("adtag", "ADTag of the proxy.").HexBytes() ) -func init() { +func main() { // nolint: gocyclo rand.Seed(time.Now().UTC().UnixNano()) app.Version(version) app.HelpFlag.Short('h') -} -func main() { // nolint: gocyclo kingpin.MustParse(app.Parse(os.Args[1:])) err := setRLimit() diff --git a/mtproto/rpc/rpc.go b/mtproto/rpc/rpc.go index 5d242f5..59512a3 100644 --- a/mtproto/rpc/rpc.go +++ b/mtproto/rpc/rpc.go @@ -23,11 +23,6 @@ var ( ProxyRequestExtraSize = []byte{0x18, 0x00, 0x00, 0x00} ProxyRequestProxyTag = []byte{0xae, 0x26, 0x1e, 0xdb} - HandshakeSenderPID []byte - HandshakePeerPID []byte -) - -func init() { HandshakeSenderPID = []byte("IPIPPRPDTIME") - HandshakePeerPID = []byte("IPIPPRPDTIME") -} + HandshakePeerPID = []byte("IPIPPRPDTIME") +) diff --git a/obfuscated2/frame_test.go b/obfuscated2/frame_test.go index 42d997c..0983958 100644 --- a/obfuscated2/frame_test.go +++ b/obfuscated2/frame_test.go @@ -78,10 +78,10 @@ func TestFrameGenerateValid(t *testing.T) { } for _, test := range validTests { t.Run(strconv.Itoa(int(test)), func(tt *testing.T) { - frame := generateFrame(test) + frame := generateFrame(test) // nolint: scopelint conType, err := frame.ConnectionType() - assert.Nil(t, err) - assert.Equal(t, conType, test) + assert.Nil(tt, err) + assert.Equal(tt, conType, test) // nolint: scopelint }) } } diff --git a/stats/server.go b/stats/server.go index 90d688c..cc5f659 100644 --- a/stats/server.go +++ b/stats/server.go @@ -12,7 +12,7 @@ import ( func startServer(conf *config.Config, prometheusHandler http.Handler) { log := zap.S().Named("stats") - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") first, err := json.Marshal(GetStats()) diff --git a/wrappers/streamcipher_pool.go b/wrappers/streamcipher_pool.go index 03e4791..45253c6 100644 --- a/wrappers/streamcipher_pool.go +++ b/wrappers/streamcipher_pool.go @@ -5,12 +5,10 @@ import ( "sync" ) -var streamCipherBufferPool sync.Pool - -func init() { +var ( streamCipherBufferPool = sync.Pool{ New: func() interface{} { return &bytes.Buffer{} }, } -} +)