protonvpn-nm-lib
protonvpn-nm-lib copied to clipboard
Proton VPN NM Library
Copyright (c) 2021 Proton Technologies AG
This repository holds the Proton VPN NM Library. For licensing information see COPYING. For contribution policy see CONTRIBUTING.
Description
The Proton VPN NM (NetworkManager) Library is intended for every Proton VPN service user.
You can download the latest stable release, either from our official repositories or directly on the official GitHub repository.
Dependencies:
Distro | Command |
---|---|
Fedora/RHEL | sudo dnf install -y NetworkManager NetworkManager-openvpn NetworkManager-openvpn-gnome openvpn python3-pyxdg python3-keyring python3-jinja2 python3-distro python3-gobject libsecret-devel dbus-x11 gnome-keyring |
Ubuntu/Linux Mint/Debian and derivatives | sudo apt install -y network-manager network-manager-openvpn openvpn python3-xdg python3-keyring python3-jinja2 python3-distro gir1.2-nm-1.0 libsecret-tools dbus-x11 gnome-keyring network-manager-openvpn-gnome |
Arch Linux/Manjaro | sudo pacman -S networkmanager networkmanager-openvpn openvpn python-pyxdg python-keyring python-jinja python-distro dbus-x11 gnome-keyring |
Additional dependency:
Virtual Environment Dependencies:
If you would like to run the the CLI from within a virtual environment (for either development purposes or other), then you can easily do that with the help of pipenv. Make sure to install pipenv and additional packages before.
Distro | Command |
---|---|
Fedora/RHEL | sudo dnf install pkgconf-pkg-config networkmanager networkmanager-openvpn openvpn cairo-devel cairo-gobject-devel libsecret-devel gobject-introspection-devel dbus-x11 gnome-keyring |
Ubuntu/Linux Mint/Debian and derivatives | sudo apt install -y pkg-config network-manager network-manager-openvpn openvpn libcairo2-dev libgirepository1.0-dev gir1.2-nm-1.0 dbus-x11 libsecret-tools gnome-keyring |
Arch Linux/Manjaro | sudo pacman -S pkgconf networkmanager networkmanager-openvpn openvpn cairo base-devel gobject-introspection pkgconf dbus-x11 libsecret gnome-keyring gtk3 |
Install inside virtual environment:
-
cd protonvpn-nm-core
-
pipenv install
(installs virtual environment and all necessary dependencies from Pipfile). -
pipenv shell
(enter virtual environment). -
pip install -e .
(to install).
How to use:
Import
from protonvpn_nm_lib.api import protonvpn
Login
protonvpn.login("[email protected]", "ProtonPassword")
Logout
protonvpn.logout()
Connect
protonvpn.setup_connection(ConnectionTypeEnum.SERVERNAME, "PT#12", ProtocolEnum.TCP)
protonvpn.connect()
Disconnect
protonvpn.disconnect()
API | Description |
---|---|
protonvpn.login(username, password) |
Login with your Proton credentials. |
protonvpn.logout() |
Logout user and delete current user session. |
protonvpn.setup_connection(connection_type, connection_type_extra_arg, protocol) |
Setup and configure VPN connection prior to calling protonvpn.connect(). |
protonvpn.setup_reconnect() |
Setup and configure VPN connection to a previously connected server. Should be called before calling protonvpn.connect(). |
protonvpn.connect() |
Should be used either after protonvpn.setup_connection() protonvpn.setup_reconnect(). |
protonvpn.disconnect() |
Disconnect from Proton VPN. |
protonvpn.check_session_exists() |
Check if sessions exists. |
protonvpn.get_connection_status() |
Get active connection status. |
protonvpn.get_settings() |
Get user settings. This object can be used to get and set user settings. |
protonvpn.get_session() |
Get user session. This object can be used to get servers list, get keyring data and other. |
protonvpn.get_country() |
Get country. |
protonvpn.get_connection_metadata() |
Get metadata of an active Proton VPN connection. |
protonvpn.get_non_active_protonvpn_connection() |
Get non active Proton VPN connection. |
protonvpn.get_active_protonvpn_connection() |
Get active Proton VPN connection. |
protonvpn.ensure_connectivity() |
Ensure that there is an internet connection. |