bot: Add try for TLSA missing
All checks were successful
Build Docker / Build Docker (push) Successful in 16s
All checks were successful
Build Docker / Build Docker (push) Successful in 16s
This commit is contained in:
parent
1b9f4eafc8
commit
2ac733f33d
31
bot.py
31
bot.py
@ -196,7 +196,11 @@ async def ssl(ctx, domain: str):
|
|||||||
|
|
||||||
|
|
||||||
message = message + "\n## TLSA Record from webserver:\n`" + tlsa_server + "`\n"
|
message = message + "\n## TLSA Record from webserver:\n`" + tlsa_server + "`\n"
|
||||||
|
else:
|
||||||
|
message = message + "\n## Website Certificate:\n:x: No certificate found\n"
|
||||||
|
message = message + "\n## TLSA Record from webserver:\n:x: No certificate found\n"
|
||||||
|
|
||||||
|
try:
|
||||||
# Check for TLSA record
|
# Check for TLSA record
|
||||||
response = resolver.resolve("_443._tcp."+domain, "TLSA")
|
response = resolver.resolve("_443._tcp."+domain, "TLSA")
|
||||||
tlsa_records = []
|
tlsa_records = []
|
||||||
@ -213,24 +217,25 @@ async def ssl(ctx, domain: str):
|
|||||||
else:
|
else:
|
||||||
message = message + "\n## Result:\n:x: TLSA record does not match certificate\n"
|
message = message + "\n## Result:\n:x: TLSA record does not match certificate\n"
|
||||||
|
|
||||||
|
except:
|
||||||
# If message is too long, send it in 2 messages
|
message = message + "\n## TLSA Records from DNS:\n:x: No TLSA record found\n"
|
||||||
if (len(message) > 2000):
|
message = message + "\n## Result:\n:x: No TLSA record found\n"
|
||||||
# Split on the last line under 2000 characters
|
|
||||||
message1 = message[:2000]
|
|
||||||
message1 = message1[:message1.rfind("\n")]
|
|
||||||
message2 = message[len(message1):]
|
|
||||||
|
|
||||||
|
|
||||||
await ctx.response.send_message(message1)
|
# If message is too long, send it in 2 messages
|
||||||
await ctx.channel.send(message2)
|
if (len(message) > 2000):
|
||||||
|
# Split on the last line under 2000 characters
|
||||||
|
message1 = message[:2000]
|
||||||
|
message1 = message1[:message1.rfind("\n")]
|
||||||
|
message2 = message[len(message1):]
|
||||||
|
|
||||||
|
|
||||||
|
await ctx.response.send_message(message1)
|
||||||
|
await ctx.channel.send(message2)
|
||||||
|
|
||||||
|
|
||||||
else:
|
|
||||||
await ctx.response.send_message(message)
|
|
||||||
else:
|
else:
|
||||||
ctx.response.send_message(f"No certificate found for {domain}")
|
await ctx.response.send_message(message)
|
||||||
return
|
|
||||||
|
|
||||||
# Catch all exceptions
|
# Catch all exceptions
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user