1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-31 16:27:41 -04:00
v2fly/infra/conf/v5cfg/common.go

27 lines
900 B
Go
Raw Normal View History

package v5cfg
import (
2021-09-05 10:37:26 -04:00
"context"
"encoding/json"
2021-10-28 06:34:19 -04:00
"github.com/golang/protobuf/proto"
2021-10-28 06:34:19 -04:00
"github.com/v2fly/v2ray-core/v5/common/environment/envctx"
"github.com/v2fly/v2ray-core/v5/common/environment/envimpl"
"github.com/v2fly/v2ray-core/v5/common/registry"
)
func loadHeterogeneousConfigFromRawJSON(interfaceType, name string, rawJSON json.RawMessage) (proto.Message, error) {
2021-09-05 10:37:26 -04:00
fsdef := envimpl.NewDefaultFileSystemDefaultImpl()
ctx := envctx.ContextWithEnvironment(context.TODO(), fsdef)
2022-06-28 08:26:01 -04:00
if len(rawJSON) == 0 {
rawJSON = []byte("{}")
2021-09-07 07:29:40 -04:00
}
return registry.LoadImplementationByAlias(ctx, interfaceType, name, []byte(rawJSON))
}
// LoadHeterogeneousConfigFromRawJSON private API
func LoadHeterogeneousConfigFromRawJSON(ctx context.Context, interfaceType, name string, rawJSON json.RawMessage) (proto.Message, error) {
return loadHeterogeneousConfigFromRawJSON(interfaceType, name, rawJSON)
}