ethstats: ethstats pong reply mangles any ping substring in the nonce

if a ping payload's nonce contain ping, the pong is malformed
This commit is contained in:
Weixie Cui 2026-05-30 00:19:53 +08:00
parent 95320ffe69
commit 23e2a5573c

View file

@ -388,7 +388,7 @@ func (s *Service) readLoop(conn *connWrapper) {
// If the network packet is a system ping, respond to it directly
var ping string
if err := json.Unmarshal(blob, &ping); err == nil && strings.HasPrefix(ping, "primus::ping::") {
if err := conn.WriteJSON(strings.ReplaceAll(ping, "ping", "pong")); err != nil {
if err := conn.WriteJSON(strings.Replace(ping, "primus::ping::", "primus::pong::", 1)); err != nil {
log.Warn("Failed to respond to system ping message", "err", err)
return
}