Coder Social home page Coder Social logo

dagrha / pypia Goto Github PK

View Code? Open in Web Editor NEW
78.0 78.0 15.0 82 KB

Configuration of Private Internet Access VPN routes for Linux

License: GNU General Public License v3.0

Python 100.00%
linux networkmanager networkmanager-applet openvpn pia privateinternetaccess python vpn-routes

pypia's People

Contributors

ackl avatar dagrha avatar domwilliams0 avatar javascriptdude avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pypia's Issues

Package not installable via pip

I can't find this package at https://pypi.python.org.

Could you please upload it there? Installing via PIP is the standard way to distribute Python packages, and makes tracking versions and performing upgrades seamless. Installing via git repo is horribly inconvenient.

NetworkManager re-connect to vpn on boot?

Hi,

I'm wondering if you could help me figure out how to get the VPN to re-connect automatically on boot

I'm on Fedora 30 headless with nmtui. Installed using pypia very basic (no flags, thought I was just testing but it worked so I ran with it).

I'm asking here because I'm confused, pypia didn't install .conf files I would expect for openvpn in /etc/openvpn/client

Thank you for the help and the great user-friendly script

Serious Issue!

awesomes

This is repo is awesome and on top of that your documentation was perfect as well!

I wished I found it 6 hours ago!

I would click on your affiliate link, but I already had PIA, let me know if you want me to click on anything else!

Thanks again,

Chad

I know I'm breaking github protocol, but oh well

Option to not store password

Right now the password to connect to the PIA VPN is stored in the configuration files. Even though the file is pretty well protected since it is only readable by root, this is not ideal in terms of security. At the very least I'd like to add the option to not store the password, which would require entering your password every time a VPN connection is initiated.

Ideally we'd use Keyring or Wallet to handle passwords, but since this script aims to be cross-platform with minimal dependencies, that approach would be tricky.

Thank You!

There was no way to send you a message to thank you for creating these scripts! I just installed openSUSE Leap 42.2 XFCE and the script was absolutely flawless!

I know this isn't an issue so please delete if it isn't wanted on the page.

Thanks again!

Lubuntu Script

The script had an extra " -s " in the password line. This would cause the prompt to "jump" to the error stating that no password was entered after one typed in the username. Below it is written just as how the first lines are for the username, without the " -s " .

read_user_passwd( )
{
echo -n "Please enter your PIA password. This gets added to your VPN config files: "
read PASSWD
if [ -z $PASSWD ]; then
error "A password must be provided for the installation to proceed"
fi
}

Error using pypia

Hi
When I use pypia -i, I get this:
Traceback (most recent call last):
File "/usr/local/bin/pypia", line 7, in
from pypia.pypia import main
File "/usr/local/lib/python2.7/dist-packages/pypia/pypia.py", line 38, in
from queue import Queue
ImportError: No module named queue

Never had problem using your script in the past. Using KdE Nexus
Thanks

Error using pypia on PythonAnywhere

When I run pypia -i in the console at PythonAnywhere I get the following error:

Traceback (most recent call last):
File "/home/MyProject/.virtualenvs/myproject/bin/pypia", line 10, in
sys.exit(main())
File "/home/MyProject/.virtualenvs/,yproject/lib/python3.5/site-packages/pypia/pypia.py", line 336, in main
distro.install_packages()
File "/home/MyProject/.virtualenvs/myproject/lib/python3.5/site-packages/pypia/pypia.py", line 83, in install_packages
subprocess.call(['sudo'] + [i for i in self.install_command.format(package).split()])
File "/usr/lib/python3.5/subprocess.py", line 247, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.5/subprocess.py", line 676, in init
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1289, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'sudo'

Any suggestions?

Add raspian OS support (Raspberry Pi)

$ pypia -i
Traceback (most recent call last):
File "/usr/local/bin/pypia", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/pypia/pypia.py", line 334, in main
distro = Distro()
File "/usr/local/lib/python3.5/dist-packages/pypia/pypia.py", line 58, in init
self.get_package_info()
File "/usr/local/lib/python3.5/dist-packages/pypia/pypia.py", line 75, in get_package_info
logging.ERROR('{} is not yet supported.'.format(self.distro.upper()))
TypeError: 'int' object is not callable

"pypia -i" fails with error message "needs an internet connection"

Hi,

Description

Trying to use pypia on ubuntu. Download does work but pypia -i command fails
PIA VPN configurations were not able to be downloaded.This script needs an internet connection to be able to fetch them automatically. Exiting.
whereas i have an internet connection up and working

$ ping google.fr
PING google.fr (142.250.201.163) 56(84) bytes of data.
64 bytes from 142.250.201.163: icmp_seq=1 ttl=116 time=30.0 ms

