Browse Source

provide environment context on loading

Shelikhoo 4 years ago
parent
commit
8982a38eb4
1 changed files with 6 additions and 1 deletions
  1. 6 1
      infra/conf/v5cfg/common.go

+ 6 - 1
infra/conf/v5cfg/common.go

@@ -1,11 +1,16 @@
 package v5cfg
 package v5cfg
 
 
 import (
 import (
+	"context"
 	"encoding/json"
 	"encoding/json"
 	"github.com/golang/protobuf/proto"
 	"github.com/golang/protobuf/proto"
+	"github.com/v2fly/v2ray-core/v4/common/environment/envctx"
+	"github.com/v2fly/v2ray-core/v4/common/environment/envimpl"
 	"github.com/v2fly/v2ray-core/v4/common/registry"
 	"github.com/v2fly/v2ray-core/v4/common/registry"
 )
 )
 
 
 func loadHeterogeneousConfigFromRawJson(interfaceType, name string, rawJson json.RawMessage) (proto.Message, error) {
 func loadHeterogeneousConfigFromRawJson(interfaceType, name string, rawJson json.RawMessage) (proto.Message, error) {
-	return registry.LoadImplementationByAlias(interfaceType, name, []byte(rawJson))
+	fsdef := envimpl.NewDefaultFileSystemDefaultImpl()
+	ctx := envctx.ContextWithEnvironment(context.TODO(), fsdef)
+	return registry.LoadImplementationByAlias(ctx, interfaceType, name, []byte(rawJson))
 }
 }