@@ -64,6 +64,13 @@ pub mod listener_tls_detector;
6464// Implements a system for defining egress policies by hostname.
6565pub mod egress_policies;
6666
67+ declare_all_init_functions ! (
68+ init,
69+ http: new_http_filter_config_fn,
70+ network: new_network_filter_config_fn,
71+ udp_listener: new_udp_listener_filter_config_fn,
72+ ) ;
73+
6774/// This implements the [`envoy_proxy_dynamic_modules_rust_sdk::ProgramInitFunction`].
6875///
6976/// This is called exactly once when the module is loaded. It can be used to
@@ -76,14 +83,6 @@ fn init() -> bool {
7683 true
7784}
7885
79- // Register all filter types
80- declare_all_init_functions ! (
81- init,
82- http: new_http_filter_config_fn,
83- network: new_network_filter_config_fn,
84- udp_listener: new_udp_listener_filter_config_fn,
85- ) ;
86-
8786/// This implements the [`envoy_proxy_dynamic_modules_rust_sdk::NewHttpFilterConfigFunction`].
8887///
8988/// This is the entrypoint every time a new HTTP filter is created via the DynamicModuleFilter config.
@@ -109,37 +108,51 @@ fn new_http_filter_config_fn<EC: EnvoyHttpFilterConfig, EHF: EnvoyHttpFilter>(
109108 . map ( |config| Box :: new ( config) as Box < dyn HttpFilterConfig < EHF > > ) ,
110109 "metrics" => http_metrics:: FilterConfig :: new ( filter_config, envoy_filter_config)
111110 . map ( |config| Box :: new ( config) as Box < dyn HttpFilterConfig < EHF > > ) ,
112- _ => panic ! ( "Unknown filter name: {filter_name}" ) ,
111+ _ => panic ! ( "Unknown HTTP filter name: {filter_name}" ) ,
113112 }
114113}
115114
115+
116+
117+ /// This implements the [`envoy_proxy_dynamic_modules_rust_sdk::NewNetworkFilterConfigFunction`].
118+ ///
119+ /// This is the entrypoint every time a new Network filter is created via the DynamicModuleNetworkFilter config.
120+ ///
121+ /// Each argument matches the corresponding argument in the Envoy config here:
122+ /// https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/dynamic_modules/v3/dynamic_modules.proto#envoy-v3-api-msg-extensions-dynamic-modules-v3-dynamicmoduleconfig
123+ ///
124+ /// Returns None if the filter name or config is determined to be invalid by each filter's `new` function.
116125fn new_network_filter_config_fn < EC : EnvoyNetworkFilterConfig , ENF : EnvoyNetworkFilter > (
117- envoy_filter_config : & mut EC ,
126+ _envoy_filter_config : & mut EC ,
118127 filter_name : & str ,
119128 filter_config : & [ u8 ] ,
120129) -> Option < Box < dyn NetworkFilterConfig < ENF > > > {
121130 match filter_name {
122- "hostname_lookup" => egress_policies:: new_hostname_lookup_config (
123- envoy_filter_config,
124- filter_name,
125- filter_config,
126- ) ,
131+ "hostname_lookup" => egress_policies:: HostnameLookupFilterConfig :: new ( filter_config)
132+ . map ( |config| Box :: new ( config) as Box < dyn NetworkFilterConfig < ENF > > ) ,
127133 _ => panic ! ( "Unknown network filter name: {filter_name}" ) ,
128134 }
129135}
130136
137+ /// This implements the [`envoy_proxy_dynamic_modules_rust_sdk::NewUdpListenerFilterConfigFunction`].
138+ ///
139+ /// This is the entrypoint every time a new UDP Listener filter is created via the DynamicModuleUdpListenerFilter config.
140+ ///
141+ /// Each argument matches the corresponding argument in the Envoy config here:
142+ /// https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/dynamic_modules/v3/dynamic_modules.proto#envoy-v3-api-msg-extensions-dynamic-modules-v3-dynamicmoduleconfig
143+ ///
144+ /// Returns None if the filter name or config is determined to be invalid by each filter's `new` function.
131145fn new_udp_listener_filter_config_fn <
132146 EC : EnvoyUdpListenerFilterConfig ,
133147 ELF : EnvoyUdpListenerFilter ,
134148> (
135- envoy_filter_config : & mut EC ,
149+ _envoy_filter_config : & mut EC ,
136150 filter_name : & str ,
137151 filter_config : & [ u8 ] ,
138152) -> Option < Box < dyn UdpListenerFilterConfig < ELF > > > {
139153 match filter_name {
140- "dns_gateway" => {
141- egress_policies:: new_dns_gateway_config ( envoy_filter_config, filter_name, filter_config)
142- }
154+ "dns_gateway" => egress_policies:: DnsGatewayFilterConfig :: new ( filter_config)
155+ . map ( |config| Box :: new ( config) as Box < dyn UdpListenerFilterConfig < ELF > > ) ,
143156 _ => panic ! ( "Unknown UDP listener filter name: {filter_name}" ) ,
144157 }
145158}
0 commit comments