Steps

  • install pypia : sucess
  • setup pypia : fail

Distribution

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"

Traces

$ id
uid=0(root) gid=0(root) groups=0(root)

$ pip install pypia
Collecting pypia
  Downloading pypia-0.3.7.tar.gz (21 kB)
Building wheels for collected packages: pypia
  Building wheel for pypia (setup.py) ... done
  Created wheel for pypia: filename=pypia-0.3.7-py3-none-any.whl size=19642 sha256=99f25d6c7b91c360f80e18893fcf567ba684a6bb8cc3f5fd08d0760ce8f25fff
  Stored in directory: /root/.cache/pip/wheels/ea/5c/dd/85ad8b94b9c2c51c4a800952b25df1a663d0d71d76257d1b6a
Successfully built pypia
Installing collected packages: pypia
Successfully installed pypia-0.3.7

$ pypia -i
Your distro appears to be UBUNTU.
Installing network-manager-openvpn. OK? (y/n): y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
network-manager-openvpn is already the newest version (1.8.12-1).
The following packages were automatically installed and are no longer required:
  ca-certificates-mono cli-common libc-ares2 libchromaprint-tools libdiscid0 libgdiplus
  libmono-accessibility4.0-cil libmono-btls-interface4.0-cil libmono-corlib4.5-cil libmono-i18n-west4.0-cil
  libmono-i18n4.0-cil libmono-posix4.0-cil libmono-security4.0-cil libmono-system-configuration4.0-cil
  libmono-system-core4.0-cil libmono-system-data4.0-cil libmono-system-drawing4.0-cil
  libmono-system-enterpriseservices4.0-cil libmono-system-numerics4.0-cil
  libmono-system-runtime-serialization-formatters-soap4.0-cil libmono-system-security4.0-cil
  libmono-system-transactions4.0-cil libmono-system-windows-forms4.0-cil libmono-system-xml4.0-cil
  libmono-system4.0-cil libmono-webbrowser4.0-cil libqt5multimedia5-plugins libqt5multimediagsttools5
  libsmi2ldbl libspandsp2 libwireshark-data libwireshark13 libwiretap10 libwsutil11 mono-4.0-gac mono-gac
  mono-runtime mono-runtime-common mono-runtime-sgen python3-libdiscid python3-mutagen wireshark-common
  wireshark-qt xsel
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
Installing curl. OK? (y/n): y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
curl is already the newest version (7.68.0-1ubuntu2.7).
The following packages were automatically installed and are no longer required:
  ca-certificates-mono cli-common libc-ares2 libchromaprint-tools libdiscid0 libgdiplus
  libmono-accessibility4.0-cil libmono-btls-interface4.0-cil libmono-corlib4.5-cil libmono-i18n-west4.0-cil
  libmono-i18n4.0-cil libmono-posix4.0-cil libmono-security4.0-cil libmono-system-configuration4.0-cil
  libmono-system-core4.0-cil libmono-system-data4.0-cil libmono-system-drawing4.0-cil
  libmono-system-enterpriseservices4.0-cil libmono-system-numerics4.0-cil
  libmono-system-runtime-serialization-formatters-soap4.0-cil libmono-system-security4.0-cil
  libmono-system-transactions4.0-cil libmono-system-windows-forms4.0-cil libmono-system-xml4.0-cil
  libmono-system4.0-cil libmono-webbrowser4.0-cil libqt5multimedia5-plugins libqt5multimediagsttools5
  libsmi2ldbl libspandsp2 libwireshark-data libwireshark13 libwiretap10 libwsutil11 mono-4.0-gac mono-gac
  mono-runtime mono-runtime-common mono-runtime-sgen python3-libdiscid python3-mutagen wireshark-common
  wireshark-qt xsel
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

WARNING: There may have been an issue with certificate verification to the PIA server info page. Trying to bypass cert check that python performs since PEP 476.


PIA VPN configurations were not able to be downloaded.This script needs an internet connection to be able to fetch them automatically. Exiting.

PyPia on Gentoo

Yes, we exist. And since the default installer doesn't support portage I think it would be awesome to have support for gentoo

Add support for selecting route with lowest latency

To the random_pia.py script, add an option that selects the route with the lowest current latency, which would be performed on the fly. Maybe ping each endpoint, tabulate results, and connect to the fastest.

Unable to Connect - "client update needed"

Each connection has in brackets Client update needed when going via NetworkManager

Have tried several, none connect.

OS Solus 4.1

