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
+16 -10
View File
@@ -34,10 +34,9 @@ func findPrivadoServersFromZip(ctx context.Context, client network.Client, looku
if err != nil {
return nil, nil, err
}
hosts := make([]string, 0, len(contents))
for fileName, content := range contents {
if err := ctx.Err(); err != nil {
return nil, warnings, err
}
hostname, warning, err := extractHostFromOVPN(content)
if len(warning) > 0 {
warnings = append(warnings, warning)
@@ -45,16 +44,23 @@ func findPrivadoServersFromZip(ctx context.Context, client network.Client, looku
if err != nil {
return nil, warnings, fmt.Errorf("%w in %q", err, fileName)
}
const repetition = 1
IPs, err := resolveRepeat(ctx, lookupIP, hostname, repetition)
switch {
case err != nil:
return nil, warnings, err
case len(IPs) == 0:
hosts = append(hosts, hostname)
}
const repetition = 1
const timeBetween = 1
const failOnErr = false
hostToIPs, newWarnings, _ := parallelResolve(ctx, lookupIP, hosts, repetition, timeBetween, failOnErr)
warnings = append(warnings, newWarnings...)
for hostname, IPs := range hostToIPs {
switch len(IPs) {
case 0:
warning := fmt.Sprintf("no IP address found for host %q", hostname)
warnings = append(warnings, warning)
continue
case len(IPs) > 1:
case 1:
default:
warning := fmt.Sprintf("more than one IP address found for host %q", hostname)
warnings = append(warnings, warning)
}