[enh] check domain validity

This commit is contained in:
Laurent Peuch 2019-01-19 07:58:37 +01:00
parent b833a795ce
commit ae4da946d6
2 changed files with 6 additions and 0 deletions

View file

@ -1,2 +1,3 @@
sanic
aiohttp
validators

View file

@ -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: