- 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
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
// Package updater contains code to obtain the server information
|
|
// for the VPNUnlimited provider.
|
|
package updater
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"sort"
|
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
|
"github.com/qdm12/gluetun/internal/provider/common"
|
|
)
|
|
|
|
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
|
servers []models.Server, err error) {
|
|
// Hardcoded data from a user provided ZIP file since it's behind a login wall
|
|
hts, warnings := getHostToServer()
|
|
for _, warning := range warnings {
|
|
u.warner.Warn(warning)
|
|
}
|
|
|
|
hosts := hts.toHostsSlice()
|
|
resolveSettings := parallelResolverSettings(hosts)
|
|
hostToIPs, warnings, err := u.presolver.Resolve(ctx, resolveSettings)
|
|
for _, warning := range warnings {
|
|
u.warner.Warn(warning)
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if len(hostToIPs) < minServers {
|
|
return nil, fmt.Errorf("%w: %d and expected at least %d",
|
|
common.ErrNotEnoughServers, len(servers), minServers)
|
|
}
|
|
|
|
hts.adaptWithIPs(hostToIPs)
|
|
|
|
servers = hts.toServersSlice()
|
|
|
|
sort.Sort(models.SortableServers(servers))
|
|
|
|
return servers, nil
|
|
}
|