Skip to content

Commit 9aa73fb

Browse files
committed
Make Stream::rewind() public for protocol detection
PreTlsProcess implementations need to put data back onto the stream when it doesn't match the expected protocol signature. This lets the PROXY protocol handler rewind non-PROXY data so TLS proceeds normally.
1 parent b3d1960 commit 9aa73fb

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

pingora-core/src/protocols/l4/stream.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,11 @@ impl Stream {
445445
Ok(())
446446
}
447447

448-
/// Put Some data back to the head of the stream to be read again
449-
pub(crate) fn rewind(&mut self, data: &[u8]) {
448+
/// Put some data back to the head of the stream to be read again.
449+
///
450+
/// This is useful when you've read data to detect a protocol (e.g., PROXY protocol)
451+
/// but the data wasn't what you expected, so you need to "unread" it.
452+
pub fn rewind(&mut self, data: &[u8]) {
450453
if !data.is_empty() {
451454
self.rewind_read_buf.push(data.to_vec());
452455
}

0 commit comments

Comments
 (0)