[PR #5212] [MERGED] client/proxy: unify work conn wrapping across all proxy types #5177

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

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/5212
Author: @fatedier
Created: 3/6/2026
Status: Merged
Merged: 3/6/2026
Merged by: @fatedier

Base: devHead: new


📝 Commits (2)

  • 5eab214 client/proxy: extract wrapWorkConn to deduplicate UDP/SUDP connection wrapping
  • 2f70a2c client/proxy: unify work conn wrapping with pooled compression for all proxy types

📊 Changes

3 files changed (+49 additions, -69 deletions)

View changed files

📝 client/proxy/proxy.go (+39 -25)
📝 client/proxy/sudp.go (+5 -22)
📝 client/proxy/udp.go (+5 -22)

📄 Description

Summary

  • Extract duplicated rate-limiting → encryption → compression wrapping from UDPProxy, SUDPProxy, and HandleTCPWorkConnection into a shared BaseProxy.wrapWorkConn method
  • Unify all proxy types to use WithCompressionFromPool (pooled) instead of mixed pooled/non-pooled compression
  • wrapWorkConn accepts encKey parameter so XTCP can pass its own secret key
  • TCP non-plugin path: defer recycleFn() ensures pool resources are returned after Join or on error
  • Plugin path: skip recycle (plugins may retain conn after Handle returns)
  • UDP/SUDP: skip recycle (goroutine lifecycle; objects GC'd safely per golib contract)

Changes

  1. client/proxy/proxy.go — new unified wrapWorkConn(conn, encKey) (io.ReadWriteCloser, func(), error); HandleTCPWorkConnection refactored to use it
  2. client/proxy/udp.go — uses wrapWorkConn + WrapReadWriteCloserToConn
  3. client/proxy/sudp.go — same as udp.go

Test plan

  • make build compiles both frps and frpc
  • go test ./client/... passes
  • Codex correctness review: no issues found
  • Codex design review: confirmed approach is safe

🔄 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/5212 **Author:** [@fatedier](https://github.com/fatedier) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@fatedier](https://github.com/fatedier) **Base:** `dev` ← **Head:** `new` --- ### 📝 Commits (2) - [`5eab214`](https://github.com/fatedier/frp/commit/5eab21476889f02ccb6da9cedb02383906faf3a7) client/proxy: extract wrapWorkConn to deduplicate UDP/SUDP connection wrapping - [`2f70a2c`](https://github.com/fatedier/frp/commit/2f70a2c905d51ff385ba6f86fefee135c3434937) client/proxy: unify work conn wrapping with pooled compression for all proxy types ### 📊 Changes **3 files changed** (+49 additions, -69 deletions) <details> <summary>View changed files</summary> 📝 `client/proxy/proxy.go` (+39 -25) 📝 `client/proxy/sudp.go` (+5 -22) 📝 `client/proxy/udp.go` (+5 -22) </details> ### 📄 Description ## Summary - Extract duplicated rate-limiting → encryption → compression wrapping from `UDPProxy`, `SUDPProxy`, and `HandleTCPWorkConnection` into a shared `BaseProxy.wrapWorkConn` method - Unify all proxy types to use `WithCompressionFromPool` (pooled) instead of mixed pooled/non-pooled compression - `wrapWorkConn` accepts `encKey` parameter so XTCP can pass its own secret key - TCP non-plugin path: `defer recycleFn()` ensures pool resources are returned after `Join` or on error - Plugin path: skip recycle (plugins may retain conn after `Handle` returns) - UDP/SUDP: skip recycle (goroutine lifecycle; objects GC'd safely per golib contract) ## Changes 1. `client/proxy/proxy.go` — new unified `wrapWorkConn(conn, encKey) (io.ReadWriteCloser, func(), error)`; `HandleTCPWorkConnection` refactored to use it 2. `client/proxy/udp.go` — uses `wrapWorkConn` + `WrapReadWriteCloserToConn` 3. `client/proxy/sudp.go` — same as udp.go ## Test plan - [x] `make build` compiles both frps and frpc - [x] `go test ./client/...` passes - [x] Codex correctness review: no issues found - [x] Codex design review: confirmed approach is safe --- <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:56:09 -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#5177
No description provided.