• NAT之stun确定nat类型


    NAT之确定nat类型

    下载安装twisted和zope
    http://twistedmatrix.com/trac/wiki/Downloads
    http://pypi.python.org/pypi/zope.interface/3.8.0#downloads

    下载stunclient
    http://code.google.com/p/stunclient/

    这里面有个stun子目录,说是用于发现NAT类型
    This code comes from Shtoom: http://divmod.org/projects/shtoom

    执行里面的stun.py,就会log一个文件,在我电脑上如下(很费解啊)

    01:23:30 [-] Log opened.
    01:23:30 [-] <class '__main__.TestStunDiscoveryProtocol'> starting on 5061
    01:23:30 [-] Starting protocol <__main__.TestStunDiscoveryProtocol object at 0x00EDB190>
    01:23:30 [-] startDiscover--localAddress is 0.0.0.0
    01:23:30 [-] localAddress is invalid!
    01:23:30 [-] resolving A.ROOT-SERVERS.NET
    01:23:30 [-] connecting UDP socket to 198.41.0.4
    01:23:30 [-] twisted.internet.protocol.DatagramProtocol starting on 57131
    01:23:30 [-] Starting protocol <twisted.internet.protocol.DatagramProtocol instance at 0x00EE3828>
    01:23:30 [-] connected UDP socket says 192.168.1.100
    01:23:30 [-] (Port 57131 Closed)
    01:23:30 [-] Stopping protocol <twisted.internet.protocol.DatagramProtocol instance at 0x00EE3828>
    01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
    01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
    01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
    01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
    01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
    01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
    01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
    01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
    01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
    01:23:30 [stun] got STUN response to None from ('213.192.59.75', 3478)
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] MAPPED-ADDRESS 116.48.48.225 14959
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] CHANGED-ADDRESS 213.192.59.93 3479
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] SOURCE-ADDRESS 213.192.59.75 3478
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
    01:23:30 [stun] ignoring belated STUN response to 'bcffaf59142c3cf2575d2fb6f06424' from ('213.192.59.75', 3478)
    01:23:30 [-] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
    01:23:30 [stun] ignoring belated STUN response to 'bcffaf59142c3cf2575d2fb6f06424' from ('213.192.59.75', 3478)
    01:23:30 [-] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
    01:23:30 [stun] got STUN response to '1fd789b6d02e4be456597e8be1df4a7a' from ('213.192.59.93', 3479)
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] MAPPED-ADDRESS 116.48.48.225 14959
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] CHANGED-ADDRESS 213.192.59.93 3479
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] SOURCE-ADDRESS 213.192.59.93 3479
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] calling handleStunState2b
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] 2b {'externalAddress': ('116.48.48.225', 14959), '_altStunAddress': ('213.192.59.93', 3479)}
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] STUN finished, results:
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] You're behind a <NatType FullCone>
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] and external address is ('116.48.48.225', 14959)
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] (Port 5061 Closed)
    01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] Stopping protocol <__main__.TestStunDiscoveryProtocol object at 0x00EDB190>
    01:23:30 [-] Main loop terminated.

  • 相关阅读:
    Go 工作空间 深度解析
    go语言中获取变量类型的三种方法
    go语言实现分布式对象存储系统之单体对象存储
    curl命令用法
    删除Git服务器文件但是保留本地文件
    pycharm之gitignore设置
    通过pycharm使用git
    python 有关datetime时间日期 以及时间戳转换
    Please, commit your changes or stash them before you can merge
    jinkins配置python虚拟环境
  • 原文地址:https://www.cnblogs.com/cutepig/p/2185702.html
Copyright © 2020-2023  润新知