Files
gluetun/internal/provider/cyberghost/updater/resolve.go
Quentin McGaw 0549326dfb chore(updater): tiny code changes
- Remove unneeded ctx error check in cyberghost updating code
- Move global scope caser to function local scope
- Return error if updating a single provider in `UpdateServers`
- Add comments on different error paths in `UpdateServers`
2022-06-04 13:50:29 +00:00

39 lines
847 B
Go

package cyberghost
import (
"context"
"net"
"time"
"github.com/qdm12/gluetun/internal/updater/resolver"
)
func resolveHosts(ctx context.Context, presolver resolver.Parallel,
possibleHosts []string, minServers int) (
hostToIPs map[string][]net.IP, err error) {
const (
maxFailRatio = 1
maxDuration = 20 * time.Second
betweenDuration = time.Second
maxNoNew = 4
maxFails = 10
)
settings := resolver.ParallelSettings{
MaxFailRatio: maxFailRatio,
MinFound: minServers,
Repeat: resolver.RepeatSettings{
MaxDuration: maxDuration,
BetweenDuration: betweenDuration,
MaxNoNew: maxNoNew,
MaxFails: maxFails,
SortIPs: true,
},
}
hostToIPs, _, err = presolver.Resolve(ctx, possibleHosts, settings)
if err != nil {
return nil, err
}
return hostToIPs, nil
}