check_ptr_validname.c is intentionally compact: one source file, one binary, no runtime framework overhead.
Execution flow
- Parse command line options into
struct options. - Validate the input IP and detect the address family.
- Determine the resolver from
--resolveror/etc/resolv.conf. - Perform the PTR lookup and capture latency.
- Validate the returned hostname with strict rules and optional IDN checks.
- Perform forward lookup and require a forward-confirm match.
- Emit Nagios-compatible text output or JSON output.
Important structs
struct optionsholds runtime settings such as timeout, resolver, JSON mode, and warning policy.struct check_resultaggregates state, messages, hostname data, booleans for each validation stage, and latency metrics.
Validation model
- IP parsing supports IPv4 and IPv6.
- Hostname validation is strict by default and can optionally inspect punycode labels.
- Partial consistency can be downgraded to
WARNINGwith--warn-partial. - Missing forward-confirm match remains a hard failure.
Output behavior
- Plain output is designed for Nagios and Icinga2.
--perfdataappends timing metrics.--jsonemits a structured payload for scripts and automation.
Build targets
make
make OS=linux ARCH=x86_64
make OS=windows ARCH=x86_64 CROSS=x86_64-w64-mingw32-