Feature: updater changes to have more VPN IP addresses (#364)

This commit is contained in:
Quentin McGaw
2021-02-11 08:40:25 -05:00
committed by GitHub
parent f852b7789e
commit f08a03106f
7 changed files with 173 additions and 89 deletions

View File

@@ -38,11 +38,9 @@ func findPurevpnServers(ctx context.Context, client network.Client, lookupIP loo
if err != nil {
return nil, nil, err
}
uniqueServers := map[string]models.PurevpnServer{}
hosts := make([]string, 0, len(contents))
for fileName, content := range contents {
if err := ctx.Err(); err != nil {
return nil, warnings, err
}
if strings.HasSuffix(fileName, "-tcp.ovpn") {
continue // only parse UDP files
}
@@ -53,12 +51,20 @@ func findPurevpnServers(ctx context.Context, client network.Client, lookupIP loo
if err != nil {
return nil, warnings, fmt.Errorf("%w in %q", err, fileName)
}
const repetition = 5
IPs, err := resolveRepeat(ctx, lookupIP, host, repetition)
switch {
case err != nil:
return nil, warnings, err
case len(IPs) == 0:
hosts = append(hosts, host)
}
const repetition = 20
const timeBetween = time.Second
const failOnErr = true
hostToIPs, _, err := parallelResolve(ctx, lookupIP, hosts, repetition, timeBetween, failOnErr)
if err != nil {
return nil, warnings, err
}
uniqueServers := make(map[string]models.PurevpnServer, len(hostToIPs))
for host, IPs := range hostToIPs {
if len(IPs) == 0 {
warning := fmt.Sprintf("no IP address found for host %q", host)
warnings = append(warnings, warning)
continue