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:
parent
39895a6d38
commit
cda6fc956f
2 changed files with 11 additions and 1 deletions
2
changelogs/fragments/7343-dig-tcp-option.yml
Normal file
2
changelogs/fragments/7343-dig-tcp-option.yml
Normal 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).
|
|
@ -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':
|
||||
|
|
Loading…
Reference in a new issue