Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aarant/pynat
Discover external IP addresses and NAT topologies using STUN.
https://github.com/aarant/pynat
nat-traversal python python-3 stun
Last synced: 14 days ago
JSON representation
Discover external IP addresses and NAT topologies using STUN.
- Host: GitHub
- URL: https://github.com/aarant/pynat
- Owner: aarant
- License: mit
- Created: 2018-02-22T03:29:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-21T02:18:02.000Z (over 2 years ago)
- Last Synced: 2024-12-10T10:03:50.979Z (24 days ago)
- Topics: nat-traversal, python, python-3, stun
- Language: Python
- Size: 16.6 KB
- Stars: 74
- Watchers: 1
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
.. |pypi| image:: https://img.shields.io/pypi/v/pynat.svg
.. _pypi: https://pypi.python.org/pypi/pynat
.. |license| image:: https://img.shields.io/github/license/arantonitis/pynat.svg
.. _license: https://github.com/arantonitis/pynat/tree/master/LICENSEPyNAT
*****
|pypi|_ |license|_Discover external IP addresses and NAT topologies using STUN (Simple Traversal of UDP Through Network Address Translators).
PyNAT follows `RFC 3489`_, and is inspired by a similar program for
Python 2.x called PyStun_. PyNAT supports Python 2.7 and later... _RFC 3489: https://tools.ietf.org/html/rfc3489
.. _PyStun: https://github.com/jtriley/pystunInstallation
============
PyNAT requires Python 2.7 or later.From PyPI
---------
Install PyNAT by running ``pip3 install pynat`` from the command line... note::
On some Linux systems, installation may require running pip with root permissions, or running ``pip3 install pynat --user``. The latter may require exporting `~/.local/bin` to PATH.
From GitHub
-----------
Clone or download the `git repo`_, navigate to the directory, and run::python3 setup.py sdist
cd dist
pip3 install pynat-.tar.gz
.. _git repo: https://github.com/arantonitis/pynatUsage
=====
To get information about the network topology and external IP/port used, run ``pynat``::Network type: UDP Firewall
Internal address: 127.0.0.1:54320
External address: 127.0.0.1:54320
Run ``pynat -h`` or ``pynat --help`` for more options::usage: pynat [-h] [--source_ip SOURCE_IP] [--source-port SOURCE_PORT]
[--stun-host STUN_HOST] [--stun-port STUN_PORT]PyNAT v0.0.0 Discover external IP addresses and NAT topologies using STUN.
Copyright (C) 2018 Ariel Antonitis. Licensed under the MIT License.optional arguments:
-h, --help show this help message and exit
--source_ip SOURCE_IP
The source IPv4/IPv6 address to bind to.
--source-port SOURCE_PORT
The source port to bind to.
--stun-host STUN_HOST
The STUN host to use for queries.
--stun-port STUN_PORT
The port of the STUN host to use for queries.
To use PyNAT inside a Python shell or project::from pynat import get_ip_info
topology, ext_ip, ext_port = get_ip_info()
To also get information about the internal IP, if unknown::topology, ext_ip, ext_port, int_ip = get_ip_info(include_internal=True)
Development
===========
PyNAT versioning functions on a ``MAJOR.MINOR.PATCH.[DEVELOP]`` model. Only stable, non development releases will be published to PyPI. Because PyNAT is still a beta project, the ``MAJOR`` increment will be 0. Minor increments represent new features. Patch increments represent problems fixed with existing features.