1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-21 15:05:23 +00:00

provide environment context on loading

This commit is contained in:
Shelikhoo 2021-09-05 15:37:26 +01:00
parent 141cd30ee3
commit 8982a38eb4
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316

View File

@ -1,11 +1,16 @@
package v5cfg
import (
"context"
"encoding/json"
"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"
)
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))
}