publicaddr


Namepublicaddr JSON
Version 0.14.1 PyPI version JSON
download
home_pagehttps://github.com/dmachard/python-publicaddr
SummaryGetting your public IP v4 and v6
upload_time2024-04-17 09:34:36
maintainerNone
docs_urlNone
authorDenis MACHARD
requires_pythonNone
licenseNone
keywords public ip dns http google akamai opendns cloudflare
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Testing](https://github.com/dmachard/python-publicaddr/workflows/Testing/badge.svg) ![Build](https://github.com/dmachard/python-publicaddr/workflows/Build/badge.svg) ![Publish](https://github.com/dmachard/python-publicaddr/workflows/Publish/badge.svg)

# What is this?

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Simple python module for getting your **public IP V4 and V6** from several providers in **random** mode with also several protocols (DNS, HTTPS and STUN).

Supported providers with IPv4 and IPv6:

- [x] Google (DNS & HTTP & STUN)
- [x] Cloudflare (DNS & HTTP)
- [x] OpenDNS (DNS)
- [x] Akamai (DNS & HTTP)
- [x] [Ipify](https://www.ipify.org/) (HTTP)
- [x] Icanhazip (HTTP)
- [x] [Matrix](https://www.matrix.org) (STUN)
- [x] [Framasoft](https://framasoft.org/) (STUN)
- [x] [Ifconfig.me](https://ifconfig.me/) (HTTP)

## Installation

![python 3.12.x](https://img.shields.io/badge/python%203.12.x-tested-blue) ![python 3.11.x](https://img.shields.io/badge/python%203.11.x-tested-blue) ![python 3.10.x](https://img.shields.io/badge/python%203.10.x-tested-blue)

This module can be installed from [pypi](https://pypi.org/project/publicaddr/) website

```bash
pip install publicaddr
```

## Lookup for IPv4 and v6

Lookup for your public IPs from random providers with DNS or HTTP protocols with 3 retries if no ips are returned.
This is the default behaviour of the `lookup` function.

```python
import publicaddr

publicaddr.lookup()
{'ip4': 'x.x.x.x', 'ip6': 'x:x:x:x:x:x:x:x', 'provider': 'opendns',
'proto': 'dns', 'duration': '0.037'}
```

## Lookup for public IP with specific protocol

Lookup for your public IPs from random DNS providers with specific protocol.

```python
import publicaddr

publicaddr.lookup(providers=publicaddr.DNS, retries=2)
{'ip4': 'x.x.x.x', 'ip6': 'x:x:x:x:x:x:x:x', 'provider': 'opendns',
'proto': 'dns', 'duration': '0.037'}
```

Default constants for transport protocol:

- `publicaddr.HTTPS`
- `publicaddr.DNS`
- `publicaddr.STUN`

## Get IPv4 or IPv6 only

Get your public IPv4 with default provider (Google with DNS protocol).

```python
import publicaddr

publicaddr.get(ip=publicaddr.IPv4)
{'ip': 'x.x.x.x', 'duration': '0.025'}
```

Default constants for IP version:

- `publicaddr.IPv4`
- `publicaddr.IPv6`

## Get IP with specific provider

Example to use the provider Cloudflare instead of the default one.

```python
import publicaddr

myip = publicaddr.get(provider=publicaddr.CLOUDFLARE, proto=publicaddr.DNS)
{'ip': 'x:x:x:x:x:x:x:x', 'duration': '0.020'}
```

Default constants for providers:

- `publicaddr.CLOUDFLARE`
- `publicaddr.GOOGLE`
- `publicaddr.OPENDNS`
- `publicaddr.AKAMAI`
- `publicaddr.IPIFY`
- `publicaddr.ICANHAZIP`
- `publicaddr.MATRIX`
- `publicaddr.FRAMASOFT`
- `publicaddr.MULLVAD` *(disabled by default in config because IPv6 is not supported)*
- `publicaddr.IFCONFIG_ME`

## Custom configuration

See the default [configuration file](../main/publicaddr/publicaddr.yml)

## For developpers

### Run from source

```bash
sudo apt install python3-venv
python3 -m venv venv
source venv/bin/activate
```

```bash
python3 -m pip install -r requirements.txt
python3 example.py
```

### Run test units

```bash
python3 -m unittest discover tests/
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dmachard/python-publicaddr",
    "name": "publicaddr",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "public ip dns http google akamai opendns cloudflare",
    "author": "Denis MACHARD",
    "author_email": "d.machard@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ba/d7/26d1ea37fc3dfff26d5e86aa7b861e341d8bc5124e1c7bf56b77b3ffc8dd/publicaddr-0.14.1.tar.gz",
    "platform": "any",
    "description": "![Testing](https://github.com/dmachard/python-publicaddr/workflows/Testing/badge.svg) ![Build](https://github.com/dmachard/python-publicaddr/workflows/Build/badge.svg) ![Publish](https://github.com/dmachard/python-publicaddr/workflows/Publish/badge.svg)\n\n# What is this?\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nSimple python module for getting your **public IP V4 and V6** from several providers in **random** mode with also several protocols (DNS, HTTPS and STUN).\n\nSupported providers with IPv4 and IPv6:\n\n- [x] Google (DNS & HTTP & STUN)\n- [x] Cloudflare (DNS & HTTP)\n- [x] OpenDNS (DNS)\n- [x] Akamai (DNS & HTTP)\n- [x] [Ipify](https://www.ipify.org/) (HTTP)\n- [x] Icanhazip (HTTP)\n- [x] [Matrix](https://www.matrix.org) (STUN)\n- [x] [Framasoft](https://framasoft.org/) (STUN)\n- [x] [Ifconfig.me](https://ifconfig.me/) (HTTP)\n\n## Installation\n\n![python 3.12.x](https://img.shields.io/badge/python%203.12.x-tested-blue) ![python 3.11.x](https://img.shields.io/badge/python%203.11.x-tested-blue) ![python 3.10.x](https://img.shields.io/badge/python%203.10.x-tested-blue)\n\nThis module can be installed from [pypi](https://pypi.org/project/publicaddr/) website\n\n```bash\npip install publicaddr\n```\n\n## Lookup for IPv4 and v6\n\nLookup for your public IPs from random providers with DNS or HTTP protocols with 3 retries if no ips are returned.\nThis is the default behaviour of the `lookup` function.\n\n```python\nimport publicaddr\n\npublicaddr.lookup()\n{'ip4': 'x.x.x.x', 'ip6': 'x:x:x:x:x:x:x:x', 'provider': 'opendns',\n'proto': 'dns', 'duration': '0.037'}\n```\n\n## Lookup for public IP with specific protocol\n\nLookup for your public IPs from random DNS providers with specific protocol.\n\n```python\nimport publicaddr\n\npublicaddr.lookup(providers=publicaddr.DNS, retries=2)\n{'ip4': 'x.x.x.x', 'ip6': 'x:x:x:x:x:x:x:x', 'provider': 'opendns',\n'proto': 'dns', 'duration': '0.037'}\n```\n\nDefault constants for transport protocol:\n\n- `publicaddr.HTTPS`\n- `publicaddr.DNS`\n- `publicaddr.STUN`\n\n## Get IPv4 or IPv6 only\n\nGet your public IPv4 with default provider (Google with DNS protocol).\n\n```python\nimport publicaddr\n\npublicaddr.get(ip=publicaddr.IPv4)\n{'ip': 'x.x.x.x', 'duration': '0.025'}\n```\n\nDefault constants for IP version:\n\n- `publicaddr.IPv4`\n- `publicaddr.IPv6`\n\n## Get IP with specific provider\n\nExample to use the provider Cloudflare instead of the default one.\n\n```python\nimport publicaddr\n\nmyip = publicaddr.get(provider=publicaddr.CLOUDFLARE, proto=publicaddr.DNS)\n{'ip': 'x:x:x:x:x:x:x:x', 'duration': '0.020'}\n```\n\nDefault constants for providers:\n\n- `publicaddr.CLOUDFLARE`\n- `publicaddr.GOOGLE`\n- `publicaddr.OPENDNS`\n- `publicaddr.AKAMAI`\n- `publicaddr.IPIFY`\n- `publicaddr.ICANHAZIP`\n- `publicaddr.MATRIX`\n- `publicaddr.FRAMASOFT`\n- `publicaddr.MULLVAD` *(disabled by default in config because IPv6 is not supported)*\n- `publicaddr.IFCONFIG_ME`\n\n## Custom configuration\n\nSee the default [configuration file](../main/publicaddr/publicaddr.yml)\n\n## For developpers\n\n### Run from source\n\n```bash\nsudo apt install python3-venv\npython3 -m venv venv\nsource venv/bin/activate\n```\n\n```bash\npython3 -m pip install -r requirements.txt\npython3 example.py\n```\n\n### Run test units\n\n```bash\npython3 -m unittest discover tests/\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Getting your public IP v4 and v6",
    "version": "0.14.1",
    "project_urls": {
        "Homepage": "https://github.com/dmachard/python-publicaddr"
    },
    "split_keywords": [
        "public",
        "ip",
        "dns",
        "http",
        "google",
        "akamai",
        "opendns",
        "cloudflare"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "425740afd6c0f37d688928288e4ff251b202d03e71c55615cf0229114cefe1c4",
                "md5": "81c262e17998c57653f3df349c3208f0",
                "sha256": "28ede5ce06dbe6d8dbe4a149572f608bff5bf3eb092829035ec25eaea58b33cf"
            },
            "downloads": -1,
            "filename": "publicaddr-0.14.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "81c262e17998c57653f3df349c3208f0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10536,
            "upload_time": "2024-04-17T09:34:35",
            "upload_time_iso_8601": "2024-04-17T09:34:35.449504Z",
            "url": "https://files.pythonhosted.org/packages/42/57/40afd6c0f37d688928288e4ff251b202d03e71c55615cf0229114cefe1c4/publicaddr-0.14.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bad726d1ea37fc3dfff26d5e86aa7b861e341d8bc5124e1c7bf56b77b3ffc8dd",
                "md5": "ee5ae36eb151cd0cb7e0b1dd03e1a7c7",
                "sha256": "fc6d98932abe0da7beda44375115c617d6f9213b30772368c45583a469752ac1"
            },
            "downloads": -1,
            "filename": "publicaddr-0.14.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ee5ae36eb151cd0cb7e0b1dd03e1a7c7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8883,
            "upload_time": "2024-04-17T09:34:36",
            "upload_time_iso_8601": "2024-04-17T09:34:36.644620Z",
            "url": "https://files.pythonhosted.org/packages/ba/d7/26d1ea37fc3dfff26d5e86aa7b861e341d8bc5124e1c7bf56b77b3ffc8dd/publicaddr-0.14.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 09:34:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dmachard",
    "github_project": "python-publicaddr",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "publicaddr"
}
        
Elapsed time: 0.30444s