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

[PR #7343/cda6fc95 backport][stable-7] Add TCP option for dig plugin. (#7349)

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>
(cherry picked from commit cda6fc956f)

Co-authored-by: k_e <niea.seven@gmail.com>
This commit is contained in:
patchback[bot] 2023-10-04 19:37:33 +02:00 committed by GitHub
parent b279694779
commit c75711167f
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." - "Class."
type: str type: str
default: 'IN' default: 'IN'
tcp:
description: Use TCP to lookup DNS records.
default: false
type: bool
version_added: 7.5.0
notes: 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. - 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. - 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') flat = self.get_option('flat')
fail_on_error = self.get_option('fail_on_error') fail_on_error = self.get_option('fail_on_error')
real_empty = self.get_option('real_empty') real_empty = self.get_option('real_empty')
tcp = self.get_option('tcp')
try: try:
rdclass = dns.rdataclass.from_text(self.get_option('class')) rdclass = dns.rdataclass.from_text(self.get_option('class'))
except Exception as e: except Exception as e:
@ -375,6 +381,8 @@ class LookupModule(LookupBase):
fail_on_error = boolean(arg) fail_on_error = boolean(arg)
elif opt == 'real_empty': elif opt == 'real_empty':
real_empty = boolean(arg) real_empty = boolean(arg)
elif opt == 'tcp':
tcp = boolean(arg)
continue continue
@ -408,7 +416,7 @@ class LookupModule(LookupBase):
for domain in domains: for domain in domains:
try: try:
answers = myres.query(domain, qtype, rdclass=rdclass) answers = myres.query(domain, qtype, rdclass=rdclass, tcp=tcp)
for rdata in answers: for rdata in answers:
s = rdata.to_text() s = rdata.to_text()
if qtype.upper() == 'TXT': if qtype.upper() == 'TXT':