1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add TCP option for dig plugin. (#7343)

* Add TCP option for dig plugin.

* Add changelog of dig tcp option

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: s-miyachi <s-miyachi@jocdn.co.jp>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
k_e 2023-10-05 01:47:37 +09:00 committed by GitHub
parent 39895a6d38
commit cda6fc956f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- dig lookup plugin - add TCP option to enable the use of TCP connection during DNS lookup (https://github.com/ansible-collections/community.general/pull/7343).

View file

@ -70,6 +70,11 @@ DOCUMENTATION = '''
- "Class."
type: str
default: 'IN'
tcp:
description: Use TCP to lookup DNS records.
default: false
type: bool
version_added: 7.5.0
notes:
- ALL is not a record per-se, merely the listed fields are available for any record results you retrieve in the form of a dictionary.
- While the 'dig' lookup plugin supports anything which dnspython supports out of the box, only a subset can be converted into a dictionary.
@ -329,6 +334,7 @@ class LookupModule(LookupBase):
flat = self.get_option('flat')
fail_on_error = self.get_option('fail_on_error')
real_empty = self.get_option('real_empty')
tcp = self.get_option('tcp')
try:
rdclass = dns.rdataclass.from_text(self.get_option('class'))
except Exception as e:
@ -375,6 +381,8 @@ class LookupModule(LookupBase):
fail_on_error = boolean(arg)
elif opt == 'real_empty':
real_empty = boolean(arg)
elif opt == 'tcp':
tcp = boolean(arg)
continue
@ -408,7 +416,7 @@ class LookupModule(LookupBase):
for domain in domains:
try:
answers = myres.query(domain, qtype, rdclass=rdclass)
answers = myres.query(domain, qtype, rdclass=rdclass, tcp=tcp)
for rdata in answers:
s = rdata.to_text()
if qtype.upper() == 'TXT':