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:
parent
4d3c57dd39
commit
1876fbd6cd
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user