Minor fixes

This commit is contained in:
世界
2022-07-10 14:22:28 +08:00
parent 29f78248dc
commit 7f84191748
12 changed files with 69 additions and 39 deletions

View File

@@ -144,11 +144,11 @@ type ShadowsocksDestination struct {
}
type TunInboundOptions struct {
InterfaceName string `json:"interface_name,omitempty"`
MTU uint32 `json:"mtu,omitempty,omitempty"`
Inet4Address ListenPrefix `json:"inet4_address,omitempty"`
Inet6Address ListenPrefix `json:"inet6_address,omitempty"`
AutoRoute bool `json:"auto_route,omitempty"`
HijackDNS bool `json:"hijack_dns,omitempty"`
InterfaceName string `json:"interface_name,omitempty"`
MTU uint32 `json:"mtu,omitempty,omitempty"`
Inet4Address *ListenPrefix `json:"inet4_address,omitempty"`
Inet6Address *ListenPrefix `json:"inet6_address,omitempty"`
AutoRoute bool `json:"auto_route,omitempty"`
HijackDNS bool `json:"hijack_dns,omitempty"`
InboundOptions
}

View File

@@ -161,7 +161,7 @@ type ListenPrefix netip.Prefix
func (p ListenPrefix) MarshalJSON() ([]byte, error) {
prefix := netip.Prefix(p)
if !prefix.IsValid() {
return json.Marshal("")
return json.Marshal(nil)
}
return json.Marshal(prefix.String())
}
@@ -179,3 +179,10 @@ func (p *ListenPrefix) UnmarshalJSON(bytes []byte) error {
*p = ListenPrefix(prefix)
return nil
}
func (p *ListenPrefix) Build() netip.Prefix {
if p == nil {
return netip.Prefix{}
}
return netip.Prefix(*p)
}