mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 16:15:49 -06:00
[PR #5228] [CLOSED] server/plugin: add CloseUserConn operation to server plugin system #5192
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#5192
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fatedier/frp/pull/5228
Author: @xb-bxy
Created: 3/10/2026
Status: ❌ Closed
Base:
dev← Head:feat/close-user-conn📝 Commits (2)
67922ccfeat: add CloseUserConn operation and related plugin management8fe0f8bfeat: add CloseUserConn test cases for plugin server📊 Changes
7 files changed (+161 additions, -19 deletions)
View changed files
📝
pkg/config/v1/validation/validation.go(+1 -0)📝
pkg/plugin/server/manager.go(+42 -12)📝
pkg/plugin/server/plugin.go(+7 -6)📝
pkg/plugin/server/types.go(+7 -0)📝
server/proxy/proxy.go(+10 -1)📝
test/e2e/legacy/plugin/server.go(+46 -0)📝
test/e2e/v1/plugin/server.go(+48 -0)📄 Description
WHY --> Feature Request
When a user connection is accepted, the
NewUserConnplugin operation is triggered. However, there is no corresponding lifecycle hook when the user connection is closed. This makes it impossible for plugins to track connection duration, perform cleanup, emit metrics per connection, or audit user session end-events.Without
CloseUserConn, plugins have no way to know when a proxied user connection has terminated.Changes
OpCloseUserConn = "CloseUserConn"operation constant to the plugin op setCloseUserConnContentstruct (mirrorsNewUserConnContent) withuser,proxy_name,proxy_type, andremote_addrfieldscloseUserConnPlugins []Pluginfield toManagerand register plugins that supportOpCloseUserConnManager.CloseUserConn()method that fans out the event to all registered plugins (errors are collected and logged as warnings, not blocking)handleUserTCPConnection, add adeferthat callsCloseUserConnafter the user connection closes, passing the same content asNewUserConnworkConn = nilafterworkConn.Close()inGetWorkConnFromPool, and improve the closing log withuserConn.RemoteAddrServer Plugin Config Example
Plugin handler receives
CloseUserConnPOST request with body:Test plan
CloseUserConnop receives the event after each user connection closesCloseUserConnis not called (zero-cost fast path whencloseUserConnPluginsis empty)CloseUserConnerrors are logged as warnings and do not affect the data transfer resultNewUserConn→ data transfer →CloseUserConnlifecycle is correct end-to-endgo vet plugin.cleango buildcompiles cleanlygo test plugin.)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.