From 0183d752a0c1cfaf0d2a7bd0294dc8e0c81be4ed Mon Sep 17 00:00:00 2001 From: MetaCubeX Date: Wed, 16 Mar 2022 22:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=20[Fix]=20=E4=BC=98=E5=8C=96geodata=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 18 ------------------ config/config.go | 1 + config/initial.go | 19 +++++++++++-------- go.mod | 2 +- 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index d15dccb8..30fc023e 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,7 @@ NAME=Clash.Meta BINDIR=bin BRANCH=$(shell git rev-parse --abbrev-ref HEAD) -VERSION=$(shell git describe --tags || echo "unknown version" ) -ifeq ($(BRANCH),Alpha) VERSION=alpha-$(shell git rev-parse --short HEAD) -endif BUILDTIME=$(shell date -u) GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=$(VERSION)" \ -X "github.com/Dreamacro/clash/constant.BuildTime=$(BUILDTIME)" \ @@ -64,33 +61,18 @@ linux-amd64-AutoIptables: linux-arm64: GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ -linux-arm64-AutoIptables: - GOARCH=arm64 GOOS=linux $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@ - linux-armv5: GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ -linux-armv5-AutoIptables: - GOARCH=arm GOOS=linux GOARM=5 $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@ - linux-armv6: GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ -linux-armv6-AutoIptables: - GOARCH=arm GOOS=linux GOARM=6 $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@ - linux-armv7: GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ -linux-armv7-AutoIptables: - GOARCH=arm GOOS=linux GOARM=7 $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@ - linux-armv8: GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ -linux-armv8-AutoIptables: - GOARCH=arm64 GOOS=linux $(GOBUILDOP) -o $(BINDIR)/$(NAME)-$@ - linux-mips-softfloat: GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ diff --git a/config/config.go b/config/config.go index 36a938cc..8ca33fd0 100644 --- a/config/config.go +++ b/config/config.go @@ -566,6 +566,7 @@ func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[strin if err := initGeoSite(); err != nil { return nil, nil, fmt.Errorf("can't initial GeoSite: %w", err) } + initMode = false } parsed, parseErr := R.ParseRule(ruleName, payload, target, params) if parseErr != nil { diff --git a/config/initial.go b/config/initial.go index 0ad5673a..69b6ce16 100644 --- a/config/initial.go +++ b/config/initial.go @@ -12,6 +12,8 @@ import ( "github.com/Dreamacro/clash/log" ) +var initMode = true + func downloadMMDB(path string) (err error) { resp, err := http.Get("https://raw.githubusercontents.com/Loyalsoldier/geoip/release/Country.mmdb") if err != nil { @@ -71,14 +73,15 @@ func initGeoSite() error { } log.Infoln("Download GeoSite.dat finish") } - - if !geodata.Verify(C.GeositeName) { - log.Warnln("GeoSite.dat invalid, remove and download") - if err := os.Remove(C.Path.GeoSite()); err != nil { - return fmt.Errorf("can't remove invalid GeoSite.dat: %s", err.Error()) - } - if err := downloadGeoSite(C.Path.GeoSite()); err != nil { - return fmt.Errorf("can't download GeoSite.dat: %s", err.Error()) + if initMode { + if !geodata.Verify(C.GeositeName) { + log.Warnln("GeoSite.dat invalid, remove and download") + if err := os.Remove(C.Path.GeoSite()); err != nil { + return fmt.Errorf("can't remove invalid GeoSite.dat: %s", err.Error()) + } + if err := downloadGeoSite(C.Path.GeoSite()); err != nil { + return fmt.Errorf("can't download GeoSite.dat: %s", err.Error()) + } } } return nil diff --git a/go.mod b/go.mod index 49f8492a..896ea4d8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Dreamacro/clash -go 1.17 +go 1.18 require ( github.com/Dreamacro/go-shadowsocks2 v0.1.7