ethstats: set readlimit on ethstats server connection #26207 (#1450)

This prevents DoS when connected to a malicious ethstats server.

Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
Daniel Liu 2025-09-08 15:40:41 +08:00 committed by GitHub
parent 1bd4eaab88
commit 84e19a7b7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -57,6 +57,8 @@ const (
txChanSize = 4096
// chainHeadChanSize is the size of channel listening to ChainHeadEvent.
chainHeadChanSize = 10
messageSizeLimit = 15 * 1024 * 1024
)
type consensusEngine interface {
@ -129,6 +131,7 @@ type connWrapper struct {
}
func newConnectionWrapper(conn *websocket.Conn) *connWrapper {
conn.SetReadLimit(messageSizeLimit)
return &connWrapper{conn: conn}
}