Feature: filter by country, region and city for Privado

This commit is contained in:
Quentin McGaw
2021-05-09 00:51:34 +00:00
parent a7a5cca8dd
commit 8407542600
10 changed files with 467 additions and 268 deletions

View File

@@ -6,6 +6,7 @@ import (
"context"
"errors"
"fmt"
"net/http"
"strings"
"github.com/qdm12/gluetun/internal/models"
@@ -17,7 +18,7 @@ import (
var ErrNotEnoughServers = errors.New("not enough servers found")
func GetServers(ctx context.Context, unzipper unzip.Unzipper,
presolver resolver.Parallel, minServers int) (
client *http.Client, presolver resolver.Parallel, minServers int) (
servers []models.PrivadoServer, warnings []string, err error) {
const url = "https://privado.io/apps/ovpn_configs.zip"
contents, err := unzipper.FetchAndExtract(ctx, url)
@@ -66,6 +67,10 @@ func GetServers(ctx context.Context, unzipper unzip.Unzipper,
servers = hts.toServersSlice()
if err := setLocationInfo(ctx, client, servers); err != nil {
return nil, warnings, err
}
sortServers(servers)
return servers, warnings, nil