Skip to content

Commit 78334c9

Browse files
committed
feat(l4): make Stream::rewind() public for protocol detection
Make the rewind() method public so that PreTlsProcess implementations can put data back onto the stream when the data doesn't match the expected protocol signature. This is needed for PROXY protocol detection where the pre-TLS handler reads initial bytes to check for the PROXY signature, and must rewind if the data is not PROXY protocol so TLS can proceed normally.
1 parent 45e6402 commit 78334c9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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)