proxy-wasm-rust-sdk icon indicating copy to clipboard operation
proxy-wasm-rust-sdk copied to clipboard

Question: How to filter on non-HTTP TCP packets.

Open Galgamins opened this issue 2 years ago • 1 comments

Hi. I'm trying to figure out how to create an envoy filter in Rust for non-HTTP TCP packets, specifically the client hello of the TLS handshake. I don't see any functions in the ABI for that, is that not supported? Or any L3/L4 in general?

Galgamins avatar Oct 26 '23 21:10 Galgamins

impl StreamContext for HttpBody {
    fn on_downstream_data(&mut self, _data_size: usize, _end_of_stream: bool) -> Action {
        if let Some(data) = self.get_downstream_data(0, _data_size) {
            if let Ok(packet) = std::str::from_utf8(&data) {
                let _ = proxy_wasm::hostcalls::log(LogLevel::Debug, packet);
            } else {
                info!("data is not utf8");
            }
        }

        Action::Continue
    }

    fn on_upstream_data(&mut self, _data_size: usize, _end_of_stream: bool) -> Action {
        info!("获取到上游数据");
        Action::Continue
    }
}

Use StreamContext

liuxuzxx avatar Aug 30 '24 05:08 liuxuzxx