Overview

pif

Discovers your public IP address using pre-defined checkers (external services).

Installation

Install with latest stable version from PyPI

or install the latest stable version from source

or install into python path

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

Command line usage

It's possible to get your public IP address from command line using the pif.commands.get_public_ip module.

Example:(simple)
Example:(with preferred checked and verbose output)

License

GPL 2.0/LGPL 2.1

Support

For any issues contact me at the e-mail given in the Author section.

Author

Artur Barseghyan <artur.barseghyan@gmail.com>

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.