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

protonvpn-cli 2.2.4 causes ipv6 related warnings on host with ipv6 disabled #193

Open GonzRon opened 4 years ago

GonzRon commented 4 years ago

Hi,

With Ipv6 kernel module disabled on the host, I believe this is happening because you are calling manage_ipv6 function in connection.py without first checking if ipv6 is available.

in this case running the same command manually reproduces the error warning:

root@io:~/.pvpn-cli#ip6tables-restore ip6tables.backup
modprobe: ERROR: could not insert 'ip6_tables': Unknown symbol in module, or unknown parameter (see dmesg)
ip6tables-restore v1.4.21: ip6tables-restore: unable to initialize table 'filter'

Error occurred at line: 1
Try `ip6tables-restore -h' or 'ip6tables-restore --help' for more information.

you could simply do the following to absorb stdout and stderr from ipv6 if you don't care about whether your commands are working or not (or if you are not checking for the return status from the command anyways) :

subprocess.run(['ls', '-l'], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)

Here's the full output


Connecting to US-NJ#6 via TCP...
modprobe: ERROR: could not insert 'ip6_tables': Unknown symbol in module, or unknown parameter (see dmesg)
ip6tables v1.4.21: can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
modprobe: ERROR: could not insert 'ip6_tables': Unknown symbol in module, or unknown parameter (see dmesg)
ip6tables v1.4.21: can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
Connected!

root@io:~/.pvpn-cli# cat pvpn-cli.log
2020-06-12 10:44:39,942 — protonvpn-cli — DEBUG — cli:84 — ###########################
2020-06-12 10:44:39,943 — protonvpn-cli — DEBUG — cli:85 — ### NEW PROCESS STARTED ###
2020-06-12 10:44:39,943 — protonvpn-cli — DEBUG — cli:86 — ###########################
2020-06-12 10:44:39,943 — protonvpn-cli — DEBUG — cli:87 — ['/usr/local/bin/protonvpn', 'c', '-f']
2020-06-12 10:44:39,944 — protonvpn-cli — DEBUG — cli:88 — USER: root
2020-06-12 10:44:39,944 — protonvpn-cli — DEBUG — cli:89 — CONFIG_DIR: /root/.pvpn-cli
2020-06-12 10:44:39,967 — protonvpn-cli — DEBUG — cli:92 — Arguments
{'--cc': None, '--fastest': True, '--help': False, '--p2p': False, '--random': False, '--sc': False, '--tor': False, '--version': False, '-p': None, '<servername>': None, 'c': True, 'configure': False, 'connect': False, 'd': False, 'disconnect': False, 'examples': False, 'init': False, 'r': False, 'reconnect': False, 'refresh': False, 's': False, 'status': False}
2020-06-12 10:44:40,011 — protonvpn-cli — DEBUG — fastest:145 — Starting fastest connect
2020-06-12 10:44:40,013 — protonvpn-cli — DEBUG — disconnect:307 — Initiating disconnect
2020-06-12 10:44:40,036 — protonvpn-cli — DEBUG — is_connected:197 — Checking connection Status. OpenVPN processes: 0
2020-06-12 10:44:40,037 — protonvpn-cli — DEBUG — manage_dns:606 — Restoring DNS
2020-06-12 10:44:40,037 — protonvpn-cli — DEBUG — manage_dns:623 — No Backupfile found
2020-06-12 10:44:40,037 — protonvpn-cli — DEBUG — manage_ipv6:686 — Restoring ip6tables
2020-06-12 10:44:40,038 — protonvpn-cli — DEBUG — manage_ipv6:701 — No Backupfile found
2020-06-12 10:44:40,038 — protonvpn-cli — DEBUG — manage_killswitch:776 — Restoring iptables
2020-06-12 10:44:40,038 — protonvpn-cli — DEBUG — manage_killswitch:785 — No Backupfile found
2020-06-12 10:44:40,038 — protonvpn-cli — DEBUG — disconnect:347 — No connection found
2020-06-12 10:44:40,043 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/logicals
2020-06-12 10:44:40,917 — protonvpn-cli — DEBUG — call_api:65 — Successful json response
2020-06-12 10:44:41,179 — protonvpn-cli — DEBUG — pull_server_data:87 — SERVER_INFO_FILE written
2020-06-12 10:44:41,249 — protonvpn-cli — DEBUG — pull_server_data:94 — last_api_call updated
2020-06-12 10:44:41,253 — protonvpn-cli — DEBUG — get_servers:101 — Reading servers from file
2020-06-12 10:44:41,290 — protonvpn-cli — DEBUG — get_fastest_server:171 — Returning fastest server with pool size 4
2020-06-12 10:44:41,291 — protonvpn-cli — DEBUG — openvpn_connect:442 — Initiating OpenVPN connection
2020-06-12 10:44:41,291 — protonvpn-cli — DEBUG — openvpn_connect:444 — Connecting to US-NJ#6 via TCP
2020-06-12 10:44:41,292 — protonvpn-cli — DEBUG — get_servers:101 — Reading servers from file
2020-06-12 10:44:41,366 — protonvpn-cli — DEBUG — render_j2_template:255 — Rendered /root/.pvpn-cli/connect.ovpn from openvpn_template.j2
2020-06-12 10:44:41,388 — protonvpn-cli — DEBUG — disconnect:307 — Initiating disconnect
2020-06-12 10:44:41,411 — protonvpn-cli — DEBUG — is_connected:197 — Checking connection Status. OpenVPN processes: 0
2020-06-12 10:44:41,412 — protonvpn-cli — DEBUG — manage_dns:606 — Restoring DNS
2020-06-12 10:44:41,412 — protonvpn-cli — DEBUG — manage_dns:623 — No Backupfile found
2020-06-12 10:44:41,412 — protonvpn-cli — DEBUG — manage_ipv6:686 — Restoring ip6tables
2020-06-12 10:44:41,413 — protonvpn-cli — DEBUG — manage_ipv6:701 — No Backupfile found
2020-06-12 10:44:41,413 — protonvpn-cli — DEBUG — manage_killswitch:776 — Restoring iptables
2020-06-12 10:44:41,413 — protonvpn-cli — DEBUG — manage_killswitch:785 — No Backupfile found
2020-06-12 10:44:41,413 — protonvpn-cli — DEBUG — disconnect:347 — No connection found
2020-06-12 10:44:41,414 — protonvpn-cli — DEBUG — get_ip_info:143 — Getting IP Information
2020-06-12 10:44:41,416 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/location
2020-06-12 10:44:41,887 — protonvpn-cli — DEBUG — call_api:65 — Successful json response
2020-06-12 10:44:41,893 — protonvpn-cli — DEBUG — openvpn_connect:474 — OpenVPN process started
2020-06-12 10:44:44,755 — protonvpn-cli — DEBUG — set_config_value:134 — Writing dns_server to [metadata] in config file
2020-06-12 10:44:44,786 — protonvpn-cli — DEBUG — manage_dns:554 — Leak Protection initiated
2020-06-12 10:44:44,788 — protonvpn-cli — DEBUG — manage_dns:568 — DNS Leak Protection is enabled
2020-06-12 10:44:44,789 — protonvpn-cli — DEBUG — manage_dns:574 — /etc/resolv.conf (resolv.conf) backed up
2020-06-12 10:44:44,790 — protonvpn-cli — DEBUG — manage_dns:585 — Removed existing DNS Servers
2020-06-12 10:44:44,791 — protonvpn-cli — DEBUG — manage_dns:593 — Added ProtonVPN or custom DNS
2020-06-12 10:44:44,793 — protonvpn-cli — DEBUG — set_config_value:134 — Writing resolvconf_hash to [metadata] in config file
2020-06-12 10:44:44,794 — protonvpn-cli — DEBUG — manage_ipv6:643 — Disabling IPv6
2020-06-12 10:44:44,800 — protonvpn-cli — DEBUG — manage_ipv6:658 — Backing up ip6tables rules
2020-06-12 10:44:44,871 — protonvpn-cli — DEBUG — manage_ipv6:683 — IPv6 disabled successfully
2020-06-12 10:44:44,874 — protonvpn-cli — DEBUG — get_ip_info:143 — Getting IP Information
2020-06-12 10:44:44,876 — protonvpn-cli — DEBUG — call_api:36 — Initiating API Call: https://api.protonvpn.ch/vpn/location
2020-06-12 10:44:45,510 — protonvpn-cli — DEBUG — call_api:65 — Successful json response
2020-06-12 10:44:45,511 — protonvpn-cli — DEBUG — openvpn_connect:508 — Connection successful
2020-06-12 10:44:45,537 — protonvpn-cli — DEBUG — openvpn_connect:527 — Writing connection info to file
longwuyuan commented 4 years ago

Would anyone know if the error i get is also related as I have ipv6 disabled as well ;

$ sudo protonvpn c -r                                                                            130 _
Traceback (most recent call last):
  File "/usr/local/bin/protonvpn", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/protonvpn_cli/cli.py", line 73, in main
    cli()
  File "/usr/local/lib/python3.8/dist-packages/protonvpn_cli/cli.py", line 114, in cli
    connection.random_c(protocol)
  File "/usr/local/lib/python3.8/dist-packages/protonvpn_cli/connection.py", line 139, in random_c
    openvpn_connect(servername, protocol)
  File "/usr/local/lib/python3.8/dist-packages/protonvpn_cli/connection.py", line 456, in openvpn_connect
    disconnect(passed=True)
  File "/usr/local/lib/python3.8/dist-packages/protonvpn_cli/connection.py", line 344, in disconnect
    manage_dns("restore")
  File "/usr/local/lib/python3.8/dist-packages/protonvpn_cli/connection.py", line 610, in manage_dns
    oldhash = get_config_value("metadata", "resolvconf_hash")
  File "/usr/local/lib/python3.8/dist-packages/protonvpn_cli/utils.py", line 123, in get_config_value
    return config[group][key]
  File "/usr/lib/python3.8/configparser.py", line 1254, in __getitem__
    raise KeyError(key)
KeyError: 'resolvconf_hash'
GonzRon commented 4 years ago

@longwuyuan your issue is not related to this issue or ipv6.

longwuyuan commented 4 years ago

Thanks