settings.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import sys
  2. from pathlib import Path
  3. from typing import Any
  4. from pydantic import BaseModel
  5. from pydantic_settings import BaseSettings
  6. class LogConfig(BaseModel):
  7. datetime_format: str = "%Y-%m-%d %H:%M:%S"
  8. LOG_LEVEL: str = "DEBUG" # 修改日志级别为 DEBUG
  9. LOG_DIR: Path = ''
  10. class Settings(BaseSettings):
  11. # 基础配置
  12. BASE_DIR: Path = Path(__file__).parent.parent.absolute()
  13. OUTPUT_DIR: Path = BASE_DIR / "output"
  14. APP_NAME: str = "proxy-pool"
  15. DEBUG: bool = True
  16. HOST: str = "0.0.0.0"
  17. PORT: int = 5010
  18. WORKERS: int = 1
  19. LOG_CONF: LogConfig = LogConfig(LOG_DIR = Path(OUTPUT_DIR / "logs"))
  20. SUBSCRIPTION_USER_AGENT: str = "clash-verge/v1.7.5"
  21. # mihomo 配置
  22. MIHOMO_BIN_PATH: Path = BASE_DIR / r"output\download\mihomo\mihomo-windows-amd64-go120.exe"
  23. MIHOMO_TEMP_PATH: Path = OUTPUT_DIR / "temp"
  24. MIHOMO_DOWNLOAD_URL: str = "https://github.com/MetaCubeX/mihomo/releases/download/v1.18.6/mihomo-windows-amd64-go120-v1.18.6.zip"
  25. # 路径配置
  26. PATH_CONFIG_DIR: Path = BASE_DIR / "output/configs"
  27. PATH_SUBSCRIPTION_DIR: Path = BASE_DIR / "output/subscriptions"
  28. APP_CONFIG:Path = BASE_DIR / "config/app.yaml"
  29. class Config:
  30. case_sensitive = True
  31. settings = Settings()
  32. sys.path.append(str(settings.BASE_DIR))