Fix tor geoip

This commit is contained in:
世界 2022-11-10 22:42:05 +08:00
parent 24f4dfea04
commit 3d76777760
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -41,9 +41,18 @@ func NewTor(ctx context.Context, router adapter.Router, logger log.ContextLogger
startConf := newConfig() startConf := newConfig()
startConf.DataDir = os.ExpandEnv(options.DataDirectory) startConf.DataDir = os.ExpandEnv(options.DataDirectory)
startConf.TempDataDirBase = os.TempDir() 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 != "" { if options.ExecutablePath != "" {
startConf.ExePath = options.ExecutablePath startConf.ExePath = options.ExecutablePath
startConf.ExtraArgs = options.ExtraArgs
startConf.ProcessCreator = nil startConf.ProcessCreator = nil
startConf.UseEmbeddedControlConn = false startConf.UseEmbeddedControlConn = false
} }