Skip to content

Commit 5d04989

Browse files
authored
dynamic_modules: add examples for network & listener modules (#52)
1 parent db78e3f commit 5d04989

11 files changed

Lines changed: 2662 additions & 4 deletions

rust/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
[package]
32
name = "envoy-proxy-dynamic-modules-rust-sdk-examples"
43
version = "0.1.0"
@@ -20,4 +19,4 @@ tempfile = "3.16.0"
2019
[lib]
2120
name = "rust_module"
2221
path = "src/lib.rs"
23-
crate-type = ["cdylib"]
22+
crate-type = ["cdylib", "rlib"]

rust/src/http_zero_copy_regex_waf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ mod tests {
126126
#[test]
127127
/// This demonstrates how to write a test without Envoy using a mock provided by the SDK.
128128
fn test_filter() {
129-
let mut filter_config = FilterConfig::new("Hello [Ww].+").unwrap();
129+
let filter_config = FilterConfig::new("Hello [Ww].+").unwrap();
130130
let mut envoy_filter = MockEnvoyHttpFilter::new();
131131
let mut filter: Box<dyn HttpFilter<MockEnvoyHttpFilter>> =
132132
filter_config.new_http_filter(&mut envoy_filter);

rust/src/lib.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,65 @@
1+
//! Envoy Dynamic Modules Rust SDK Examples
2+
//!
3+
//! This crate contains example implementations of Envoy dynamic modules using the Rust SDK.
4+
//!
5+
//! # HTTP Filters
6+
//!
7+
//! The main library exports HTTP filter examples that work with `declare_init_functions!`:
8+
//! - `passthrough` - A minimal filter that passes all data through unchanged.
9+
//! - `access_logger` - Logs request/response information.
10+
//! - `random_auth` - Randomly rejects requests (for testing).
11+
//! - `zero_copy_regex_waf` - Zero-copy regex-based WAF filter.
12+
//! - `header_mutation` - Adds/removes/modifies headers.
13+
//! - `metrics` - Collects request/response metrics.
14+
//!
15+
//! # Network Filters
16+
//!
17+
//! Network filter examples are provided as public modules. To use them, create a separate
18+
//! crate that includes this library and uses `declare_network_filter_init_functions!` with
19+
//! the module's `new_filter_config` function.
20+
//!
21+
//! Available network filters:
22+
//! - [`network_echo`] - Echoes data back to the client.
23+
//! - [`network_rate_limiter`] - Limits concurrent connections.
24+
//! - [`network_protocol_logger`] - Logs protocol information.
25+
//! - [`network_redis`] - Redis RESP protocol parser and command filter.
26+
//!
27+
//! # Listener Filters
28+
//!
29+
//! Listener filter examples are provided as public modules. To use them, create a separate
30+
//! crate that includes this library and uses `declare_listener_filter_init_functions!` with
31+
//! the module's `new_filter_config` function.
32+
//!
33+
//! Available listener filters:
34+
//! - [`listener_ip_allowlist`] - IP allowlist/blocklist filter.
35+
//! - [`listener_tls_detector`] - TLS protocol detection filter.
36+
//! - [`listener_sni_router`] - SNI-based routing filter.
37+
138
use envoy_proxy_dynamic_modules_rust_sdk::*;
239

40+
// HTTP filter examples.
341
mod http_access_logger;
442
mod http_header_mutation;
543
mod http_metrics;
644
mod http_passthrough;
745
mod http_random_auth;
846
mod http_zero_copy_regex_waf;
947

48+
// Network filter examples.
49+
// These modules can be used to create standalone network filter cdylibs.
50+
// See each module's documentation for usage instructions.
51+
pub mod network_echo;
52+
pub mod network_protocol_logger;
53+
pub mod network_rate_limiter;
54+
pub mod network_redis;
55+
56+
// Listener filter examples.
57+
// These modules can be used to create standalone listener filter cdylibs.
58+
// See each module's documentation for usage instructions.
59+
pub mod listener_ip_allowlist;
60+
pub mod listener_sni_router;
61+
pub mod listener_tls_detector;
62+
1063
declare_init_functions!(init, new_http_filter_config_fn);
1164

1265
/// This implements the [`envoy_proxy_dynamic_modules_rust_sdk::ProgramInitFunction`].

0 commit comments

Comments
 (0)