[PR #2901] [CLOSED] Nathole #4655

Closed
opened 2026-05-05 14:46:13 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/2901
Author: @shangweixiao
Created: 4/20/2022
Status: Closed

Base: devHead: nathole


📝 Commits (2)

  • 9d4c96e optimize NAT hole,support symmetric NAT
  • 958a4a2 fixed a spelling error

📊 Changes

11 files changed (+195 additions, -67 deletions)

View changed files

📝 client/proxy/proxy.go (+57 -26)
📝 client/visitor.go (+54 -19)
📝 cmd/frpc/sub/root.go (+1 -0)
📝 cmd/frpc/sub/xtcp.go (+3 -0)
📝 go.mod (+1 -0)
📝 go.sum (+2 -0)
📝 pkg/config/proxy.go (+7 -3)
📝 pkg/config/visitor.go (+4 -1)
📝 pkg/msg/msg.go (+8 -4)
📝 pkg/nathole/nathole.go (+35 -14)
📝 pkg/util/util/util.go (+23 -0)

📄 Description

ref:#1795 #2376
使用XTCP进行NAT穿透,当对方是Symmetric NAT时不能复用对方与服务器之间的端口进行通信,这是Symmetric NAT的限制,因此目前XTCP成功率较低。但如果双方均是Symmetric NAT则肯定无法进行穿透。
穿透流程:

  1. 客户端启动时通过STUN检测自己所在网络的NAT类型。
  2. 将自己的NAT发送给服务器。
  3. 服务器将双方的NAT类型通知双方。
  4. 如果对方是Symmetric NAT,向对方不同端口上发送数据包进行探测。目前是固定探测对方与服务器通信端口前后各2000个端口,有非常大的成功率。

另外,支持在配置文件中使用stun_server配置STUN服务器,默认使用stun.voipstunt.com:3478。针对STUN检测较慢的现象,代码进行了优化,启动时只操作一次,也可以设置 stun_server = disable 禁用STUN。


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fatedier/frp/pull/2901 **Author:** [@shangweixiao](https://github.com/shangweixiao) **Created:** 4/20/2022 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `nathole` --- ### 📝 Commits (2) - [`9d4c96e`](https://github.com/fatedier/frp/commit/9d4c96e2526b0ec93f8532d7ecdcaec56cd24f58) optimize NAT hole,support symmetric NAT - [`958a4a2`](https://github.com/fatedier/frp/commit/958a4a225f079e20613a36c55e5f7cd1ae16253e) fixed a spelling error ### 📊 Changes **11 files changed** (+195 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `client/proxy/proxy.go` (+57 -26) 📝 `client/visitor.go` (+54 -19) 📝 `cmd/frpc/sub/root.go` (+1 -0) 📝 `cmd/frpc/sub/xtcp.go` (+3 -0) 📝 `go.mod` (+1 -0) 📝 `go.sum` (+2 -0) 📝 `pkg/config/proxy.go` (+7 -3) 📝 `pkg/config/visitor.go` (+4 -1) 📝 `pkg/msg/msg.go` (+8 -4) 📝 `pkg/nathole/nathole.go` (+35 -14) 📝 `pkg/util/util/util.go` (+23 -0) </details> ### 📄 Description ref:#1795 #2376 使用XTCP进行NAT穿透,当对方是Symmetric NAT时不能复用对方与服务器之间的端口进行通信,这是Symmetric NAT的限制,因此目前XTCP成功率较低。但如果双方均是Symmetric NAT则肯定无法进行穿透。 穿透流程: 1. 客户端启动时通过STUN检测自己所在网络的NAT类型。 2. 将自己的NAT发送给服务器。 3. 服务器将双方的NAT类型通知双方。 4. 如果对方是Symmetric NAT,向对方不同端口上发送数据包进行探测。目前是固定探测对方与服务器通信端口前后各2000个端口,有非常大的成功率。 另外,支持在配置文件中使用stun_server配置STUN服务器,默认使用stun.voipstunt.com:3478。针对STUN检测较慢的现象,代码进行了优化,启动时只操作一次,也可以设置 stun_server = disable 禁用STUN。 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 14:46:13 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#4655
No description provided.