Skip to content

Commit 286860b

Browse files
committed
remove protos
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>
1 parent c558927 commit 286860b

7 files changed

Lines changed: 32 additions & 153 deletions

File tree

rust/Cargo.lock

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

rust/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ dashmap = "6.1.0"
1616
once_cell = "1.20.2"
1717
hickory-proto = "0.24"
1818
parking_lot = "0.12"
19-
prost = "0.13"
20-
21-
[build-dependencies]
22-
prost-build = "0.13"
2319

2420
[dev-dependencies]
2521
tempfile = "3.16.0"

rust/build.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

rust/src/dns_gateway/config.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use std::collections::HashMap;
2+
3+
#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize)]
4+
pub struct DnsGatewayConfig {
5+
/// Base IPv4 address for virtual IP allocation (e.g. "10.10.0.0").
6+
#[serde(default)]
7+
pub base_ip: String,
8+
/// CIDR prefix length (1-32). A /24 gives 256 IPs.
9+
#[serde(default)]
10+
pub prefix_len: u32,
11+
/// Each entry defines a domain pattern and associated metadata.
12+
#[serde(default)]
13+
pub domains: Vec<DomainMatcher>,
14+
}
15+
16+
#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize)]
17+
pub struct DomainMatcher {
18+
/// Exact domain ("example.com") or wildcard pattern ("*.example.com").
19+
#[serde(default)]
20+
pub domain: String,
21+
/// String key-value pairs exposed in Envoy filter state as `envoy.dns_gateway.metadata.<key>.`
22+
#[serde(default)]
23+
pub metadata: HashMap<String, String>,
24+
}

rust/src/dns_gateway/dns_gateway.proto

Lines changed: 0 additions & 22 deletions
This file was deleted.

rust/src/dns_gateway/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
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
107
pub mod cache_lookup;
11-
mod proto;
8+
mod config;
129
mod virtual_ip_cache;
1310

1411
use 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",

rust/src/dns_gateway/proto.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)