1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 18:00:43 +00:00

add custom jsonpb unmarshaler for multi-observatory

This commit is contained in:
Shelikhoo 2021-09-07 13:16:47 +01:00
parent df03970c22
commit 68c8759f4b
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316

View File

@ -2,6 +2,7 @@ package multiObservatory
import (
"context"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/common/taggedfeatures"
@ -31,6 +32,12 @@ func New(ctx context.Context, config *Config) (*Observer, error) {
return &Observer{config: config, ctx: ctx, TaggedFeatures: holder}, nil
}
func (x *Config) UnmarshalJSONPB(unmarshaler *jsonpb.Unmarshaler, bytes []byte) error {
var err error
x.Holders, err = taggedfeatures.LoadJsonConfig(context.TODO(), "service", "background", bytes)
return err
}
func init() {
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
return New(ctx, config.(*Config))