ProtonVPN / linux-cli

Official ProtonVPN Linux app (CLI)
https://protonvpn.com/download-linux
GNU General Public License v3.0
335 stars 43 forks source link

Throws errors when proton password is changed #9

Open axlevxa opened 3 years ago

axlevxa commented 3 years ago

Throws daunting error upon changing proton password. Steps to reproduce:

  1. Install and set up linux cli with existing password
  2. Change protonvpn password
  3. Try to connect to server

Fixed by logging out and back in. But could be nice to have a friendlier error message.

ProtonVPN CLI v3.6.0 (protonvpn-nm-lib v3.2.1; proton-client v0.5.1) on Mint 20; kernel: Linux 5.4.0-74-generic

$ protonvpn-cli c

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/proton/cert_pinning.py", line 88, in _validate_conn
    r = super(TLSPinningHTTPSConnectionPool, self)._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 996, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 314, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7fd911309f10>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: TLSPinningHTTPSConnectionPool(host='api.protonvpn.ch', port=443): Max retries exceeded with url: /vpn/logicals (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd911309f10>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/proton/api.py", line 99, in api_request
    ret = fct(
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: TLSPinningHTTPSConnectionPool(host='api.protonvpn.ch', port=443): Max retries exceeded with url: /vpn/logicals (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd911309f10>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/protonvpn_nm_lib/core/session/session.py", line 26, in __call__
    result = self._func(session, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/protonvpn_nm_lib/core/session/session.py", line 443, in update_servers_if_needed
    self.__proton_api.api_request('/vpn/logicals')
  File "/usr/lib/python3/dist-packages/proton/api.py", line 106, in api_request
    raise NewConnectionError(e)
proton.exceptions.NewConnectionError: TLSPinningHTTPSConnectionPool(host='api.protonvpn.ch', port=443): Max retries exceeded with url: /vpn/logicals (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd911309f10>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/protonvpn-cli", line 11, in <module>
    load_entry_point('protonvpn-cli==3.6.0', 'console_scripts', 'protonvpn-cli')()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/main.py", line 21, in main
    ProtonVPNCLI()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli.py", line 59, in __init__
    getattr(self, args.command)()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli.py", line 63, in c
    self.connect()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli.py", line 124, in connect
    self.cli_wrapper.connect(args)
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli_wrapper.py", line 132, in connect
    servername, protocol = self.dialog.start()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli_dialog.py", line 48, in start
    self.servers = self.session.servers
  File "/usr/lib/python3/dist-packages/protonvpn_nm_lib/core/session/session.py", line 490, in servers
    self.update_servers_if_needed()
  File "/usr/lib/python3/dist-packages/protonvpn_nm_lib/core/session/session.py", line 44, in __call__
    raise APIError("An error occured while attempting to reach API")
protonvpn_nm_lib.exceptions.APIError: An error occured while attempting to reach API
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 153, in apport_excepthook
    with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_bin_protonvpn-cli.1001.crash'

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/proton/cert_pinning.py", line 88, in _validate_conn
    r = super(TLSPinningHTTPSConnectionPool, self)._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 996, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 314, in connect
    conn = self._new_conn()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7fd911309f10>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: TLSPinningHTTPSConnectionPool(host='api.protonvpn.ch', port=443): Max retries exceeded with url: /vpn/logicals (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd911309f10>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/proton/api.py", line 99, in api_request
    ret = fct(
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: TLSPinningHTTPSConnectionPool(host='api.protonvpn.ch', port=443): Max retries exceeded with url: /vpn/logicals (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd911309f10>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/protonvpn_nm_lib/core/session/session.py", line 26, in __call__
    result = self._func(session, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/protonvpn_nm_lib/core/session/session.py", line 443, in update_servers_if_needed
    self.__proton_api.api_request('/vpn/logicals')
  File "/usr/lib/python3/dist-packages/proton/api.py", line 106, in api_request
    raise NewConnectionError(e)
proton.exceptions.NewConnectionError: TLSPinningHTTPSConnectionPool(host='api.protonvpn.ch', port=443): Max retries exceeded with url: /vpn/logicals (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd911309f10>: Failed to establish a new connection: [Errno -2] Name or service not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/protonvpn-cli", line 11, in <module>
    load_entry_point('protonvpn-cli==3.6.0', 'console_scripts', 'protonvpn-cli')()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/main.py", line 21, in main
    ProtonVPNCLI()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli.py", line 59, in __init__
    getattr(self, args.command)()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli.py", line 63, in c
    self.connect()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli.py", line 124, in connect
    self.cli_wrapper.connect(args)
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli_wrapper.py", line 132, in connect
    servername, protocol = self.dialog.start()
  File "/usr/lib/python3/dist-packages/protonvpn_cli/cli_dialog.py", line 48, in start
    self.servers = self.session.servers
  File "/usr/lib/python3/dist-packages/protonvpn_nm_lib/core/session/session.py", line 490, in servers
    self.update_servers_if_needed()
  File "/usr/lib/python3/dist-packages/protonvpn_nm_lib/core/session/session.py", line 44, in __call__
    raise APIError("An error occured while attempting to reach API")
protonvpn_nm_lib.exceptions.APIError: An error occured while attempting to reach API
calexandru2018 commented 3 years ago

Hey @axlevxa

Thank you for your report. We'll definitely look more into this.