Rafficer / linux-cli-community

Linux command-line client for ProtonVPN. Written in Python.
https://protonvpn.com
GNU General Public License v3.0
1.31k stars 198 forks source link

[BUG] `protonvpn status` fails with KeyError because of stale features set #327

Open hgenchev99 opened 3 years ago

hgenchev99 commented 3 years ago

Describe the bug When calling protonvpn status sometimes it fails with KeyError: 8 or KeyError: 16. The API was updated (supposedly) and now it features two new features Streaming and IPv6 with corresponding keys of 8 and 16 but the status function was not updated to handle the two new types.

To Reproduce Steps to reproduce the behavior:

Expected behavior The connection status

Error Messages/Program Output/Log Messages (output of the status command)

Traceback (most recent call last):
  File "/usr/local/bin/protonvpn", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/cli.py", line 72, in main
    cli()
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/cli.py", line 144, in cli
    connection.status()
  File "/usr/local/lib/python3.6/dist-packages/protonvpn_cli/connection.py", line 435, in status
    + "Sent:         {0}".format(tx_amount)
KeyError: 8

Desktop (please complete the following information):

Additional context This dict has to be updated with the two new features https://github.com/ProtonVPN/linux-cli-community/blob/master/protonvpn_cli/connection.py#L399

hgenchev99 commented 3 years ago

Info about the server provided in the example


{
  "Name": "CA#7",
  "EntryCountry": "CA",
  "ExitCountry": "CA",
  "Domain": "172.83.40.66",
  "Tier": 2,
  "Features": 8,
  "Region": null,
  "City": "Vancouver",
  "Score": 1.27208323,
  "HostCountry": null,
  "Location": {
    "Lat": 49.25,
    "Long": -123.133
  },
  "Status": 1,
  "Servers": [
    {
      "EntryIP": "172.83.40.66",
      "ExitIP": "172.83.40.69",
      "Domain": "lxc-ca-02.protonvpn.com",
      "Label": "1",
      "Generation": 0,
      "Status": 1,
      "ServicesDownReason": null
    }
  ],
  "Load": 58
}