Feature: log out country, region and city of IP

This commit is contained in:
Quentin McGaw
2021-02-08 00:01:14 +00:00
parent 3e527fee8b
commit 3deb65b529
6 changed files with 80 additions and 47 deletions

View File

@@ -3,10 +3,13 @@ package updater
import (
"context"
"fmt"
"net/http"
"sort"
"strings"
"time"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/publicip"
"github.com/qdm12/golibs/network"
)
@@ -60,7 +63,11 @@ func findPurevpnServers(ctx context.Context, client network.Client, lookupIP loo
warnings = append(warnings, warning)
continue
}
country, region, city, err := getIPInfo(ctx, client, IPs[0])
// TODO remove once we move away from network.Client
const httpTimeout = 3 * time.Second
httpClient := &http.Client{Timeout: httpTimeout}
country, region, city, err := publicip.Info(ctx, httpClient, IPs[0])
if err != nil {
return nil, warnings, err
}