mirror of
https://github.com/p4gefau1t/trojan-go.git
synced 2024-04-21 12:21:34 +00:00
Fix: read geoip and geosite in config file (#359)
Co-authored-by: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
This commit is contained in:
co-authored by
loyalsoldier
parent
068d23371c
commit
07fec5eb26
+9
-2
@@ -34,9 +34,16 @@ func GetProgramDir() string {
|
||||
}
|
||||
|
||||
func GetAssetLocation(file string) string {
|
||||
if filepath.IsAbs(file) {
|
||||
return file
|
||||
}
|
||||
if loc := os.Getenv("TROJAN_GO_LOCATION_ASSET"); loc != "" {
|
||||
log.Debugf("env set: TROJAN_GO_LOCATION_ASSET=%s", loc)
|
||||
return filepath.Join(loc, file)
|
||||
absPath, err := filepath.Abs(loc)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Debugf("env set: TROJAN_GO_LOCATION_ASSET=%s", absPath)
|
||||
return filepath.Join(absPath, file)
|
||||
}
|
||||
return filepath.Join(GetProgramDir(), file)
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ func NewClient(ctx context.Context, underlay tunnel.Client) (*Client, error) {
|
||||
ipCode := loadCode(cfg, "geoip:")
|
||||
for _, c := range ipCode {
|
||||
code := c.code
|
||||
cidrs, err := geodataLoader.LoadGeoIP(code)
|
||||
cidrs, err := geodataLoader.LoadIP(cfg.Router.GeoIPFilename, code)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
} else {
|
||||
@@ -341,7 +341,7 @@ func NewClient(ctx context.Context, underlay tunnel.Client) (*Client, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
domainList, err := geodataLoader.LoadGeoSite(code)
|
||||
domainList, err := geodataLoader.LoadSite(cfg.Router.GeoSiteFilename, code)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user