Skip to content

Commit

Permalink
hotfix(protonvpn): fix free detection and update p2p->port_forward
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jul 31, 2024
1 parent 4c3da54 commit ceb6ff4
Show file tree
Hide file tree
Showing 3 changed files with 1,881 additions and 3,141 deletions.
2 changes: 1 addition & 1 deletion internal/provider/protonvpn/updater/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ type logicalServer struct {
City *string `json:"City"`
Servers []physicalServer `json:"Servers"`
Features uint16 `json:"Features"`
Tier *uint8 `json:"Tier,omitempty"`
}

type physicalServer struct {
EntryIP netip.Addr `json:"EntryIP"`
ExitIP netip.Addr `json:"ExitIP"`
Domain string `json:"Domain"`
Status uint8 `json:"Status"`
Tier *uint8 `json:"Tier,omitempty"`
}

func fetchAPI(ctx context.Context, client *http.Client) (
Expand Down
18 changes: 9 additions & 9 deletions internal/provider/protonvpn/updater/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
// ipv6: featuresBits&16 != 0, - unused.
}

//nolint:lll
// See https://github.com/ProtonVPN/protonvpn-nm-lib/blob/31d5f99fbc89274e4e977a11e7432c0eab5a3ef8/protonvpn_nm_lib/enums.py#L56-L62
free := false
if logicalServer.Tier == nil {
u.warner.Warn("tier field not set for server " + logicalServer.Name)
} else if *logicalServer.Tier == 0 {
free = true
}

for _, physicalServer := range logicalServer.Servers {
if physicalServer.Status == 0 { // disabled so skip server
u.warner.Warn("ignoring server " + physicalServer.Domain + " with status 0")
Expand All @@ -57,15 +66,6 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
hostname := physicalServer.Domain
entryIP := physicalServer.EntryIP

//nolint:lll
// See https://github.com/ProtonVPN/protonvpn-nm-lib/blob/31d5f99fbc89274e4e977a11e7432c0eab5a3ef8/protonvpn_nm_lib/enums.py#L56-L62
free := false
if physicalServer.Tier == nil {
u.warner.Warn("tier field not set for server " + hostname)
} else if *physicalServer.Tier == 0 {
free = true
}

// Note: for multi-hop use the server name or hostname
// instead of the country
countryCode := logicalServer.ExitCountry
Expand Down
Loading

0 comments on commit ceb6ff4

Please sign in to comment.