File size: 1,476 Bytes
3a4b37f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
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


def _clean_url(value: str) -> str:
    return value.rstrip("/") if value else ""


# ── 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 = _clean_url(
    os.environ.get("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)