Public IP address checker.
Project description
Package
pif
Description
Discovers your public IP address using pre-defined checkers (external services).
Installation
Install with latest stable version from PyPI
$ pip install pif
or install the latest stable version from source
$ pip install -e hg+https://bitbucket.org/barseghyanartur/pif@stable#egg=pif
or install into python path
$ python setup.py install
That’s all. See the Usage and examples section for more.
Usage and examples
Basic usage
Get public IP
>>> from pif import get_public_ip >>> get_public_ip()
Get public IP using preferred checker
>>> get_public_ip('whatismyip.com')
List available checkers
>>> from pif.utils import list_checkers >>> list_checkers()
Registering a custom IP checker
pif ships with a number of pre-defined public IP checkers. But you may extend it by defining your own ones as follows.
>>> from pif.base import BaseIPChecker, registry
>>>
>>> class MyPublicIPChecker(BaseIPChecker):
>>> uid = 'mypublicipchecker' # UID of the checker
>>>
>>> def get_public_ip(self):
>>> # Implement your logic
>>>
>>> registry.register(MyPublicIPChecker) # Register the checker
>>>
>>> get_public_ip('mypublicipchecker') # Get public IP using the preferred checker
License
GPL 2.0/LGPL 2.1
Support
For any issues contact me at the e-mail given in the Author section.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pif-0.4.tar.gz.
File metadata
- Download URL: pif-0.4.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0acf7d30bcdf41085f0c172a599cbbc404e56124bde71720cb54721defccd99b
|
|
| MD5 |
a763385be864abffcd18cdeda67832b6
|
|
| BLAKE2b-256 |
7c35471ac2512371ea9a7aec80c59d8026ee5d300e01c724af52b14b2ec54d7f
|