fix(ivpn): split city into city and region

- Fix bad city values containing a comma
- update ivpn servers data
This commit is contained in:
Quentin McGaw
2024-08-19 03:10:53 +00:00
parent d166314f8b
commit c450c54d67
2 changed files with 538 additions and 455 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"sort"
"strings"
"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/qdm12/gluetun/internal/models"
@@ -58,9 +59,11 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
servers = make([]models.Server, 0, len(hostToIPs))
for _, serverData := range data.Servers {
city, region := parseCity(serverData.City)
server := models.Server{
Country: serverData.Country,
City: serverData.City,
City: city,
Region: region,
ISP: serverData.ISP,
}
@@ -96,3 +99,11 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
return servers, nil
}
func parseCity(city string) (parsedCity, region string) {
commaIndex := strings.Index(city, ", ")
if commaIndex == -1 {
return city, ""
}
return city[:commaIndex], city[commaIndex+2:]
}

File diff suppressed because it is too large Load Diff