wimotek-chromium-sync
专为 Chromium / Chrome 设计的通用会话与 Cookie 穿透热同步工具。
支持在本地容器与远程服务器容器之间双向热同步登录凭证(Cookie + LocalStorage),全端口可参数化自定义,内置智能流向识别与带心跳保活的 SSH 隧道自愈管理。
🌟 核心特性
- 全端口自由定义:本地容器端口、远程实际端口、本地隧道映射端口及 SSH 端口均可自由配置或通过环境变量覆盖。
- 智能双向流向探测 (auto):连通后自动探测两端 Cookie 数量与页面状态,支持智能推荐、人工交互确认或全自动执行。
- 内置心跳保活隧道:内置 ServerAliveInterval=15 与端口占用检测,已存在则自动复用,不存在则自动拉起,绝不产生假死僵尸连接。
- 无 TTY 环境自适应:在 Linux Crontab 定时任务、无图形后台或 CI 流程中自动回退,不因无键盘输入而崩溃。
- 双生态支持:同时发布于 PyPI 与 npm,支持 Python 代码导入与命令行跨语言一键执行。
📦 安装
Python 环境 (PyPI)
pip install wimotek-chromium-sync
Node.js 环境 (npm)
npm install wimotek-chromium-sync
🚀 极简使用示例
1. Python 代码调用(仅需 3 行)
from chromium_sync import ChromiumSync
自由定制两端的所有端口
syncer = ChromiumSync( remote_ssh="root@xx.xx.xx", # 远程 SSH 服务器
remote_ssh_port=22, # SSH 连接端口
local_cdp_port=16002, # 本地容器的 CDP 端口
remote_cdp_port=9222, # 远程容器的实际
CDP 端口 remote_tunnel_port=9222, # 本地用于接收隧道的端口
direction="auto", # 智能判断: 自动往缺少凭证的一端同步
timeout=15 # 倒计时等待秒数 (0 为秒执行) )
syncer.run()
2. 命令行使用 (CLI 模式)
无论是通过 pip 安装还是 npm 安装,均可直接在终端中敲命令运行:
查看所有端口与流向选项
chromium-sync --help
自由指定各端口全自动推送 (0 秒等待)
chromium-sync
--remote-ssh root@xx.xx.xx
--ssh-port 22
--local-port 9222
--tunnel-port 9222
--direction push
--timeout 0
⚙️ 端口与参数对应说明
| 参数名称 | 命令行选项 | 对应环境变量 | 默认值 | 详细说明 |
|---|---|---|---|---|
| remote_ssh | --remote-ssh | CHROMIUM_REMOTE_SSH | root@xx.xx.xx | 远程 SSH 连接主机 |
| remote_ssh_port | --ssh-port | CHROMIUM_SSH_PORT | 22 | 远程服务器的 SSH 端口 |
| local_cdp_port | --local-port | CHROMIUM_LOCAL_PORT | 16002 | 运行在本机的容器 CDP 端口 |
| remote_cdp_port | --remote-port | CHROMIUM_REMOTE_CDP_PORT | 9222 | 运行在远端服务器上的容器实际端口 |
| remote_tunnel_port | --tunnel-port | CHROMIUM_TUNNEL_PORT | 9222 | SSH 隧道映射到本机的监听端口 |
| direction | --direction | CHROMIUM_DIRECTION | push | 默认同步流向 (push 或 pull 或 auto) |
| timeout | --timeout | CHROMIUM_TIMEOUT | 15 | 倒计时交互等待秒数,0 为免打扰秒执行 |
| auto_close_tunnel | --auto-close | - | False | 任务完成后是否关闭创建的 SSH 隧道 |
🤖 自动化与定时任务配置示例
配合 Linux Crontab,每天凌晨自动将本地维护好的登录态推送到云端远程容器:
编辑定时任务
crontab -e
添加此行:每天凌晨 3:00 自动执行同步且不弹任何提示
0 3 * * * /usr/local/bin/chromium-sync --direction push --timeout 0 --auto-close >> /tmp/chromium_sync.log 2>&1
📄 License
MIT License
Metadata
Release files for wimotek-chromium-sync 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wimotek_chromium_sync-1.0.7.tar.gz | 9.7 kB | Without provenance | Details for wimotek_chromium_sync-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wimotek_chromium_sync-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for wimotek_chromium_sync-1.0.7-py3-none-any.whl |
Total release size: 18.6 kB
Release files / wimotek_chromium_sync-1.0.7.tar.gz
| Download URL | wimotek_chromium_sync-1.0.7.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64ad514ac1d37612a7a0002d832a53447b23ed73da42cda5f5e81ce8d9c4005e
|
|
BLAKE2b-256 checksum How to use checksums |
cf77cb0b21a26e0c30e59ff7b358be948cb37150f32585a8c26076cee229f4d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Release files / wimotek_chromium_sync-1.0.7-py3-none-any.whl
| Download URL | wimotek_chromium_sync-1.0.7-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24bb12e5d2decd5ceaaa9703b9c8c12a22675c245ff03cca8a0650bb15d4fb40
|
|
BLAKE2b-256 checksum How to use checksums |
4a3bc497d81ae3fe58b41bf351addc474990d9e3193301bbc83ff03ac703b75b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Security for wimotek-chromium-sync 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.