Browse Source

add custom jsonpb unmarshaler for multi-observatory

Shelikhoo 4 years ago
parent
commit
68c8759f4b
1 changed files with 7 additions and 0 deletions
  1. 7 0
      app/observatory/multiObservatory/muti.go

+ 7 - 0
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))