Skip to content

Commit

Permalink
fix(ivpn): split city into city and region
Browse files Browse the repository at this point in the history
- Fix bad city values containing a comma
- update ivpn servers data
  • Loading branch information
qdm12 committed Aug 19, 2024
1 parent 4203f4f commit eaece0c
Show file tree
Hide file tree
Showing 2 changed files with 284 additions and 201 deletions.
13 changes: 12 additions & 1 deletion internal/provider/ivpn/updater/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"sort"
"strings"

"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/qdm12/gluetun/internal/models"
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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:]
}
Loading

0 comments on commit eaece0c

Please sign in to comment.