33//! This filter demonstrates:
44//! 1. UDP listener filter structure with `UdpListenerFilterConfig` and `UdpListenerFilter` traits.
55//! 2. DNS query parsing and response.
6- //! 3. Using protobof for configuration.
7- //!
8- //! See dns_gateway.proto for the protobuf definitions of the config.
96
107pub mod cache_lookup;
11- mod proto ;
8+ mod config ;
129mod virtual_ip_cache;
1310
1411use envoy_proxy_dynamic_modules_rust_sdk:: * ;
@@ -74,27 +71,27 @@ impl DnsGatewayFilterConfig {
7471 } ;
7572 let value = & config_json[ "value" ] ;
7673
77- let proto_config : proto :: DnsGatewayConfig = match serde_json:: from_value ( value. clone ( ) ) {
74+ let gateway_config : config :: DnsGatewayConfig = match serde_json:: from_value ( value. clone ( ) ) {
7875 Ok ( cfg) => cfg,
7976 Err ( err) => {
8077 eprintln ! ( "Error parsing DnsGatewayConfig: {err}" ) ;
8178 return None ;
8279 }
8380 } ;
8481
85- if proto_config . base_ip . is_empty ( ) {
82+ if gateway_config . base_ip . is_empty ( ) {
8683 eprintln ! ( "base_ip is required for DNS gateway" ) ;
8784 return None ;
8885 }
89- let base_ip: Ipv4Addr = match proto_config . base_ip . parse ( ) {
86+ let base_ip: Ipv4Addr = match gateway_config . base_ip . parse ( ) {
9087 Ok ( ip) => ip,
9188 Err ( err) => {
9289 eprintln ! ( "Invalid base_ip: {err}" ) ;
9390 return None ;
9491 }
9592 } ;
9693
97- let prefix_len = match u8:: try_from ( proto_config . prefix_len ) {
94+ let prefix_len = match u8:: try_from ( gateway_config . prefix_len ) {
9895 Ok ( v) => v,
9996 Err ( err) => {
10097 eprintln ! ( "Invalid prefix_len: {err}" ) ;
@@ -108,7 +105,7 @@ impl DnsGatewayFilterConfig {
108105
109106 init_cache ( u32:: from ( base_ip) , prefix_len) ;
110107
111- let domains: Arc < [ DomainMatcher ] > = proto_config
108+ let domains: Arc < [ DomainMatcher ] > = gateway_config
112109 . domains
113110 . into_iter ( )
114111 . map ( |d| DomainMatcher {
@@ -397,7 +394,7 @@ mod tests {
397394
398395 #[ test]
399396 fn test_config_parsing_missing_prefix_len ( ) {
400- // proto3 defaults missing uint32 to 0, which fails the 1..=32 range check.
397+ // serde defaults missing uint32 to 0, which fails the 1..=32 range check.
401398 let config = r#"{
402399 "value": {
403400 "base_ip": "10.10.0.0",
0 commit comments