mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-02 03:17:37 +03:00
badoption: Finish netip options
This commit is contained in:
parent
3f30aaf25e
commit
478265cd45
1 changed files with 14 additions and 0 deletions
|
@ -35,6 +35,13 @@ func (a *Addr) UnmarshalJSON(content []byte) error {
|
|||
|
||||
type Prefix netip.Prefix
|
||||
|
||||
func (p *Prefix) Build(defaultPrefix netip.Prefix) netip.Prefix {
|
||||
if p == nil {
|
||||
return defaultPrefix
|
||||
}
|
||||
return netip.Prefix(*p)
|
||||
}
|
||||
|
||||
func (p *Prefix) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(netip.Prefix(*p).String())
|
||||
}
|
||||
|
@ -55,6 +62,13 @@ func (p *Prefix) UnmarshalJSON(content []byte) error {
|
|||
|
||||
type Prefixable netip.Prefix
|
||||
|
||||
func (p *Prefixable) Build(defaultPrefix netip.Prefix) netip.Prefix {
|
||||
if p == nil {
|
||||
return defaultPrefix
|
||||
}
|
||||
return netip.Prefix(*p)
|
||||
}
|
||||
|
||||
func (p *Prefixable) MarshalJSON() ([]byte, error) {
|
||||
prefix := netip.Prefix(*p)
|
||||
if prefix.Bits() == prefix.Addr().BitLen() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue