Skip to main content

Reliable IP location changer using OpenVPN and WhatIsMyIP

Project description

IP Location Changer

tests

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.1.0.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.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for iplocationchanger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b1a9a90818b209b348eaef7ebfb9c18e1f38e3b50f3dbafdbbc54378327bdd37
MD5 11c7f35b24312259e605a10bfca572b5
BLAKE2b-256 6e8a47ba28f7bcc5016d779b0bcac92a67612e730426188bdecd15c1cc0d995f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for iplocationchanger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fc120f383523d6b9ca9a9ab7f338c45dbd0f2e24fc04d3754369c47f7004b7b
MD5 b876149c02349b4f112f07da70c0107b
BLAKE2b-256 b8bad48076a53fdb220a7020035e4348066acfdd4238f5a17bf59646b6108b68

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