mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-21 12:28:39 +00:00
wgengine/router: tighten isMissingIPv6Err
So it doesn't false positive if misused. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
8f5b52e571
commit
7e9d1f7808
@ -11,6 +11,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -366,13 +367,18 @@ func configureInterface(cfg *Config, tun *tun.NativeTun) error {
|
|||||||
|
|
||||||
// isMissingIPv6Err reports whether err is due to IPv6 not being enabled on the machine.
|
// isMissingIPv6Err reports whether err is due to IPv6 not being enabled on the machine.
|
||||||
//
|
//
|
||||||
// It's intended for use on errors returned by the winipcfg.Interface.GetIpInterface
|
// It only currently supports the errors returned by winipcfg.Interface.GetIpInterface.
|
||||||
// method, which ultimately calls:
|
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-getipinterfaceentry
|
|
||||||
func isMissingIPv6Err(err error) bool {
|
func isMissingIPv6Err(err error) bool {
|
||||||
|
if se, ok := err.(*os.SyscallError); ok {
|
||||||
|
switch se.Syscall {
|
||||||
|
case "iphlpapi.GetIpInterfaceEntry":
|
||||||
// ERROR_NOT_FOUND from means the address family (IPv6) is not found.
|
// ERROR_NOT_FOUND from means the address family (IPv6) is not found.
|
||||||
// (ERROR_FILE_NOT_FOUND means that the interface doesn't exist.)
|
// (ERROR_FILE_NOT_FOUND means that the interface doesn't exist.)
|
||||||
return errors.Is(err, windows.ERROR_NOT_FOUND)
|
// https://docs.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-getipinterfaceentry
|
||||||
|
return se.Err == windows.ERROR_NOT_FOUND
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// routeLess reports whether ri should sort before rj.
|
// routeLess reports whether ri should sort before rj.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user