If I try via terminal I get
pypia -f
Pinging all PIA servers. This might take a few seconds...

ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
ping: unknown host
Traceback (most recent call last):
File "/usr/bin/pypia", line 11, in
load_entry_point('pypia==0.3.7', 'console_scripts', 'pypia')()
File "/usr/lib/python3.7/site-packages/pypia/pypia.py", line 357, in main
print(lat)
File "/usr/lib/python3.7/site-packages/pypia/pypia.py", line 306, in str
.format(self.ip_addresses[k], j[0], j[1], j[2], j[3],
IndexError: list index out of range

CentOS support

openvpn
$ yum list | grep openvpn
NetworkManager-openvpn.x86_64 1:1.2.6-1.el7 epel
NetworkManager-openvpn-gnome.x86_64 1:1.2.6-1.el7 epel
kde-plasma-networkmanagement-openvpn.x86_64
openvpn.x86_64 2.4.4-1.el7 epel
openvpn-auth-ldap.x86_64 2.0.3-14.1.el7 epel
openvpn-devel.x86_64 2.4.4-1.el7 epel

Output of get_distro()
centos

OS name
$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

Error Installing on Manjaro KDE

pypia i gives me:

Traceback (most recent call last):
File "/usr/bin/pypia", line 11, in
load_entry_point('pypia==0.2.1', 'console_scripts', 'pypia')()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 301, in main
distro = Distro()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 54, in init
self.get_package_info()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 64, in get_package_info
with open('./pypia/package_info.json', 'r') as package_info:
FileNotFoundError: [Errno 2] No such file or directory: './pypia/package_info.json'

How to set up on Solus?

I am new to Solus, moving from Ubuntu (so I'm still learning), but how do I set this up on Solus?


tio@trom ~ $ pip install pypia
bash: pip: command not found
tio@trom ~ $ eopkg install pypia
Program terminated.
You have to be root for this operation.
Please use 'eopkg help' for general help.
tio@trom ~ $ sudo eopkg install pypia
Password: 
System error. Program terminated.
Repo item pypia not found
Please use 'eopkg help' for general help.
Use --debug to see a traceback.
tio@trom ~ $ pypia -i
bash: pypia: command not found
tio@trom ~ $ 

openSUSE Tumbleweed Failed Execution

pip install pypia seems to work fine:

linux-6ofw:/home/drhedberg # pip install pypia
Collecting pypia
Downloading https://files.pythonhosted.org/packages/b7/ed/757b101d69dea59d0de1eb63aa4eb2aca06e17a98811549c4cc6961a012f/pypia-0.3.4.tar.gz
Installing collected packages: pypia
Running setup.py install for pypia ... done
Successfully installed pypia-0.3.4

pypia -i however fails:

linux-6ofw:/home/drhedberg # pypia -i
Traceback (most recent call last):
File "/usr/bin/pypia", line 11, in
load_entry_point('pypia==0.3.4', 'console_scripts', 'pypia')()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 324, in main
distro = Distro()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 57, in init
self.get_package_info()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 71, in get_package_info
self.required_packages = package_dict['required_packages'][self.distro]
KeyError: 'opensuse-tumbleweed'

Killswitch?

Not really an issue, never really touched github so I don't really know where to put suggestions, It would be fantastic if you were to implement a killswitch, or just straight away reconnecting when I log back in after being away for a while. But a killswitch would be amazing if you would be willing to, again sorry If I posted in the wrong place.

Initialising problem with opensuse leap 15.0

system: openSuSE Leap 15.0 - kernel 4.12.14-lp150.12.4-default

the installation had no problems, but starting the script gives the next error:

user@host:~> sudo pypia -i
[sudo] password for root:
Traceback (most recent call last):
File "/usr/bin/pypia", line 11, in
load_entry_point('pypia==0.3.4', 'console_scripts', 'pypia')()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 324, in main
distro = Distro()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 57, in init
self.get_package_info()
File "/usr/lib/python3.6/site-packages/pypia/pypia.py", line 71, in get_package_info
self.required_packages = package_dict['required_packages'][self.distro]
KeyError: 'opensuse-leap'
user@host:~>

Is this because suse leap 15 is not supported ?

pypia: command not found

Playing with Ubuntu Gnome today and installed pypia but command cannot be found (from shell):

pypia: command not found

The issue is related to an OS bug where ~/.local/bin is not in the PATH for the user. Of course it would be best to just add ~/.local/bin to PATH but the quick workaround would be to execute as follows:
$ ~/.local/bin/pypia -i

Another alternative would be to get pypia.py from github and run:
$ python3 pypia.py -i

That's it, just though I would help others from stumbling on this.

Pypia on Debian 9 Stretch

Hello dagrha
First, thanks a lot for creating this program/script. It's VERY useful and I managed to install PIA VPN on Debian 9 Stretch, using your script.
At first, however, the script wouldn't run because sudo isn't installed on Debian 9 and I am not going to install sudo. As a workaround, I deleted all occurrences of sudo in your script and managed to get it working.
My suggestion is to change the script so it'll run on computers without sudo.
//Saltani

Syntax Error

Whenever I try to run a script, terminal outputs the following:

./install_lubuntu.sh: 6: ./install_lubuntu.sh: Syntax error: newline unexpected

Script fails on Ubuntu 16.04

Here is the output from the terminal:

[REDACTED]@[REDACTED]:~/Downloads/PIA_install_scripts-master$ sudo sh install_ubuntu.sh
[sudo] password for [REDACTED]: 
Python already installed
Package network-manager-openvpn already installed
Please enter your PIA login: [REDACTED]
Please enter your PIA password. This gets added to your VPN config files: install_ubuntu.sh: 61: read: Illegal option -s
A password must be provided for the installation to proceed
[REDACTED]@[REDACTED]:~/Downloads/PIA_install_scripts-master$

Not able to ping all servers

Seems like I'm only able to ping and list the US servers and not the rest?

Exception in thread Thread-25:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pypia/pypia.py", line 272, in ping
    result = subprocess.check_output(['ping', '-c', '3', ip]).decode('utf-8')
  File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ping', '-c', '3', '31.168.172.142']' returned non-zero exit status 1

Exception in thread Thread-22:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pypia/pypia.py", line 272, in ping
    result = subprocess.check_output(['ping', '-c', '3', ip]).decode('utf-8')
  File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ping', '-c', '3', '108.61.122.217']' returned non-zero exit status 1

Please add ArchMerge distro

Hello, not too long ago you added ArchLabs for me. The maintainer of that distro has branched off and created ArchMerge which I am now using. Aside from adding the new name, the rest should be the same as ArchLabs was.
Thanks!

Upgrade to 17.10

Greetings,

I had pypia working prefectly on 16.10, but the upgrade to 17.10 seems to have messed up my configurations.

Just to complicate thing I'm running the python command thru PHP. I know crazy right? (long story)

    echo exec('ls', $out);
    echo exec('pwd', $out);
    echo exec('python3 pypia/pypia.py -s -r us  2>&1', $out);
    var_dump($out);```

So this command worked just fine in 16.10, but upgrading to 17.10, I might have missed a configuration. Obviously the command `python3 pypia/pypia.py -s -r us` works just fine from the command line. But when I access the php file from a web browser I get the following

`{ [0]=> string(11) "LICENSE.txt" [1]=> string(9) "README.md" [2]=> string(14) "legacy_scripts" [3]=> string(5) "pypia" [4]=> string(8) "setup.py" [5]=> string(7) "test.sh" [6]=> string(19) "/var/www/html/pypia" [7]=> string(88) "Connection 'PIA - US East' deactivation failed: Not authorized to deactivate connections" [8]=> string(74) "Error: Connection activation failed: Not authorized to control networking." [9]=> string(30) "Disconnecting PIA - US East..." [10]=> string(30) "Activating PIA - US Midwest..." } ` 

I suspect it's because the user "www-data" does not have access to control networking? This might be outside the scope of the code, cause it deals more with network configurations?

Thanks 

Manjaro 17.0 KDE - not connecting

I have a fresh install of Manjaro 17.0 KDE and your script worked flawlessly to populate the connections in the network manager. However, any connection I click on says "connecting" for a couple seconds and then stops and goes back to listed as "never used". I'm not getting any pop up error messages at all. Hoping you can help me troubleshoot this. I'm not terribly experienced, but follow direction well! Let me know if you need more info. Thanks.
John

Add ArchLabs distribution for pypia

Wasn't sure exactly where to submit this request, so I hope this is ok. In reference to your requested information:

  1. networkmanager-openvpn
  2. pacman install or packer install
  3. (I couldn't follow your instructions, but the distribution is archlabs)
    This is the error I get currently:
    Traceback (most recent call last):
    File "pypia.py", line 240, in
    install_packages(package_dict)
    File "pypia.py", line 84, in install_packages
    required_packages = package_dict['required_packages'][distro]
    KeyError: 'archlabs'

add encryption options

Default now is SHA-1 hashing and AES-128 cipher. 128 bit AES is probably enough but it would be nice to have the option of 256.

Request: Add option to uninstall

Hello dagrha,

It would be most appreciated by me and (hopefully) other users that you add an uninstall option to pypia when installing via manual method (git clone method). If not, add maybe an uninstall guide in the README.

Much appreciated,
Mohamad

Feature to check pypia status?

It would be useful to add a feature to check if PIA is connected and which location is connected to.
I don't think this exists.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.