mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-29 00:46:16 +01:00
hub: add guard to WSConn.Ping to ensure no nil conn ptr
This commit is contained in:
@@ -111,6 +111,9 @@ func (ws *WsConn) Close(msg []byte) {
|
|||||||
|
|
||||||
// Ping sends a ping frame to keep the connection alive.
|
// Ping sends a ping frame to keep the connection alive.
|
||||||
func (ws *WsConn) Ping() error {
|
func (ws *WsConn) Ping() error {
|
||||||
|
if ws.conn == nil {
|
||||||
|
return gws.ErrConnClosed
|
||||||
|
}
|
||||||
ws.conn.SetDeadline(time.Now().Add(deadline))
|
ws.conn.SetDeadline(time.Now().Add(deadline))
|
||||||
return ws.conn.WritePing(nil)
|
return ws.conn.WritePing(nil)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user