diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index f6b622f5..a81cfc1c 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -13,15 +13,10 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 - #with: - # go-version: ${{ steps.version.outputs.go_version }} with: - go-version: 1.18.x + go-version: ${{ steps.version.outputs.go_version }} - name: golangci-lint - #uses: golangci/golangci-lint-action@v3 - #with: - # version: latest - run: | - go install github.com/golangci/golangci-lint/cmd/golangci-lint@ec95236 - golangci-lint run ./... + uses: golangci/golangci-lint-action@v3 + with: + version: latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 795a8a03..fc838377 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,10 +11,8 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 - #with: - # go-version: ${{ steps.version.outputs.go_version }} with: - go-version: 1.18.x + go-version: ${{ steps.version.outputs.go_version }} - name: Check out code into the Go module directory uses: actions/checkout@v3 diff --git a/.golangci.yaml b/.golangci.yaml index 05cf626a..a0764585 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -4,9 +4,7 @@ linters: - gofumpt - staticcheck - govet -# - gci - - gofmt - - goimports + - gci linters-settings: gci: diff --git a/listener/tun/device/tun/tun_wireguard.go b/listener/tun/device/tun/tun_wireguard.go index 1e1d5527..dabd1252 100644 --- a/listener/tun/device/tun/tun_wireguard.go +++ b/listener/tun/device/tun/tun_wireguard.go @@ -5,6 +5,7 @@ package tun import ( "fmt" "runtime" + "strings" "github.com/Dreamacro/clash/common/pool" "github.com/Dreamacro/clash/listener/tun/device" @@ -50,9 +51,18 @@ func Open(name string, mtu uint32) (_ device.Device, err error) { } nt, err := tun.CreateTUN(t.name, forcedMTU) // forcedMTU do not work on wintun, need to be setting by other way + + // retry if abnormal exit on Windows at last time + if err != nil && runtime.GOOS == "windows" && + strings.HasSuffix(err.Error(), "file already exists.") { + + nt, err = tun.CreateTUN(t.name, forcedMTU) + } + if err != nil { return nil, fmt.Errorf("create tun: %w", err) } + t.nt = nt.(*tun.NativeTun) tunMTU, err := nt.MTU()