linux-cli-community icon indicating copy to clipboard operation
linux-cli-community copied to clipboard

Dialog Error

Open mreza0100 opened this issue 2 years ago • 28 comments

Describe the bug When I try to choose a server protonvpn connect, it give me error

To Reproduce Steps to reproduce the behavior:

  1. install protonvpn via pip3(latest version)
  2. install dialog sudo pacman -S dialog
  3. protonvpn init
  4. protonvpn connect

Expected behavior Show me the server lists

Error Messages/Program Output/Log Messages (~/.pvpn-cli/pvpn-cli.log)

2022-06-03 21:55:10,588 — protonvpn-cli — DEBUG — dialog:46 — Starting dialog connect
2022-06-03 21:55:10,593 — protonvpn-cli — DEBUG — call_api:38 — Initiating API Call: https://api.protonmail.ch/vpn/logicals
2022-06-03 21:55:11,728 — protonvpn-cli — DEBUG — call_api:67 — Successful json response
2022-06-03 21:55:11,764 — protonvpn-cli — DEBUG — pull_server_data:89 — SERVER_INFO_FILE written
2022-06-03 21:55:11,766 — protonvpn-cli — DEBUG — pull_server_data:96 — last_api_call updated
2022-06-03 21:55:11,767 — protonvpn-cli — DEBUG — get_servers:103 — Reading servers from file
2022-06-03 21:55:11,774 — protonvpn-cli — DEBUG — show_dialog:36 — Showing Dialog: Choose a country:

Error:

