Browse Source

added build context to V5 conf

Shelikhoo 4 years ago
parent
commit
ae46fb7b28
1 changed files with 16 additions and 1 deletions
  1. 16 1
      infra/conf/v5cfg/root.go

+ 16 - 1
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)
 	}