From 3df93382222d56fcc12c02ea7df1202be645496c Mon Sep 17 00:00:00 2001 From: Akkariin Meiko Date: Sun, 8 Sep 2019 18:08:36 +0800 Subject: [PATCH] Update control.go --- server/control.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/control.go b/server/control.go index 6d65ae7..b428e9b 100755 --- a/server/control.go +++ b/server/control.go @@ -428,6 +428,12 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy) (remoteAddr string, err return remoteAddr, err } + // Load configures from NewProxy message and check. + pxyConf, err = config.NewProxyConfFromMsg(pxyMsg) + if err != nil { + return + } + if g.GlbServerCfg.EnableApi { nowTime := time.Now().Unix() @@ -454,18 +460,17 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy) (remoteAddr string, err } } - // Load configures from NewProxy message and check. - pxyConf, err = config.NewProxyConfFromMsg(pxyMsg) - if err != nil { - return - } - // NewProxy will return a interface Proxy. // In fact it create different proxies by different proxy type, we just call run() here. pxy, err := proxy.NewProxy(ctl.runId, ctl.rc, ctl.statsCollector, ctl.poolCount, workConn, pxyConf) if err != nil { return remoteAddr, err } + + err = ctl.pxyManager.Add(pxyMsg.ProxyName, pxy) + if err != nil { + return + } // Check ports used number in each client if g.GlbServerCfg.MaxPortsPerClient > 0 { @@ -497,11 +502,6 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy) (remoteAddr string, err } }() - err = ctl.pxyManager.Add(pxyMsg.ProxyName, pxy) - if err != nil { - return - } - ctl.mu.Lock() ctl.proxies[pxy.GetName()] = pxy ctl.mu.Unlock()