Skip to content

Draft: Add +human option

Julia Evans requested to merge jvns/bind9:human-flag into main

Draft implementation of a +human flag, discussed in #4233. Right now this is extremely rough -- all of the if statements are pretty ugly, there are no tests yet, and I've probably missed a lot of things since I'm new to this codebase. Would love feedback.

Some notes:

  • I took the approach of modifying dns_message_pseudosectiontotext and dns_message_sectiontotext instead of creating a parallel implementation (the way the +yaml option does) because that seems lower-maintenance and has less risk of diverging. I noticed that the YAML version already diverges from the text version a little -- it doesn't include the same warnings for example.
  • sets lookup->identify instead of lookup->stats because I think it's much more readable
  • turns off printcmd to suppress the confusing first few lines of output
  • Adds a little more whitespace and indentation to make the structure of each section more clear

Here's some example output:

$ dig +human example.com
;; Got answer:
;; HEADER:
;    opcode: QUERY
;    status: NOERROR
;    id: 60905
;    flags: qr rd ra
;    records: QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
;    EDNS: version: 0, flags:; udp: 1232

;; QUESTION SECTION:
;    example.com.			IN	A

;; ANSWER SECTION:
example.com.		74183	IN	A	93.184.216.34

;; Received 56 bytes from 192.168.1.1#53(192.168.1.1) in 18 ms

Merge request reports