From 571d2a00755287afad5b0a93b36f1d75a3d55895 Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Wed, 18 Aug 2021 13:26:23 +0800 Subject: [PATCH] Migration: go 1.17 --- .github/workflows/go.yml | 2 +- Makefile | 6 +++++- common/sockopt/reuseaddr_other.go | 1 + component/dialer/bind_others.go | 1 + component/process/process_other.go | 5 ++++- dns/filters.go | 2 +- go.mod | 18 +++++++++++++----- go.sum | 16 ++++++++-------- listener/redir/tcp_linux_other.go | 1 + listener/redir/tcp_other.go | 1 + listener/tproxy/setsockopt_linux.go | 1 + listener/tproxy/setsockopt_other.go | 1 + listener/tproxy/udp_linux.go | 1 + listener/tproxy/udp_other.go | 1 + rule/geoip.go | 4 ++++ 15 files changed, 44 insertions(+), 17 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 343e31ba1..d8a514eae 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -9,7 +9,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 with: - go-version: 1.16 + go-version: 1.17 - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index 686514460..97328bc23 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ PLATFORM_LIST = \ WINDOWS_ARCH_LIST = \ windows-386 \ windows-amd64 \ + windows-arm64 \ windows-arm32v7 all: linux-amd64 darwin-amd64 windows-amd64 # Most used @@ -91,7 +92,10 @@ windows-386: windows-amd64: GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe - + +windows-arm64: + GOARCH=arm64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe + windows-arm32v7: GOARCH=arm GOOS=windows GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe diff --git a/common/sockopt/reuseaddr_other.go b/common/sockopt/reuseaddr_other.go index 2b1369508..c07083de0 100644 --- a/common/sockopt/reuseaddr_other.go +++ b/common/sockopt/reuseaddr_other.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package sockopt diff --git a/component/dialer/bind_others.go b/component/dialer/bind_others.go index be30bae84..e09b5ff84 100644 --- a/component/dialer/bind_others.go +++ b/component/dialer/bind_others.go @@ -1,3 +1,4 @@ +//go:build !linux && !darwin // +build !linux,!darwin package dialer diff --git a/component/process/process_other.go b/component/process/process_other.go index 1e0bd4478..f8a6ebbb4 100644 --- a/component/process/process_other.go +++ b/component/process/process_other.go @@ -1,4 +1,7 @@ -// +build !darwin,!linux,!windows +//go:build !darwin && !linux && !windows && (!freebsd || !amd64) +// +build !darwin +// +build !linux +// +build !windows // +build !freebsd !amd64 package process diff --git a/dns/filters.go b/dns/filters.go index 583883fab..a6bc6c544 100644 --- a/dns/filters.go +++ b/dns/filters.go @@ -15,7 +15,7 @@ type geoipFilter struct{} func (gf *geoipFilter) Match(ip net.IP) bool { record, _ := mmdb.Instance().Country(ip) - return record.Country.IsoCode != "CN" && record.Country.IsoCode != "" + return record.Country.IsoCode != "CN" && !ip.IsPrivate() } type ipnetFilter struct { diff --git a/go.mod b/go.mod index 28e4d44ba..34915dd7a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Dreamacro/clash -go 1.16 +go 1.17 require ( github.com/Dreamacro/go-shadowsocks2 v0.1.7 @@ -13,10 +13,18 @@ require ( github.com/oschwald/geoip2-golang v1.5.0 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 - go.uber.org/atomic v1.8.0 - golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e - golang.org/x/net v0.0.0-20210614182718-04defd469f4e + go.uber.org/atomic v1.9.0 + golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 + golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c + golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 gopkg.in/yaml.v2 v2.4.0 ) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/oschwald/maxminddb-golang v1.8.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/text v0.3.6 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +) diff --git a/go.sum b/go.sum index fa37dc3be..2c433ac0a 100644 --- a/go.sum +++ b/go.sum @@ -29,14 +29,14 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.uber.org/atomic v1.8.0 h1:CUhrE4N1rqSE6FM9ecihEjRkLQu8cDfgDyoOs83mEY4= -go.uber.org/atomic v1.8.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= -golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -45,8 +45,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 h1:c8PlLMqBbOHoqtjteWm5/kbe6rNY2pbRfbIMVnepueo= +golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= diff --git a/listener/redir/tcp_linux_other.go b/listener/redir/tcp_linux_other.go index 95472823c..3299843d0 100644 --- a/listener/redir/tcp_linux_other.go +++ b/listener/redir/tcp_linux_other.go @@ -1,3 +1,4 @@ +//go:build linux && !386 // +build linux,!386 package redir diff --git a/listener/redir/tcp_other.go b/listener/redir/tcp_other.go index 50968e9ab..592e9584f 100644 --- a/listener/redir/tcp_other.go +++ b/listener/redir/tcp_other.go @@ -1,3 +1,4 @@ +//go:build !darwin && !linux && !freebsd // +build !darwin,!linux,!freebsd package redir diff --git a/listener/tproxy/setsockopt_linux.go b/listener/tproxy/setsockopt_linux.go index a70223f7f..1e92db128 100644 --- a/listener/tproxy/setsockopt_linux.go +++ b/listener/tproxy/setsockopt_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package tproxy diff --git a/listener/tproxy/setsockopt_other.go b/listener/tproxy/setsockopt_other.go index 059477284..24fb7c7b4 100644 --- a/listener/tproxy/setsockopt_other.go +++ b/listener/tproxy/setsockopt_other.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package tproxy diff --git a/listener/tproxy/udp_linux.go b/listener/tproxy/udp_linux.go index 40c177e7e..f68ce8f1f 100644 --- a/listener/tproxy/udp_linux.go +++ b/listener/tproxy/udp_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package tproxy diff --git a/listener/tproxy/udp_other.go b/listener/tproxy/udp_other.go index a4531b5d0..f899fc3d2 100644 --- a/listener/tproxy/udp_other.go +++ b/listener/tproxy/udp_other.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package tproxy diff --git a/rule/geoip.go b/rule/geoip.go index be4b5029f..0b94c4c28 100644 --- a/rule/geoip.go +++ b/rule/geoip.go @@ -20,6 +20,10 @@ func (g *GEOIP) Match(metadata *C.Metadata) bool { if ip == nil { return false } + + if g.country == "LAN" { + return ip.IsPrivate() + } record, _ := mmdb.Instance().Country(ip) return record.Country.IsoCode == g.country }