fix: Add more strict domain checking
All checks were successful
Build Docker / Build_Master_AMD (push) Successful in 1m13s
Build Docker / Build_Master_ARM (push) Successful in 1m15s
Build Docker / Build_Bot_ARM (push) Successful in 1m43s
Build Docker / Build_Bot_AMD (push) Successful in 3m18s

This commit is contained in:
2025-04-22 18:54:57 +10:00
parent 58624e152e
commit 04e1335173

View File

@@ -4,6 +4,7 @@ import discord
from discord import app_commands from discord import app_commands
import requests import requests
import asyncio import asyncio
import re
load_dotenv() load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN') TOKEN = os.getenv('DISCORD_TOKEN')
@@ -79,6 +80,12 @@ async def createsite(ctx, domain: str, licence: str = None):
await ctx.response.send_message("You must specify a domain without http:// or https://",ephemeral=True) await ctx.response.send_message("You must specify a domain without http:// or https://",ephemeral=True)
return return
domain = domain.lower().trim()
# Regex for a domain (or a tld)
if not re.match(r'^[a-z0-9-]+(\.[a-z0-9-]+)*$', domain):
await ctx.response.send_message("You must specify a valid domain",ephemeral=True)
return
if FREE_LICENCE == True: # If free licences are enabled then auto generate a licence if FREE_LICENCE == True: # If free licences are enabled then auto generate a licence
r = requests.post(f"http://{Master_IP}:{Master_Port}/add-licence",headers={"key":os.getenv('LICENCE_KEY')}) r = requests.post(f"http://{Master_IP}:{Master_Port}/add-licence",headers={"key":os.getenv('LICENCE_KEY')})
if r.status_code == 200: if r.status_code == 200: