Skip to main content

parse_resolvectl_domains

Function parse_resolvectl_domains 

Source
pub fn parse_resolvectl_domains(content: &str) -> ResolvectlDomains
Expand description

Parses resolvectl status --no-pager output into per-scope DNS search domains.

Handles the two shapes that tripped up the previous single-line parser:

  • Wrapped values. resolvectl right-aligns labels and continues long values on following indented, label-less lines; those continuations were silently dropped.
  • Routing-only domains. systemd prefixes a domain with ~ when it should only route queries to that link, never be appended as a search suffix. Every ~ entry is excluded (the old code special-cased only the exact catch-all ~.).

Sections are recognised by content (Global, Link N (iface)) rather than by indentation, since resolvectl’s exact column padding varies with the longest label present. A Link header always creates an entry, even with no domain line, so callers can distinguish “managed, no domain” from “not managed at all”.