Commit 5b16105
authored
feat(dns): parse reverse-DNS (PTR) query names into IP addresses (#2691)
## Summary
The conversion foundation for reverse DNS (PTR). A PTR query name is an
address in `in-addr.arpa` / `ip6.arpa` form; resolving it means going
**name → address**, which is a clean inverse — so this does it in Rust
instead of a large PL/pgSQL function:
- `arpa_qname_to_ip(&str) -> Option<IpAddr>` reverses the four octets
(IPv4) or 32 nibbles (IPv6); `Ipv6Addr` assembles the address, so the
IPv6 case is a few lines. Returns `None` for non-arpa / malformed names.
- Table tests (`value_scenarios!`) cover IPv4, IPv6, and the reject
cases.
The PTR handler will parse the incoming qname with this and look the
interface up by **address** (an indexed `WHERE address = $ip`), rather
than computing an arpa string for every row in a view. The address index
+ `find_ptr_record` land with #2639; the handler with #2641.
> **Reworked from the original SQL approach** (a `nico_ip_to_arpa_qname`
PL/pgSQL function + `dns_records_ptr` view). Doing the inverse in Rust
avoids a large SQL function, keeps the logic testable in one place, and
makes the lookup a plain indexed address equality. The existing
`nico_inet_to_dns_hostname` (forward instance DNS) is tracked for the
same treatment separately.
Implements #2637. Part of the #2630 epic (reverse DNS / PTR records).
Draft pending review.
Signed-off-by: Chet Nichols III <chetn@nvidia.com>1 parent 3984006 commit 5b16105
1 file changed
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
28 | 72 | | |
29 | 73 | | |
30 | 74 | | |
| |||
39 | 83 | | |
40 | 84 | | |
41 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
42 | 118 | | |
43 | 119 | | |
44 | 120 | | |
| |||
0 commit comments