Rafficer / linux-cli-community

Linux command-line client for ProtonVPN. Written in Python.

Home Page:https://protonvpn.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

hgenchev99 opened this issue · comments

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:

  • protonvpn c CA#7
  • protonvpn s

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):

  • OS: Ubuntu 18.04
  • Python Version: 3.6
  • ProtonVPN-CLI Version: ProtonVPN-CLI v2.2.11

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

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
}