Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Galgamins opened this issue Oct 26, 2023 · 1 comment
Open

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

Galgamins opened this issue Oct 26, 2023 · 1 comment

Comments

@Galgamins
Copy link

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?

@liuxuzxx
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants