plus-sync
v1.2.0
Published
分布式P2P文件同步客户端
Maintainers
Readme
PeerSync - 分布式P2P文件同步客户端
测试双向同步
实时文件同步客户端,支持多客户端 P2P 同步。
安装
方式一:通过 NPM 安装
npm install -g plus-sync方式二:下载可执行文件
从 Releases 下载对应平台的可执行文件:
- Windows:
peersync-win.exe - Linux:
peersync-linux - macOS:
peersync-macos
使用方法
方式一:使用配置文件(推荐)
# 生成配置文件
peersync --init-config
# 编辑 peersync.config,设置房间ID和认证信息
# 然后直接启动
peersync方式二:命令行参数
peersync --room <room-id> --dir <sync-directory> [options]命令行参数说明
| 参数 | 说明 | 默认值 |
|------|------|--------|
| --room <id> | 房间ID(必填,或从配置文件读取) | - |
| --dir <path> | 本地同步目录 | ./sync |
| --server <url> | 服务器地址 | wss://trae.ssh.skillup.host:8868 |
| --token <token> | 认证令牌(可选,或从配置文件读取) | - |
| --strategy <strategy> | 冲突解决策略: server/local/prompt | server |
| --bidirectional <bool> | 双向同步开关 | true |
| --watch-delay <ms> | 文件监控延迟 | 500 |
| --verbose, -v | 调试模式 | false |
| --init | 生成 .syncignore 文件 | - |
| --init-config | 生成 peersync.config 文件 | - |
| --help | 显示帮助 | - |
配置文件 peersync.config
# 基本配置
room = myproject # 房间ID(必填)
authToken = your-token # 认证令牌(可选)
server = wss://example.com # 服务器地址
# 同步选项
strategy = server # 冲突解决策略
bidirectional = true # 双向同步
watchDelay = 500 # 监控延迟(毫秒)
# 忽略规则(逗号分隔)
ignore = node_modules/**, .git/**, *.log使用示例
# 生成配置文件
peersync --init-config
# 生成忽略文件
peersync --init
# 使用配置文件启动(无需参数)
peersync
# 或使用命令行参数
peersync --room myproject --dir ./myproject
# 带认证令牌
peersync --room myproject --dir ./myproject --token abc123
# 本地优先冲突解决
peersync --room myproject --dir ./myproject --strategy local功能特性
- ✅ 实时文件同步
- ✅ P2P 多客户端同步
- ✅ 配置文件支持(peersync.config)
- ✅ 认证与房间隔离
- ✅ 增量更新
- ✅ 全量同步
- ✅ 冲突检测与解决
- ✅ 自动重连
- ✅ 文件变更节流优化
- ✅ 并发同步队列
- ✅ 空文件支持
- ✅ 循环同步检测
冲突解决策略
server: 服务器优先(默认)local: 本地优先prompt: 提示用户选择
开发
# 克隆仓库
git clone <repo-url>
cd sync
# 安装依赖
npm install
# 运行测试
npm test
# 打包可执行文件
npm run build许可证
MIT
