使用STUN(简单UDP通过NAT的网络穿越)发现外部IP地址和NAT拓扑。
项目描述
使用STUN(简单UDP通过NAT的网络穿越)发现外部IP地址和NAT拓扑。
PyNAT遵循RFC 3489,并受名为PyStun的类似Python 2.x程序的启发。PyNAT支持Python 2.7及更高版本。
安装
PyNAT需要Python 2.7或更高版本。
从PyPI
通过命令行运行pip3 install pynat来安装PyNAT。
从GitHub
克隆或下载git仓库,导航到目录,然后运行
python3 setup.py sdist cd dist pip3 install pynat-<version>.tar.gz
用法
要获取有关网络拓扑和使用的内部IP/端口的详细信息,请运行pynat
Network type: UDP Firewall Internal address: 127.0.0.1:54320 External address: 127.0.0.1:54320
运行pynat -h 或 pynat --help 获取更多选项
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.
要在Python shell或项目中使用PyNAT
from pynat import get_ip_info topology, ext_ip, ext_port = get_ip_info()
要获取有关内部IP的详细信息,如果未知
topology, ext_ip, ext_port, int_ip = get_ip_info(include_internal=True)
开发
PyNAT版本功能基于主版本.次版本.修订号.[开发版本]模型。只有稳定、非开发版本将发布到PyPI。因为PyNAT仍然是一个测试项目,主版本的增量将是0。次版本增量代表新功能。修订号增量代表使用现有功能修复的问题。
项目详情
关闭
pynat-0.7.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 96168d472b7abc47c348cd4f6c4c1f13180bdc8c796918b1e98b4de9d0a59ede |
|
MD5 | 87e6e326e3ebff9664d0db7bab294ce6 |
|
BLAKE2b-256 | ffdbddaa52e3df42415231cbaf1d2f10593072cddf8317d743c5bb05fba2c2fb |