Class: ZZQ::Transport::MQTTS::LimitedStream
- Inherits:
-
IO::Stream::Buffered
- Object
- IO::Stream::Buffered
- ZZQ::Transport::MQTTS::LimitedStream
- Defined in:
- lib/zzq/transport/mqtts.rb
Overview
Buffered stream with a per-connection byte cap. When the cap is reached on either direction the underlying socket is closed and the next I/O raises — forcing the peer to reconnect and negotiate fresh keys before ChaCha20-Poly1305’s nonce counter approaches its unsafe range.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(io, limit = DATA_LIMIT) ⇒ LimitedStream
constructor
A new instance of LimitedStream.
Constructor Details
#initialize(io, limit = DATA_LIMIT) ⇒ LimitedStream
Returns a new instance of LimitedStream.
136 137 138 139 140 |
# File 'lib/zzq/transport/mqtts.rb', line 136 def initialize(io, limit = DATA_LIMIT) super(io) @limit = limit @bytes = 0 end |
Class Method Details
.wrap(io, limit: DATA_LIMIT) ⇒ Object
126 127 128 129 130 131 132 133 |
# File 'lib/zzq/transport/mqtts.rb', line 126 def self.wrap(io, limit: DATA_LIMIT) if io.respond_to?(:buffered=) io.buffered = false elsif io.respond_to?(:sync=) io.sync = true end new(io, limit) end |