From fb468ee63e19e8f1dc7b8050a46eb05705ff2e0b Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Tue, 28 May 2024 18:55:09 -0400 Subject: [PATCH] fix(seautils): retrieve A, AAAA, and CNAME records by default (& docstring changes) --- seautils/seautils.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/seautils/seautils.py b/seautils/seautils.py index ce9c64e..1feb77a 100644 --- a/seautils/seautils.py +++ b/seautils/seautils.py @@ -88,12 +88,19 @@ class SeaUtils(commands.Cog): @commands.command(name='dig', aliases=['dnslookup', 'nslookup']) @commands.is_owner() - async def dig(self, ctx: commands.Context, name: str, type: str | None = 'ANY', server: str | None = None, port: int = 53) -> None: - """Retrieve DNS information for a domain.""" + async def dig(self, ctx: commands.Context, name: str, type: str | None = None, server: str | None = None, port: int = 53) -> None: + """Retrieve DNS information for a domain. + + Uses `dig` to perform a DNS query. Will fall back to `nslookup` if `dig` is not installed on the system. + `nslookup` does not provide as much information as `dig`, so only the `name` parameter will be used if `nslookup` is used. + Will return the A, AAAA, and CNAME records for a domain by default. You can specify a different record type with the `type` parameter.""" command_opts: list[str | int] = ['dig'] + query_types = [type] if type else ['A', 'AAAA', 'CNAME'] if server: command_opts.extend(['@', server]) - command_opts.extend([name, type, '-p', str(port), '+yaml']) + for query_type in query_types: + command_opts.extend([name, query_type]) + command_opts.extend(['-p', str(port), '+yaml']) try: process: Process = await asyncio.create_subprocess_exec(*command_opts, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)