Reliable IP location changer using OpenVPN and WhatIsMyIP
Project description
IP Location Changer
Reliable IP location changer using OpenVPN and WhatIsMyIP.
This package allows changing the IP of the host machine by using openvpn configuration files (and optionally credentials), and verifying the IP location change using WhatIsMyIP.
Usage
from iplocationchanger.service.location_changer_service import LocationChangerService
try:
lcs = LocationChangerService(
'reoiotiyotrkc77690543031b421b',
{
'TR': '/assets/NCVPN-TR-Istanbul-TCP.ovpn',
},
'/usr/local/openvpn',
'/assets/openvpncredentials',
)
country = 'TR'
success, msg = lcs.connect_region(country)
if not success:
logging.error(msg)
raise Exception(
f'could not connect location: {country}. {msg}.'
)
# Other code logic
finally:
lcs.disconnect_region()
Standalone Execution
# Sample execution
python3 src/iplocationchanger/__main__.py \
-w reoiotiyotrkc77690543031b421b \
-l TR -o "/usr/local/openvpn" \
-c "/assets/configmap.json" \
-u "ncpuser@namecheap" -p "PaSsWoRd"
Requirements
- Linux or macOS
openvpn
is installed on the host PCopenvpn
configuration files- (optional)
openvpn
credentials - WhatIsMyIP API Key
- User with
sudo
permissions without password requirements forkillall
andopenvpn
.
Fulfilling sudo
requirements without password prompt
Granting sudo
requirements to a user without having them supply a password can be approached by editing the /etc/sudoers
file as such:
username ALL = (ALL) NOPASSWD: /usr/bin/killall, /usr/bin/openvpn
Environment Setup
python3 -m venv ./.venv
source ./.venv/bin/activate
python -m pip install -r requirements/dev.txt
Run tests
coverage run --rcfile .coveragerc -m unittest discover -t src/ -s src/tests/unit
coverage report -m
Config
Config files are JSON-formatted files with 2-letter ISO 3166 country codes as keys
and paths to corresponding OpenVPN configuration files as values
.
A sample config file is shown below:
{
"TR": "/assets/NCVPN-TR-Istanbul-TCP.ovpn",
"AR": "/assets/NCVPN-AR-Buenos-Aires-TCP.ovpn"
}
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
Close
Hashes for iplocationchanger-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aaa53179e567cb27721e8be33c6b792e578af22fcaa9d9460fb2ed862aa2a8f |
|
MD5 | 8e67c194406865d735f4358968bcd8a9 |
|
BLAKE2b-256 | b299ea43f540afc8fe7aa2a8f696e5fce926722101f422bb0b1cde40ae480552 |