Simple IP rotation using python.
Project description
sirup: simple IP rotation using python
A wrapper around the openvpn CLI to connect to VPN servers and rotate the IP address in python programs.
What is required
- An account with a VPN service that supports openvpn (for instance ProtonVPN or surfshark).
- A linux OS with superuser rights.
openvpn
for linux. See here for installation instructions.
How to install
To install from pip, do:
python -m pip install sirup
To install sirup from GitHub repository, do:
python -m pip install 'sirup @ git+https://github.com/ivory-tower-private-power/sirup'
How to use sirup
The package has two functionalities: connecting to a VPN server, and rotating the IP address.
1. Start up
This step is necessary for both functionalities.
import os
import getpass
import time
seed = 123
mypass = "/path/to/credentials.txt" # the user name and password credentials from your user account with the VPN service
config_path = "/path/to/config/files/" # the .opvn configuration files from your VPN service
Functionality 1: Connecting to a single VPN server
The sirup.VPNConnector.VPNConnector
class has two methods: connect
and disconnect
. They are used as follows.
from sirup.VPNConnector import VPNConnector
config_file = os.path.join(config_path, "name-of-one-config-file.ovpn")
pwd = getpass.getpass()
connector = VPNConnector(auth_file=mypass, config_file=config_file)
connector.connect(pwd=pwd)
time.sleep(10)
connector.disconnect(pwd=pwd)
Functionality 2: Using the IP rotation feature
The sirup.IPRotator.IPRotator
class has three methods: connect()
, rotate()
, disconnect()
. They are used as follows.
from sirup.IPRotator import IPRotator
rotator = IPRotator(auth_file=mypass, config_location=config_path, seed=seed) # will ask for the sudo password
rotator.connect()
print(rotator.connector.current_ip)
rotator.rotate()
print(rotator.connector.current_ip)
rotator.disconnect()
Note
Before using the package, have a look at "Making sure the VPN connection works correctly" to make sure the VPN service works properly.
Documentation
The documentation of sirup can be found on Read the Docs.
Contributing
If you want to contribute to the development of sirup, have a look at the contribution guidelines.
Credits
This package was created with Cookiecutter and the NLeSC/python-template.
The logo was generated using Chat-GPT and Micorosoft Co-Pilot on July 18th 2024 at 9:32am using this prompt.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sirup-0.2.4.tar.gz
.
File metadata
- Download URL: sirup-0.2.4.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e1c41b050093d8cf9b5cb7f4efd2771fe24eb568353e83b5e1d8feba0a688ee |
|
MD5 | 609accc2839b8d4b483cde06edabfc17 |
|
BLAKE2b-256 | f19545aa5f41f3f3f58da624339fee0922f475687c18fc33ed8c1a3dce15b452 |
File details
Details for the file sirup-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: sirup-0.2.4-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb67a7608934244be6c0dbf5cd4cc9fffcd84e457c9dcfaae488343d4001cabb |
|
MD5 | 20af1490de84fedf03d70de1b27b2835 |
|
BLAKE2b-256 | a22334fb338974c571dd747e24396623d8cee1745358bc612b8eb556b547e9ee |