feat: pass error over response of ping and StartWorkConn
This commit is contained in:
parent
a4a3d16570
commit
52bbfc089c
@ -159,6 +159,11 @@ func (ctl *Control) HandleReqWorkConn(inMsg *msg.ReqWorkConn) {
|
||||
workConn.Close()
|
||||
return
|
||||
}
|
||||
if startMsg.Error != "" {
|
||||
xl.Error("StartWorkConn contains error: %s", startMsg.Error)
|
||||
workConn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
// dispatch this work connection to related proxy
|
||||
ctl.pm.HandleWorkConn(startMsg.ProxyName, workConn, &startMsg)
|
||||
@ -319,6 +324,11 @@ func (ctl *Control) msgHandler() {
|
||||
case *msg.NewProxyResp:
|
||||
ctl.HandleNewProxyResp(m)
|
||||
case *msg.Pong:
|
||||
if m.Error != "" {
|
||||
xl.Error("Pong contains error: %s", m.Error)
|
||||
ctl.conn.Close()
|
||||
return
|
||||
}
|
||||
ctl.lastPong = time.Now()
|
||||
xl.Debug("receive heartbeat from server")
|
||||
}
|
||||
|
@ -462,11 +462,16 @@ func (ctl *Control) manager() {
|
||||
case *msg.Ping:
|
||||
if err := ctl.authVerifier.VerifyPing(m); err != nil {
|
||||
xl.Warn("received invalid ping: %v", err)
|
||||
ctl.sendCh <- &msg.Pong{
|
||||
Error: "invalid authentication in ping",
|
||||
}
|
||||
return
|
||||
}
|
||||
ctl.lastPing = time.Now()
|
||||
xl.Debug("receive heartbeat")
|
||||
ctl.sendCh <- &msg.Pong{}
|
||||
ctl.sendCh <- &msg.Pong{
|
||||
Error: "",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ func (pxy *BaseProxy) GetWorkConnFromPool(src, dst net.Addr) (workConn net.Conn,
|
||||
SrcPort: uint16(srcPort),
|
||||
DstAddr: dstAddr,
|
||||
DstPort: uint16(dstPort),
|
||||
Error: "",
|
||||
})
|
||||
if err != nil {
|
||||
xl.Warn("failed to send message to work connection from pool: %v, times: %d", err, i)
|
||||
|
@ -438,6 +438,9 @@ func (svr *Service) RegisterWorkConn(workConn net.Conn, newMsg *msg.NewWorkConn)
|
||||
// Check auth.
|
||||
if err := svr.authVerifier.VerifyNewWorkConn(newMsg); err != nil {
|
||||
xl.Warn("Invalid authentication in NewWorkConn message on run id [%s]", newMsg.RunId)
|
||||
msg.WriteMsg(workConn, &msg.StartWorkConn{
|
||||
Error: "invalid authentication in NewWorkConn",
|
||||
})
|
||||
return
|
||||
}
|
||||
ctl.RegisterWorkConn(workConn)
|
||||
|
Loading…
Reference in New Issue
Block a user