Project 03 · Rust · In progress
netwatch
A network analyzer in Rust. It starts small: look at DNS queries, and point at the ones going to trackers.
Right now it’s a struct, two methods and four hard-coded queries. The packet capture comes later.
How it works ↓- 24.2.0.1www.example.com[Allowed] (71727287848484351)
- 242.8.0.1www.test.com[Allowed] (9394758383854412)
- 44.42.41.24ads.google.com[Blocked] (9394371943949)Flagged
- 12.1.11.12telemetry.cloudflare.com[Blocked] (93894174839394)Flagged
Total blocked: 2
The four queries hard-coded in main.rs, in the format describe() prints.
How it works
One struct holds a query. One method prints it, one decides if it looks like a tracker.
struct DnsQuery {
domain: String,
client_ip: String,
timestamp: u64,
blocked: bool,
}
impl DnsQuery {
fn flagged_as_tracker(&self) -> bool {
["ads", "telemetry", "tracker"]
.iter()
.any(|k| self.domain.contains(k))
}
}Trimmed: describe() and the sample data are left out.
One domain, three keywords
telemetry.cloudflare.com
- "ads"false
- "telemetry"contains → true
- "tracker"false
flagged_as_tracker() → trueany() stops at the first match
Simple and easy to fool: “badstuff.com” matches “ads”, and a tracker called “metrics” gets through. That’s what the blocklist is for.
Roadmap
- done
Model a query
A struct, a describe(), a tracker check.
- next
Read real packets
Listen on UDP port 53 and parse the DNS header and question.
- planned
Blocklists
Swap the three keywords for a real list of tracker domains.
- planned
Per-device view
Group queries by client so you can see which device is the chatty one.
- planned
Live in the terminal
A small TUI that scrolls as queries come in.