mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/golang/protobuf/jsonpb"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -209,3 +211,12 @@ func NewIPOrDomain(addr Address) *IPOrDomain {
|
|||||||
panic("Unknown Address type.")
|
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