updater: refactoring and set DNS server correctly

- Fix CLI operation not setting DNS server
- Fix periodic operation not setting DNS server
- Set DNS address for resolution once at start for both CLI and periodic operation
- Inject resolver to each provider instead of creating it within
- Use resolver settings on every call to `.Resolve` method, instead of passing it to constructor
- Move out minServers check from resolver
This commit is contained in:
Quentin McGaw
2022-06-11 17:41:57 +00:00
parent 1bd355ab96
commit 447a7c9891
70 changed files with 366 additions and 229 deletions

View File

@@ -6,13 +6,14 @@ import (
"github.com/qdm12/gluetun/internal/updater/resolver"
)
func newParallelResolver() *resolver.Parallel {
func parallelResolverSettings(hosts []string) (settings resolver.ParallelSettings) {
const (
maxFailRatio = 0.1
maxNoNew = 1
maxFails = 2
)
settings := resolver.ParallelSettings{
return resolver.ParallelSettings{
Hosts: hosts,
MaxFailRatio: maxFailRatio,
Repeat: resolver.RepeatSettings{
MaxDuration: time.Second,
@@ -21,5 +22,4 @@ func newParallelResolver() *resolver.Parallel {
SortIPs: true,
},
}
return resolver.NewParallelResolver(settings)
}