From 393d0662a5bfa48493b5f37cdda178b5bc8bb504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 17 Nov 2024 15:47:28 +0800 Subject: [PATCH] Update workflow --- .github/renovate.json | 19 ++++++ .github/update_dependencies.sh | 3 +- .github/workflows/lint.yml | 37 +++++++++++ .github/workflows/test.yml | 112 +++++++++++++++++++++++++++++++++ .golangci.yml | 16 ++--- Makefile | 12 ++-- v3_server.go | 3 +- 7 files changed, 185 insertions(+), 17 deletions(-) create mode 100644 .github/renovate.json create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..6612115 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "commitMessagePrefix": "[dependencies]", + "extends": [ + "config:base", + ":disableRateLimiting" + ], + "golang": { + "enabled": false + }, + "packageRules": [ + { + "matchManagers": [ + "github-actions" + ], + "groupName": "github-actions" + } + ] +} \ No newline at end of file diff --git a/.github/update_dependencies.sh b/.github/update_dependencies.sh index d63123b..4702ddf 100755 --- a/.github/update_dependencies.sh +++ b/.github/update_dependencies.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash PROJECTS=$(dirname "$0")/../.. - -go get -x github.com/sagernet/sing@$(git -C $PROJECTS/sing rev-parse HEAD) +go get -x github.com/sagernet/$1@$(git -C $PROJECTS/$1 rev-parse HEAD) go mod tidy diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..b80c649 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,37 @@ +name: Lint + +on: + push: + branches: + - dev + paths-ignore: + - '**.md' + - '.github/**' + - '!.github/workflows/lint.yml' + pull_request: + branches: + - dev + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ^1.23 + - name: Cache go module + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + key: go-${{ hashFiles('**/go.sum') }} + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3afe968 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,112 @@ +name: test + +on: + push: + branches: + - main + - dev + paths-ignore: + - '**.md' + - '.github/**' + - '!.github/workflows/debug.yml' + pull_request: + branches: + - main + - dev + +jobs: + build: + name: Linux + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ^1.23 + - name: Build + run: | + make test + build_go120: + name: Linux (Go 1.20) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ~1.20 + continue-on-error: true + - name: Build + run: | + make test + build_go121: + name: Linux (Go 1.21) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ~1.21 + continue-on-error: true + - name: Build + run: | + make test + build_go122: + name: Linux (Go 1.22) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ~1.22 + continue-on-error: true + - name: Build + run: | + make test + build_windows: + name: Windows + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ^1.23 + continue-on-error: true + - name: Build + run: | + make test + build_darwin: + name: macOS + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ^1.23 + continue-on-error: true + - name: Build + run: | + make test \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index bfd0bdb..b29967d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,11 +5,8 @@ linters: - govet - gci - staticcheck - -run: - skip-dirs: - - tls - - tls_compact + - paralleltest + - ineffassign linters-settings: gci: @@ -18,5 +15,10 @@ linters-settings: - standard - prefix(github.com/sagernet/) - default - staticcheck: - go: '1.20' + +run: + go: "1.23" + +issues: + exclude-dirs: + - internal diff --git a/Makefile b/Makefile index 21f3618..e47456e 100644 --- a/Makefile +++ b/Makefile @@ -8,14 +8,14 @@ fmt_install: go install -v github.com/daixiang0/gci@latest lint: - GOOS=linux golangci-lint run . - GOOS=android golangci-lint run . - GOOS=windows golangci-lint run . - GOOS=darwin golangci-lint run . - GOOS=freebsd golangci-lint run . + GOOS=linux golangci-lint run ./... + GOOS=android golangci-lint run ./... + GOOS=windows golangci-lint run ./... + GOOS=darwin golangci-lint run ./... + GOOS=freebsd golangci-lint run ./... lint_install: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest test: - go test -v . \ No newline at end of file + go test -v ./... \ No newline at end of file diff --git a/v3_server.go b/v3_server.go index f700206..eebd3ef 100644 --- a/v3_server.go +++ b/v3_server.go @@ -15,7 +15,6 @@ import ( "github.com/sagernet/sing/common/buf" "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" - "github.com/sagernet/sing/common/rw" ) func extractFrame(conn net.Conn) (*buf.Buffer, error) { @@ -63,7 +62,7 @@ func verifyClientHello(frame []byte, users []User) (*User, error) { for _, user := range users { hmacSHA1Hash := hmac.New(sha1.New, []byte(user.Password)) hmacSHA1Hash.Write(frame[tlsHeaderSize:hmacIndex]) - hmacSHA1Hash.Write(rw.ZeroBytes[:4]) + hmacSHA1Hash.Write([]byte{0, 0, 0, 0}) hmacSHA1Hash.Write(frame[hmacIndex+hmacSize:]) if hmac.Equal(frame[hmacIndex:hmacIndex+hmacSize], hmacSHA1Hash.Sum(nil)[:hmacSize]) { return &user, nil