Fix: Treat a zero MaxBufferedBytes as disabled

Consistent with the per-IP limits, a zero cap now means "no limit" instead
of closing every connection after its first byte, so a Config built from
zero values cannot wedge the listener.

Co-Authored-By: deepseek-v4-pro
This commit is contained in:
yuanyuanxianganddeepseek-v4-pro committed 2026-10-13 16:28:13 +02:00
1 parent 870a5832ea
commit d477cbfee9
1 file changed
+1 -1
+1 -1
View File
@@ -412,7 +412,7 @@ func (s *Server) handleConnection(conn net.Conn) {
// Hard cap on unparsed inbound bytes (memory-DoS guard). A peer
// that sends bytes that never assemble into a complete packet can
// otherwise grow this buffer without bound.
if ctx.InBuffer.Len() > s.config.MaxBufferedBytes {
if s.config.MaxBufferedBytes > 0 && ctx.InBuffer.Len() > s.config.MaxBufferedBytes {
s.logger.Warn("Inbound buffer exceeded %d bytes from ip=%s conn=%d — closing",
s.config.MaxBufferedBytes, ctx.GetPeerIP(), ctx.ID)
break