cc3m / config.py
kokokoasd's picture
Upload 20 files
72688d6 verified
"""
Centralized configuration for HugPanel.
Single Responsibility: all constants and paths live here.
Dependency Inversion: other modules depend on this abstraction, not on each other.
"""
import os
import re
from pathlib import Path
# ── Paths ──────────────────────────────────────
DATA_DIR = Path(os.environ.get("DATA_DIR", "/data/zones"))
ZONES_META = DATA_DIR.parent / "zones_meta.json"
DATA_DIR.mkdir(parents=True, exist_ok=True)
# ── Validation ─────────────────────────────────
ZONE_NAME_PATTERN = re.compile(r"^[a-zA-Z0-9_-]{1,50}$")
# ── Port Limits ────────────────────────────────
MIN_PORT = 1024
MAX_PORT = 65535
# ── Terminal ───────────────────────────────────
SCROLLBACK_SIZE = 128 * 1024 # 128 KB
# ── Admin API (Cloudflare Worker) ──────────────
ADMIN_API_URL = "https://hugpanel-admin.lab70018.workers.dev"
# ── Backup (local temp dir) ────────────────────
BACKUP_DIR = DATA_DIR.parent / "backups"
BACKUP_DIR.mkdir(parents=True, exist_ok=True)