From 68c8759f4b1171a2a921205e481e58ede9a1b9b6 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Tue, 7 Sep 2021 13:16:47 +0100 Subject: [PATCH] add custom jsonpb unmarshaler for multi-observatory --- app/observatory/multiObservatory/muti.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/observatory/multiObservatory/muti.go b/app/observatory/multiObservatory/muti.go index 9131dd613..c8baa6d20 100644 --- a/app/observatory/multiObservatory/muti.go +++ b/app/observatory/multiObservatory/muti.go @@ -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))