Fix: wintun dns address
This commit is contained in:
parent
f3304cf245
commit
e07c3a7fe0
1 changed files with 8 additions and 7 deletions
|
@ -39,9 +39,11 @@ startOver:
|
||||||
tryTimes++
|
tryTimes++
|
||||||
|
|
||||||
var (
|
var (
|
||||||
luid = winipcfg.LUID(dev.(*tun.TUN).LUID())
|
luid = winipcfg.LUID(dev.(*tun.TUN).LUID())
|
||||||
ip = addr.Masked().Addr().Next()
|
ip = addr.Masked().Addr().Next()
|
||||||
addresses = []netip.Prefix{netip.PrefixFrom(ip, addr.Bits())}
|
gw = ip.Next()
|
||||||
|
addresses = []netip.Prefix{netip.PrefixFrom(ip, addr.Bits())}
|
||||||
|
dnsAddress = []netip.Addr{gw}
|
||||||
|
|
||||||
family4 = winipcfg.AddressFamily(windows.AF_INET)
|
family4 = winipcfg.AddressFamily(windows.AF_INET)
|
||||||
familyV6 = winipcfg.AddressFamily(windows.AF_INET6)
|
familyV6 = winipcfg.AddressFamily(windows.AF_INET6)
|
||||||
|
@ -123,7 +125,7 @@ startOver:
|
||||||
// add gateway
|
// add gateway
|
||||||
deduplicatedRoutes = append(deduplicatedRoutes, &winipcfg.RouteData{
|
deduplicatedRoutes = append(deduplicatedRoutes, &winipcfg.RouteData{
|
||||||
Destination: addr.Masked(),
|
Destination: addr.Masked(),
|
||||||
NextHop: addr.Masked().Addr().Next().Next(),
|
NextHop: gw,
|
||||||
Metric: 0,
|
Metric: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -193,12 +195,11 @@ startOver:
|
||||||
return fmt.Errorf("unable to set v6 metric and MTU: %w", err)
|
return fmt.Errorf("unable to set v6 metric and MTU: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dnsAdds := []netip.Addr{netip.MustParseAddr("198.18.0.2")}
|
err = luid.SetDNS(family4, dnsAddress, nil)
|
||||||
err = luid.SetDNS(family4, dnsAdds, nil)
|
|
||||||
if err == windows.ERROR_NOT_FOUND && retryOnFailure {
|
if err == windows.ERROR_NOT_FOUND && retryOnFailure {
|
||||||
goto startOver
|
goto startOver
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return fmt.Errorf("unable to set DNS %s %s: %w", "198.18.0.2", "nil", err)
|
return fmt.Errorf("unable to set DNS %s %s: %w", dnsAddress[0].String(), "nil", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
wintunInterfaceName = dev.Name()
|
wintunInterfaceName = dev.Name()
|
||||||
|
|
Loading…
Reference in a new issue