Start supporting a server blocklist
This commit is contained in:
parent
2d2b2e5873
commit
1e6a290fb3
6 changed files with 45 additions and 0 deletions
|
@ -5,6 +5,7 @@ from urllib.parse import urlparse
|
|||
|
||||
from loguru import logger
|
||||
|
||||
from app.config import BLOCKED_SERVERS
|
||||
from app.config import DEBUG
|
||||
|
||||
|
||||
|
@ -53,6 +54,10 @@ def is_url_valid(url: str) -> bool:
|
|||
if not parsed.hostname or parsed.hostname.lower() in ["localhost"]:
|
||||
return False
|
||||
|
||||
if parsed.hostname in BLOCKED_SERVERS:
|
||||
logger.warning(f"{parsed.hostname} is blocked")
|
||||
return False
|
||||
|
||||
ip_address = _getaddrinfo(
|
||||
parsed.hostname, parsed.port or (80 if parsed.scheme == "http" else 443)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue