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:
parent
df03970c22
commit
68c8759f4b
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue
Block a user