Add tun inbound for linux

This commit is contained in:
世界 committed 2022-07-09 22:44:18 +08:00
1 parent c463d0cf80
commit 730144cc26
19 files changed
+623 -22

No files matched your search

+24
View File
@@ -155,3 +155,27 @@ func (d *Duration) UnmarshalJSON(bytes []byte) error {
*d = Duration(duration)
return nil
}
type ListenPrefix netip.Prefix
func (p ListenPrefix) MarshalJSON() ([]byte, error) {
prefix := netip.Prefix(p)
if !prefix.IsValid() {
return json.Marshal("")
}
return json.Marshal(prefix.String())
}
func (p *ListenPrefix) UnmarshalJSON(bytes []byte) error {
var value string
err := json.Unmarshal(bytes, &value)
if err != nil {
return err
}
prefix, err := netip.ParsePrefix(value)
if err != nil {
return err
}
*p = ListenPrefix(prefix)
return nil
}