Inbound rule support

This commit is contained in:
世界
2022-07-02 14:07:50 +08:00
parent 9f4c0ff624
commit 7c57eb70e8
34 changed files with 622 additions and 247 deletions

27
option/address.go Normal file
View File

@@ -0,0 +1,27 @@
package option
import (
"encoding/json"
"net/netip"
)
type ListenAddress netip.Addr
func (a *ListenAddress) MarshalJSON() ([]byte, error) {
value := netip.Addr(*a).String()
return json.Marshal(value)
}
func (a *ListenAddress) UnmarshalJSON(bytes []byte) error {
var value string
err := json.Unmarshal(bytes, &value)
if err != nil {
return err
}
addr, err := netip.ParseAddr(value)
if err != nil {
return err
}
*a = ListenAddress(addr)
return nil
}