feat: support independent tcp4, tcp6, udp4, udp6 connectivity check

This commit is contained in:
mzz2017
2023-02-08 20:15:24 +08:00
committed by mzz
parent 551e79d9e5
commit 5e7b68822a
26 changed files with 738 additions and 222 deletions

View File

@ -5,6 +5,8 @@
package consts
import "net/netip"
type DialerSelectionPolicy string
const (
@ -13,3 +15,32 @@ const (
DialerSelectionPolicy_MinAverage10Latencies DialerSelectionPolicy = "min_avg10"
DialerSelectionPolicy_MinLastLatency DialerSelectionPolicy = "min"
)
const (
UdpCheckLookupHost = "connectivitycheck.gstatic.com."
)
type L4ProtoStr string
const (
L4ProtoStr_TCP L4ProtoStr = "tcp"
L4ProtoStr_UDP L4ProtoStr = "udp"
)
type IpVersionStr string
const (
IpVersionStr_4 IpVersionStr = "4"
IpVersionStr_6 IpVersionStr = "6"
)
func IpVersionFromAddr(addr netip.Addr) IpVersionStr {
var ipversion IpVersionStr
switch {
case addr.Is4() || addr.Is4In6():
ipversion = IpVersionStr_4
case addr.Is6():
ipversion = IpVersionStr_6
}
return ipversion
}