Skip to main content

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"
}

Metadata

Release files for iplocationchanger 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iplocationchanger 0.1.0
File Size Uploaded Provenance Actions
iplocationchanger-0.1.0.tar.gz 8.9 kB Without provenance Details for iplocationchanger-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for iplocationchanger 0.1.0
File Interpreter ABI Platform Actions
iplocationchanger-0.1.0-py3-none-any.whl Python 3 none any Details for iplocationchanger-0.1.0-py3-none-any.whl

Total release size: 19.9 kB

Release files / iplocationchanger-0.1.0.tar.gz

Download URL iplocationchanger-0.1.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b1a9a90818b209b348eaef7ebfb9c18e1f38e3b50f3dbafdbbc54378327bdd37
BLAKE2b-256 checksum
How to use checksums
6e8a47ba28f7bcc5016d779b0bcac92a67612e730426188bdecd15c1cc0d995f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / iplocationchanger-0.1.0-py3-none-any.whl

Download URL iplocationchanger-0.1.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fc120f383523d6b9ca9a9ab7f338c45dbd0f2e24fc04d3754369c47f7004b7b
BLAKE2b-256 checksum
How to use checksums
b8bad48076a53fdb220a7020035e4348066acfdd4238f5a17bf59646b6108b68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for iplocationchanger 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page