mirror of
https://github.com/safing/portmaster
synced 2025-09-05 03:59:11 +00:00
Enable Windows dnscache again
This commit is contained in:
parent
01e7160bfe
commit
bc341b60c0
1 changed files with 13 additions and 29 deletions
|
@ -33,7 +33,7 @@ func start(ch chan packet.Packet) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
go windowskext.Handler(ch)
|
go windowskext.Handler(ch)
|
||||||
go handleWindowsDNSCache()
|
go checkWindowsDNSCache()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -43,37 +43,21 @@ func stop() error {
|
||||||
return windowskext.Stop()
|
return windowskext.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleWindowsDNSCache() {
|
func checkWindowsDNSCache() {
|
||||||
|
status, err := osdetail.GetServiceStatus("dnscache")
|
||||||
err := osdetail.StopService("dnscache")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// cannot stop dnscache, try disabling
|
log.Warningf("firewall/interception: failed to check status of Windows DNS-Client: %s", err)
|
||||||
if err == osdetail.ErrServiceNotStoppable {
|
|
||||||
err := osdetail.DisableDNSCache()
|
|
||||||
if err != nil {
|
|
||||||
log.Warningf("firewall/interception: failed to disable Windows Service \"DNS Client\" (dnscache) for better interception: %s", err)
|
|
||||||
notifyDisableDNSCache()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if status == osdetail.StatusStopped {
|
||||||
|
err := osdetail.EnableDNSCache()
|
||||||
|
if err != nil {
|
||||||
|
log.Warningf("firewall/interception: failed to enable Windows Service \"DNS Client\" (dnscache): %s", err)
|
||||||
|
} else {
|
||||||
|
log.Warningf("firewall/interception: successfully enabled the dnscache")
|
||||||
notifyRebootRequired()
|
notifyRebootRequired()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// error while stopping service
|
|
||||||
log.Warningf("firewall/interception: failed to stop Windows Service \"DNS Client\" (dnscache) for better interception: %s", err)
|
|
||||||
notifyDisableDNSCache()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// log that service is stopped
|
|
||||||
log.Info("firewall/interception: Windows Service \"DNS Client\" (dnscache) is stopped for better interception")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func notifyDisableDNSCache() {
|
|
||||||
(¬ifications.Notification{
|
|
||||||
EventID: "interception:windows-disable-dns-cache",
|
|
||||||
Message: "The Portmaster needs the Windows Service \"DNS Client\" (dnscache) to be disabled for best effectiveness.",
|
|
||||||
Type: notifications.Warning,
|
|
||||||
}).Save()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func notifyRebootRequired() {
|
func notifyRebootRequired() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue