feat(registrar): Clash 节点轮换 — 单代理下多线程注册走不同出口 IP - #10
Merged
Conversation
Collaborator
Author
Collaborator
Author
shiaho777
force-pushed
the
clash-node-rotation
branch
from
August 13, 2026 05:12
b84aab8 to
a2f5e11
Compare
Collaborator
Author
问题:注册机在单代理(如 Clash 单端口 7890)下强制并发=1,
Workers>1 无效。多账号注册走同一出口 IP 容易触发 Cloudflare 风控。
方案:通过 Clash/mihomo 外部控制器 API,在每个账号注册前自动将
Selector 组切换到不同节点,让连续注册走不同出口 IP。
改动:
- gate.go: 放开 proxies<=1 时强制 return 1 的并发锁,改为 return workers
- clash_rotator.go (新增): ClashRotator 组件
- RefreshNodes(): 从 Clash API 动态拉取组内节点(自动过滤流量/到期等伪节点)
- NextNode(): round-robin 返回不同节点
- SelectNode(): PUT /proxies/{group} 切换节点
- AutoDetectClash(): 扫描本地 9090/9097/9091 端口自动发现 Clash 控制器
+ Selector 组,零配置使用
- service.go: run() 创建 rotator,runOne() 在 gate.Acquire() 后切节点
(gate 互斥保证切换不冲突)
- types.go: 新增 clash_controller / clash_selector_group 配置字段
- server: 新增 /api/registrar/clash-autodetect 端点
- UI: 高级选项加 Clash 控制器/组名输入框 + 「自动检测」按钮
不破坏现有功能:多代理场景行为不变;不填 Clash 字段时完全回退原行为。
shiaho777
force-pushed
the
clash-node-rotation
branch
from
August 13, 2026 05:14
a2f5e11 to
263f36a
Compare
|
very cool,This concurrent design was implemented due to the vulnerability of previous registration tools to anti-fraud measures, resulting in a mandatory concurrent registration limit of 1. Now concurrent registrations are possible. |
Owner
|
look good to me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



问题
注册机在单代理场景下(如 Clash 单端口
127.0.0.1:7890)强制并发 = 1,Workers > 1完全无效。多账号注册走同一出口 IP,容易触发 Cloudflare 风控(卡挑战页)。根本原因在
gate.go:方案
通过 Clash/mihomo 外部控制器 API,在每个账号注册前自动将 Selector 组切换到不同节点,让连续注册走不同出口 IP。
利用
browserGate的互斥锁保证切换不冲突:worker 在gate.Acquire()后独占切换节点 → 注册全程 IP 稳定 →gate.Release()后下一个 worker 切到另一个节点。改动
gate.goproxies <= 1的并发锁,改为return workersclash_rotator.go(新增)ClashRotator组件 +AutoDetectClash()service.gorun()创建 rotator,runOne()在 Acquire 后切节点types.goclash_controller/clash_selector_group配置server//api/registrar/clash-autodetect端点ui/ClashRotator 核心 API
自动检测(零配置)
AutoDetectClash()扫描本地9090 / 9097 / 9091等常见端口,发现 Clash 控制器后自动:用户只需 Clash 客户端在运行,点一下按钮即可。
兼容性
实测
141.11.146.67)和 🇯🇵 日本 Z01(103.151.173.207)