fix: Use another dns server
All checks were successful
Build Docker / Build Docker (push) Successful in 20s

This commit is contained in:
Nathan Woodburn 2024-02-20 17:26:02 +11:00
parent 9c9a3498a4
commit fdc5e66daa
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

17
bot.py
View File

@ -36,6 +36,9 @@ activityMessage="over the server"
statusType="watching" statusType="watching"
dns_ip = "194.50.5.26"
dns_port = 53
# Commands # Commands
@tree.command(name="ping", description="Check bot connection") @tree.command(name="ping", description="Check bot connection")
async def ping(ctx): async def ping(ctx):
@ -79,8 +82,8 @@ async def botstatus(ctx, message: str, statusmethod: str = None):
async def dig(ctx, domain: str, record_type: str = "A"): async def dig(ctx, domain: str, record_type: str = "A"):
record_type = record_type.upper() record_type = record_type.upper()
resolver = dns.resolver.Resolver() resolver = dns.resolver.Resolver()
resolver.nameservers = ["10.2.1.15"] resolver.nameservers = [dns_ip]
resolver.port = 5350 resolver.port = dns_port
try: try:
# Query the DNS record # Query the DNS record
response = resolver.resolve(domain, record_type) response = resolver.resolve(domain, record_type)
@ -95,6 +98,8 @@ async def dig(ctx, domain: str, record_type: str = "A"):
await ctx.response.send_message(f"Domain {domain} not found.") await ctx.response.send_message(f"Domain {domain} not found.")
except dns.exception.DNSException as e: except dns.exception.DNSException as e:
await ctx.response.send_message(f"An error occurred: {e}") await ctx.response.send_message(f"An error occurred: {e}")
except Exception as e:
await ctx.response.send_message(f"An error occurred: {e}")
@tree.command(name="curl", description="HTTP request") @tree.command(name="curl", description="HTTP request")
async def curl(ctx, url: str): async def curl(ctx, url: str):
@ -153,8 +158,8 @@ async def ssl(ctx, domain: str, showcert: bool = False, notifymeonexpiry: bool =
await ctx.response.send_message(f"Checking SSL certificate for {domain}...") await ctx.response.send_message(f"Checking SSL certificate for {domain}...")
message = "" message = ""
resolver = dns.resolver.Resolver() resolver = dns.resolver.Resolver()
resolver.nameservers = ["10.2.1.15"] resolver.nameservers = [dns_ip]
resolver.port = 5350 resolver.port = dns_port
domain_check = False domain_check = False
try: try:
# Query the DNS record # Query the DNS record
@ -334,8 +339,8 @@ async def checkForSSLExpiry():
userid, domain = line.split(",") userid, domain = line.split(",")
print(f"Checking SSL certificate for {domain}...", flush=True) print(f"Checking SSL certificate for {domain}...", flush=True)
resolver = dns.resolver.Resolver() resolver = dns.resolver.Resolver()
resolver.nameservers = ["10.2.1.15"] resolver.nameservers = [dns_ip]
resolver.port = 5350 resolver.port = dns_port
try: try:
# Query the DNS record # Query the DNS record
response = resolver.resolve(domain, "A") response = resolver.resolve(domain, "A")