1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 01:27:03 -05:00

added custom ip or domain unmarshal logic

This commit is contained in:
Shelikhoo 2021-09-04 20:30:39 +01:00
parent 4d3c57dd39
commit 1876fbd6cd
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316

View File

@ -2,6 +2,8 @@ package net
import (
"bytes"
"encoding/json"
"github.com/golang/protobuf/jsonpb"
"net"
"strings"
)
@ -209,3 +211,12 @@ func NewIPOrDomain(addr Address) *IPOrDomain {
panic("Unknown Address type.")
}
}
func (d *IPOrDomain) UnmarshalJSONPB(unmarshaler *jsonpb.Unmarshaler, bytes []byte) error {
var ipOrDomain string
if err := json.Unmarshal(bytes, &ipOrDomain); err != nil {
return err
}
d = NewIPOrDomain(ParseAddress(ipOrDomain))
return nil
}