[PR #5202] [MERGED] fix: close connections on error paths to prevent resource leaks #5168

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

📋 Pull Request Information

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

Base: devHead: new


📝 Commits (1)

  • 2fc4ef5 fix: close connections on error paths to prevent resource leaks

📊 Changes

6 files changed (+13 additions, -0 deletions)

View changed files

📝 client/proxy/proxy.go (+1 -0)
📝 client/visitor/sudp.go (+4 -0)
📝 client/visitor/xtcp.go (+2 -0)
📝 pkg/plugin/client/tls2raw.go (+2 -0)
📝 pkg/plugin/client/unix_domain_socket.go (+3 -0)
📝 server/proxy/http.go (+1 -0)

📄 Description

Summary

  • Fix connection/resource leaks in 7 error paths across 6 files
  • Each fix adds a missing Close() call before returning on error, preventing file descriptor and memory leaks

Fixed locations

File Leaked Resource Error Path
server/proxy/http.go tmpConn WithEncryption failure
client/proxy/proxy.go localConn ProxyProtocol WriteTo failure
client/visitor/sudp.go visitorConn 4 error paths in getNewVisitorConn
client/visitor/xtcp.go tunnelConn WithEncryption failure
client/visitor/xtcp.go lConn (UDP) NewKCPConnFromUDP failure
pkg/plugin/client/unix_domain_socket.go localConn WriteTo failure
pkg/plugin/client/tls2raw.go tlsConn TLS Handshake / Dial failure

Test plan

  • make build passes
  • make test passes
  • Codex review confirmed no correctness issues

🔄 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/5202 **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 (1) - [`2fc4ef5`](https://github.com/fatedier/frp/commit/2fc4ef5c1a9f063c9821433fddef4a870e47672e) fix: close connections on error paths to prevent resource leaks ### 📊 Changes **6 files changed** (+13 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `client/proxy/proxy.go` (+1 -0) 📝 `client/visitor/sudp.go` (+4 -0) 📝 `client/visitor/xtcp.go` (+2 -0) 📝 `pkg/plugin/client/tls2raw.go` (+2 -0) 📝 `pkg/plugin/client/unix_domain_socket.go` (+3 -0) 📝 `server/proxy/http.go` (+1 -0) </details> ### 📄 Description ## Summary - Fix connection/resource leaks in 7 error paths across 6 files - Each fix adds a missing `Close()` call before returning on error, preventing file descriptor and memory leaks ### Fixed locations | File | Leaked Resource | Error Path | |------|----------------|------------| | `server/proxy/http.go` | `tmpConn` | `WithEncryption` failure | | `client/proxy/proxy.go` | `localConn` | ProxyProtocol `WriteTo` failure | | `client/visitor/sudp.go` | `visitorConn` | 4 error paths in `getNewVisitorConn` | | `client/visitor/xtcp.go` | `tunnelConn` | `WithEncryption` failure | | `client/visitor/xtcp.go` | `lConn` (UDP) | `NewKCPConnFromUDP` failure | | `pkg/plugin/client/unix_domain_socket.go` | `localConn` | `WriteTo` failure | | `pkg/plugin/client/tls2raw.go` | `tlsConn` | TLS Handshake / Dial failure | ## Test plan - [x] `make build` passes - [x] `make test` passes - [x] Codex review confirmed no correctness issues --- <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:55:59 -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#5168
No description provided.