feat: dns routing (#26)

This commit is contained in:
mzz
2023-02-25 02:38:21 +08:00
committed by GitHub
parent 33ad434f8a
commit 8bd6a77398
48 changed files with 2758 additions and 1449 deletions

View File

@ -41,6 +41,16 @@ func (l L4ProtoStr) ToL4Proto() uint8 {
panic("unsupported l4proto")
}
func (l L4ProtoStr) ToL4ProtoType() L4ProtoType {
switch l {
case L4ProtoStr_TCP:
return L4ProtoType_TCP
case L4ProtoStr_UDP:
return L4ProtoType_UDP
}
panic("unsupported l4proto: " + l)
}
type IpVersionStr string
const (
@ -58,6 +68,16 @@ func (v IpVersionStr) ToIpVersion() uint8 {
panic("unsupported ipversion")
}
func (v IpVersionStr) ToIpVersionType() IpVersionType {
switch v {
case IpVersionStr_4:
return IpVersion_4
case IpVersionStr_6:
return IpVersion_6
}
panic("unsupported ipversion")
}
func IpVersionFromAddr(addr netip.Addr) IpVersionStr {
var ipversion IpVersionStr
switch {