From ae46fb7b28e78cd9dfb6ac5274d60f8ba35a432b Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sat, 4 Sep 2021 21:46:10 +0100 Subject: [PATCH] added build context to V5 conf --- infra/conf/v5cfg/root.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/infra/conf/v5cfg/root.go b/infra/conf/v5cfg/root.go index 50028686a..f3ab4b516 100644 --- a/infra/conf/v5cfg/root.go +++ b/infra/conf/v5cfg/root.go @@ -7,7 +7,10 @@ import ( core "github.com/v2fly/v2ray-core/v4" "github.com/v2fly/v2ray-core/v4/app/dispatcher" "github.com/v2fly/v2ray-core/v4/app/proxyman" + "github.com/v2fly/v2ray-core/v4/common/platform" "github.com/v2fly/v2ray-core/v4/common/serial" + "github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon" + "github.com/v2fly/v2ray-core/v4/infra/conf/geodata" "github.com/v2fly/v2ray-core/v4/infra/conf/synthetic/log" "google.golang.org/protobuf/types/known/anypb" ) @@ -81,7 +84,19 @@ func loadJsonConfig(data []byte) (*core.Config, error) { return nil, newError("unable to load json").Base(err) } - message, err := rootConfig.BuildV5(context.TODO()) + buildctx := cfgcommon.NewConfigureLoadingContext(context.Background()) + + geoloadername := platform.NewEnvFlag("v2ray.conf.geoloader").GetValue(func() string { + return "standard" + }) + + if loader, err := geodata.GetGeoDataLoader(geoloadername); err == nil { + cfgcommon.SetGeoDataLoader(buildctx, loader) + } else { + return nil, newError("unable to create geo data loader ").Base(err) + } + + message, err := rootConfig.BuildV5(buildctx) if err != nil { return nil, newError("unable to build config").Base(err) }