Do not suggest using stale DNS cache when disabled by user

This commit is contained in:
Daniel 2023-07-20 14:04:56 +02:00
parent 5fe78dbad5
commit fce1a7ac33
2 changed files with 5 additions and 3 deletions

View file

@ -63,6 +63,7 @@ var (
cfgOptionNoAssignedNameserversOrder = 1
CfgOptionUseStaleCacheKey = "dns/useStaleCache"
useStaleCacheConfigOption *config.Option
useStaleCache config.BoolOption
cfgOptionUseStaleCacheOrder = 2
@ -205,7 +206,7 @@ The format is: "protocol://ip:port?parameter=value&parameter=value"
}
noAssignedNameservers = status.SecurityLevelOption(CfgOptionNoAssignedNameserversKey)
err = config.Register(&config.Option{
useStaleCacheConfigOption = &config.Option{
Name: "Always Use DNS Cache",
Key: CfgOptionUseStaleCacheKey,
Description: "Always use the DNS cache, even if entries have expired. Expired entries are refreshed afterwards in the background. This can improve DNS resolving performance a lot, but may lead to occasional connection errors due to outdated DNS records.",
@ -217,7 +218,8 @@ The format is: "protocol://ip:port?parameter=value&parameter=value"
config.DisplayOrderAnnotation: cfgOptionUseStaleCacheOrder,
config.CategoryAnnotation: "Resolving",
},
})
}
err = config.Register(useStaleCacheConfigOption)
if err != nil {
return err
}

View file

@ -51,7 +51,7 @@ var suggestUsingStaleCacheNotification *notifications.Notification
func suggestUsingStaleCacheTask(ctx context.Context, t *modules.Task) error {
switch {
case useStaleCache():
case useStaleCache() || useStaleCacheConfigOption.IsSetByUser():
// If setting is already active, disable task repeating.
t.Repeat(0)