Fixed bug where if --interface-name was provided, the local-addr string was used to look-up the interface
Fixed bug where if the --local-addr string was provided, it wouldn't be copied correctly and used by ZDNS.
Added code so that if a loopback name server was to be used, a loopback local address would also be used
Throw error if both a loopback and non-loopback name server is provided. Prevents us having to handle the complexities of handling both
Added validation for interface + nameservers need to be both loopback or neither loopback
Testing
The original 3 queries mentioned in the Issue (#337) pass:
~/zdns on phillip/337-loopback! ⌚ 3:07:29
$ echo example.com | ./zdns A --verbosity=5 --timeout=1 --retries=0
INFO[0000] No name servers specified. will use: 127.0.0.53:53
INFO[0000] using local address(es): [127.0.0.1]
DEBU[0000] DEPTH 01: [****WIRE LOOKUP*** A example.com 127.0.0.53:53]
{"data":{"additionals":[{"flags":"","type":"EDNS0","udpsize":65494,"version":0}],"answers":[{"answer":"93.184.215.14","class":"IN","name":"example.com","ttl":3540,"type":"A"}],"protocol":"udp","resolver":"127.0.0.53:53"},"name":"example.com","status":"NOERROR","timestamp":"2024-06-13T03:07:40Z"}
~/zdns on phillip/337-loopback! ⌚ 3:07:40
$ echo example.com | ./zdns A --verbosity=5 --timeout=1 --retries=0 --local-interface=lo
INFO[0000] No name servers specified. will use: 127.0.0.53:53
INFO[0000] using local interface: lo
INFO[0000] using local address(es): [127.0.0.1 ::1]
DEBU[0000] DEPTH 01: [****WIRE LOOKUP*** A example.com 127.0.0.53:53]
{"data":{"additionals":[{"flags":"","type":"EDNS0","udpsize":65494,"version":0}],"answers":[{"answer":"93.184.215.14","class":"IN","name":"example.com","ttl":3527,"type":"A"}],"protocol":"udp","resolver":"127.0.0.53:53"},"name":"example.com","status":"NOERROR","timestamp":"2024-06-13T03:07:53Z"}
~/zdns on phillip/337-loopback! ⌚ 3:07:53
$ echo example.com | ./zdns A --verbosity=5 --timeout=1 --retries=0 --local-addr=127.0.0.1
INFO[0000] No name servers specified. will use: 127.0.0.53:53
INFO[0000] using local address: 127.0.0.1
INFO[0000] using local address(es): [127.0.0.1]
DEBU[0000] DEPTH 01: [****WIRE LOOKUP*** A example.com 127.0.0.53:53]
{"data":{"additionals":[{"flags":"","type":"EDNS0","udpsize":65494,"version":0}],"answers":[{"answer":"93.184.215.14","class":"IN","name":"example.com","ttl":3518,"type":"A"}],"protocol":"udp","resolver":"127.0.0.53:53"},"name":"example.com","status":"NOERROR","timestamp":"2024-06-13T03:08:03Z"}
Most of the changes here are from pulling the ResolverConfig validation out into separate functions. I think this both makes it easier to reason through each function and makes testing easier.
Closes #337
Changes
--interface-name
was provided, thelocal-addr
string was used to look-up the interface--local-addr
string was provided, it wouldn't be copied correctly and used by ZDNS.Testing
The original 3 queries mentioned in the Issue (#337) pass: