PyStun3
=======
A Python STUN client for getting NAT type and external IP. Supports Python
versions 2 and 3.
This project has been forked several times:
- `original project by gaohawk`_
- `taken over by jtriley`_
- `forked and patched to support py3 by zoumi`_
- and, finally, forked by `TalkIQ`_
PyStun follows `RFC 3489`_. A server following STUN-bis hasn't been found on
internet so RFC3489 is the only implementation.
Installation
------------
To install the latest version::
$ pip install pystun3
or download/clone the source and install manually using::
$ cd /path/to/pystun3/src
$ python setup.py install
If you're hacking on ``pystun3`` you should use the 'develop' command instead::
$ python setup.py develop
This will make a link to the sources inside your site-packages directory so
that any changes are immediately available for testing.
Usage
-----
From command line::
$ pystun3
NAT Type: Full Cone
External IP: <your-ip-here>
External Port: 54320
Pass --help for more options::
% pystun3 --help
usage: pystun3 [-h] [-d] [-H STUN_HOST] [-P STUN_PORT] [-i SOURCE_IP]
[-p SOURCE_PORT] [--version]
optional arguments:
-h, --help show this help message and exit
-d, --debug Enable debug logging (default: False)
-H STUN_HOST, --host STUN_HOST
STUN host to use (default: None)
-P STUN_PORT, --host-port STUN_PORT
STUN host port to use (default: 3478)
-i SOURCE_IP, --interface SOURCE_IP
network interface for client (default: 0.0.0.0)
-p SOURCE_PORT, --port SOURCE_PORT
port to listen on for client (default: 54320)
--version show program's version number and exit
From Python::
import stun
nat_type, external_ip, external_port = stun.get_ip_info()
This will rotate through an internal list of STUN servers until a response is
found. If no response is found you will get ``"Blocked"`` as the ``nat_type``
and ``None`` for ``external_ip`` and ``external_port``.
If you prefer to use a specific STUN server::
nat_type, external_ip, external_port = stun.get_ip_info(stun_host='stun.ekiga.net')
If you prefer to use a specific STUN server port::
nat_type, external_ip, external_port = stun.get_ip_info(stun_port=3478)
You may also specify the client interface and port that is used although this
is not needed::
sip = "0.0.0.0" # interface to listen on (all)
port = 54320 # port to listen on
nat_type, external_ip, external_port = stun.get_ip_info(sip, port)
Read the code for more details...
LICENSE
-------
MIT
.. _forked and patched to support py3 by zoumi: https://github.com/zoumi/pystun
.. _original project by gaohawk: http://code.google.com/p/pystun/
.. _RFC 3489: http://www.ietf.org/rfc/rfc3489.txt
.. _taken over by jtriley: https://github.com/jtriley/pystun
.. _TalkIQ: https://github.com/talkiq
Raw data
{
"_id": null,
"home_page": "https://github.com/Narlim/pystun3",
"name": "pystun3-fix",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "STUN NAT",
"author": "Narlim (original authors: gaohawk, Justin Riley)",
"author_email": "wangweimingooo@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/61/e9/c2158456fba87effa41047a4e58c283da0582c126dece92fa3d164a98152/pystun3-fix-1.0.1.tar.gz",
"platform": null,
"description": "PyStun3\n=======\nA Python STUN client for getting NAT type and external IP. Supports Python\nversions 2 and 3.\n\nThis project has been forked several times:\n\n- `original project by gaohawk`_\n- `taken over by jtriley`_\n- `forked and patched to support py3 by zoumi`_\n- and, finally, forked by `TalkIQ`_\n\nPyStun follows `RFC 3489`_. A server following STUN-bis hasn't been found on\ninternet so RFC3489 is the only implementation.\n\nInstallation\n------------\nTo install the latest version::\n\n $ pip install pystun3\n\nor download/clone the source and install manually using::\n\n $ cd /path/to/pystun3/src\n $ python setup.py install\n\nIf you're hacking on ``pystun3`` you should use the 'develop' command instead::\n\n $ python setup.py develop\n\nThis will make a link to the sources inside your site-packages directory so\nthat any changes are immediately available for testing.\n\nUsage\n-----\nFrom command line::\n\n $ pystun3\n NAT Type: Full Cone\n External IP: <your-ip-here>\n External Port: 54320\n\nPass --help for more options::\n\n % pystun3 --help\n usage: pystun3 [-h] [-d] [-H STUN_HOST] [-P STUN_PORT] [-i SOURCE_IP]\n [-p SOURCE_PORT] [--version]\n\n optional arguments:\n -h, --help show this help message and exit\n -d, --debug Enable debug logging (default: False)\n -H STUN_HOST, --host STUN_HOST\n STUN host to use (default: None)\n -P STUN_PORT, --host-port STUN_PORT\n STUN host port to use (default: 3478)\n -i SOURCE_IP, --interface SOURCE_IP\n network interface for client (default: 0.0.0.0)\n -p SOURCE_PORT, --port SOURCE_PORT\n port to listen on for client (default: 54320)\n --version show program's version number and exit\n\nFrom Python::\n\n import stun\n nat_type, external_ip, external_port = stun.get_ip_info()\n\nThis will rotate through an internal list of STUN servers until a response is\nfound. If no response is found you will get ``\"Blocked\"`` as the ``nat_type``\nand ``None`` for ``external_ip`` and ``external_port``.\n\nIf you prefer to use a specific STUN server::\n\n nat_type, external_ip, external_port = stun.get_ip_info(stun_host='stun.ekiga.net')\n\nIf you prefer to use a specific STUN server port::\n\n nat_type, external_ip, external_port = stun.get_ip_info(stun_port=3478)\n\nYou may also specify the client interface and port that is used although this\nis not needed::\n\n sip = \"0.0.0.0\" # interface to listen on (all)\n port = 54320 # port to listen on\n nat_type, external_ip, external_port = stun.get_ip_info(sip, port)\n\nRead the code for more details...\n\nLICENSE\n-------\nMIT\n\n.. _forked and patched to support py3 by zoumi: https://github.com/zoumi/pystun\n.. _original project by gaohawk: http://code.google.com/p/pystun/\n.. _RFC 3489: http://www.ietf.org/rfc/rfc3489.txt\n.. _taken over by jtriley: https://github.com/jtriley/pystun\n.. _TalkIQ: https://github.com/talkiq\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python STUN client for getting NAT type and external IP (RFC 3489)",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/Narlim/pystun3"
},
"split_keywords": [
"stun",
"nat"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "61e9c2158456fba87effa41047a4e58c283da0582c126dece92fa3d164a98152",
"md5": "d849b37324aab19bc8449ffd7077f8bb",
"sha256": "99622181d4a2c66115fa60f7b43053c6ad02725c34051e231edb9e477ebc3c43"
},
"downloads": -1,
"filename": "pystun3-fix-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "d849b37324aab19bc8449ffd7077f8bb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6225,
"upload_time": "2023-09-07T01:21:26",
"upload_time_iso_8601": "2023-09-07T01:21:26.681621Z",
"url": "https://files.pythonhosted.org/packages/61/e9/c2158456fba87effa41047a4e58c283da0582c126dece92fa3d164a98152/pystun3-fix-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-07 01:21:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Narlim",
"github_project": "pystun3",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"lcname": "pystun3-fix"
}