common.go 581 B

12345678910111213141516
  1. package v5cfg
  2. import (
  3. "context"
  4. "encoding/json"
  5. "github.com/golang/protobuf/proto"
  6. "github.com/v2fly/v2ray-core/v4/common/environment/envctx"
  7. "github.com/v2fly/v2ray-core/v4/common/environment/envimpl"
  8. "github.com/v2fly/v2ray-core/v4/common/registry"
  9. )
  10. func loadHeterogeneousConfigFromRawJson(interfaceType, name string, rawJson json.RawMessage) (proto.Message, error) {
  11. fsdef := envimpl.NewDefaultFileSystemDefaultImpl()
  12. ctx := envctx.ContextWithEnvironment(context.TODO(), fsdef)
  13. return registry.LoadImplementationByAlias(ctx, interfaceType, name, []byte(rawJson))
  14. }