diff --git a/src/frp/models/server/config.go b/src/frp/models/server/config.go index 8657ec6d..1d49c661 100644 --- a/src/frp/models/server/config.go +++ b/src/frp/models/server/config.go @@ -294,3 +294,9 @@ func CreateProxy(s *ProxyServer) error { ProxyServers[s.Name] = s return nil } + +func DeleteProxy(proxyName string) { + ProxyServersMutex.Lock() + defer ProxyServersMutex.Unlock() + delete(ProxyServers, proxyName) +} diff --git a/src/frp/models/server/server.go b/src/frp/models/server/server.go index ad855146..b15f5cfa 100644 --- a/src/frp/models/server/server.go +++ b/src/frp/models/server/server.go @@ -186,6 +186,10 @@ func (p *ProxyServer) Close() { p.CtlConn.Close() } } + // if the proxy created by PrivilegeMode, delete it when closed + if p.PrivilegeMode { + DeleteProxy(p.Name) + } p.Unlock() }