Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

udp打洞穿透nat实现p2p GitHub - pannzh/P2P-Over-MiddleBoxes-Demo: A simple demo of P2P communication over middle boxes such as NAT

P2P-Over-MiddleBoxes-Demo

一个简单的P2P通信示例

English README

p2pchat

一个P2P聊天程序,使用UDP打洞创建链接。

编译

    make p2pchat

运行

    ./p2pchat/server 

./p2pchat/client :
>>> help

测试:

编译

    make test

运行

    ./run_test.sh

常见问题

通信不正常/打洞不成功?

该UDP打洞示例仅支持锥形地址转换器(Cone NAT),如果两个客户端都在同一个公网结点下,需要确保出口路由器支持 回环传输(LOOPBACK TRANSMISSION)

我咋知道我的NAT是什么类型?

在 stun目录下有个简单的Python脚本,用RFC3489(经典STUN协议)的示例来检测NAT类型。 运行:

    cd stun
python3 classic_stun_client.py [本地IP]

运行结果示例如下:

    INFO:root:running test I with stun.ideasip.com:3478
INFO:root:MAPPED_ADDRESS: 220.181.57.217:46208
INFO:root:running test II with stun.ideasip.com:3478
INFO:root:running test I with 217.116.122.138:3479
INFO:root:MAPPED_ADDRESS: 220.181.57.217:2732
NAT_TYPE: Symmetric NAT

相关介绍文章

  • https://evilpan.com/2015/10/31/p2p-over-middle-box/

注: 本项目只是一个简单的UDP打洞示例,如果想构建成熟的P2P应用,可以接着参考STUN/TURN以及ICE等协议。



This post first appeared on IT瘾 | IT社区推荐资讯, please read the originial post: here

Share the post

udp打洞穿透nat实现p2p GitHub - pannzh/P2P-Over-MiddleBoxes-Demo: A simple demo of P2P communication over middle boxes such as NAT

×

Subscribe to It瘾 | It社区推荐资讯

Get updates delivered right to your inbox!

Thank you for your subscription

×