Add DNS filtering

This commit is contained in:
nex 2023-01-03 15:12:09 +00:00
parent 538896dae0
commit 4047c11f1d
2 changed files with 11 additions and 0 deletions

View file

@ -3,6 +3,7 @@ import io
import os import os
import random import random
import re import re
import dns.resolver
from time import sleep as time_sleep from time import sleep as time_sleep
from typing import Literal from typing import Literal
from typing import Tuple, Optional, Dict from typing import Tuple, Optional, Dict
@ -376,6 +377,15 @@ class OtherCog(commands.Cog):
if re.match(line.strip(), url.netloc): if re.match(line.strip(), url.netloc):
return await ctx.edit(content="That domain is blacklisted.") return await ctx.edit(content="That domain is blacklisted.")
try:
for response in await asyncio.to_thread(dns.resolver.resolve, url.netloc, "A"):
if response.address == "0.0.0.0":
return await ctx.edit(content="That domain is filtered.")
except dns.resolver.NXDOMAIN:
return await ctx.edit(content="That domain does not exist.")
except dns.resolver.NoAnswer:
return await ctx.edit(content="DNS resolver did not respond.")
try: try:
screenshot = await self.screenshot_website( screenshot = await self.screenshot_website(
ctx, ctx,

View file

@ -8,3 +8,4 @@ nltk==3.7
psutil==5.9.4 psutil==5.9.4
selenium==4.7.2 selenium==4.7.2
chromedriver==2.24.1 chromedriver==2.24.1
dnspython==2.2.1