Files
any-auto-register/api/config.py
zhouye d4716eb5c6 feat: DuckMail 支持自定义域名和 API Key 直连模式
通过 domain.duckmail.sbs 配置私有域名后,可使用 API Key 直连 DuckMail API,
无需经过前端代理转发。新增 duckmail_domain 和 duckmail_api_key 配置项。
2026-03-31 13:35:50 +08:00

91 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from fastapi import APIRouter
from pydantic import BaseModel
from core.config_store import config_store
router = APIRouter(prefix="/config", tags=["config"])
CONFIG_KEYS = [
"laoudo_auth",
"laoudo_email",
"laoudo_account_id",
"yescaptcha_key",
"twocaptcha_key",
"default_executor",
"default_captcha_solver",
"duckmail_api_url",
"duckmail_provider_url",
"duckmail_bearer",
"duckmail_domain",
"duckmail_api_key",
"freemail_api_url",
"freemail_admin_token",
"freemail_username",
"freemail_password",
"moemail_api_url",
"skymail_api_base",
"skymail_token",
"skymail_domain",
"mail_provider",
"maliapi_base_url",
"maliapi_api_key",
"maliapi_domain",
"maliapi_auto_domain_strategy",
"cfworker_api_url",
"cfworker_admin_token",
"cfworker_custom_auth",
"cfworker_domain",
"cfworker_domains",
"cfworker_enabled_domains",
"cfworker_fingerprint",
"smstome_cookie",
"smstome_country_slugs",
"smstome_phone_attempts",
"smstome_otp_timeout_seconds",
"smstome_poll_interval_seconds",
"smstome_sync_max_pages_per_country",
"luckmail_base_url",
"luckmail_api_key",
"luckmail_email_type",
"luckmail_domain",
"cpa_api_url",
"cpa_api_key",
"cpa_cleanup_enabled",
"cpa_cleanup_interval_minutes",
"cpa_cleanup_threshold",
"cpa_cleanup_concurrency",
"cpa_cleanup_register_delay_seconds",
"sub2api_api_url",
"sub2api_api_key",
"team_manager_url",
"team_manager_key",
"codex_proxy_url",
"codex_proxy_key",
"codex_proxy_upload_type",
"cliproxyapi_management_key",
"grok2api_url",
"grok2api_app_key",
"grok2api_pool",
"grok2api_quota",
"kiro_manager_path",
"kiro_manager_exe",
]
class ConfigUpdate(BaseModel):
data: dict
@router.get("")
def get_config():
all_cfg = config_store.get_all()
# 只返回已知 key未设置的返回空字符串
return {k: all_cfg.get(k, "") for k in CONFIG_KEYS}
@router.put("")
def update_config(body: ConfigUpdate):
# 只允许更新已知 key
safe = {k: v for k, v in body.data.items() if k in CONFIG_KEYS}
config_store.set_many(safe)
return {"ok": True, "updated": list(safe.keys())}