From b3d75948138403284f7e7a532807d2701dc46781 Mon Sep 17 00:00:00 2001 From: Anankke Date: Tue, 12 Apr 2022 22:06:06 -0400 Subject: [PATCH 1/5] Chore: add `none` alias to `dummy` on ShadowsocksR (#2056) --- adapter/outbound/shadowsocksr.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/adapter/outbound/shadowsocksr.go b/adapter/outbound/shadowsocksr.go index a5f07ef6..ea1c2838 100644 --- a/adapter/outbound/shadowsocksr.go +++ b/adapter/outbound/shadowsocksr.go @@ -92,6 +92,12 @@ func (ssr *ShadowSocksR) ListenPacketContext(ctx context.Context, metadata *C.Me } func NewShadowSocksR(option ShadowSocksROption) (*ShadowSocksR, error) { + // SSR protocol compatibility + // https://github.com/Dreamacro/clash/pull/2056 + if option.Cipher == "none" { + option.Cipher = "dummy" + } + addr := net.JoinHostPort(option.Server, strconv.Itoa(option.Port)) cipher := option.Cipher password := option.Password @@ -103,13 +109,14 @@ func NewShadowSocksR(option ShadowSocksROption) (*ShadowSocksR, error) { ivSize int key []byte ) + if option.Cipher == "dummy" { ivSize = 0 key = core.Kdf(option.Password, 16) } else { ciph, ok := coreCiph.(*core.StreamCipher) if !ok { - return nil, fmt.Errorf("%s is not dummy or a supported stream cipher in ssr", cipher) + return nil, fmt.Errorf("%s is not none or a supported stream cipher in ssr", cipher) } ivSize = ciph.IVSize() key = ciph.Key From c282d662ca78e4044bb7b2af44f37ed58bdcd9bc Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Wed, 13 Apr 2022 17:51:21 +0800 Subject: [PATCH 2/5] Fix: make golangci lint support multi GOOS --- Makefile | 6 +++++- component/process/process_windows.go | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index aed9ca4b..36d7b3a2 100644 --- a/Makefile +++ b/Makefile @@ -130,7 +130,11 @@ all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST) releases: $(gz_releases) $(zip_releases) lint: - golangci-lint run ./... + GOOS=darwin golangci-lint run ./... + GOOS=windows golangci-lint run ./... + GOOS=linux golangci-lint run ./... + GOOS=freebsd golangci-lint run ./... + GOOS=openbsd golangci-lint run ./... clean: rm $(BINDIR)/* diff --git a/component/process/process_windows.go b/component/process/process_windows.go index e2fb96ca..c51a36f6 100644 --- a/component/process/process_windows.go +++ b/component/process/process_windows.go @@ -174,7 +174,7 @@ func newSearcher(isV4, isTCP bool) *searcher { func getTransportTable(fn uintptr, family int, class int) ([]byte, error) { for size, buf := uint32(8), make([]byte, 8); ; { ptr := unsafe.Pointer(&buf[0]) - err, _, _ := syscall.Syscall6(fn, 6, uintptr(ptr), uintptr(unsafe.Pointer(&size)), 0, uintptr(family), uintptr(class), 0) + err, _, _ := syscall.SyscallN(fn, 6, uintptr(ptr), uintptr(unsafe.Pointer(&size)), 0, uintptr(family), uintptr(class), 0) switch err { case 0: @@ -209,7 +209,7 @@ func getExecPathFromPID(pid uint32) (string, error) { buf := make([]uint16, syscall.MAX_LONG_PATH) size := uint32(len(buf)) - r1, _, err := syscall.Syscall6( + r1, _, err := syscall.SyscallN( queryProcName, 4, uintptr(h), uintptr(1), From 4dfba73e5cd015f610ba6864546426e72db605a2 Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Thu, 14 Apr 2022 23:27:49 +0800 Subject: [PATCH 3/5] Fix: SyscallN should not use nargs --- component/process/process_windows.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/component/process/process_windows.go b/component/process/process_windows.go index c51a36f6..26a389a0 100644 --- a/component/process/process_windows.go +++ b/component/process/process_windows.go @@ -174,7 +174,7 @@ func newSearcher(isV4, isTCP bool) *searcher { func getTransportTable(fn uintptr, family int, class int) ([]byte, error) { for size, buf := uint32(8), make([]byte, 8); ; { ptr := unsafe.Pointer(&buf[0]) - err, _, _ := syscall.SyscallN(fn, 6, uintptr(ptr), uintptr(unsafe.Pointer(&size)), 0, uintptr(family), uintptr(class), 0) + err, _, _ := syscall.SyscallN(fn, uintptr(ptr), uintptr(unsafe.Pointer(&size)), 0, uintptr(family), uintptr(class), 0) switch err { case 0: @@ -210,12 +210,12 @@ func getExecPathFromPID(pid uint32) (string, error) { buf := make([]uint16, syscall.MAX_LONG_PATH) size := uint32(len(buf)) r1, _, err := syscall.SyscallN( - queryProcName, 4, + queryProcName, uintptr(h), uintptr(1), uintptr(unsafe.Pointer(&buf[0])), uintptr(unsafe.Pointer(&size)), - 0, 0) + ) if r1 == 0 { return "", err } From 2c9a4d276a07f1567f6ca1ae7e736a4dfa4b21da Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Thu, 14 Apr 2022 23:37:41 +0800 Subject: [PATCH 4/5] Chore: add more github action cache --- .github/workflows/docker.yml | 4 ++++ .github/workflows/release.yml | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 18590edd..19fe0d88 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -49,6 +49,8 @@ jobs: platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 push: true tags: 'dreamacro/clash:dev,ghcr.io/dreamacro/clash:dev' + cache-from: type=gha + cache-to: type=gha,mode=max - name: Get all docker tags if: startsWith(github.ref, 'refs/tags/') @@ -74,3 +76,5 @@ jobs: platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 push: true tags: ${{steps.tags.outputs.result}} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8226d875..08f97ba3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,9 @@ jobs: - name: Cache go module uses: actions/cache@v2 with: - path: ~/go/pkg/mod + path: | + ~/go/pkg/mod + ~/.cache/go-build key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- From e010940b614900c4c249a4d535de1bffc0632a98 Mon Sep 17 00:00:00 2001 From: Kr328 Date: Sat, 16 Apr 2022 15:31:26 +0800 Subject: [PATCH 5/5] Improve: replace bootstrap dns (#2080) --- component/resolver/defaults.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 component/resolver/defaults.go diff --git a/component/resolver/defaults.go b/component/resolver/defaults.go new file mode 100644 index 00000000..8a04bd17 --- /dev/null +++ b/component/resolver/defaults.go @@ -0,0 +1,12 @@ +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris + +package resolver + +import _ "unsafe" + +//go:linkname defaultNS net.defaultNS +var defaultNS []string + +func init() { + defaultNS = []string{"114.114.114.114:53", "8.8.8.8:53"} +}