feat(api): add endpoint to kick proxy by name

This commit is contained in:
2025-10-14 21:33:38 +08:00
parent ef96481f58
commit a76ba823ee
2 changed files with 54 additions and 0 deletions

View File

@@ -94,6 +94,28 @@ func (cm *ControlManager) Close() error {
return nil
}
// KickByProxyName finds the Control that manages the given proxy (tunnel) name and closes
// the entire control connection (disconnects the frpc). Returns an error if no such proxy is found.
func (cm *ControlManager) KickByProxyName(proxyName string) error {
cm.mu.RLock()
var target *Control
for _, ctl := range cm.ctlsByRunID {
ctl.mu.RLock()
_, ok := ctl.proxies[proxyName]
ctl.mu.RUnlock()
if ok {
target = ctl
break
}
}
cm.mu.RUnlock()
if target == nil {
return fmt.Errorf("no proxy found with name [%s]", proxyName)
}
return target.Close()
}
type Control struct {
// all resource managers and controllers
rc *controller.ResourceController