From 299bd7b5cb4fec1b82d92c64f3a59cc7a75e9823 Mon Sep 17 00:00:00 2001 From: fatedier Date: Thu, 29 Dec 2016 23:48:17 +0800 Subject: [PATCH] frps: fix panic caused by frps closing the nil channel, fix #205 --- src/models/server/config.go | 1 - src/models/server/server.go | 22 ++++++++++++++++++---- src/utils/version/version.go | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/models/server/config.go b/src/models/server/config.go index 9a4a82b..12f5824 100644 --- a/src/models/server/config.go +++ b/src/models/server/config.go @@ -405,7 +405,6 @@ func CreateProxy(s *ProxyServer) error { ProxyServers[s.Name] = s metric.SetProxyInfo(s.Name, s.Type, s.BindAddr, s.UseEncryption, s.UseGzip, s.PrivilegeMode, s.CustomDomains, s.Locations, s.ListenPort) - s.Init() return nil } diff --git a/src/models/server/server.go b/src/models/server/server.go index a6d7e4f..27590bf 100644 --- a/src/models/server/server.go +++ b/src/models/server/server.go @@ -83,6 +83,8 @@ func NewProxyServerFromCtlMsg(req *msg.ControlReq) (p *ProxyServer) { p.HostHeaderRewrite = req.HostHeaderRewrite p.HttpUserName = req.HttpUserName p.HttpPassWord = req.HttpPassWord + + p.Init() return } @@ -298,10 +300,22 @@ func (p *ProxyServer) Release() { l.Close() } } - close(p.ctlMsgChan) - close(p.workConnChan) - close(p.udpSenderChan) - close(p.closeChan) + if p.ctlMsgChan != nil { + close(p.ctlMsgChan) + p.ctlMsgChan = nil + } + if p.workConnChan != nil { + close(p.workConnChan) + p.workConnChan = nil + } + if p.udpSenderChan != nil { + close(p.udpSenderChan) + p.udpSenderChan = nil + } + if p.closeChan != nil { + close(p.closeChan) + p.closeChan = nil + } if p.CtlConn != nil { p.CtlConn.Close() } diff --git a/src/utils/version/version.go b/src/utils/version/version.go index f8c7582..97b1dc1 100644 --- a/src/utils/version/version.go +++ b/src/utils/version/version.go @@ -19,7 +19,7 @@ import ( "strings" ) -var version string = "0.9.1" +var version string = "0.9.2" func Full() string { return version