惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - toong

envoy DDOS HTTP/2 Bomb CVE-2026-47774 安全漏洞分析 python运行虚拟化环境 大模型从0到1 绑定网卡中断后是否需要设置RFS linux socket reuse port 小测试 现代C++ envoy timeout 说明 观察中断的脚本 /proc/interrupts openssl查看编译时选项设置的方法 内核ipsec转发优化方法 提高ipsec多核并行能力的优化方法之一 tc qdisc 的burst如何设置 bash模拟netstat取值的脚本 linux内核对MSI网卡队列的smp_affinity亲和CPU选择 bash多并发--进程池数量控制 bash单例模式 linux 分析中断 linux 查看 ipsec 丢包 linux内核rps与rfs机制分析 linux获取CPU利用率的快捷命令 开启openssl legacy的方法
P2P与FRP与websocket
toong · 2026-04-15 · via 博客园 - toong

P2P是什么

peer to peer, 点对点,去中心化。

圆锥型NAT是什么

类型

规则

比喻

对P2P打洞的友好度

完全圆锥型NAT

映射建立后,任何外部IP和端口都能通过该映射访问内网主机。

你家开了一扇固定的门(公网端口),全世界任何人都能进来

极高,是P2P最理想的环境。

受限圆锥型NAT

只允许曾经收到过内网主机数据包的外部IP(不限端口)访问。内主机给外部IP A发过包,则 A的任何端口都能访问回来。

你给某人寄过信,他就获得了你家门的钥匙,但他全家(所有端口)都能用这把钥匙。

,打洞成功的关键是双方需要先向对方“发个包”来获得访问权限。

端口受限圆锥型NAT

最严格的圆锥型。只允许特定的外部IP:端口对访问。即内主机向外部 B:PortY发过包,则只有 B:PortY能访问回来。

你只允许特定的邮差(IP:端口)从你寄信的同一个门进来

特性

圆锥型NAT

对称型NAT

映射规则

基于内网(源)端口。同一内网源端口,无论发往何处,都使用同一个公网端口

基于目标(外部)地址。同一内网源端口,发往不同的外部地址,会被分配不同的公网端口

P2P可行性

支持。因为STUN服务器看到的公网端口,和对端连接时使用的端口是同一个。

通常不支持。设备B想连接A时,需要的端口是A与STUN通信的端口,但A与B通信时,NAT会分配一个全新的端口,导致“洞”对不上。

比喻

你有一个固定的个人信箱(公网端口),所有人都往这个信箱寄信。

你每次给不同的人寄信,邮局都给你一个全新的、仅限该收件人使用的临时信箱。别人不知道你下次会用哪个信箱。

WEB3是什么

基于p2p与区块链的下一代网络。 其核心还是“去中心化”。与20年前流行的bitTorrent不同,区块链与比特币,解决了其商业模式问题。

扩展阅读:filecoin

FRP

介绍

https://gofrp.org/zh-cn/

安装

server

docker pull ghcr.io/fatedier/frps:v0.68.0

client

docker pull ghcr.io/fatedier/frpc:v0.68.0

解压镜像

docker save ffc4ed8d13eb -o frpc.tar
cat manifest.json |jq -r '.[0].Layers[-1]'
tar xf blobs/sha256/2937107aa94bfd084e4176dd17fd14de08ace496fe3df7040001dd4772c679f5

文件树

image

运行

配置

tong@T27 ~/S/frp [SIGINT]> cat frps.toml 
bindPort = 7000
tong@T27 ~/S/frp> cat frpc.toml 
serverAddr = "172.17.0.1"
serverPort = 7000

[[proxies]]
name = "ssh"
type = "tcp"
localIP = "172.17.0.1"
localPort = 22
remotePort = 6000

启动

# 服务器
docker run -it --rm --name frps -v ./frps.toml:/frps.toml -p 7000:7000 -p 6000:6000 ghcr.io/fatedier/frps:v0.68.0 -c /frps.toml

#客户端
docker run -it --rm --name frpc -v ./frpc.toml:/frpc.toml ghcr.io/fatedier/frpc:v0.68.0 -c /frpc.toml

也可以解压出来直接运行

image

其他特性

frpc与frps之间可以设置传输层加密

[[proxies]]
name = "ssh"
type = "tcp"
localPort = 22
remotePort = 6000
transport.useEncryption = true
transport.useCompression = true

frpc与frps之间支持设置成quic

frpc与frps之间可以使用tls双向证书校验

frpc与frps之间可以配置健康检查

客户端支持server mode限速

服务端支持登陆插件

websocket

搭个小例子

mkdir ws
npm init -y
npm install ws
npm install wschat

最简的server例子

tong@T27 ~/S/f/ws> cat server.js
// minimal_server.js
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', ws => {
  console.log('新连接');
  ws.send('连接成功');
  
  ws.on('message', message => {
    console.log('收到:', message);
    ws.send(`回声: ${message}`);
  });
});

console.log('WebSocket服务器运行在 ws://localhost:8080');

运行server

运行client

wscat -c ws://localhost:8080

websocket报文

image

FRP配置websocket

 服务器管理页面

image

其他

image

只有圆锥形nat设备可以打洞

image