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:
1 parent
870a5832ea
commit
d477cbfee9
1 file changed
+1
-1
@@ -412,7 +412,7 @@ func (s *Server) handleConnection(conn net.Conn) {
|
|||||||
// Hard cap on unparsed inbound bytes (memory-DoS guard). A peer
|
// Hard cap on unparsed inbound bytes (memory-DoS guard). A peer
|
||||||
// that sends bytes that never assemble into a complete packet can
|
// that sends bytes that never assemble into a complete packet can
|
||||||
// otherwise grow this buffer without bound.
|
// 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.logger.Warn("Inbound buffer exceeded %d bytes from ip=%s conn=%d — closing",
|
||||||
s.config.MaxBufferedBytes, ctx.GetPeerIP(), ctx.ID)
|
s.config.MaxBufferedBytes, ctx.GetPeerIP(), ctx.ID)
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in new issue
Block a user