Skip to main content

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
from iplocationchanger.exception.location_changer_service_exception import LocationChangerServiceException


try:
  lcs = LocationChangerService(
    'reoiotiyotrkc77690543031b421b',
    {
      'TR': '/assets/NCVPN-TR-Istanbul-TCP.ovpn',
    },
    '/usr/local/openvpn',
    '/assets/openvpncredentials',
  )

  country = 'TR'
  try:
    lcs.connect_region(country)
    # Other code logic...

  except LocationChangerServiceException as e:
    # locaiton change failed
    logging.error(e)
    exit(1)
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 PC
  • openvpn configuration files
  • (optional) openvpn credentials
  • WhatIsMyIP API Key
  • User with sudo permissions without password requirements for killall and openvpn.

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

iplocationchanger-0.0.3.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iplocationchanger-0.0.3-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file iplocationchanger-0.0.3.tar.gz.

File metadata

  • Download URL: iplocationchanger-0.0.3.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for iplocationchanger-0.0.3.tar.gz
Algorithm Hash digest
SHA256 016201bb32918950902df2eb5dff828a3e66ea8223bb7420987cb58fcb918ebf
MD5 f78c6e670a36361ec7f6b897e9019fac
BLAKE2b-256 3b6ce56546a6a5afbb8ddb4e490bfec8111f13db7e9e6c510a8351d143431eda

See more details on using hashes here.

File details

Details for the file iplocationchanger-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for iplocationchanger-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a27bd8234e50521761233c8afebe612192893c33aa3a31498bd49dfe62eda828
MD5 dffc7342ca4d75d8f876b302e59762ed
BLAKE2b-256 f0a73b3e752e78b30f2336f2dee417c1b9bb0d023c536c85cf5a445ae24ab77e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page