feat(seautils): added dig command
This commit is contained in:
parent
1405dae49e
commit
e9c062afa9
1 changed files with 20 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
|
||||
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
|
||||
|
||||
import asyncio
|
||||
import inspect
|
||||
import operator
|
||||
from functools import partial, partialmethod
|
||||
|
@ -82,3 +83,22 @@ class SeaUtils(commands.Cog):
|
|||
await ctx.send(embed=embed, reference=ctx.message.to_reference(fail_if_not_exists=False))
|
||||
else:
|
||||
await ctx.send(content="Object not found!", reference=ctx.message.to_reference(fail_if_not_exists=False))
|
||||
|
||||
@commands.command(name='dig', aliases=['dnslookup', 'nslookup'])
|
||||
@commands.is_owner()
|
||||
async def dig(self, ctx: commands.Context, name: str, type: str | None = 'A', server: str | None = None, port: int = 53) -> None:
|
||||
"""Retrieve DNS information for a domain."""
|
||||
command_opts: list[str | int] = ['dig']
|
||||
if server:
|
||||
command_opts.extend(['@', server])
|
||||
command_opts.extend([name, type])
|
||||
if port != 53:
|
||||
command_opts.extend(['-p', port])
|
||||
command_opts.extend(['+yaml'])
|
||||
|
||||
process = await asyncio.create_subprocess_exec(*command_opts, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
||||
stdout, stderr = await process.communicate()
|
||||
if stderr:
|
||||
await ctx.send(content=cf.box(text=stderr.decode()))
|
||||
else:
|
||||
await ctx.send(content=cf.box(text=stdout.decode(), lang='yaml'))
|
||||
|
|
Loading…
Reference in a new issue