diff --git a/resolver/config.go b/resolver/config.go index e64efdc7..18669d5a 100644 --- a/resolver/config.go +++ b/resolver/config.go @@ -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¶meter=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¶meter=value" config.DisplayOrderAnnotation: cfgOptionUseStaleCacheOrder, config.CategoryAnnotation: "Resolving", }, - }) + } + err = config.Register(useStaleCacheConfigOption) if err != nil { return err } diff --git a/resolver/metrics.go b/resolver/metrics.go index 8d531107..f118d075 100644 --- a/resolver/metrics.go +++ b/resolver/metrics.go @@ -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)