From e580c7b6e62b1d756f55e157470cf47596b7a36d Mon Sep 17 00:00:00 2001 From: fatedier Date: Tue, 28 Jun 2016 00:55:30 +0800 Subject: [PATCH] all: release resources when proxy closed using privilege mode --- src/frp/models/server/config.go | 6 ++++++ src/frp/models/server/server.go | 4 ++++ 2 files changed, 10 insertions(+) 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() }