From 3d767777607e67eefce6b4a974bec750bc5a7aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 10 Nov 2022 22:42:05 +0800 Subject: [PATCH] Fix tor geoip --- outbound/tor.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/outbound/tor.go b/outbound/tor.go index b1818e3b..07f4e588 100644 --- a/outbound/tor.go +++ b/outbound/tor.go @@ -41,9 +41,18 @@ func NewTor(ctx context.Context, router adapter.Router, logger log.ContextLogger startConf := newConfig() startConf.DataDir = os.ExpandEnv(options.DataDirectory) startConf.TempDataDirBase = os.TempDir() + startConf.ExtraArgs = options.ExtraArgs + if options.DataDirectory != "" { + dataDirAbs, _ := filepath.Abs(startConf.DataDir) + if geoIPPath := filepath.Join(dataDirAbs, "geoip"); rw.FileExists(geoIPPath) && !common.Contains(options.ExtraArgs, "--GeoIPFile") { + options.ExtraArgs = append(options.ExtraArgs, "--GeoIPFile", geoIPPath) + } + if geoIP6Path := filepath.Join(dataDirAbs, "geoip6"); rw.FileExists(geoIP6Path) && !common.Contains(options.ExtraArgs, "--GeoIPv6File") { + options.ExtraArgs = append(options.ExtraArgs, "--GeoIPv6File", geoIP6Path) + } + } if options.ExecutablePath != "" { startConf.ExePath = options.ExecutablePath - startConf.ExtraArgs = options.ExtraArgs startConf.ProcessCreator = nil startConf.UseEmbeddedControlConn = false }