Blood Strike

Heretic Webdl !!exclusive!! File

return parsed

headers = "Content-Disposition": f'attachment; filename="filename"', # The downstream `StreamingResponse` will automatically forward # the `Content-Type` from the remote response if we set it later. heretic webdl

import httpx from fastapi import HTTPException, status from .config import settings WHITELISTED_DOMAINS = set( filter(None, os

# Load .env only when running locally (Heroku injects env vars itself) if Path(".env").exists(): load_dotenv(".env") WHITELISTED_DOMAINS = set( filter(None

class Settings: # ---- security / abuse limits ------------------------------------------------- MAX_CONTENT_LENGTH = int(os.getenv("MAX_CONTENT_LENGTH", "104857600")) # 100 MiB # Optional whitelist (comma‑separated). If empty → allow any domain. WHITELISTED_DOMAINS = set( filter(None, os.getenv("WHITELISTED_DOMAINS", "").split(",")) ) # Rate limiting – simple token bucket stored in memory (good enough for free tier) RATE_LIMIT = int(os.getenv("RATE_LIMIT", "10")) # requests per minute per IP

# --------------------------------------------------- # # Simple in‑memory rate limiter (IP → timestamps) # --------------------------------------------------- # _rate_limiter: Dict[str, list[datetime]] = defaultdict(list)