|
|
@ -126,19 +126,24 @@ func isDefaultGateway(rm *route.RouteMessage) bool {
|
|
|
|
|
|
|
|
|
|
|
|
dst := rm.Addrs[unix.RTAX_DST]
|
|
|
|
dst := rm.Addrs[unix.RTAX_DST]
|
|
|
|
netmask := rm.Addrs[unix.RTAX_NETMASK]
|
|
|
|
netmask := rm.Addrs[unix.RTAX_NETMASK]
|
|
|
|
|
|
|
|
if dst == nil || netmask == nil {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if dst.Family() == syscall.AF_INET &&
|
|
|
|
if dst.Family() == syscall.AF_INET && netmask.Family() == syscall.AF_INET {
|
|
|
|
netmask.Family() == syscall.AF_INET &&
|
|
|
|
dstAddr, dstOk := dst.(*route.Inet4Addr)
|
|
|
|
dst.(*route.Inet4Addr).IP == v4default &&
|
|
|
|
nmAddr, nmOk := netmask.(*route.Inet4Addr)
|
|
|
|
netmask.(*route.Inet4Addr).IP == v4default {
|
|
|
|
if dstOk && nmOk && dstAddr.IP == v4default && nmAddr.IP == v4default {
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if dst.Family() == syscall.AF_INET6 &&
|
|
|
|
if dst.Family() == syscall.AF_INET6 && netmask.Family() == syscall.AF_INET6 {
|
|
|
|
netmask.Family() == syscall.AF_INET6 &&
|
|
|
|
dstAddr, dstOk := dst.(*route.Inet6Addr)
|
|
|
|
dst.(*route.Inet6Addr).IP == v6default &&
|
|
|
|
nmAddr, nmOk := netmask.(*route.Inet6Addr)
|
|
|
|
netmask.(*route.Inet6Addr).IP == v6default {
|
|
|
|
if dstOk && nmOk && dstAddr.IP == v6default && nmAddr.IP == v6default {
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|