diff --git a/Dockerfile b/Dockerfile index f0efe09..956da1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ RUN CC="zig cc -target aarch64-linux-gnu" CXX="zig c++ -target aarch64-linux-gnu RUN CC="zig cc -target x86_64-linux-gnu" CXX="zig c++ -target x86_64-linux-gnu" CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o /build/amd64_libgo_module.so . ##### Build the final image ##### -FROM envoyproxy/envoy-dev:af61c6b2101e8c70281b661d2bd726115ae1da2d AS envoy +FROM envoyproxy/envoy:dev-78fc79f72c883549cd6b29db11e02e6fb74c63d0 AS envoy ARG TARGETARCH ENV ENVOY_DYNAMIC_MODULES_SEARCH_PATH=/usr/local/lib COPY --from=rust_builder /build/${TARGETARCH}_librust_module.so /usr/local/lib/librust_module.so diff --git a/ENVOY_VERSION b/ENVOY_VERSION index 0a3cda6..ded22bd 100644 --- a/ENVOY_VERSION +++ b/ENVOY_VERSION @@ -1 +1 @@ -af61c6b2101e8c70281b661d2bd726115ae1da2d \ No newline at end of file +78fc79f72c883549cd6b29db11e02e6fb74c63d0 \ No newline at end of file diff --git a/README.md b/README.md index ad5496c..82cc8e5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Dynamic Modules Examples -> Envoy Version: [af61c6b2101e8c70281b661d2bd726115ae1da2d] v1.36-dev +> Envoy Version: [78fc79f72c883549cd6b29db11e02e6fb74c63d0] v1.36-dev > > Since dynamic modules are tied with a specific Envoy version, this repository is based on the specific commit of Envoy. > For examples for a specific Envoy version, please check out `release/v` branches: @@ -89,6 +89,6 @@ If you want to explicitly specify the docker image, use `ENVOY_IMAGE` environmen ENVOY_IMAGE=foo-bar-image:latest go test . -v -count=1 ``` -[af61c6b2101e8c70281b661d2bd726115ae1da2d]: https://github.com/envoyproxy/envoy/tree/af61c6b2101e8c70281b661d2bd726115ae1da2d +[78fc79f72c883549cd6b29db11e02e6fb74c63d0]: https://github.com/envoyproxy/envoy/tree/78fc79f72c883549cd6b29db11e02e6fb74c63d0 [Envoy]: https://github.com/envoyproxy/envoy [High Level Doc]: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/dynamic_modules diff --git a/go/gosdk/abi.go b/go/gosdk/abi.go index b60e807..05bb38d 100644 --- a/go/gosdk/abi.go +++ b/go/gosdk/abi.go @@ -3,7 +3,7 @@ package gosdk // Following is a distillation of the Envoy ABI for dynamic modules: -// https://github.com/envoyproxy/envoy/blob/af61c6b2101e8c70281b661d2bd726115ae1da2d/source/extensions/dynamic_modules/abi.h +// https://github.com/envoyproxy/envoy/blob/78fc79f72c883549cd6b29db11e02e6fb74c63d0/source/extensions/dynamic_modules/abi.h // // Why not using the header file directly? That is because Go runtime complains // about passing pointers to C code on the boundary. In the following code, we replace @@ -161,8 +161,8 @@ import ( "unsafe" ) -// https://github.com/envoyproxy/envoy/blob/af61c6b2101e8c70281b661d2bd726115ae1da2d/source/extensions/dynamic_modules/abi_version.h -var version = append([]byte("c32cc7696650a6a54653327e6609734a8b32aeb5c80a6a664687636a0d671666"), 0) +// https://github.com/envoyproxy/envoy/blob/78fc79f72c883549cd6b29db11e02e6fb74c63d0/source/extensions/dynamic_modules/abi_version.h +var version = append([]byte("f2712929b605772d35c34d9ac8ccd7e168197a50951e9c96b64e03256bf80265"), 0) //export envoy_dynamic_module_on_program_init func envoy_dynamic_module_on_program_init() uintptr { diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 2705ce7..aa095d0 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -84,7 +84,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "envoy-proxy-dynamic-modules-rust-sdk" version = "0.1.0" -source = "git+https://github.com/envoyproxy/envoy?rev=af61c6b2101e8c70281b661d2bd726115ae1da2d#af61c6b2101e8c70281b661d2bd726115ae1da2d" +source = "git+https://github.com/envoyproxy/envoy?rev=78fc79f72c883549cd6b29db11e02e6fb74c63d0#78fc79f72c883549cd6b29db11e02e6fb74c63d0" dependencies = [ "bindgen", "mockall", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d188333..bef4e57 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/envoyproxy/dynamic-modules-example" [dependencies] # The SDK version must match the Envoy version due to the strict compatibility requirements. -envoy-proxy-dynamic-modules-rust-sdk = { git = "https://github.com/envoyproxy/envoy", rev = "af61c6b2101e8c70281b661d2bd726115ae1da2d" } +envoy-proxy-dynamic-modules-rust-sdk = { git = "https://github.com/envoyproxy/envoy", rev = "78fc79f72c883549cd6b29db11e02e6fb74c63d0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" rand = "0.9.0" diff --git a/rust/src/http_access_logger.rs b/rust/src/http_access_logger.rs index ecb695f..e98a0e0 100644 --- a/rust/src/http_access_logger.rs +++ b/rust/src/http_access_logger.rs @@ -75,9 +75,9 @@ impl FilterConfig { } } -impl HttpFilterConfig for FilterConfig { +impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EC) -> Box> { + fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { let tx = self.tx.clone(); Box::new(Filter { tx, diff --git a/rust/src/http_header_mutation.rs b/rust/src/http_header_mutation.rs index f00e8eb..af3fabc 100644 --- a/rust/src/http_header_mutation.rs +++ b/rust/src/http_header_mutation.rs @@ -29,9 +29,9 @@ impl FilterConfig { } } -impl HttpFilterConfig for FilterConfig { +impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EC) -> Box> { + fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { Box::new(Filter { request_headers: self.request_headers.clone(), remove_request_headers: self.remove_request_headers.clone(), diff --git a/rust/src/http_passthrough.rs b/rust/src/http_passthrough.rs index bc17a89..91d51c2 100644 --- a/rust/src/http_passthrough.rs +++ b/rust/src/http_passthrough.rs @@ -19,9 +19,9 @@ impl FilterConfig { } } -impl HttpFilterConfig for FilterConfig { +impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EC) -> Box> { + fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { Box::new(Filter {}) } } diff --git a/rust/src/http_random_auth.rs b/rust/src/http_random_auth.rs index 357640f..3d697f5 100644 --- a/rust/src/http_random_auth.rs +++ b/rust/src/http_random_auth.rs @@ -16,9 +16,9 @@ impl FilterConfig { } } -impl HttpFilterConfig for FilterConfig { +impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EC) -> Box> { + fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { Box::new(Filter {}) } } diff --git a/rust/src/http_zero_copy_regex_waf.rs b/rust/src/http_zero_copy_regex_waf.rs index 45cb5d4..aee115a 100644 --- a/rust/src/http_zero_copy_regex_waf.rs +++ b/rust/src/http_zero_copy_regex_waf.rs @@ -28,9 +28,9 @@ impl FilterConfig { } } -impl HttpFilterConfig for FilterConfig { +impl HttpFilterConfig for FilterConfig { /// This is called for each new HTTP filter. - fn new_http_filter(&mut self, _envoy: &mut EC) -> Box> { + fn new_http_filter(&mut self, _envoy: &mut EHF) -> Box> { Box::new(Filter { re: self.re.clone(), }) @@ -126,14 +126,10 @@ mod tests { #[test] /// This demonstrates how to write a test without Envoy using a mock provided by the SDK. fn test_filter() { - struct EnvoyConfig {} - impl EnvoyHttpFilterConfig for EnvoyConfig {} - let mut envoy_config = EnvoyConfig {}; let mut filter_config = FilterConfig::new("Hello [Ww].+").unwrap(); - let mut filter: Box> = - filter_config.new_http_filter(&mut envoy_config); - let mut envoy_filter = MockEnvoyHttpFilter::new(); + let mut filter: Box> = + filter_config.new_http_filter(&mut envoy_filter); // Not end of stream, so we should buffer the request body. assert_eq!(filter.on_request_body(&mut envoy_filter, false), abi::envoy_dynamic_module_type_on_http_filter_request_body_status::StopIterationAndBuffer); diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 233f0cc..f06a96a 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -32,17 +32,17 @@ fn new_http_filter_config_fn( _envoy_filter_config: &mut EC, filter_name: &str, filter_config: &[u8], -) -> Option>> { +) -> Option>> { let filter_config = std::str::from_utf8(filter_config).unwrap(); match filter_name { "passthrough" => Some(Box::new(http_passthrough::FilterConfig::new(filter_config))), "access_logger" => http_access_logger::FilterConfig::new(filter_config) - .map(|config| Box::new(config) as Box>), + .map(|config| Box::new(config) as Box>), "random_auth" => Some(Box::new(http_random_auth::FilterConfig::new(filter_config))), "zero_copy_regex_waf" => http_zero_copy_regex_waf::FilterConfig::new(filter_config) - .map(|config| Box::new(config) as Box>), + .map(|config| Box::new(config) as Box>), "header_mutation" => http_header_mutation::FilterConfig::new(filter_config) - .map(|config| Box::new(config) as Box>), + .map(|config| Box::new(config) as Box>), _ => panic!("Unknown filter name: {filter_name}"), } }