wimotek-chromium-sync 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![npm version](https://img.shields.io/npm/v/wimotek-chromium-sync.svg?style=flat-square)](https://www.npmjs.com/package/wimotek-chromium-sync)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](LICENSE)
6
6
 
7
- 专为 Chromium / Chrome 设计的通用会话与 Cookie 集群同步调度工具。支持 1对1 与 1对多集群、本地直连免密、SSH 私钥内容/文件与密码认证、Cookie 有效期智能融合(Merge)以及轻量静态探针。
7
+ 专为 Chromium / Chrome 设计的生产级会话与 Cookie 集群同步调度引擎。支持 1对1 与 1对多集群、域名白/黑名单过滤、会话级连接池复用、Cookie 指纹变更差量同步 (Diff Sync)、本地免密直连及 SSH 私钥文本(PEM)/路径与密码认证。
8
8
 
9
9
  ---
10
10
 
@@ -13,23 +13,22 @@
13
13
  1. **统一现代节点模型 (1对1 / 1对多集群)**:
14
14
  * 原生支持任意规模的节点集群管理与多隧道并发映射。
15
15
  * **本地节点免密直连**:配置本地端口即可直接直连 CDP 探针,跳过 SSH 隧道拉起。
16
-
17
- 2. **原生私钥内容 (PEM String) / 路径与密码认证**:
18
- * `ssh_key`: 原生支持**私钥文本内容字符串**(如以 `-----BEGIN` 开头的 PEM 文本)或**私钥文件绝对路径**(如 `~/.ssh/id_rsa`),调用方无需配置繁琐的环境变量中转。
19
- * `ssh_password`: 直接支持 SSH 密码认证,支持集群级默认凭证与单节点重载。
20
-
21
- 3. **结构化执行指标返回 (Structured Return Dict)**:
22
- * `syncer.run()` 与 `await syncer.run_async()` 执行后返回标准指标字典,上层 Web 控制台可直接捕获迁移量、源端/目标端存量、耗时及明细,无需额外发送 CDP 探针度量。
23
-
24
- 4. **双驱动入口:原生异步协程 + 同步阻塞**:
25
- * 原生提供 `await syncer.run_async()` 与 `await syncer.inspect_async()`,适配 FastAPI、Tornado、aiohttp 等现代异步服务。
26
- * 同步环境直接调用 `syncer.run()`,开箱即用。
27
-
28
- 5. **暴露轻量静态探针工具方法 (无需实例化集群)**:
29
- * 提供单点工具函数:`ChromiumSync.get_cookies(port=9222)`、`ChromiumSync.set_cookies(cookies, port=9222)`、`ChromiumSync.probe(port=9222)`,单点探测仅需 1 行代码。
30
-
31
- 6. **全节点智能 Merge 算法**:
32
- * 汇总所有节点 Cookie,针对冲突项**优先保留有效期最新(expires 更长 / 最新持久凭证)的 Cookie**,并写回热刷新。
16
+ 2. **域名白名单 / 黑名单过滤机制 (Domain Filter)**:
17
+ * **`include_domains`**:仅提取与同步关注的关键业务域名(如 `['.google.com', '.github.com', '.twitter.com']`),剔除海量无关噪音。
18
+ * **`exclude_domains`**:自动过滤广告、统计追踪类垃圾 Cookie(如 `['doubleclick.net', 'google-analytics.com']`),大幅提升同步速率并防止从端污染。
19
+ 3. **会话级连接池复用 (Connection Pooling)**:
20
+ * 原生支持异步与同步上下文管理器:`async with ChromiumSync(...) as syncer:`。
21
+ * 在高频周期调度、定时巡检场景下,复用底层常驻 WebSocket CDP 会话与 SSH 隧道,避免重复握手建立与销毁,消除网络与 CPU 抖动。
22
+ 4. **Cookie 指纹变更差量同步 (Diff / Delta Sync)**:
23
+ * 默认开启 `diff=True`:自动比对目标端与待同步 Cookie 的核心指纹 `(name, domain, path, value)`。
24
+ * **仅对产生实质变动的凭据执行写入**,若完全一致则直接跳过,并避免无意义触发浏览器页面重载,**极大保护从属节点的磁盘与 SSD IO 寿命**。
25
+ 5. **原生私钥内容 (PEM String) / 路径与密码认证**:
26
+ * `ssh_key`: 原生支持**私钥 PEM 文本内容字符串**或**私钥文件绝对路径**,调用方无需配置环境变量中转。
27
+ * `ssh_password`: 直接支持 SSH 密码认证,支持集群级默认凭证与单节点自定义。
28
+ 6. **结构化执行指标返回 (Structured Return Dict)**:
29
+ * 执行后返回包含 `status`、`transferred_count`、`diff_skipped_count`、`duration` 等度量指标的标准字典,Web 控制台可直接消费展示。
30
+ 7. **全量纯函数工具方法开箱即用**:
31
+ * 模块顶级导出 `merge_cookies`、`filter_cookies`、`compute_cookie_delta` 等独立纯函数工具,无需 CDP 环境亦可直接处理和计算 Cookie 差量。
33
32
 
34
33
  ---
35
34
 
@@ -50,57 +49,53 @@ npm install -g wimotek-chromium-sync
50
49
 
51
50
  ## 🚀 极简开发示例
52
51
 
53
- ### 1. 轻量静态探针工具(无需实例化集群)
54
- 单点探测某个节点时,直接 1 行静态调用:
52
+ ### 1. 会话级连接池复用 (高频周期调度推荐)
53
+ 使用 `async with` 上下文管理器常驻复用 CDP 连接与隧道,杜绝频繁断连与握手损耗:
55
54
  ```python
55
+ import asyncio
56
56
  from chromium_sync import ChromiumSync
57
57
 
58
- # 1. 单点探测节点在线状态与页面信息
59
- info = ChromiumSync.probe(port=9222)
60
- print(info)
61
- # {'online': True, 'cookie_count': 42, 'page_title': 'GitHub', 'page_url': 'https://github.com', ...}
62
-
63
- # 2. 单点直接提取 Cookie 列表
64
- cookies = ChromiumSync.get_cookies(port=9222)
65
-
66
- # 3. 单点直接批量写入 Cookie 并热刷新页面
67
- ChromiumSync.set_cookies(cookies, port=9223, reload=True)
58
+ async def periodic_sync_task():
59
+ # 进入上下文时自动预热连接池与隧道
60
+ async with ChromiumSync(
61
+ nodes=[
62
+ {"id": "local", "cdp_port": 9222},
63
+ {"id": "kr2", "ssh_host": "kr2.wimotek.com", "ssh_key": "~/.ssh/id_rsa", "cdp_port": 9222}
64
+ ],
65
+ mode="merge",
66
+ include_domains=["google.com", "github.com"], # 仅同步核心业务域名
67
+ diff=True # 开启差量比对,保护磁盘
68
+ ) as syncer:
69
+ for round_idx in range(5):
70
+ # 复用已建立的 WebSocket 会话执行热同步
71
+ result = await syncer.sync_async()
72
+ print(f"第 {round_idx + 1} 轮同步完成: 写入 {result['transferred_count']} 条, 跳过一致凭据 {result['diff_skipped_count']} 条")
73
+ await asyncio.sleep(60)
74
+
75
+ asyncio.run(periodic_sync_task())
68
76
  ```
69
77
 
70
78
  ---
71
79
 
72
- ### 2. 现代多节点集群同步与结构化返回
73
-
74
- #### (1) Python 同步调用 (同步脚本 / Celery 任务)
80
+ ### 2. 域名过滤与差量同步 (Diff Sync)
75
81
  ```python
76
82
  from chromium_sync import ChromiumSync
77
83
 
78
84
  syncer = ChromiumSync(
79
85
  nodes=[
80
- {"id": "local", "name": "本地容器", "cdp_port": 9223},
81
- {
82
- "id": "kr2",
83
- "name": "韩国生产服",
84
- "ssh_host": "kr2.wimotek.com",
85
- "ssh_user": "root",
86
- # 直接支持私钥文本内容 (PEM String) 或文件路径
87
- "ssh_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIB...\n-----END RSA PRIVATE KEY-----",
88
- "cdp_port": 9222
89
- },
90
- {
91
- "id": "sg1",
92
- "name": "新加坡服",
93
- "ssh_host": "sg1.wimotek.com",
94
- "ssh_user": "ubuntu",
95
- # 直接支持密码认证
96
- "ssh_password": "YourStrongPassword123",
97
- "cdp_port": 9222
98
- }
86
+ {"id": "local", "cdp_port": 9223},
87
+ {"id": "kr2", "ssh_host": "kr2.wimotek.com", "ssh_user": "root", "ssh_key": "~/.ssh/id_rsa", "cdp_port": 9222},
88
+ {"id": "sg1", "ssh_host": "sg1.wimotek.com", "ssh_user": "ubuntu", "ssh_password": "YourPassword", "cdp_port": 9222}
99
89
  ],
100
- mode="merge" # "merge" (合并最新凭据) 或 "sync" (单源广播)
90
+ mode="merge",
91
+ # 白名单:仅同步以下业务站点的 Cookie
92
+ include_domains=["google.com", "twitter.com", "x.com", "github.com"],
93
+ # 黑名单:过滤广告与追踪类 Cookie
94
+ exclude_domains=["doubleclick.net", "google-analytics.com"],
95
+ # 差量比对 (默认 True)
96
+ diff=True
101
97
  )
102
98
 
103
- # 执行同步并获取度量指标字典
104
99
  result = syncer.run()
105
100
  print(result)
106
101
  ```
@@ -108,91 +103,166 @@ print(result)
108
103
  ```python
109
104
  {
110
105
  "status": "success", # "success" | "failed"
111
- "mode": "merge", # 执行模式
112
- "transferred_count": 45, # 实际迁移/融合生成的 Cookie 数量
113
- "source_total": 80, # 源端/融合前凭证总数
114
- "target_total": 45, # 目标端/融合后凭证总数
115
- "nodes_synced": ["local", "kr2", "sg1"], # 成功同步的节点列表
116
- "duration": 1.25, # 耗时(秒)
117
- "details": "全节点 Merge 成功: 融合 45 条最新凭证至 ['本地容器', '韩国生产服', '新加坡服']",
106
+ "mode": "merge",
107
+ "transferred_count": 8, # 本次真正变动并写入的 Cookie 数量
108
+ "diff_skipped_count": 34, # 指纹完全相同、跳过写入以保护磁盘的 Cookie 数量
109
+ "source_total": 42, # 过滤后的业务凭证总数
110
+ "target_total": 42,
111
+ "nodes_synced": ["local", "kr2", "sg1"],
112
+ "duration": 0.85, # 耗时(秒)
113
+ "details": "全节点 Merge 成功: 融合并向 ['local', 'kr2', 'sg1'] 写入 8 条凭证 (跳过一致指纹 34 条)",
118
114
  "error": None
119
115
  }
120
116
  ```
121
117
 
122
- #### (2) FastAPI / aiohttp 异步协程原生驱动
118
+ ---
119
+
120
+ ### 3. 轻量静态探针(无需实例化集群)
121
+ 单点探测某个节点时,直接 1 行静态调用:
123
122
  ```python
124
- from fastapi import FastAPI
125
123
  from chromium_sync import ChromiumSync
126
124
 
127
- app = FastAPI()
125
+ # 1. 单点探测节点在线状态与页面信息
126
+ info = ChromiumSync.probe(port=9222)
127
+ print(info)
128
+ # {'online': True, 'cookie_count': 42, 'page_title': 'GitHub', 'page_url': 'https://github.com', ...}
129
+
130
+ # 2. 单点直接提取 Cookie (支持域名过滤)
131
+ cookies = ChromiumSync.get_cookies(port=9222, include_domains=["github.com"])
128
132
 
129
- @app.post("/api/sync")
130
- async def trigger_sync():
131
- syncer = ChromiumSync(
132
- nodes=[
133
- {"id": "local", "cdp_port": 9222},
134
- {"id": "cloud", "ssh_host": "remote.host.com", "ssh_key": "~/.ssh/id_rsa", "cdp_port": 9222}
135
- ],
136
- mode="merge"
137
- )
138
- # 原生 asyncio 协程,零线程切换开销,高并发性能极佳
139
- result = await syncer.run_async()
140
- return result
133
+ # 3. 单点写入 Cookie 并启用差量检测
134
+ ChromiumSync.set_cookies(cookies, port=9223, reload=True, diff=True)
135
+ ```
136
+
137
+ ---
138
+
139
+ ### 4. 导出顶级独立纯函数工具
140
+ 即使没有运行中的 CDP 浏览器,亦可使用顶级导出的纯函数对 Cookie 结构做离线处理:
141
+ ```python
142
+ from chromium_sync import merge_cookies, filter_cookies, compute_cookie_delta
143
+
144
+ raw_cookies = [
145
+ {"name": "token", "value": "val1", "domain": ".github.com", "path": "/", "expires": 1700000000},
146
+ {"name": "_ad", "value": "track", "domain": ".doubleclick.net", "path": "/", "expires": 1700000000}
147
+ ]
148
+
149
+ # 1. 独立过滤域名
150
+ filtered = filter_cookies(raw_cookies, include_domains=["github.com"])
151
+
152
+ # 2. 独立比对两组 Cookie 差量
153
+ delta, skipped = compute_cookie_delta(incoming_cookies=filtered, existing_cookies=[])
154
+
155
+ # 3. 多端 Cookie 离线融合 (优先保留最新过期时间)
156
+ merged = merge_cookies([[c1, c2], [c3]])
141
157
  ```
142
158
 
143
159
  ---
144
160
 
145
- ### 3. 命令行 CLI 执行
161
+ ### 5. 命令行 (CLI) 快速执行
146
162
 
147
- #### (1) 内联语法直接启动多节点 Merge
163
+ #### (1) 带域名过滤与差量比对的同步
148
164
  ```bash
149
165
  chromium-sync \
150
- --node id=local,port=9223 \
151
- --node id=kr2,ssh=root@kr2.wimotek.com,port=9222,key=~/.ssh/id_rsa \
152
- --node id=sg1,ssh=ubuntu@sg1.wimotek.com,port=9222,pass=SecretPass123 \
166
+ --config cluster.json \
167
+ --include-domains google.com github.com twitter.com \
168
+ --exclude-domains doubleclick.net google-analytics.com \
153
169
  --mode merge
154
170
  ```
155
171
 
156
- #### (2) 仅查看节点状态与 Cookie 数量 (ASCII 表格)
172
+ #### (2) 仅查看过滤后的节点状态表格 (ASCII 报表)
157
173
  ```bash
158
- chromium-sync --config cluster.json --status
174
+ chromium-sync \
175
+ --config cluster.json \
176
+ --include-domains google.com github.com \
177
+ --status
159
178
  ```
160
179
  输出样例:
161
180
  ```text
162
- ==========================================================================================
163
- 节点 ID | 节点名称 | 类型 | CDP端口/映射 | Cookie数 | 当前页面状态
164
- ------------------------------------------------------------------------------------------
165
- local | 本地容器 | 本地直连 | 9223 | 42 条 | [Google] https://google.com
166
- kr2 | 韩国节点 | SSH远程 | 19222 | 38 条 | [GitHub] https://github.com
167
- ==========================================================================================
181
+ ============================================================================================
182
+ 节点 ID | 节点名称 | 类型 | CDP端口/映射 | Cookie有效数 | 当前页面状态
183
+ --------------------------------------------------------------------------------------------
184
+ local | 本地容器 | 本地直连 | 9223 | 18 条 | [GitHub] https://github.com
185
+ kr2 | 韩国生产服 | SSH远程 | 19222 | 16 条 | [Google] https://google.com
186
+ --------------------------------------------------------------------------------------------
187
+ 过滤规则: [白名单: google.com, github.com]
188
+ ============================================================================================
168
189
  ```
169
190
 
170
- #### (3) 导出 Cookie 详情或执行结果为 JSON
191
+ #### (3) 导出指标 JSON (供 CI/CD 或自动化运维捕获)
171
192
  ```bash
172
- # 1. 导出所有节点及 Cookie 列表为 JSON
173
- chromium-sync --config cluster.json --status --json > /tmp/cluster_data.json
174
-
175
- # 2. 执行同步并将结构化指标以 JSON 打印 (方便 CI/CD 或流水线捕获)
176
193
  chromium-sync --config cluster.json --mode merge --json
177
194
  ```
178
195
 
196
+ #### (4) 命令行内联多节点语法
197
+ ```bash
198
+ chromium-sync \
199
+ --node id=local,port=9223 \
200
+ --node id=kr2,ssh=root@kr2.wimotek.com,port=9222,key=~/.ssh/id_rsa \
201
+ --node id=sg1,ssh=ubuntu@sg1.wimotek.com,port=9222,pass=SecretPassword \
202
+ --mode merge
203
+ ```
204
+
179
205
  ---
180
206
 
181
- ## ⚙️ 节点参数配置规范 (NodeConfig)
207
+ ## ⚙️ 核心参数与配置规范
208
+
209
+ ### `cluster.json` 配置文件结构
210
+ ```json
211
+ [
212
+ {
213
+ "id": "local",
214
+ "name": "本机容器",
215
+ "cdp_port": 9222
216
+ },
217
+ {
218
+ "id": "kr2",
219
+ "name": "韩国服",
220
+ "ssh_host": "kr2.wimotek.com",
221
+ "ssh_port": 22,
222
+ "ssh_user": "root",
223
+ "ssh_key": "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----",
224
+ "cdp_port": 9222
225
+ },
226
+ {
227
+ "id": "sg1",
228
+ "name": "新加坡服",
229
+ "ssh_host": "sg1.wimotek.com",
230
+ "ssh_user": "ubuntu",
231
+ "ssh_password": "Password123",
232
+ "cdp_port": 9222
233
+ }
234
+ ]
235
+ ```
236
+
237
+ ### `ChromiumSync` 初始化参数
182
238
 
183
- | 字段 | 类型 | 默认值 | 详细说明 |
239
+ | 参数字段 | 类型 | 默认值 | 详细说明 |
184
240
  | :--- | :--- | :--- | :--- |
185
- | `id` | str | 必填 | 节点唯一标识符 (例如 `local`, `kr2`) |
186
- | `name` | str | `id` | 节点显示名称 |
187
- | `is_local` | bool | 自动识别 | 是否为本地节点 (不填 `ssh_host` 或填回环地址自动判定为本地,免密直连) |
188
- | `cdp_host` | str | `127.0.0.1` | 节点 CDP 服务监听的主机地址 |
189
- | `cdp_port` | int | `9222` | 节点暴露的 CDP 端口 |
190
- | `ssh_host` | str | `None` | 远程服务器 IP 或主机名 (提供该字段时识别为远程 SSH 节点) |
191
- | `ssh_port` | int | `22` | 远程服务器 SSH 端口 |
192
- | `ssh_user` | str | `root` | 远程 SSH 用户名 |
193
- | `ssh_key` | str | `None` | **SSH 私钥 (同时支持文件绝对路径 或 私钥 PEM 文本字符串)** |
194
- | `ssh_password` | str | `None` | SSH 登录密码 (自动适配 `sshpass` 与原生 `SSH_ASKPASS`) |
195
- | `tunnel_port` | int | 自动分配 | 本地用于映射隧道的端口 (多节点自动分配防冲突) |
241
+ | `nodes` | list | 必填 | 节点配置列表 (支持 `NodeConfig` 或 dict) |
242
+ | `mode` | str | `'sync'` | 同步策略: `'merge'`(全端融合最新凭证) 或 `'sync'`(单源广播) |
243
+ | `include_domains` | list | `None` | **域名白名单**:仅同步匹配列表的 Cookie (如 `['google.com']`) |
244
+ | `exclude_domains` | list | `None` | **域名黑名单**:排除广告/统计类 Cookie (如 `['doubleclick.net']`) |
245
+ | `diff` | bool | `True` | **指纹差量同步**:相同凭据跳过写入,避免频繁刷盘并保护磁盘 IO |
246
+ | `source` | str | 第一个节点 | `'sync'` 模式下的源节点 ID |
247
+ | `targets` | list | 其余节点 | `'sync'` 模式下的目标节点 ID 列表 |
248
+ | `ssh_key` | str | `None` | 集群默认 SSH 私钥 (支持私钥文件绝对路径 或 私钥 PEM 文本内容) |
249
+ | `ssh_password` | str | `None` | 集群默认 SSH 密码认证 |
250
+ | `auto_close_tunnel` | bool | `False` | 任务完成后是否自动关闭创建的 SSH 隧道 |
251
+ | `verbose` | bool | `True` | 是否输出详细调度日志 |
252
+
253
+ ---
254
+
255
+ ## 📚 模块导出接口一览 (`__all__`)
256
+
257
+ ```python
258
+ from chromium_sync import (
259
+ ChromiumSync, # 主集群调度器与连接池上下文
260
+ NodeConfig, # 统一节点配置数据类
261
+ merge_cookies, # 多节点 Cookie 智能融合纯函数
262
+ filter_cookies, # 域名白名单/黑名单过滤纯函数
263
+ compute_cookie_delta # Cookie 指纹变更差量计算纯函数
264
+ )
265
+ ```
196
266
 
197
267
  ---
198
268
 
@@ -2,7 +2,7 @@
2
2
  wimotek-chromium-sync Package
3
3
  Universal Chromium Session & Cookie Synchronizer with SSH Tunnel and Cluster Support
4
4
  """
5
- from .core import ChromiumSync, NodeConfig, merge_cookies
5
+ from .core import ChromiumSync, NodeConfig, merge_cookies, filter_cookies, compute_cookie_delta
6
6
 
7
- __version__ = "1.2.0"
8
- __all__ = ["ChromiumSync", "NodeConfig", "merge_cookies"]
7
+ __version__ = "1.3.0"
8
+ __all__ = ["ChromiumSync", "NodeConfig", "merge_cookies", "filter_cookies", "compute_cookie_delta"]
@@ -72,23 +72,20 @@ def main():
72
72
  formatter_class=argparse.RawDescriptionHelpFormatter,
73
73
  epilog="""
74
74
  使用示例:
75
- # 1. 快速查看节点状态与 Cookie 数量 (ASCII 表格)
75
+ # 1. 过滤仅同步指定业务域名 (如 google, twitter, github)
76
+ chromium-sync --config cluster.json --include-domains google.com twitter.com github.com --mode merge
77
+
78
+ # 2. 排除广告/统计类无关域名 (如 doubleclick, google-analytics)
79
+ chromium-sync --config cluster.json --exclude-domains doubleclick.net google-analytics.com --mode merge
80
+
81
+ # 3. 快速查看过滤后的节点状态与 Cookie 数量 (ASCII 表格)
76
82
  chromium-sync --node id=local,port=9222 --node id=kr2,ssh=root@kr2.wimotek.com,port=9222,key=~/.ssh/id_rsa --status
77
83
 
78
- # 2. 导出节点状态与 Cookie 详情为 JSON (便于程序直接提取 Cookie 列表)
84
+ # 4. 导出节点状态与 Cookie 详情为 JSON (便于程序直接提取 Cookie 列表)
79
85
  chromium-sync --config cluster.json --status --json
80
86
 
81
- # 3. 全节点 Cookie 智能 Merge (合并所有节点并保留最新有效期)
87
+ # 5. 全节点 Cookie 智能 Merge (合并所有节点并保留最新有效期,默认启用指纹差量 Diff)
82
88
  chromium-sync --config cluster.json --mode merge
83
-
84
- # 4. 指定单源节点广播同步并输出结构化指标 JSON
85
- chromium-sync --config cluster.json --mode sync --source local --json
86
-
87
- # 5. 极简命令行多节点直接同步
88
- chromium-sync \\
89
- --node id=local,port=9223 \\
90
- --node id=kr2,ssh=root@kr2.wimotek.com,port=9222,key=~/.ssh/id_rsa \\
91
- --mode merge
92
89
  """
93
90
  )
94
91
 
@@ -101,6 +98,15 @@ def main():
101
98
  parser.add_argument("--ssh-key", help="集群默认 SSH 私钥 (支持私钥文件绝对路径 或 私钥 PEM 文本内容)")
102
99
  parser.add_argument("--ssh-password", help="集群默认 SSH 连接密码")
103
100
 
101
+ # 域名过滤机制
102
+ parser.add_argument("--include-domains", nargs="*", default=None,
103
+ help="域名白名单过滤列表 (如: google.com twitter.com github.com)")
104
+ parser.add_argument("--exclude-domains", nargs="*", default=None,
105
+ help="域名黑名单过滤列表 (如: doubleclick.net google-analytics.com)")
106
+
107
+ # 差量写入策略
108
+ parser.add_argument("--no-diff", action="store_true", help="禁用指纹差量检测,强制全量覆写目标节点 Cookie")
109
+
104
110
  # 同步模式
105
111
  parser.add_argument("--mode", choices=["sync", "merge"], default="sync",
106
112
  help="同步方式: 'merge'(合并所有节点最新Cookie), 'sync'(单源广播同步,默认)")
@@ -143,6 +149,9 @@ def main():
143
149
  mode=args.mode,
144
150
  source=args.source,
145
151
  targets=args.targets,
152
+ include_domains=args.include_domains,
153
+ exclude_domains=args.exclude_domains,
154
+ diff=(not args.no_diff),
146
155
  ssh_key=args.ssh_key,
147
156
  ssh_password=args.ssh_password,
148
157
  auto_close_tunnel=args.auto_close,