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

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - 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