feat(protonvpn): determine free status with tier value

This commit is contained in:
Quentin McGaw
2024-07-29 09:01:47 +00:00
parent 264480b659
commit 4c47b6f142
3 changed files with 735 additions and 33 deletions

View File

@@ -31,6 +31,7 @@ type physicalServer struct {
ExitIP netip.Addr `json:"ExitIP"` ExitIP netip.Addr `json:"ExitIP"`
Domain string `json:"Domain"` Domain string `json:"Domain"`
Status uint8 `json:"Status"` Status uint8 `json:"Status"`
Tier *uint8 `json:"Tier,omitempty"`
} }
func fetchAPI(ctx context.Context, client *http.Client) ( func fetchAPI(ctx context.Context, client *http.Client) (

View File

@@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"sort" "sort"
"strings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
@@ -58,9 +57,12 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
hostname := physicalServer.Domain hostname := physicalServer.Domain
entryIP := physicalServer.EntryIP entryIP := physicalServer.EntryIP
lowerCaseName := strings.ToLower(name) //nolint:lll
var free bool // See https://github.com/ProtonVPN/protonvpn-nm-lib/blob/31d5f99fbc89274e4e977a11e7432c0eab5a3ef8/protonvpn_nm_lib/enums.py#L56-L62
if strings.Contains(hostname, "free") || strings.Contains(lowerCaseName, "free") { free := false
if physicalServer.Tier == nil {
u.warner.Warn("tier field not set for server " + hostname)
} else if *physicalServer.Tier == 0 {
free = true free = true
} }

File diff suppressed because it is too large Load Diff