fix: wire mail provider into standalone registration
This commit is contained in:
@@ -25,11 +25,13 @@
|
|||||||
常见填写示例:
|
常见填写示例:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"proxy": "http://127.0.0.1:7897"
|
"proxy": "http://127.0.0.1:17891"
|
||||||
```
|
```
|
||||||
|
|
||||||
如果你本地跑了 Clash / Mihomo / sing-box,一般就是本机 HTTP 代理端口。
|
如果你本地跑了 Clash / Mihomo / sing-box,一般就是本机 HTTP 代理端口。
|
||||||
|
|
||||||
|
按当前这台机器的实测结果,`17891` 是可用的 US 出口代理。
|
||||||
|
|
||||||
如果你不想走固定代理,也可以留空:
|
如果你不想走固定代理,也可以留空:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -57,6 +57,10 @@ python3 /root/standalone_cli/main.py config init
|
|||||||
- `bearer_token` 或 `email` + `password`
|
- `bearer_token` 或 `email` + `password`
|
||||||
- 邮箱提供商配置 `mail_provider_configs`
|
- 邮箱提供商配置 `mail_provider_configs`
|
||||||
|
|
||||||
|
当前这台机器实测可用的代理是:
|
||||||
|
|
||||||
|
- `http://127.0.0.1:17891`
|
||||||
|
|
||||||
模板里的 URL 现在使用了更明确的占位值:
|
模板里的 URL 现在使用了更明确的占位值:
|
||||||
|
|
||||||
- `https://your-cpa.example.com`
|
- `https://your-cpa.example.com`
|
||||||
@@ -102,6 +106,12 @@ python3 /root/standalone_cli/main.py register --sleep-min 5 --sleep-max 30
|
|||||||
python3 /root/standalone_cli/main.py register --proxy http://127.0.0.1:7897 --once
|
python3 /root/standalone_cli/main.py register --proxy http://127.0.0.1:7897 --once
|
||||||
```
|
```
|
||||||
|
|
||||||
|
如果你直接使用当前机器的代理,建议改成:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 /root/standalone_cli/main.py register --proxy http://127.0.0.1:17891 --once
|
||||||
|
```
|
||||||
|
|
||||||
### 查看本地 token
|
### 查看本地 token
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -175,6 +185,8 @@ cd /root/standalone_cli
|
|||||||
docker compose up --build
|
docker compose up --build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
当前 compose 默认执行一次性命令 `--json config show`,用于快速验证镜像和配置挂载是否正常,不会常驻运行。
|
||||||
|
|
||||||
## 验证命令
|
## 验证命令
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"proxy": "",
|
"proxy": "http://127.0.0.1:17891",
|
||||||
"auto_register": false,
|
"auto_register": false,
|
||||||
"mail_providers": [
|
"mail_providers": [
|
||||||
"mailtm"
|
"mailtm"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
image: openai-pool-standalone:latest
|
image: openai-pool-standalone:latest
|
||||||
container_name: openai-pool-standalone
|
container_name: openai-pool-standalone
|
||||||
restart: unless-stopped
|
restart: "no"
|
||||||
volumes:
|
volumes:
|
||||||
- /root/standalone_cli/data:/app/data
|
- /root/standalone_cli/data:/app/data
|
||||||
command: ["config", "show"]
|
command: ["--json", "config", "show"]
|
||||||
|
|||||||
10
main.py
10
main.py
@@ -15,6 +15,7 @@ if str(PROJECT_ROOT) not in sys.path:
|
|||||||
sys.path.insert(0, str(PROJECT_ROOT))
|
sys.path.insert(0, str(PROJECT_ROOT))
|
||||||
|
|
||||||
from openai_pool_orchestrator import TOKENS_DIR, __version__
|
from openai_pool_orchestrator import TOKENS_DIR, __version__
|
||||||
|
from openai_pool_orchestrator.mail_providers import MultiMailRouter
|
||||||
from openai_pool_orchestrator.register import _write_text_atomic, run as register_run
|
from openai_pool_orchestrator.register import _write_text_atomic, run as register_run
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -185,6 +186,7 @@ def handle_register(args: argparse.Namespace) -> dict[str, Any]:
|
|||||||
sleep_min = max(1, args.sleep_min)
|
sleep_min = max(1, args.sleep_min)
|
||||||
sleep_max = max(sleep_min, args.sleep_max)
|
sleep_max = max(sleep_min, args.sleep_max)
|
||||||
proxy = args.proxy if args.proxy is not None else str(cfg.get("proxy") or "").strip() or None
|
proxy = args.proxy if args.proxy is not None else str(cfg.get("proxy") or "").strip() or None
|
||||||
|
mail_router = MultiMailRouter(cfg)
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
runs: List[dict[str, Any]] = []
|
runs: List[dict[str, Any]] = []
|
||||||
@@ -192,8 +194,11 @@ def handle_register(args: argparse.Namespace) -> dict[str, Any]:
|
|||||||
count += 1
|
count += 1
|
||||||
print(f"\n[{time.strftime('%H:%M:%S')}] >>> 开始第 {count} 次注册流程 <<<")
|
print(f"\n[{time.strftime('%H:%M:%S')}] >>> 开始第 {count} 次注册流程 <<<")
|
||||||
try:
|
try:
|
||||||
|
provider_name, provider = mail_router.next_provider()
|
||||||
|
print(f"[*] 本次使用邮箱提供商: {provider_name}")
|
||||||
token_json = register_run(
|
token_json = register_run(
|
||||||
proxy,
|
proxy,
|
||||||
|
mail_provider=provider,
|
||||||
proxy_pool_config={
|
proxy_pool_config={
|
||||||
"enabled": bool(cfg.get("proxy_pool_enabled", False)),
|
"enabled": bool(cfg.get("proxy_pool_enabled", False)),
|
||||||
"api_url": cfg.get("proxy_pool_api_url", ""),
|
"api_url": cfg.get("proxy_pool_api_url", ""),
|
||||||
@@ -203,8 +208,13 @@ def handle_register(args: argparse.Namespace) -> dict[str, Any]:
|
|||||||
"country": cfg.get("proxy_pool_country", "US"),
|
"country": cfg.get("proxy_pool_country", "US"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
mail_router.report_success(provider_name)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
token_json = None
|
token_json = None
|
||||||
|
try:
|
||||||
|
mail_router.report_failure(provider_name)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
runs.append({"ok": False, "error": str(exc)})
|
runs.append({"ok": False, "error": str(exc)})
|
||||||
print(f"[Error] 发生未捕获异常: {exc}")
|
print(f"[Error] 发生未捕获异常: {exc}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user