Update control.go

This commit is contained in:
Akkariin Meiko 2019-09-08 18:08:36 +08:00 committed by GitHub
parent 23d36090a0
commit 3df9338222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -428,6 +428,12 @@ func (ctl *Control) RegisterProxy(pxyMsg *msg.NewProxy) (remoteAddr string, err
return remoteAddr, err return remoteAddr, err
} }
// Load configures from NewProxy message and check.
pxyConf, err = config.NewProxyConfFromMsg(pxyMsg)
if err != nil {
return
}
if g.GlbServerCfg.EnableApi { if g.GlbServerCfg.EnableApi {
nowTime := time.Now().Unix() 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. // NewProxy will return a interface Proxy.
// In fact it create different proxies by different proxy type, we just call run() here. // 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) pxy, err := proxy.NewProxy(ctl.runId, ctl.rc, ctl.statsCollector, ctl.poolCount, workConn, pxyConf)
if err != nil { if err != nil {
return remoteAddr, err return remoteAddr, err
} }
err = ctl.pxyManager.Add(pxyMsg.ProxyName, pxy)
if err != nil {
return
}
// Check ports used number in each client // Check ports used number in each client
if g.GlbServerCfg.MaxPortsPerClient > 0 { 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.mu.Lock()
ctl.proxies[pxy.GetName()] = pxy ctl.proxies[pxy.GetName()] = pxy
ctl.mu.Unlock() ctl.mu.Unlock()