Skip to content

Commit

Permalink
ipn/proton: fix ProtonLogicals json defs
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Dec 15, 2024
1 parent 4e63d94 commit 8bab306
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions intra/ipn/warp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ var defaultHeaders = map[string]string{
}

// raw.githubusercontent.com/ProtonVPN/android-app/81a6dfb9a0/app/src/main/assets/GuestHoleServers.json
var prebuiltProtonServersJson = []byte(`{
[
var prebuiltProtonServersJson = []byte(`[
{
"Name": "CH#134",
"EntryCountry": "CH",
Expand Down
14 changes: 8 additions & 6 deletions intra/ipn/warp/proton.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ type ProtonCertResponse struct {

// github.com/ProtonVPN/android-app/blob/master/app/src/b9c6e59de40/assets/GuestHoleServers.json
type ProtonServerResponse struct {
R []ProtonLogicals `json:"ProtonLogicals"`
Code int `json:"Code"`
R []ProtonLogicals `json:"LogicalServers"`
}

// {
Expand Down Expand Up @@ -328,9 +329,10 @@ type ProtonLogicals struct {
VPNGatewayID string `json:"VPNGatewayID"`
ID string `json:"ID"`
Load int `json:"Load"`
Location ProtonServerLocation
Status int `json:"Status"`
Servers []ProtonServer
Status int `json:"Status"`

Location ProtonServerLocation `json:"Location"`
Servers []ProtonServer `json:"Servers"`
}

// "Location": {
Expand Down Expand Up @@ -1195,12 +1197,12 @@ func protonServersByCountry(logicals []ProtonLogicals) map[string][]ProtonServer
}

func protonServersPrebuilt() []ProtonLogicals {
var prebuilts ProtonServerResponse
var prebuilts []ProtonLogicals
err := json.Unmarshal(prebuiltProtonServersJson, &prebuilts)
if err != nil {
log.E("proton: servers: %d unmarshal: %v", len(prebuiltProtonServersJson), err)
}
return prebuilts.R
return prebuilts
}

// go.dev/play/p/9kapzPiG72r
Expand Down

0 comments on commit 8bab306

Please sign in to comment.