Skip to content

bastiaanwilliams/OCL

Repository files navigation

Alt text
OpenVPN Client Gui for Linux with MFA/2FA support.

A very simple user-friendly OpenVPN client for Linux with MFA/2FA support, built with Python3 and Tkinter. This application provides a graphical interface for the cli openvpn client (/usr/bin/openvpn) on Linux. Managing OpenVPN connections including features like configuration file selection, authentication handling (including MFA/2FA), network traffic monitoring, dark/light theme, store credentials savely (through keyring) etc.



Newest Version 1.8.2 – Added a menu structure and updated style/themes
The newest version of the OCL code includes a menu (top bar) with entries for:
Add Config File
About
Settings
Quit

The Settings menu item opens a themed Settings window, letting you enable/disable the splash screen and pick between Dark or Light themes. After saving, these preferences are written to a JSON file (config.json) in ~/.openvpn_client/, and the theme is applied instantly to the entire interface. On relaunch, the app remembers these preferences, so it continues in the chosen theme and respects the splash screen setting. This design provides a user-friendly and persistent settings experience, allowing users to customize the look and feel of your OpenVPN Linux Client with minimal effort.

Version 1.0 – New Bundled OpenVPN Approach

In this v1.0 release, OCL now bundles its own OpenVPN client binary inside a dedicated bin/ folder, rather than relying on a system-wide installation of OpenVPN. This change provides the following benefits:

Self-Contained: Users no longer need to install OpenVPN separately; the client executable (version OpenVPN 2.5.9 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Feb 14 2023) is included within the bin distribution.
Consistent Version: Every user runs the exact same version of OpenVPN, preventing version mismatches across different systems or distros.
Easier Setup: Fewer prerequisites—just clone the repository (or unzip the release package) and run the script.

Folder Structure
scss
Copy code
my_openvpn_app/
├── bin/
│ ├── openvpn (Linux binary)
│ ├── openvpn.exe (Windows binary, if needed)
│ └── openvpn_macos (Mac binary, if needed)
├── images/
│ ├── background_dark.png
│ ├── background_light.png
│ ├── ...
├── openvpn_gui.py (Main program)
├── README.md
└── ...

bin/: Holds the compiled OpenVPN binaries (one per supported platform).>
images/: Contains UI images (like backgrounds, icons, logos).
openvpn_gui.py: Main Python script that calls bin/openvpn instead of relying on /usr/sbin/openvpn.

How It Works
Startup: When you run openvpn_gui.py, it detects your operating system (Windows, macOS, Linux, etc.) and chooses the appropriate binary from bin/.
Connection: The script spawns the bundled OpenVPN binary (openvpn.exe or openvpn) with your chosen .ovpn configuration.
No System Dependencies: You do not need to install OpenVPN via package managers—everything is self-contained here.

License & Compliance
Because OpenVPN is licensed under the GPLv2, we include its binaries and provide (or offer) corresponding source code. Check our LICENSE_OPENVPN file for details, or see the official OpenVPN GitHub for source code and additional licensing information.


Alt text Alt text

Features:
Easy Configuration: Browse and select your OpenVPN .ovpn configuration files effortlessly. Secure Authentication: Enter your username and password securely, with support for Multi-Factor Authentication (MFA). Real-Time Traffic Monitoring: Monitor the total amount of data sent and received since the VPN connection was established. Theme Customization: Toggle between light and dark themes to suit your preferences. Splash Screen: A sleek splash screen that can be disabled for future launches. Cross-Platform Compatibility: Designed to work seamlessly on most Linux distributions. See screenshots.


Used Modules:
import tkinter as tk
from tkinter import filedialog, messagebox
from PIL import Image, ImageTk
import threading
import pexpect
import psutil
import time
import re
import os
import netifaces
import sys
import queue
import json
import keyring from pathlib import Path
from screeninfo import get_monitors
import platform

---- NEW IMPORTS FOR ENCRYPTION ----

from cryptography.fernet import Fernet



Install Pythonm modules with pip3 preferable in a virtual environment:
python3 -m venv venv
source venv/bin/activate
pip3 install Pillow
pip3 install pexpect
pip3 install psutils
pip3 install screeninfo
pip3 install netifaces
pip3 install cryptography
pip3 install keyring

Requirements
-Python 3.6 or higher
-Python Libraries and Pip Modules

The following Python libraries and pip modules are required to run the OpenVPN Linux Client:
Standard Libraries:

-tkinter (usually comes pre-installed with Python on most Linux distributions)
-json
-pathlib
-os
-re
-subprocess
-queue
-time
-threading

Third-Party Libraries:


-Pillow (pip install Pillow)
-pexpect (pip install pexpect)
-psutil (pip install psutil)
-screeninfo (pip install screeninfo)


Installation of Dependencies:
Before running the application, ensure that all required libraries are installed.
You can install the necessary pip modules using the following command:


pip3 install Pillow pexpect psutil screeninfo
Note: tkinter is typically included with Python on most Linux distributions.
If it's not installed, you can install it using your distribution's package manager.
For example, on Debian/Ubuntu-based systems:


sudo apt-get install python3-tk
Installation
Clone the Repository

git clone https://github.com/yourusername/openvpn-linux-client.git
cd openvpn-linux-client
Install Dependencies


As mentioned in the Requirements section, install the necessary pip modules:


pip3 install Pillow pexpect psutil screeninfo
Ensure OpenVPN is Installed

NOTE: The client relies on the OpenVPN binary. Install OpenVPN using your distribution's package manager if it's not already installed.
Debian/Ubuntu:
sudo apt-get update
sudo apt-get install openvpn

Fedora:
sudo dnf install openvpn

Arch Linux:
sudo pacman -S openvpn
Prepare OpenVPN Configuration

Obtain your .ovpn configuration file from your VPN provider and ensure it's accessible on your system.

Usage:
Run the Application:
Copy the project folder (ocl) to your computer. Navigate to the project directory and execute the main Python script:
python3 openvpn_client.py

Or use the executable:
(Create with Nuitka: python3 -m nuitka --onefile --enable-plugin=tk-inter --include-data-dir=./images=./images --include-data-dir=./bin=./bin openvpn_linux_client.py)

./openvpn_linux_client.bin

Select Configuration File:
Click the Browse button to locate and select your OpenVPN .ovpn configuration file.
The selected configuration path will be displayed. If the path is too long, it will wrap to ensure readability.


Enter Credentials:
Username: Enter your VPN username.
Password: Enter your VPN password. The input is masked for security.
Connect to VPN

Click the Connect button to initiate the VPN connection.
If Multi-Factor Authentication (MFA) is required, a popup will appear prompting you to enter your 2FA code.

Monitor Network Traffic:
Once connected, the application will display the total amount of data sent and received since the connection was established.

Toggle Theme:
Use the theme toggle button to switch between light and dark themes based on your preference.


Disconnect from VPN:
Click the Disconnect button to terminate the VPN connection.


Configuration:
The application stores its configuration in a JSON file located at ~/.openvpn_client/config.json.
This file includes settings like whether to show the splash screen on startup.


Example config.json:
json
Copy code
{
"show_splash": false
}
To reset the configuration, you can delete the config.json file, and the application will recreate it with default settings upon the next launch.


Contributing:
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request.


Fork the Repository
Create a New Branch
git checkout -b feature/YourFeatureName
Make Your Changes
Commit Your Changes
git commit -m "Add some feature"
Push to the Branch
git push origin feature/YourFeatureName
Open a Pull Request


About

OpenVPN CLient GUI for Linux with MFA/2FA support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages