ms-dnsp 0.1.0

Pure-Rust parser and builder for the MS-DNSP dnsRecord blob stored in Active-Directory-integrated DNS zones.
Documentation
# ms-dnsp

[![crates.io](https://img.shields.io/crates/v/ms-dnsp.svg)](https://crates.io/crates/ms-dnsp)
[![docs.rs](https://docs.rs/ms-dnsp/badge.svg)](https://docs.rs/ms-dnsp)

Parser and builder for the **`dnsRecord`** blob — how an Active-Directory-integrated DNS zone
stores each resource record (MS-DNSP §2.3.2.2, `DNS_RPC_RECORD`). Pure Rust, no FFI, no
network, no LDAP client of its own.

A `dnsNode` object under `DC=<zone>,CN=MicrosoftDNS,DC=DomainDnsZones,…` carries one
multi-valued `dnsRecord` attribute; every value is one of these blobs — a 24-byte header
plus type-specific data. Read them out of an LDAP search, hand them here.

```rust
use ms_dnsp::{DnsRecord, RecordData};

for value in entry.attr_values("dnsRecord") {
    let rec = DnsRecord::parse(value)?;
    match &rec.data {
        RecordData::A(ip)     => println!("A     {ip}  ttl={}", rec.ttl),
        RecordData::Srv { port, target, .. } => println!("SRV   {target}:{port}"),
        other                 => println!("{other:?}"),
    }
}
```

Building works the same way and is byte-for-byte round-trip stable:

```rust
let rec = DnsRecord::new(RecordData::A("10.0.0.5".parse()?)).with_ttl(600);
let blob = rec.to_bytes();
```

## Covers

`A`, `AAAA`, `NS`, `CNAME`, `PTR`, `SOA`, `MX`, `SRV`, `TXT`, and `DNS_TYPE_ZERO`
tombstones. Any other type is preserved verbatim as `RecordData::Unknown`, so a record this
crate does not model still round-trips unchanged.

Both name encodings are handled: `DNS_COUNT_NAME` (length + label count + length-prefixed
labels) and `DNS_RPC_NAME`.

## Details that bite

* `dwTtlSeconds` is **big-endian**; every other integer in the header is little-endian.
* `dwTimeStamp` is *hours* since 1601-01-01 UTC, and `0` means the record is static and will
  never be scavenged — `DnsRecord::timestamp_unix()` and `is_static()` handle both.
* `Rank` decides which copy of a record wins; authoritative zone data is `rank::ZONE`
  (`0xF0`).

Parsing never panics: every length byte is validated against the buffer before it is used.

## Who this is for

* Auditing AD-integrated DNS: who can update which zone, which records are unsecured, what
  the SRV topology exposes.
* DFIR and inventory over an LDAP dump, with no Windows host in the loop.
* Anything that has to write records back into AD without going through the DNS RPC server.

## License

MIT