This is a backport of PR #8970 as merged into main (8610223d03d46c02b4190661a62d1977ba8f4a89).
SUMMARY
Currently, when specifying multiple nameservers, only the very last one is actually used. Fix that by collecting all specified nameservers and passing them to the Resolver after the argument processing is done.
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
dig
ADDITIONAL INFORMATION
Currently, when specifying multiple nameservers either using multiple @ns.example.com arguments or by specifying multiple nameservers in a single argument (@ns1.example.com,ns2.example.com), due to a bug only the very last nameserver that is specified is actually used.
This is because for every iteration of the for ns in nsset loop, the local list of nameservers is cleared and after adding the currently processed nameserver entry, the whole nameservers list of the Resolver instance is overridden with that new list with just one element. And as far as I can see, when setting that nameserver property, the dnspython library actually overrides the existing list and doesn't do some trickery to append the new nameservers or something like that.
Therefore, the assignment of the nameservers property of the Resolver is moved after the argument processing so all nameservers are added and then collectively written to the nameservers property of the Resolver.
This is a backport of PR #8970 as merged into main (8610223d03d46c02b4190661a62d1977ba8f4a89).
SUMMARY
Currently, when specifying multiple nameservers, only the very last one is actually used. Fix that by collecting all specified nameservers and passing them to the Resolver after the argument processing is done.
ISSUE TYPE
COMPONENT NAME
dig
ADDITIONAL INFORMATION
Currently, when specifying multiple nameservers either using multiple
@ns.example.com
arguments or by specifying multiple nameservers in a single argument (@ns1.example.com,ns2.example.com
), due to a bug only the very last nameserver that is specified is actually used. This is because for every iteration of thefor ns in nsset
loop, the local list of nameservers is cleared and after adding the currently processed nameserver entry, the wholenameservers
list of the Resolver instance is overridden with that new list with just one element. And as far as I can see, when setting thatnameserver
property, the dnspython library actually overrides the existing list and doesn't do some trickery to append the new nameservers or something like that.Therefore, the assignment of the
nameservers
property of the Resolver is moved after the argument processing so all nameservers are added and then collectively written to thenameservers
property of the Resolver.