Traceback (most recent call last):
  File "/usr/bin/protonvpn", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/protonvpn_cli/cli.py", line 72, in main
    cli()
  File "/usr/lib/python3.10/site-packages/protonvpn_cli/cli.py", line 134, in cli
    connection.dialog()
  File "/usr/lib/python3.10/site-packages/protonvpn_cli/connection.py", line 83, in dialog
    country = show_dialog("Choose a country:", choices)
  File "/usr/lib/python3.10/site-packages/protonvpn_cli/connection.py", line 38, in show_dialog
    code, tag = d.menu(headline, title="ProtonVPN-CLI", choices=choices)
  File "/usr/lib/python3.10/site-packages/dialog.py", line 2935, in menu
    return self._widget_with_string_output(
  File "/usr/lib/python3.10/site-packages/dialog.py", line 1728, in _widget_with_string_output
    code, output = self._perform(args, **kwargs)
  File "/usr/lib/python3.10/site-packages/dialog.py", line 1523, in _perform
    exit_code, output = self._handle_program_exit(child_pid,
  File "/usr/lib/python3.10/site-packages/dialog.py", line 1489, in _handle_program_exit
    self._wait_for_program_termination(child_pid,
  File "/usr/lib/python3.10/site-packages/dialog.py", line 1435, in _wait_for_program_termination
    raise DialogError(
dialog.DialogError: dialog-like terminated due to an error: the dialog-like program exited with status 3 (which was passed to it as the DIALOG_ERROR environment variable). Sometimes, the reason is simply that dialog was given a height or width parameter that is too big for the terminal in use. Its output, with leading and trailing whitespace stripped, was:

Expected at least 20 tokens for --men, have 4.
Use --help to list options.

Desktop (please complete the following information):

  • OS: Manjaro Linux x86_64
  • Python Version: [e.g. 3.7.4 (Python 3.10.4)]
  • ProtonVPN-CLI Version: ProtonVPN-CLI v2.2.11

Additional context I have updated the all the packages (sudo pacman -Syu) Even updating python dependencies (yay -S $(pacman -Qoq /usr/lib/python3.9))

mreza0100 avatar Jun 03 '22 17:06 mreza0100

And also when I try to connect without dialog like: sudo protonvpn connect -f I get:

Traceback (most recent call last):
  File "/usr/bin/protonvpn", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/protonvpn_cli/cli.py", line 72, in main
    cli()
  File "/usr/lib/python3.10/site-packages/protonvpn_cli/cli.py", line 121, in cli
    connection.fastest(protocol)
  File "/usr/lib/python3.10/site-packages/protonvpn_cli/connection.py", line 164, in fastest
    fastest_server = get_fastest_server(server_pool)
  File "/usr/lib/python3.10/site-packages/protonvpn_cli/utils.py", line 175, in get_fastest_server
    fastest_server = random.choice(fastest_pool[:pool_size])["Name"]
  File "/usr/lib/python3.10/random.py", line 378, in choice
    return seq[self._randbelow(len(seq))]
IndexError: list index out of range

mreza0100 avatar Jun 03 '22 17:06 mreza0100

I put a print before code, tag = d.menu(headline, title="ProtonVPN-CLI", choices=choices), for choices, and I see that the array is empty! Maybe the problem is fetching server lists?

mreza0100 avatar Jun 03 '22 17:06 mreza0100

Same is happening to me.

Just yesterday I noticed an anomaly of many servers being in 14% usage at two regions of Netherlands and USA, along with an enlarged server size—Previously it was around 50, yesterday it was 130~; Entirely likely some large change is underway with server lists.

I don't think filling in an issue here will do any good though; none of the issues over span of 10 months have gotten a reply from maintainers.

KoshulaDora avatar Jun 04 '22 07:06 KoshulaDora

Same is happening to me!

aliazani avatar Jun 04 '22 07:06 aliazani

@kylekatarnls @Rafficer Can you help us, please?

After init proton, ~/.pvpn-cli/serverinfo.json is filled with server data. The problem is here when it tries to Sort server IDs by Tier. the result of that is an empty array, which is why the dialog can't show anything, and random function in protonvpn connect -f giving list index out of range. As metadata, the result of printing user_tier was 0.

mreza0100 avatar Jun 04 '22 08:06 mreza0100

Hello, we had to revamp the list the API is returning. We'll see if we can bring support back for the old CLI.

In the meantime you can use the new official CLI: https://github.com/ProtonVPN/linux-cli

Side note: we'll try to maintain the support as long as possible (e.g. as long as it does not penalize other users), but there is no plan to provide long term support for this repository and I would encourage people to migrate to the official CLI above which is backed by Proton and continuously tested when the API evolves.

kylekatarnls avatar Jun 04 '22 09:06 kylekatarnls

I'm having the same issue.

(I prefer this one over the "official" cli, and except for this current issue, it has been reliable and works very well. I've tested the "official" cli and the app over time, and it's inconsistent and still doesn't work as well as it should. Hopefully this one can stick around.)

poisonowl avatar Jun 04 '22 09:06 poisonowl

doesn't work as well as it should

If you have precise issues with the latest version of the official CLI, you should reach the support for it to be fixed/get help: https://protonvpn.com/support/report-a-bug/#linux

kylekatarnls avatar Jun 04 '22 10:06 kylekatarnls

doesn't work as well as it should

If you have precise issues with the latest version of the official CLI, you should reach the support for it to be fixed/get help: https://protonvpn.com/support/report-a-bug/#linux

Okay, I understand. I'm from Iran and we can't just simply login and use it. For logging in to the official VPN I have to have another VPN just to log in! And I don't have that, it's just like my phone or windows app.

But with this version, I can just use open connect credentials, and there is no need for another VPN. Right now I installed the official app, and it just can't connect and authorize me.

Is there any way that I can make this app work right now?

mreza0100 avatar Jun 04 '22 10:06 mreza0100

@mreza0100 api.protonvpn.ch is blocked by some ISPs in Iran, but I noticed that MCI net hasn't blocked this api yet, so I logged in with MCI net and after that I was able to switch to other ISPs and easily connect to fastest server via -f flag then it was possible to use protonvpn-cli connect and choose the server of my choice. I should notice that it isn't possible to choose the server of your choice at first so you should first connect to fastest server and then try to change the server!

aliazani avatar Jun 04 '22 11:06 aliazani

As a temporary work-around, I'm re-enabling servers that should be compatible again with this CLI. If you refresh the list, you should now see NL-FREE#26 for instance.

kylekatarnls avatar Jun 04 '22 11:06 kylekatarnls

As a temporary work-around, I'm re-enabling servers that should be compatible again with this CLI. If you refresh the list, you should now see NL-FREE#26 for instance.

Do you know any solution that I can change api.protonvpn.ch to api.protonmail.ch I can't have both of them installed, if I do so, both of them not working. And can't just use one server, even if I want it to, what will happen for the future.

mreza0100 avatar Jun 04 '22 11:06 mreza0100

I experienced the same problem yesterday and today apparently it is working again. I'd like to point out that this project is very important because the official client requires systemd, which some relevant distros do not adopt.

autogris avatar Jun 04 '22 13:06 autogris

As a temporary work-around, I'm re-enabling servers that should be compatible again with this CLI. If you refresh the list, you should now see NL-FREE#26 for instance.

Can you pls just enable it again? Like old good days? @kaplun

mreza0100 avatar Jun 04 '22 19:06 mreza0100

It is already, just refresh the list, you'll have the 3 usual countries available again for the time being before we can find a long term solution. Because censorships evolves so our infra has to evolve too. Stopping updates is sadly not an option. As we really have a lot of people left with no solution if we do.

While on the other side for Linux users, we still provide other solutions if the official CLI or app can't run on your distro, it's also possible to download config file to use the vanilla client of WireGuard or OpenVPN.

kylekatarnls avatar Jun 04 '22 21:06 kylekatarnls

Hello, we had to revamp the list the API is returning. We'll see if we can bring support back for the old CLI.

In the meantime you can use the new official CLI: https://github.com/ProtonVPN/linux-cli

Side note: we'll try to maintain the support as long as possible (e.g. as long as it does not penalize other users), but there is no plan to provide long term support for this repository and I would encourage people to migrate to the official CLI above which is backed by Proton and continuously tested when the API evolves.

The problem is that the official Cli version doesn't support headless machine. So I don't understand how to use my subscription without your cli version. Is anyone able to give me some hints on how solve this impasse?

tamet83 avatar Jun 11 '22 09:06 tamet83

Version 2.2.11 of this repository should still allow you for now to connect to both free and paid servers.

kylekatarnls avatar Jun 12 '22 09:06 kylekatarnls

Version 2.2.11 of this repository should still allow you for now to connect to both free and paid servers.

Unfortunately it provides me only free servers despite my payed subscription. I don’t understand why.

tamet83 avatar Jun 12 '22 15:06 tamet83

Maybe I know. If you had Basic plan, you've been upgraded for free to Plus, can you try to reconfigure selecting Plus plan?

kylekatarnls avatar Jun 12 '22 15:06 kylekatarnls

I’ll give it a try and let you know. Thanks for the hint.

tamet83 avatar Jun 12 '22 17:06 tamet83

Maybe I know. If you had Basic plan, you've been upgraded for free to Plus, can you try to reconfigure selecting Plus plan?

That worked for me, thanks for the help!

mikearmagedon avatar Jun 16 '22 17:06 mikearmagedon

I didn't work for me. This is the error i have:

Traceback (most recent call last):
  File "/usr/local/bin/protonvpn", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/cli.py", line 72, in main
    cli()
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/cli.py", line 134, in cli
    connection.dialog()
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/connection.py", line 124, in dialog
    openvpn_connect(server_result, protocol_result)
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/connection.py", line 456, in openvpn_connect
    disconnect(passed=True)
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/connection.py", line 335, in disconnect
    manage_dns("restore")
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/connection.py", line 612, in manage_dns
    oldhash = get_config_value("metadata", "resolvconf_hash")
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/utils.py", line 125, in get_config_value
    return config[group][key]
  File "/usr/lib/python3.9/configparser.py", line 1254, in __getitem__
    raise KeyError(key)
KeyError: 'resolvconf_hash'

tamet83 avatar Jun 25 '22 23:06 tamet83

Sorry, what are the steps? This error cannot happen when running protonvpn configure AFAIK.

Are you still on 2.2.11?

Did you run protonvpn configure successfully?

Do you see paid servers once you configure with "Plus" plan?

I suspect it happen when connecting as it fails on the step: manage_dns("restore") and so API update is likely unrelated there, it might need instead a reinstall (with cached data cleanup).

kylekatarnls avatar Jun 26 '22 12:06 kylekatarnls

Hi, I have a basic plan. I tried to configure protonvpn as plus service as you advised me before and I can see all payed servers but I can’t connect to any of them.

I confirm that I’m on 2.2.11 version and I successfully configured it.

I’ll try reinstalling it and let you know as soon as possible.

This is last chance before I switch to NordVPN.

tamet83 avatar Jun 26 '22 14:06 tamet83

As far as I know, NordVPN does not have a linux CLI, they just provide OpenVPN files and those can be used with the openvpn program but ProtonVPN provides the same, they can be downloaded from https://account.protonvpn.com/ so I don't really see why it would be any better to switch to another service.

I have a basic plan.

It no longer exist, you have a Plus plan now for the same price ;)

kylekatarnls avatar Jun 26 '22 14:06 kylekatarnls

As far as I know, NordVPN does not have a linux CLI, they just provide OpenVPN files and those can be used with the openvpn program but ProtonVPN provides the same, they can be downloaded from https://account.protonvpn.com/ so I don't really see why it would be any better to switch to another service.

They have it and it works very, very well.

I have a basic plan.

It no longer exist, you have a Plus plan now for the same price ;)

You're right, I didn't notice it. My bad.

I suspect it happen when connecting as it fails on the step: manage_dns("restore") and so API update is likely unrelated there, it might need instead a reinstall (with cached data cleanup).

I tried to reinstall again the cli version, but still have the same error.

protonvpn c --p2p
Traceback (most recent call last):
  File "/usr/local/bin/protonvpn", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/cli.py", line 72, in main
    cli()
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/cli.py", line 128, in cli
    connection.feature_f(4, protocol)
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/connection.py", line 212, in feature_f
    disconnect(passed=True)
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/connection.py", line 344, in disconnect
    manage_dns("restore")
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/connection.py", line 612, in manage_dns
    oldhash = get_config_value("metadata", "resolvconf_hash")
  File "/usr/local/lib/python3.9/dist-packages/protonvpn_cli/utils.py", line 125, in get_config_value
    return config[group][key]
  File "/usr/lib/python3.9/configparser.py", line 1254, in __getitem__
    raise KeyError(key)
KeyError: 'resolvconf_hash'

I also tried to connect manually, by choosing the server, but still doesn't work at all.

tamet83 avatar Jun 26 '22 15:06 tamet83

Did you also clean cached data (~/.pvpn-cli)?

kylekatarnls avatar Jun 26 '22 15:06 kylekatarnls

~/.pvpn-cli

No I didn't. Now it works again. Thank you so much. At least I can use my payed subscription without loosing money.

I'm going to switch to NordVPN next. I don't think ProtonVPN developers will implement a cli version like yours.

Meanwhile really thanks for your help.

tamet83 avatar Jun 26 '22 15:06 tamet83