mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-26 03:11:21 +08:00
flush dns cache on system dns change
This commit is contained in:
parent
b3962066da
commit
4d9421bcbc
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/gofrs/uuid/v5"
|
"github.com/gofrs/uuid/v5"
|
||||||
"github.com/sagernet/sing/common/control"
|
"github.com/sagernet/sing/common/control"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
"github.com/sagernet/sing/common/windnsapi"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
"log"
|
"log"
|
||||||
@ -160,6 +161,8 @@ func (d *DnsManager) restoreSystemDNS(ifx control.Interface) {
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("[restoreSystemDNS] failed to set dns servers:", err)
|
log.Println("[restoreSystemDNS] failed to set dns servers:", err)
|
||||||
|
} else {
|
||||||
|
_ = windnsapi.FlushResolverCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("[restoreSystemDNS] Local DNS Server removed for:", ifx.Name)
|
log.Println("[restoreSystemDNS] Local DNS Server removed for:", ifx.Name)
|
||||||
@ -202,6 +205,8 @@ func (d *DnsManager) setSystemDNS(ifx control.Interface) {
|
|||||||
|
|
||||||
if err = luid.SetDNS(winipcfg.AddressFamily(windows.AF_INET), newDnsServers, nil); err != nil {
|
if err = luid.SetDNS(winipcfg.AddressFamily(windows.AF_INET), newDnsServers, nil); err != nil {
|
||||||
log.Println("[setSystemDNS] failed to set dns servers:", err)
|
log.Println("[setSystemDNS] failed to set dns servers:", err)
|
||||||
|
} else {
|
||||||
|
_ = windnsapi.FlushResolverCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("[setSystemDNS] Local DNS Server added for:", ifx.Name)
|
log.Println("[setSystemDNS] Local DNS Server added for:", ifx.Name)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user