Struct sshpuffin::ssh::deframe::SshMessageDeframer
source · pub struct SshMessageDeframer {
pub frames: VecDeque<RawSshMessage>,
pub desynced: bool,
buf: Box<[u8; 35000]>,
used: usize,
}
Expand description
This deframer works to reconstruct SSH messages
from arbitrary-sized reads, buffering as necessary.
The input is read()
, the output is the frames
deque.
Fields§
§frames: VecDeque<RawSshMessage>
Completed frames for output.
desynced: bool
Set to true if the peer is not talking SSH, but some other protocol. The caller should abort the connection, because the deframer cannot recover.
buf: Box<[u8; 35000]>
A fixed-size buffer containing the currently-accumulating TLS message.
used: usize
What size prefix of buf
is used.
Implementations§
source§impl SshMessageDeframer
impl SshMessageDeframer
pub fn new() -> Self
sourcepub fn read(&mut self, rd: &mut dyn Read) -> Result<usize>
pub fn read(&mut self, rd: &mut dyn Read) -> Result<usize>
Read some bytes from rd
, and add them to our internal
buffer. If this means our internal buffer contains
full messages, decode them all.
sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Returns true if we have messages for the caller to process, either whole messages in our output queue or partial messages in our buffer.
sourcefn try_deframe_one(&mut self) -> BufferContents
fn try_deframe_one(&mut self) -> BufferContents
Does our buf
contain a full message? It does if it is big enough to
contain a header, and that header has a length which falls within buf
.
If so, deframe it and place the message onto the frames output queue.
fn buf_consume(&mut self, taken: usize)
Trait Implementations§
source§impl Default for SshMessageDeframer
impl Default for SshMessageDeframer
source§impl ProtocolMessageDeframer<SshProtocolTypes> for SshMessageDeframer
impl ProtocolMessageDeframer<SshProtocolTypes> for SshMessageDeframer
type OpaqueProtocolMessage = RawSshMessage
fn pop_frame(&mut self) -> Option<RawSshMessage>
fn read(&mut self, rd: &mut dyn Read) -> Result<usize>
Auto Trait Implementations§
impl Freeze for SshMessageDeframer
impl RefUnwindSafe for SshMessageDeframer
impl Send for SshMessageDeframer
impl Sync for SshMessageDeframer
impl Unpin for SshMessageDeframer
impl UnwindSafe for SshMessageDeframer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Tail, T> Prepend<T> for Tail
impl<Tail, T> Prepend<T> for Tail
§type PreprendResult = Tail
type PreprendResult = Tail
TupleList
], of an [Prepend::prepend()
] call,
including the prepended entry.