diff --git a/requirements.txt b/requirements.txt index 384cf27..e6795bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ sanic aiohttp +validators diff --git a/server.py b/server.py index 52254b2..8810864 100644 --- a/server.py +++ b/server.py @@ -1,4 +1,5 @@ import aiohttp +import validators from sanic import Sanic from sanic.log import logger @@ -27,6 +28,10 @@ async def check_http(request): domain = data["domain"] + if not validators.domain(domain): + logger.info(f"Invalid request, is not in the right format (domain is : {domain})") + return json_response({"status": "error", "content": "domain is not in the right format (do not include http:// or https://)"}) + # TODO DNS check async with aiohttp.ClientSession() as session: