Quick Start¶
Get up and running with Hornet in under five minutes.
1. Add the dependency¶
Add hornet to your Cargo.toml:
To enable serde support on all AST types:
2. Parse a named.conf¶
use hornet_bind9::parse_named_conf;
fn main() -> hornet::Result<()> {
let input = r#"
options {
directory "/var/cache/bind";
recursion yes;
allow-query { any; };
};
zone "example.com" {
type primary;
file "/etc/bind/zones/example.com.db";
};
"#;
let conf = parse_named_conf(input)?;
println!("Parsed {} statement(s)", conf.statements.len());
Ok(())
}
3. Parse a zone file¶
use hornet_bind9::parse_zone_file;
fn main() -> hornet::Result<()> {
let zone_text = r#"
$ORIGIN example.com.
$TTL 1h
@ IN SOA ns1 admin (2024010101 1d 2h 4w 5m)
@ IN NS ns1.example.com.
@ IN A 93.184.216.34
"#;
let zone = parse_zone_file(zone_text)?;
for record in zone.records() {
let name = record.name.as_deref().unwrap_or("@");
println!("{}: {}", name, record.rdata.rtype());
}
Ok(())
}
4. Install the CLI¶
Verify the installation:
Then validate any BIND9 config:
Next Steps¶
- Prerequisites — Rust version requirements and optional dependencies
- Parsing Guide — Deep dive into parsing options and error handling
- Validation Guide — Understanding diagnostic severities
- CLI Reference — All CLI commands and flags