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()
|
workConn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if startMsg.Error != "" {
|
||||||
|
xl.Error("StartWorkConn contains error: %s", startMsg.Error)
|
||||||
|
workConn.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// dispatch this work connection to related proxy
|
// dispatch this work connection to related proxy
|
||||||
ctl.pm.HandleWorkConn(startMsg.ProxyName, workConn, &startMsg)
|
ctl.pm.HandleWorkConn(startMsg.ProxyName, workConn, &startMsg)
|
||||||
@ -319,6 +324,11 @@ func (ctl *Control) msgHandler() {
|
|||||||
case *msg.NewProxyResp:
|
case *msg.NewProxyResp:
|
||||||
ctl.HandleNewProxyResp(m)
|
ctl.HandleNewProxyResp(m)
|
||||||
case *msg.Pong:
|
case *msg.Pong:
|
||||||
|
if m.Error != "" {
|
||||||
|
xl.Error("Pong contains error: %s", m.Error)
|
||||||
|
ctl.conn.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
ctl.lastPong = time.Now()
|
ctl.lastPong = time.Now()
|
||||||
xl.Debug("receive heartbeat from server")
|
xl.Debug("receive heartbeat from server")
|
||||||
}
|
}
|
||||||
|
@ -462,11 +462,16 @@ func (ctl *Control) manager() {
|
|||||||
case *msg.Ping:
|
case *msg.Ping:
|
||||||
if err := ctl.authVerifier.VerifyPing(m); err != nil {
|
if err := ctl.authVerifier.VerifyPing(m); err != nil {
|
||||||
xl.Warn("received invalid ping: %v", err)
|
xl.Warn("received invalid ping: %v", err)
|
||||||
|
ctl.sendCh <- &msg.Pong{
|
||||||
|
Error: "invalid authentication in ping",
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctl.lastPing = time.Now()
|
ctl.lastPing = time.Now()
|
||||||
xl.Debug("receive heartbeat")
|
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),
|
SrcPort: uint16(srcPort),
|
||||||
DstAddr: dstAddr,
|
DstAddr: dstAddr,
|
||||||
DstPort: uint16(dstPort),
|
DstPort: uint16(dstPort),
|
||||||
|
Error: "",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
xl.Warn("failed to send message to work connection from pool: %v, times: %d", err, i)
|
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.
|
// Check auth.
|
||||||
if err := svr.authVerifier.VerifyNewWorkConn(newMsg); err != nil {
|
if err := svr.authVerifier.VerifyNewWorkConn(newMsg); err != nil {
|
||||||
xl.Warn("Invalid authentication in NewWorkConn message on run id [%s]", newMsg.RunId)
|
xl.Warn("Invalid authentication in NewWorkConn message on run id [%s]", newMsg.RunId)
|
||||||
|
msg.WriteMsg(workConn, &msg.StartWorkConn{
|
||||||
|
Error: "invalid authentication in NewWorkConn",
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctl.RegisterWorkConn(workConn)
|
ctl.RegisterWorkConn(workConn)
|
||||||
|
Loading…
Reference in New Issue
Block a user