PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.
Dart airdrop-alternativeclipboardclipboard-sharingclipboard-synccopy-pastecross-platformend-to-end-encryptionfile-syncfile-transferfluttergolanglinuxmacosnat-traversalp2pself-hostedtailscaleuniversal-clipboardwebrtcwindows
docs: describe local network mode
baiyuze5cdddfe6695a
diff --git a/README.md b/README.mdindex d4f5644..22282f2 100644--- a/README.md+++ b/README.md@@ -35,7 +35,7 @@Universal Clipboard needs the same Apple ID and both Macs close by. AirDrop makes you accept every time and doesn't touch the clipboard. Messaging yourself means manual downloads and your files on someone else's server. With one Mac and one Windows PC, none of the built-in options work.-With CopySync you pair two computers once. After that, copy on one and paste on the other — Mac to Mac, Mac to Windows, or Windows to Windows. Data goes directly between the devices; when a direct connection can't be made, it is relayed through a server you run yourself. Everything is end-to-end encrypted and the server cannot read it.+With CopySync you pair two computers once. After that, copy on one and paste on the other — Mac to Mac, Mac to Windows, or Windows to Windows. On the same network it works with no server at all; across networks, a server you run yourself or Tailscale lets the two find each other. Data goes directly between the devices, end-to-end encrypted; when a direct connection can't be made, it is relayed through your server, which still can't read it.| | CopySync | Universal Clipboard | AirDrop | Chat apps ||---|:-:|:-:|:-:|:-:|@@ -52,6 +52,7 @@ With CopySync you pair two computers once. After that, copy on one and paste on- **Text, rich text, images, files and folders.** What you copy is what comes out on the other side.- **Size-aware transfer.** Anything under 50 MB (adjustable) is pushed as soon as you copy; larger files sync as a record you pull when you need them.- **History** of the last 3 days (adjustable) across all your computers, with image preview.+- **No server on the same network.** Computers find each other and pair with a code; on a different subnet you also enter an address.- **Direct first, relay as fallback**, including office networks with several uplinks.- **Fingerprint check when pairing**, so neither the server nor anyone on the network can impersonate your device.- **Runs in the background**, starts at login, recovers from crashes. English, Chinese and Japanese.@@ -65,15 +66,19 @@ With CopySync you pair two computers once. After that, copy on one and paste on## Get started-New here? The **[quick start](https://baiyuze.github.io/copysync/en/start/)** walks through it with screenshots. You need **the app on each computer** and **a server both can reach**.+New here? The **[quick start](https://baiyuze.github.io/copysync/en/start/)** walks through it with screenshots. You need **the app on each computer**. On the same network that's all; across networks, add a server or Tailscale.-**1. Run the server.** There are three ways; pick the one that fits. Each has a step-by-step guide:+**1. Install the app** on each computer: [CopySync.dmg](https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg) for macOS 13+, [CopySync-Setup.exe](https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe) for Windows 10/11 ([portable zip](https://github.com/baiyuze/copysync/releases/latest/download/CopySync-windows-x64.zip)). The builds aren't notarized or code-signed yet: on Mac, allow it once under **System Settings → Privacy & Security → Open Anyway**; on Windows, click **More info → Run anyway**. Then click **Turn on background sync**, and allow CopySync when Windows Firewall asks, or when macOS asks to find devices on your local network.++**2. Pair.** On one computer, **Devices → Add device → Show a code**; on the other, **Enter a code**. On a different subnet, click **On a different subnet?** and also enter the address shown under the code. Confirm only if both screens show the same two fingerprint lines. From then on, copy on either one and paste on the other.++**3. Across networks (optional).** Three ways to connect, each with a step-by-step guide:| Way | Best for | You need ||---|---|---|+| **[Same network](https://baiyuze.github.io/copysync/en/lan/)** | Computers behind one router, at home or in the office | Nothing || **[Public server](https://baiyuze.github.io/copysync/en/cloud/)** | Computers on different networks that should sync from anywhere | A Linux VM with a public IP; the smallest is enough |-| **[LAN](https://baiyuze.github.io/copysync/en/server/)** | All computers on one network (home or office) | One always-on Windows, Mac or Linux computer there |-| **[LAN + Tailscale](https://baiyuze.github.io/copysync/en/tailscale/)** | Across networks without a public server | An always-on computer, and [Tailscale](https://tailscale.com) on every computer |+| **[Tailscale](https://baiyuze.github.io/copysync/en/tailscale/)** | Across networks without a server | [Tailscale](https://tailscale.com) on every computer; enter the other's Tailscale address when pairing |On a public server:@@ -83,27 +88,23 @@ tar xzf copysync-server-linux-amd64.tar.gz && cd copysync-server-linux-amd64sudo ./install.sh <public IP of the server>```-Open TCP 8787, UDP 3478 and UDP 32768–60999. Docker and all options: [server deployment guide](server/deploy/README.md).--**2. Install the app** on each computer: [CopySync.dmg](https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg) for macOS 13+, [CopySync-Setup.exe](https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe) for Windows 10/11 ([portable zip](https://github.com/baiyuze/copysync/releases/latest/download/CopySync-windows-x64.zip)). The builds aren't notarized or code-signed yet: on Mac, allow it once under **System Settings → Privacy & Security → Open Anyway**; on Windows, click **More info → Run anyway**. Then click **Turn on background sync** and enter `ws://<server address>:8787/signal` under **Settings → Signaling server**.--**3. Pair.** On one computer, **Devices → Add device → Show a code**; on the other, **Enter a code**. Confirm only if both screens show the same two fingerprint lines. From then on, copy on either one and paste on the other.+Open TCP 8787, UDP 3478 and UDP 32768–60999, then enter `ws://<server address>:8787/signal` under **Settings → Signaling server** on each computer. Docker and all options: [server deployment guide](server/deploy/README.md).| | Requirement ||---|---|| **Mac app** | macOS 13 Ventura or later; Intel and Apple silicon || **Windows app** | Windows 10 (21H2 or later) and 11, x64 |-| **Server** | Linux (x86_64, ARM64; systemd or Docker), macOS, or Windows 10/11 x64 |+| **Server** | Optional, only to sync across networks: Linux (x86_64, ARM64; systemd or Docker), macOS, or Windows 10/11 x64 || **iPhone / iPad** | Not supported: iOS doesn't let apps watch the clipboard in the background |## Documentation- [How it works](guide/how-it-works.md): architecture, NAT traversal, security model, fallbacks, lessons learned- [Troubleshooting](guide/troubleshooting.md) and known limitations-- [Quick start](https://baiyuze.github.io/copysync/en/start/) · [Public server](https://baiyuze.github.io/copysync/en/cloud/) · [LAN](https://baiyuze.github.io/copysync/en/server/) · [LAN + Tailscale](https://baiyuze.github.io/copysync/en/tailscale/), all with screenshots+- [Quick start](https://baiyuze.github.io/copysync/en/start/) · [Same network](https://baiyuze.github.io/copysync/en/lan/) · [Public server](https://baiyuze.github.io/copysync/en/cloud/) · [Tailscale](https://baiyuze.github.io/copysync/en/tailscale/) · [Run a server on your LAN](https://baiyuze.github.io/copysync/en/server/), all with screenshots- [Server deployment](server/deploy/README.md): Windows, macOS, Linux, Docker, Tailscale- [Building from source](guide/building.md)-- Design notes (Chinese): [NAT traversal on multi-uplink networks](design/nat-traversal.md), [Windows client](design/windows-client.md)+- Design notes (Chinese): [Local network mode](design/lan-mode.md), [NAT traversal on multi-uplink networks](design/nat-traversal.md), [Windows client](design/windows-client.md)- [Changelog](CHANGELOG.md)## Licensediff --git a/README.zh-CN.md b/README.zh-CN.mdindex 26084f0..f364e66 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -35,7 +35,7 @@通用剪贴板要同一个 Apple ID、两台离得近;隔空投送每次都要点接收,也不管剪贴板;发给自己要手动下载,文件还留在别人的服务器上。一台 Mac、一台 Windows 时,系统自带的办法一个都用不了。-CopySync 的做法是:两台电脑配对一次,之后在一台上复制,另一台上直接粘贴。Mac 与 Mac、Mac 与 Windows、Windows 与 Windows 都可以。数据在两台设备之间直接传输,打不通直连时经过你自己部署的服务器中转,全程端到端加密,服务器看不到内容。+CopySync 的做法是:两台电脑配对一次,之后在一台上复制,另一台上直接粘贴。Mac 与 Mac、Mac 与 Windows、Windows 与 Windows 都可以。同一个网络里装好就能用,不需要服务器;跨网络时,由你自己部署的服务器或 Tailscale 让两台电脑找到彼此。数据在两台设备之间直接传输,全程端到端加密,打不通直连时经你的服务器中转,服务器也看不到内容。| | CopySync | 通用剪贴板 | 隔空投送 | 聊天软件 ||---|:-:|:-:|:-:|:-:|@@ -52,6 +52,7 @@ CopySync 的做法是:两台电脑配对一次,之后在一台上复制,- **文本、带格式的文本、图片、文件、文件夹**都能同步。复制什么,对面粘贴出来就是什么。- **按大小分流**:50 MB 以内(可调)复制时直接推送;更大的文件只同步一条记录,需要时再拉取。- **复制记录**:所有设备上最近 3 天(可调)复制过的内容,图片可以预览。+- **同一网络里不需要服务器**:自动发现,输入配对码就能用;不在同一网段时多输一个地址。- **直连优先,自动中转**,公司双线这类多出口网络也能直连。- **配对时核对安全指纹**,防止服务器或网络上的第三方冒充你的设备。- **后台常驻**,开机自启,崩溃自动恢复。中文、英文、日文界面。@@ -65,15 +66,19 @@ CopySync 的做法是:两台电脑配对一次,之后在一台上复制,## 开始使用-第一次用?跟着**[快速开始](https://baiyuze.github.io/copysync/start/)**一步步来,有截图。需要**每台电脑装一个 App**,再加**一台两端都能访问到的服务器**。+第一次用?跟着**[快速开始](https://baiyuze.github.io/copysync/start/)**一步步来,有截图。需要**每台电脑装一个 App**;同一个网络里这就够了,跨网络时再加一台服务器或 Tailscale。-**1. 部署服务器。**三种方式,按你的情况选一种,每种都有图文教程:+**1. 在每台电脑上安装 App**:macOS 13 以上用 [CopySync.dmg](https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg),Windows 10/11 用 [CopySync-Setup.exe](https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe)(也有[便携版](https://github.com/baiyuze/copysync/releases/latest/download/CopySync-windows-x64.zip))。还没有公证和代码签名:Mac 上第一次打开时到 **系统设置 → 隐私与安全性** 点 **仍要打开**;Windows 上点 **更多信息 → 仍要运行**。然后点 **启用后台同步**。Windows 防火墙询问、macOS 询问能否查找本地网络上的设备时,都选择允许。++**2. 配对。**一台点 **设备 → 添加设备 → 生成配对码**,另一台点 **输入配对码**;不在同一网段时,再点 **不在同一网段?** 输入配对码下面显示的地址。两边显示的两行安全指纹完全一致后再确认。之后在任意一台上复制,另一台就能直接粘贴。++**3. 跨网络时(可选)。**三种连接方式,每种都有图文教程:| 方式 | 适合 | 要准备 ||---|---|---|+| **[同一网络](https://baiyuze.github.io/copysync/lan/)** | 电脑都连着同一个路由器(家里或办公室) | 什么都不用 || **[公网服务器](https://baiyuze.github.io/copysync/cloud/)** | 电脑分散在不同网络里,想在哪儿都能同步 | 一台有公网 IP 的 Linux 云主机,最低配置就够 |-| **[局域网](https://baiyuze.github.io/copysync/server/)** | 电脑都在同一个网络里(家里或办公室) | 其中一台常开的 Windows、Mac 或 Linux 电脑 |-| **[局域网 + Tailscale](https://baiyuze.github.io/copysync/tailscale/)** | 要跨网络,但没有公网服务器 | 一台常开的电脑,每台电脑都装 [Tailscale](https://tailscale.com) |+| **[Tailscale](https://baiyuze.github.io/copysync/tailscale/)** | 要跨网络,但没有公网服务器 | 每台电脑都装 [Tailscale](https://tailscale.com),配对时输入对方的 Tailscale 地址 |公网服务器上的安装命令:@@ -83,27 +88,23 @@ tar xzf copysync-server-linux-amd64.tar.gz && cd copysync-server-linux-amd64sudo ./install.sh <服务器公网IP>```-放行 TCP 8787、UDP 3478 与 UDP 32768–60999。Docker 部署与全部参数见[服务器部署说明](server/deploy/README.md)。国内云服务器的域名没有备案时,客户端里请直接填 IP。--**2. 在每台电脑上安装 App**:macOS 13 以上用 [CopySync.dmg](https://github.com/baiyuze/copysync/releases/latest/download/CopySync.dmg),Windows 10/11 用 [CopySync-Setup.exe](https://github.com/baiyuze/copysync/releases/latest/download/CopySync-Setup.exe)(也有[便携版](https://github.com/baiyuze/copysync/releases/latest/download/CopySync-windows-x64.zip))。还没有公证和代码签名:Mac 上第一次打开时到 **系统设置 → 隐私与安全性** 点 **仍要打开**;Windows 上点 **更多信息 → 仍要运行**。然后点 **启用后台同步**,在 **设置 → 信令服务器地址** 填入 `ws://<服务器地址>:8787/signal`。--**3. 配对。**一台点 **设备 → 添加设备 → 生成配对码**,另一台点 **输入配对码**。两边显示的两行安全指纹完全一致后再确认。之后在任意一台上复制,另一台就能直接粘贴。+放行 TCP 8787、UDP 3478 与 UDP 32768–60999,然后在每台电脑的 **设置 → 信令服务器地址** 填入 `ws://<服务器地址>:8787/signal`。Docker 部署与全部参数见[服务器部署说明](server/deploy/README.md)。国内云服务器的域名没有备案时,客户端里请直接填 IP。| | 要求 ||---|---|| **Mac 客户端** | macOS 13 Ventura 及以上;Intel 与 Apple 芯片通用 || **Windows 客户端** | Windows 10(21H2 及以上)与 11,x64 |-| **服务器** | Linux(x86_64、ARM64;systemd 或 Docker)、macOS,或 Windows 10/11 x64 |+| **服务器** | 可选,只在跨网络时需要:Linux(x86_64、ARM64;systemd 或 Docker)、macOS,或 Windows 10/11 x64 || **iPhone / iPad** | 暂不支持:iOS 不允许 App 在后台监听剪贴板 |## 文档- [工作原理](guide/how-it-works.zh-CN.md):架构、NAT 打洞、安全模型、兜底、踩过的坑- [排障](guide/troubleshooting.zh-CN.md)与已知限制-- [快速开始](https://baiyuze.github.io/copysync/start/) · [公网服务器](https://baiyuze.github.io/copysync/cloud/) · [局域网](https://baiyuze.github.io/copysync/server/) · [局域网 + Tailscale](https://baiyuze.github.io/copysync/tailscale/),都是图文教程+- [快速开始](https://baiyuze.github.io/copysync/start/) · [同一网络](https://baiyuze.github.io/copysync/lan/) · [公网服务器](https://baiyuze.github.io/copysync/cloud/) · [Tailscale](https://baiyuze.github.io/copysync/tailscale/) · [在局域网里部署服务器](https://baiyuze.github.io/copysync/server/),都是图文教程- [服务器部署说明](server/deploy/README.md):Windows、macOS、Linux、Docker、Tailscale- [从源码构建](guide/building.zh-CN.md)-- 技术方案:[多出口网络的 NAT 打洞](design/nat-traversal.md)、[Windows 客户端](design/windows-client.md)+- 技术方案:[局域网直连](design/lan-mode.md)、[多出口网络的 NAT 打洞](design/nat-traversal.md)、[Windows 客户端](design/windows-client.md)- [更新记录](CHANGELOG.md)## 许可diff --git a/design/lan-mode.md b/design/lan-mode.mdnew file mode 100644index 0000000..a7d967d--- /dev/null+++ b/design/lan-mode.md@@ -0,0 +1,182 @@+# 局域网直连:不用服务器也能配对和同步++> 状态:已实现,随 1.4.0 发布+> 代码:`client-core/internal/transport/lan/`(发现、信令、配对、地址簿)、`transport/signed/`(签名与校验)、`peers/manager.go`(两条通道合并)+> 验证:`transport/lan/lan_test.go`、`peers/manager_test.go`、`tools/natlab/`(局域网场景)、Mac 与 Windows 虚拟机实机测试+> 相关:[多出口网络的 NAT 打洞](nat-traversal.md)++## 一、问题++1.3 之前,两台电脑必须先连上同一台信令服务器,才能配对、知道对方在线、交换连接信息。即使两台就在同一个路由器下面,用户也得先找一台常开的电脑部署服务器。++服务器在这里只做三件事:++| 服务器的职责 | 局域网里用什么代替 |+|---|---|+| 发现:谁在线、在哪个地址 | mDNS(DNS-SD)广播 |+| 转发签名的信令 | 设备之间直接用 UDP 收发 |+| 配对码:码 → 公钥 | 在局域网里直接交换 |+| STUN / TURN | 同一局域网里用不上,host candidate 就能直连 |++信任模型本来就把服务器当成不可信的转发者:信令逐条签名,配对靠人工核对指纹,DTLS 指纹随签名一起传。把转发者从服务器换成局域网,安全性不变。++## 二、原型实测++动手之前,先用一个临时程序(mDNS 注册与浏览,加固定 UDP 端口互发 hello)在 Mac 和 Windows 虚拟机之间测了几种情况。虚拟机在 Parallels 的共享网络里,与 Mac 同一网段,网络类型是「公用」。++### Windows 防火墙++| 情况 | 结果 |+|---|---|+| 程序没有任何防火墙规则 | Windows 能发现 Mac(自己发出的查询,回答作为回包放行);Mac 发现不了 Windows(Windows 回答不了查询)。Windows 主动打招呼后,双方都能收发 |+| 有显式的入站阻止规则(相当于弹窗时点了取消) | 同上。有状态防火墙对回包一律放行,阻止规则只挡主动连进来的包 |+| 只有 Mac 知道 Windows 的地址,Windows 不知道 Mac 的 | 不通:Mac 的包被挡,Windows 不会主动发 |+| 只有 Windows 知道 Mac 的地址 | 通 |+| 两边都知道对方地址 | 通 |+| 删掉程序的入站规则,再加一条 UDP 允许规则 | 只有 Mac 知道地址时也通了 |++结论:++- **被挡的一方只要先发包就能通。** 所以设计成「两边都往对方发」,谁也不依赖入站规则。+- **Windows 内置的 mDNS 入站规则只放行系统的 Dnscache 服务**,我们自己的进程收不到别人的查询。改用系统的 DNS-SD 服务(`DnsServiceRegister`)注册后,即使有阻止规则,Mac 也能立刻发现 Windows。浏览仍用 pion/mdns,不受影响。+- 弹窗点过取消、或者跨网段时被连的一方是 Windows,就需要放行。界面上提供一个按钮,用一次 UAC 运行 netsh 修好。++### macOS 15 的本地网络权限++从终端运行的程序不受限制,但同一个程序打包成 App、由 launchd 启动(与后台服务一样)时,往局域网地址发包直接返回 `sendto: no route to host`。对方先发来的包仍然能收到,也能回复。++这说明 1.3 的后台服务在 macOS 15 上其实也连不到局域网地址。它和 Windows 虚拟机之间显示「直连」,是因为 Parallels 的 NAT 让虚拟机的包看起来来自 Mac 自己的 IP,恰好绕开了限制。两台 Mac 之间如果都没拿到权限,谁也连不上谁。++处理办法:++- 后台服务的 Info.plist 加上 `NSLocalNetworkUsageDescription`(中英日本地化)与 `NSBonjourServices`。+- LaunchAgent 写上 `AssociatedBundleIdentifiers`,让系统知道后台服务属于 CopySync.app(TN3179 的建议)。+- 后台服务发现发往本机直连网段的包返回 `EHOSTUNREACH` 时,报告「被系统拦截」,界面提示用户去「系统设置 → 隐私与安全性 → 本地网络」打开。++## 三、方案++### 1. 两条通道并存++`peers.Manager` 同时持有信令服务器客户端和局域网通道:++- **在线**:服务器说在线、局域网里可达、P2P 已连通,任一成立即可。服务器断开只清掉服务器那一半。+- **发送信令**:签一次名,局域网可达就走局域网,连着服务器就也经服务器转发。接收方的 `signed.Verifier` 两条路共用一份 nonce 记录,只处理先到的那份。+- **配对结果通用**:配对只是交换公钥,局域网里配好的设备,以后加上服务器照样能跨网络同步。++签名与校验从信令客户端里抽到 `transport/signed`,并补上一条检查:`to_device_id` 必须是本机。服务器按收件人转发,这条检查以前可有可无;局域网里谁都能把截到的消息转发给第三台设备,必须有。++### 2. 发现++- 服务类型 `_copysync._udp`,实例名每次启动随机(`copysync-` 加 12 位十六进制),不带设备名。+- TXT:`v=1`,`t=当日令牌`,配对码开放期间加 `p=1`。+- 令牌是 `sha256("copysync-lan|" + device_id + "|" + UTC 日期)` 的前 8 字节。已配对的设备按昨天、今天、明天各算一遍就能认出对方;同一网络里的其他人看到的只是一串每天都变的字符,无法跨天关联。+- Windows 上由系统的 DNS-SD 服务回答查询(见上一节),其他平台由 pion/mdns 回答。网络变化时(本机地址集合变了)重新加入组播、重新广播。++### 3. 局域网信令++- 固定 UDP 端口 8788,被占用时(同一台 Mac 上两个用户都登录着)退回随机端口,端口随 mDNS 和地址一起告诉对方。+- 每个包是 4 字节魔数 `CSL1` 加 `LanPacket`,上限 16 KB,按来源限速。+- 已配对设备之间收发的就是服务器转发的那种 `Signed`。上线通知是 `SignalMessage` 里新增的 `LanHello`:自报的地址、要不要回一条、自己多久发一次。+- 对每台还没连通的设备,每 10 秒往它可能在的地址发 hello(已连通时 30 秒保活)。候选地址按顺序取:最近一次收到它消息的来源、mDNS 发现的、它自报的、地址簿里的,最多 12 个。+- 收到有效消息就记下来源地址,并标记可达;超过对方声明间隔的三倍没收到,视为不可达。+- 信令发往对方最近的来源地址,150 毫秒后再补发一次,抵消 UDP 偶尔丢包;重复的那份被 nonce 去重。++### 4. 地址簿与跨网段++- 新表 `device_addrs(device_id, addr, last_seen)`,每台设备最多 8 个,随设备一起删除。+- 跨网段时 mDNS 过不去,配对时由用户输入对方配对码下面显示的地址。配对双方都记下对方的地址,之后任意一方换了地址,只要另一方没换,就能重新找到。+- 两边都换了地址时,在设备菜单里「输入它的地址」。不做网段扫描:在公司网络里会被当成端口扫描。+- Tailscale 不转发 mDNS,但 100.x 地址就是普通的可达地址:配对时输入它,之后同样靠地址簿。++### 5. 配对++- 显示码的一方:码在服务器和局域网两边同时开放(连着服务器时用服务器签发的码,否则本机生成,格式见 `proto/pairingcode`),一边用掉另一边就失效。错码 10 次作废。+- 输入码的一方:先在局域网里找,发往所有 `p=1` 的实例和用户输入的地址,每 500 毫秒重发,3 秒为限(输了地址时 5 秒);找不到且连着服务器再去服务器兑换。+- 请求和回复都是 `LanPairInfo`,用自带的公钥签名,并校验 ID 由公钥派生;回复回显请求的 nonce,绑定到这次请求。配对码在局域网里明文传输,与服务器模式下服务器能看到配对码等价:防中间人靠的是用户核对指纹。+- 配对请求与回复本身证明了对方在哪个地址,收到即标记可达,确认后第一次连接不必再等 hello。++### 6. 其他改动++- 服务器地址默认为空。1.4.0 之前的默认值 `ws://127.0.0.1:8787/signal` 其实没有服务器在跑,升级时清空一次(配置文件记 `config_version`,只迁移一次)。+- 没有服务器时不探测公共 STUN:只在局域网里连,探测出口没有用,还会把公网 IP 暴露给公共服务器。+- 解除配对时断开 P2P 连接(以前不断开)。+- `copysync-cli`:`join CODE [ADDRESS]`、`address DEVICE ADDR`,`nat` 里加了局域网一节。++### 代码位置++| 位置 | 内容 |+|---|---|+| `transport/lan/lan.go` | socket、hello、可达状态、地址簿、诊断 |+| `transport/lan/pairing.go` | 局域网配对 |+| `transport/lan/discovery.go`、`mdns*.go` | 发现接口、pion/mdns 实现、Windows 的系统 DNS-SD 注册、测试用的内存网络 |+| `transport/lan/addrs.go` | 本机地址、地址解析、令牌 |+| `transport/lan/permission_*.go` | macOS 打开本地网络设置、Windows 用 UAC 放行防火墙 |+| `transport/signed/` | 签名、校验、防重放、收件人检查 |+| `peers/manager.go` | 两条通道合并、配对流程 |+| `store/store.go` | `device_addrs` 表 |+| `config/config.go` | 默认不用服务器、`lan_disabled`、一次性迁移 |++## 四、能覆盖哪些场景++| 两台电脑 | 结果 |+|---|---|+| 同一网段 | mDNS 发现,直连 |+| 不同网段,网段之间互通 | 配对时输入地址,直连;之后靠地址簿 |+| 同一 tailnet | 配对时输入 100.x 地址,直连 |+| 一台是没放行防火墙的 Windows | 只要它知道对方的地址(或由系统 DNS-SD 被发现后对方打招呼),就能连上 |+| 两台都是没放行防火墙的 Windows,跨网段,只有一边知道地址 | 连不上,需要在被连的一方点「放行」 |+| 两个网段之间被隔离(访客网络等) | 连不上,只能经两边都能访问的服务器中转 |+| macOS 15 没允许本地网络 | 对方先发来时能连;两台都是这样的 Mac 时连不上,界面提示去允许 |++## 五、验证++### 单元测试与集成测试++`transport/signed/signed_test.go`:签名与校验;同一条信令从两条通道到达只处理一次;收件人不是本机时拒收;未配对、冒用 ID、时间戳过期都拒收。++`transport/lan/lan_test.go`:两个实例绑在 127.0.0.1 的不同端口上,用内存网络代替 mDNS。已配对设备互相找到并收发信令、补发的那份被去重、地址记进地址簿;只靠记得的地址互相找到;未配对设备的 hello 不算数;局域网配对、按地址配对、码只能用一次、错 10 次后作废;可达状态过期;地址解析与令牌换天。++`peers/manager_test.go`:两个完整的 `peers.Manager`。没有服务器时配对、P2P 直连、双向收消息,解除配对后断开;不同网段时不输地址找不到、输了地址能配对并直连;关掉局域网只用服务器时原来的配对路径照常工作,错码立即被拒;服务器和局域网同时开着时,同一个码只能用一次。++`config/config_test.go`:旧默认地址清空、自己的服务器保留、只迁移一次。`store/store_test.go`:地址簿的排序、上限、随设备删除。++界面:`pairing_flow_test.dart` 覆盖显示本机地址、找不到时展开地址框并带地址重试、错码提示、侧栏的局域网状态与 macOS 拦截提示。++### NAT 打洞实验室++新增 `natlab lanpeer`:不起任何服务器,用真实的局域网通道连接,两端身份由种子派生,相当于已经配对。新增两种拓扑:同一网段(网桥)与两个网段(路由器,不做 NAT)。++| 场景 | 预期 | 结果 |+|---|---|---|+| 同一网段,靠 mDNS 发现 | 直连 | 通过 |+| 两个网段,一边记得对方地址 | 直连 | 通过 |+| 两个网段,两台都挡入站新连接,都记得地址 | 直连 | 通过 |+| 两个网段,两台都挡入站新连接,只有一边记得 | 连不上 | 通过 |+| 两个网段之间被隔离 | 连不上 | 通过 |++「两台都挡入站」用每台主机上的 `iptables -A INPUT -p udp -m conntrack --ctstate NEW -j DROP` 模拟没有放行规则的 Windows 防火墙,证明两边同时发包确实能穿过有状态防火墙。++### 实机验收++Mac 与 Windows 11 虚拟机,各跑一个用 `-tags fakeclip` 编译的后台服务(独立数据目录,不碰真实剪贴板),不配服务器。Windows 上的程序是新的路径,没有任何防火墙规则。++- 局域网配对成功,两边的安全指纹一致。+- 文本双向同步;5 MB 文件从 Mac 传到 Windows,SHA-256 一致。+- 两边都重启后约 1 秒重新直连。+- 新的一对在确认配对后立即直连;8788 被占用时退回随机端口,地址里自动带上端口。++## 六、踩过的坑++- **配对后的第一次连接要等 30 秒。** 确认配对后立即发起连接,但双方还没互发过 hello,局域网通道认为对方不可达,offer 发不出去,连接停在「连接中」直到握手超时。改为配对的请求与回复到达时就标记可达;offer 发不出去时立即复位,不等超时。+- **配对前就被发现的实例,配对后认不出来。** 令牌是按已配对设备算的,配对后要把已经发现的实例重新对一遍。+- **pion 的浏览每秒报一次同一个实例,还会报出无关的服务。** 只在地址或令牌变化、或超过 30 秒时才行动;校验服务类型与 `v=1`。+- **锁的顺序。** 局域网通道持锁时回调上层(取已配对设备、查 P2P 状态),上层持锁时又查局域网的可达状态。可达状态单独放在一把叶子锁里,回调一律在锁外。+- **Parallels 的 NAT 掩盖了 macOS 的拦截**,见第二节。+- **natlab 里新建 veth 时,第一个名字先在容器自己的命名空间里创建**,起名 `eth0` 会与容器的网卡冲突;`[[ … ]] && …` 放在函数末尾、条件不成立时会让函数返回 1,触发 `set -e`。++## 七、局限与后续++- 两台都没放行防火墙的 Windows、跨网段、只有一边知道地址时连不上,需要在被连的一方点「放行」。+- macOS 15 的本地网络授权弹窗只在屏幕解锁时出现。ad-hoc 签名的版本每次更新后,系统可能把它当成新程序重新询问;有了 Developer ID 签名后会稳定。+- 不做网段扫描。两边地址都变了要手动输入一次,台式机建议在路由器里固定地址。+- 只支持 IPv4。diff --git a/docs/assets/screenshots/en/settings-tailscale-dark.png b/docs/assets/screenshots/en/settings-tailscale-dark.pngdeleted file mode 100644index 8b53a0c..0000000Binary files a/docs/assets/screenshots/en/settings-tailscale-dark.png and /dev/null differdiff --git a/docs/assets/screenshots/ja/settings-tailscale-dark.png b/docs/assets/screenshots/ja/settings-tailscale-dark.pngdeleted file mode 100644index dc01625..0000000Binary files a/docs/assets/screenshots/ja/settings-tailscale-dark.png and /dev/null differdiff --git a/docs/assets/screenshots/settings-tailscale-dark.png b/docs/assets/screenshots/settings-tailscale-dark.pngdeleted file mode 100644index 9266c26..0000000Binary files a/docs/assets/screenshots/settings-tailscale-dark.png and /dev/null differdiff --git a/docs/llms.txt b/docs/llms.txtindex 7604d71..b4dfb49 100644--- a/docs/llms.txt+++ b/docs/llms.txt@@ -1,30 +1,32 @@# CopySync-> CopySync is a free, open-source (GNU AGPL-3.0, with commercial licenses available) app for macOS and Windows that syncs the clipboard and files between computers: copy on one, paste on another — Mac to Mac, Mac to Windows, or Windows to Windows. It works across different accounts and different networks. Devices connect peer-to-peer over WebRTC with end-to-end DTLS encryption; when a direct connection fails, traffic is relayed through a TURN server the user hosts themselves. The server stores no accounts and cannot read clipboard content.+> CopySync is a free, open-source (GNU AGPL-3.0, with commercial licenses available) app for macOS and Windows that syncs the clipboard and files between computers: copy on one, paste on another — Mac to Mac, Mac to Windows, or Windows to Windows. It works across different accounts and different networks. On the same network no server is needed: devices find each other over mDNS and pair with a code. Across networks, a server the user hosts (or Tailscale) introduces them. Devices connect peer-to-peer over WebRTC with end-to-end DTLS encryption; when a direct connection fails, traffic is relayed through the user's TURN server. The server stores no accounts and cannot read clipboard content.>-> CopySync 是一款免费开源(GNU AGPL-3.0,另提供商业授权)的 macOS 与 Windows 工具,在两台电脑之间同步剪贴板与文件:一台复制,另一台直接粘贴,Mac 与 Windows 互通。不要求同一个账号,跨网络可用。设备间 WebRTC 直连、DTLS 端到端加密,打不通时经用户自建服务器的 TURN 中转;服务器不存账号,看不到复制内容。+> CopySync 是一款免费开源(GNU AGPL-3.0,另提供商业授权)的 macOS 与 Windows 工具,在两台电脑之间同步剪贴板与文件:一台复制,另一台直接粘贴,Mac 与 Windows 互通。不要求同一个账号,跨网络可用。同一网络里不需要服务器,设备靠 mDNS 互相发现、用配对码配对;跨网络时由用户自建的服务器或 Tailscale 牵线。设备间 WebRTC 直连、DTLS 端到端加密,打不通时经用户服务器的 TURN 中转;服务器不存账号,看不到复制内容。Key facts:- Current version: 1.3.4, released 2026-10-11. It adds a quick start and step-by-step guides for the three ways to run the server (public server, LAN, LAN + Tailscale) on the website; the apps and server are otherwise unchanged. 1.3.3: the server installs on Windows (as a service) and on a Mac (as a LaunchAgent) as well as Linux, and the website has a step-by-step guide for running it on a LAN. 1.3.2 stopped UU Remote placeholder files from looping through the history. 1.3.1: click a history item to preview images, including copied image files (PNG, JPEG, GIF, WebP, BMP; HEIC and TIFF on Mac), with arrows to step through several. 1.3.0 added an English and Japanese interface (follows the system language, switchable in Settings) and moves to the GNU AGPL-3.0 with an optional commercial license. 1.2.0 added the Windows client.- Mac client: macOS 13 Ventura or later, universal binary for Intel and Apple silicon. Distributed as a DMG; not notarized by Apple, so the first launch needs "Open Anyway" in System Settings → Privacy & Security.- Windows client: Windows 10 (21H2+) and Windows 11, x64. Per-user installer (CopySync-Setup.exe, no admin rights) or portable zip; not code-signed, so SmartScreen needs "More info → Run anyway" once. Runs in the notification area; pasted files are real files usable in Explorer, WeChat and Office. Skips content that password managers mark as sensitive.-- Server: a single static Go binary for Linux (x86_64, ARM64), macOS or Windows 10/11 x64. Install scripts register it as a systemd service (Linux), a LaunchAgent (macOS) or a Windows service with a firewall rule (Windows), and default to the machine's LAN address; Docker Compose also works on Linux. On a LAN, any always-on computer can run it. There are three equal ways to run it: on a public server (a cloud VM with a public IP; reachable from any network), on a LAN (any always-on computer; works only on that network), or on a LAN plus Tailscale (across networks without a public server: every computer joins the same Tailscale network and the server is installed on its 100.x.y.z address). Ports: 8787/tcp (signaling), 3478/udp (STUN/TURN), plus OS-assigned UDP relay ports. In mainland China, cloud providers intercept plain HTTP (including the WebSocket handshake) for domains without an ICP filing, so clients should use the server's IP.+- Local network mode (no server): devices on the same subnet find each other over mDNS (`_copysync._udp`, broadcasting only an anonymous token that changes daily) and exchange signed signaling over UDP 8788. On a different subnet, the user enters the address shown under the pairing code; addresses are remembered afterwards. Over Tailscale, the user enters the other computer's 100.x address when pairing. On Windows, Settings → Local network → Allow adds a firewall rule (one UAC prompt); on macOS 15, the background service needs the Local Network permission.+- Server (optional; only to sync across networks): a single static Go binary for Linux (x86_64, ARM64), macOS or Windows 10/11 x64. Install scripts register it as a systemd service (Linux), a LaunchAgent (macOS) or a Windows service with a firewall rule (Windows), and default to the machine's LAN address; Docker Compose also works on Linux. The three ways to connect are: the same network (no server), a public server (a cloud VM with a public IP; reachable from any network), or Tailscale (no server; pair by Tailscale address). A server on a LAN is still useful when two subnets can't reach each other. Ports: 8787/tcp (signaling), 3478/udp (STUN/TURN), plus OS-assigned UDP relay ports. In mainland China, cloud providers intercept plain HTTP (including the WebSocket handshake) for domains without an ICP filing, so clients should use the server's IP.- Content synced: plain text, rich text (HTML plus a plain-text copy), images, files, folders.- Works on multi-uplink networks (e.g. offices with two ISPs) that pick an uplink per destination: the client probes several STUN servers from one shared port to learn its address on every uplink and sends all of them to the peer. Diagnose with `copysync-cli nat`. If a connection lands on the relay first, the client retries the direct path with an ICE restart while idle.- Items under 50 MB (adjustable 1 MB–1 GB) are pushed on copy; larger files sync as a record and are pulled on demand.- History keeps 3 days by default (adjustable 1 hour–30 days).-- Pairing: 6-character code valid for 5 minutes, plus a human check that both devices show the same two fingerprints (one per device's Ed25519 public key), which prevents man-in-the-middle attacks by the server.+- Pairing: 6-character code valid for 5 minutes (matched on the LAN, or through the server), plus a human check that both devices show the same two fingerprints (one per device's Ed25519 public key), which prevents man-in-the-middle attacks by the server.- Not supported: iPhone/iPad (iOS forbids background clipboard monitoring). The server stores nothing: while the other computer is unreachable, the latest 20 items are kept in memory and sent when it reconnects (added to its history, not its clipboard).- Compared with Apple's Universal Clipboard: no same-Apple-ID or proximity requirement, keeps a history, handles large files and folders.## Docs- [Website (English)](https://baiyuze.github.io/copysync/en/), [简体中文](https://baiyuze.github.io/copysync/), [日本語](https://baiyuze.github.io/copysync/ja/)-- [Quick start](https://baiyuze.github.io/copysync/en/start/): install the apps, choose how to run the server, enter its address and pair ([中文](https://baiyuze.github.io/copysync/start/), [日本語](https://baiyuze.github.io/copysync/ja/start/))+- [Quick start](https://baiyuze.github.io/copysync/en/start/): install the apps, pick a way to connect, and pair ([中文](https://baiyuze.github.io/copysync/start/), [日本語](https://baiyuze.github.io/copysync/ja/start/))+- [On the same network](https://baiyuze.github.io/copysync/en/lan/): no server; pairing across subnets, firewall and macOS permission notes ([中文](https://baiyuze.github.io/copysync/lan/), [日本語](https://baiyuze.github.io/copysync/ja/lan/))- [Run the server on a public server](https://baiyuze.github.io/copysync/en/cloud/): security group, install script, checks ([中文](https://baiyuze.github.io/copysync/cloud/), [日本語](https://baiyuze.github.io/copysync/ja/cloud/))-- [Run the server on your LAN](https://baiyuze.github.io/copysync/en/server/): step-by-step guide for Windows, macOS and Linux ([中文](https://baiyuze.github.io/copysync/server/), [日本語](https://baiyuze.github.io/copysync/ja/server/))-- [Use it across networks with Tailscale](https://baiyuze.github.io/copysync/en/tailscale/): sync across networks without a public server, with the server at home on its Tailscale address ([中文](https://baiyuze.github.io/copysync/tailscale/), [日本語](https://baiyuze.github.io/copysync/ja/tailscale/))+- [Run the server on your LAN](https://baiyuze.github.io/copysync/en/server/): for subnets that can't reach each other; step-by-step guide for Windows, macOS and Linux ([中文](https://baiyuze.github.io/copysync/server/), [日本語](https://baiyuze.github.io/copysync/ja/server/))+- [Use it across networks with Tailscale](https://baiyuze.github.io/copysync/en/tailscale/): sync across networks with no server, pairing by Tailscale address ([中文](https://baiyuze.github.io/copysync/tailscale/), [日本語](https://baiyuze.github.io/copysync/ja/tailscale/))- [README (English)](https://github.com/baiyuze/copysync/blob/main/README.md): features and getting started ([中文](https://github.com/baiyuze/copysync/blob/main/README.zh-CN.md))- [How it works](https://github.com/baiyuze/copysync/blob/main/guide/how-it-works.md): architecture, NAT traversal, security model, fallbacks, lessons learned- [Troubleshooting](https://github.com/baiyuze/copysync/blob/main/guide/troubleshooting.md) and known limitations@@ -32,6 +34,7 @@ Key facts:- [Licensing](https://github.com/baiyuze/copysync/blob/main/LICENSING.md): AGPL-3.0 terms and the commercial license; versions 1.2.0 and earlier remain MIT- [Windows client design (中文)](https://baiyuze.github.io/copysync/design/windows-client.html): clipboard formats, file-name compatibility, background process, installer- [NAT traversal design (中文)](https://baiyuze.github.io/copysync/design/nat-traversal.html): multi-uplink probing, relay-to-direct upgrade, measurements and the NAT lab+- [Local network mode design (中文)](https://baiyuze.github.io/copysync/design/lan-mode.html): mDNS discovery, UDP signaling, pairing across subnets, Windows Firewall and macOS Local Network findings, NAT lab scenarios- [Changelog](https://github.com/baiyuze/copysync/blob/main/CHANGELOG.md)## Downloaddiff --git a/guide/how-it-works.md b/guide/how-it-works.mdindex 401f57d..ee35e58 100644--- a/guide/how-it-works.md+++ b/guide/how-it-works.md@@ -2,7 +2,7 @@[简体中文](how-it-works.zh-CN.md) · [Back to README](../README.md)-Two computers connect directly and encrypt everything between them. Your server only helps them find each other, and relays encrypted packets when a direct connection can't be made.+Two computers connect directly and encrypt everything between them. On the same network they find each other over mDNS, with no server. Across networks, your server helps them find each other, and relays encrypted packets when a direct connection can't be made.## Architecture@@ -20,13 +20,16 @@ flowchart LRDA <== "WebRTC direct (DTLS)" ==> DBDA <-. "Relayed via TURN when direct fails" .-> SS <-.-> DB+ DA -. "Same network: mDNS + UDP 8788 signaling" .- DB```+The server is optional: on the same network, signaling goes directly over the LAN (see "No server on the same network" below).+| Component | Role | Built with ||---|---|---|| Background service `copysyncd` | Watches the clipboard, connects to peers, sends, receives and stores | Go. The clipboard uses cgo and AppKit on Mac, and calls Win32 directly on Windows (pure Go, no C compiler) || App `CopySync` | History, pairing, settings | Flutter, one codebase for Mac and Windows; talks to the service over local gRPC |-| Server `copysync-server` | Device discovery, pairing codes, signaling, TURN relay | Go, a single static binary using about 15 MB of RAM |+| Server `copysync-server` (optional) | Across networks: device discovery, pairing codes, signaling, TURN relay | Go, a single static binary using about 15 MB of RAM || Protocol `proto/` | Messages shared by all three | Protocol Buffers |## What happens when you copy@@ -46,6 +49,17 @@ flowchart LRData flows over WebRTC data channels, encrypted with DTLS.+## No server on the same network++Since 1.4.0 signaling has two channels, the server and the LAN. Both run side by side: signals go out on every available channel and the receiver drops duplicates by nonce, and a device is online if either channel says so.++- **Discovery**: each computer announces `_copysync._udp` over mDNS. The announcement carries no device name or ID, only a token that changes daily (a hash of the device ID and the date); paired devices compute it and recognize each other.+- **Signaling**: devices exchange the same signed messages the server would forward, directly over UDP 8788. For each paired device that isn't connected yet, a hello goes to its likely addresses every 10 seconds and the receiver answers. Both sides send, so stateful firewalls treat the other side's packets as replies.+- **Different subnets**: when mDNS can't reach the other computer, you enter the address shown under its pairing code. Both sides remember each other's address, so if one changes, the other still finds it. A Tailscale 100.x address works the same way.+- **Pairing**: the code is open on the LAN and, when connected, on the server too; using it on one side closes it on the other, and 10 wrong attempts close it. Requests and replies are signed with the sender's key; the human fingerprint check is still what stops a man in the middle.++Design, measurements and validation: [Local network mode](../design/lan-mode.md) (Chinese).+## Hole punching on networks with several uplinksOffice networks with two ISPs, or carriers with a pool of NAT addresses, have several uplinks and choose one per destination IP. One office network we measured had four:@@ -68,7 +82,7 @@ What 1.1 does:A Mac behind that 4-uplink office network now connects directly to a home connection, about 3 seconds after reaching the server. The full design, measurements and validation are in [NAT traversal on multi-uplink networks](../design/nat-traversal.md) (Chinese).-The **NAT lab** (`tools/natlab`) builds real topologies with Linux network namespaces and iptables and runs CopySync's actual connection code through eleven scenarios on every commit:+The **NAT lab** (`tools/natlab`) builds real topologies with Linux network namespaces and iptables and runs CopySync's actual connection code through sixteen scenarios on every commit:| Scenario | Result ||---|---|@@ -82,12 +96,18 @@ The **NAT lab** (`tools/natlab`) builds real topologies with Linux network names| Blocked at first, network recovers later | Relay first, then direct || Office router locks a port for unsolicited packets | Direct || Home router locks a port for unsolicited packets | Relay, then direct after the first retry |+| No server, same subnet, found over mDNS | Direct |+| No server, two subnets, one side remembers the address | Direct |+| No server, both hosts block inbound, both remember | Direct |+| No server, both hosts block inbound, only one remembers | No connection (known limit) |+| No server, subnets isolated from each other | No connection |## Security model- **The server keeps no accounts.** A device's identity is an Ed25519 key, and its ID is derived from the public key, so the server can verify that an ID belongs to a key without a user table.- **Fingerprints are compared by a person when pairing.** Both Macs show the same two lines: the fingerprint of each side's public key (the first 60 bits of its SHA-256, like `R8NF-2WTC-QL5J`), in a fixed order. The server could swap keys in transit, but then the two screens would no longer match — this step is what stops a man in the middle. The fingerprints are shown separately rather than combined into one short code: an attacker controlling both forged keys could find a matching combined code with a birthday attack, while separate fingerprints need a preimage attack per key, roughly a billion times harder.-- **Every signaling message after that is signed**, so the server cannot forge a device. The DTLS certificate fingerprint of the direct channel is also sent signed and checked against the actual certificate after the handshake; a mismatch drops the connection.+- **Every signaling message after that is signed**, so the server cannot forge a device. The DTLS certificate fingerprint of the direct channel is also sent signed and checked against the actual certificate after the handshake; a mismatch drops the connection. Messages addressed to another device are rejected, because on a LAN anyone could forward a captured message to a third device.+- **Same on the local network.** The broadcast carries only an anonymous token that changes daily, so others on the network can't tell whose computer it is; messages from unpaired devices are dropped, and pairing still means comparing fingerprints.- **The relay can't read anything either.** TURN only forwards encrypted UDP packets. Relay credentials are issued per device and expire after 12 hours.- **Public STUN servers see only your public IP.** To find every uplink on multi-uplink networks, CopySync probes a few public STUN servers by default. They see your public IP, as with any WebRTC app, never content. Turn off **Probe with public servers** in Settings to use only your own server.- **Device key.** On Mac it's stored readable only by you; on Windows it's additionally encrypted with DPAPI, so another user or another computer can't decrypt a copied file.@@ -97,13 +117,16 @@ The **NAT lab** (`tools/natlab`) builds real topologies with Linux network names| Situation | What happens ||---|---|+| The other computer can't be found on the network (different subnets, guest network, client isolation) | Enter the address shown under its pairing code; it's remembered afterwards, and if both change you use "Enter its address…" in the device menu |+| Windows Firewall blocks inbound (Cancel was clicked) | Packets this computer sends first still get through; when the Windows PC is the one being reached, Settings → Local network → Allow removes the block rule and adds an allow rule with one UAC prompt |+| macOS 15 hasn't allowed Local Network access | LAN packets are blocked by the system (`EHOSTUNREACH`); the app asks you to turn on CopySync Daemon in System Settings → Privacy & Security → Local Network || No direct path (symmetric NAT, corporate firewall) | Switches to the TURN relay on your server, still encrypted; the app shows "relay" || Public STUN servers unreliable (common in mainland China) | The server runs its own STUN and clients prefer it || Multi-uplink networks that pick an uplink per destination (common in offices) | All connections share one local port; CopySync probes several servers from it to learn its address on every uplink and sends them all to the peer, filling gaps from history. See `copysync-cli nat` || Landed on the relay although a direct path works (the peer just started, its addresses arrived a moment late) | While idle, the side that started the connection runs an ICE restart to punch again and switches to direct if it works; never during a transfer. The connection stays up and only pauses for a few seconds || The other Mac sleeps, loses its network or restarts, and the connection dies silently | The dead connection is closed and reconnected right away; if the other side rebuilt its connection, this side follows || The other Mac can't be reached when you copy | The latest 20 items are kept and sent once the connection is back. They only go into the history and never overwrite what's on the other Mac's clipboard now |-| Signaling connection drops | Reconnects with exponential backoff (1 s up to 30 s, with jitter); status is shown live |+| Signaling connection drops | Reconnects with exponential backoff (1 s up to 30 s, with jitter); status is shown live, and devices on the same network keep syncing || Pairing confirmed on one side before the other | Early handshake messages are held and replayed once the other side confirms; the direct link is up within tens of milliseconds || Large files | Above the limit only a record is synced; if the source file is gone when you pull, you get a clear message || Apps that only accept plain text | Rich text is written as both HTML and plain text, so no markup leaks into the paste |@@ -125,6 +148,7 @@ Each of these was found by testing and has a regression test. The full investiga- **Who sends first matters.** Some routers (the office one we measured) keep a connection entry for a packet that arrives before you've sent anything to its source, locking the port; your own packets then leave from a different port and punching fails. That's why restarting the office Mac always connected directly while restarting the home Mac fell back to the relay: a freshly started Mac probes its uplinks first, so its addresses went out late and it ended up sending first. A rule now decides who sends first, and retries alternate the order.- **A dead connection has to be cleaned up by hand.** When pion reports "failed" it doesn't close the connection; the control channel still looks open and whatever is written to it is lost, and the layer above thinks it's connected and never reconnects. In 1.1.0 this sent six files into a dead connection after the other Mac dropped off, and none arrived.- **Public STUN domains can be poisoned by DNS**, resolving to `192.0.2.42` in our tests. Reserved ranges and proxy fake-IP ranges are filtered before probing.+- **macOS 15 blocks the background service's LAN traffic.** A launchd-started service sending to a LAN address gets `no route to host` until the user allows Local Network access; packets the other side sends first still arrive and can be answered. A Parallels VM hides this, because the VM's packets reach the Mac through NAT from the Mac's own IP.- **Simulated routers need a firewall.** When both sides punch at once, a packet let through to the router itself leaves a Linux conntrack entry, the outgoing flow then gets a new port, and punching fails. Real routers drop such packets, and the lab does too.Measured on a LAN with a direct connection: a 20 MB file transfers in about 330 ms with matching checksums.diff --git a/guide/how-it-works.zh-CN.md b/guide/how-it-works.zh-CN.mdindex 81b8768..8585529 100644--- a/guide/how-it-works.zh-CN.md+++ b/guide/how-it-works.zh-CN.md@@ -2,7 +2,7 @@[English](how-it-works.md) · [回到 README](../README.zh-CN.md)-两台电脑之间直接建立加密连接。你的服务器只负责让它们找到彼此,打不通直连的时候再帮忙转发加密后的数据包。+两台电脑之间直接建立加密连接。同一个网络里,它们靠 mDNS 自己找到彼此,不需要服务器;跨网络时,你的服务器负责让它们找到彼此,打不通直连的时候再帮忙转发加密后的数据包。## 架构@@ -20,13 +20,16 @@ flowchart LRDA <== "WebRTC 直连(DTLS 加密)" ==> DBDA <-. "打不通时经 TURN 中转" .-> SS <-.-> DB+ DA -. "同一网络:mDNS 发现 + UDP 8788 信令" .- DB```+服务器是可选的:同一网络里的两台电脑,信令直接在局域网里收发(见下文「同一网络里不用服务器」)。+| 组件 | 做什么 | 技术 ||---|---|---|| 后台服务 `copysyncd` | 监听剪贴板、与对端建立连接、收发与落盘 | Go。剪贴板部分在 Mac 上用 cgo 调用 AppKit,在 Windows 上直接调用 Win32(纯 Go,不需要 C 编译器) || 界面 `CopySync` | 复制记录、设备配对、设置 | Flutter,经本机 gRPC 与后台服务通信;Mac 与 Windows 共用一套代码 |-| 服务器 `copysync-server` | 设备发现、转达配对码、转发信令、TURN 中转 | Go,单个静态二进制,约 15 MB 内存 |+| 服务器 `copysync-server`(可选) | 跨网络时的设备发现、转达配对码、转发信令、TURN 中转 | Go,单个静态二进制,约 15 MB 内存 || 协议 `proto/` | 三方共用的消息定义 | Protocol Buffers |## 一次复制的经过@@ -46,6 +49,17 @@ flowchart LR数据走 WebRTC 数据通道,DTLS 加密。+## 同一网络里不用服务器++1.4.0 起,信令有两条通道:信令服务器和局域网。两条并存,信令从所有可用的通道发出,接收方按 nonce 去重;任一通道报告对方在线就算在线。++- **发现**:每台电脑用 mDNS 广播 `_copysync._udp`。广播里不放设备名和 ID,只放一个每天都变的令牌(设备 ID 加日期的哈希),已配对的设备算一遍就能认出对方。+- **信令**:设备之间直接用 UDP 8788 收发与服务器转发时完全相同的签名消息。对每台还没连通的设备,每 10 秒往它可能在的地址发一次 hello,收到的一方回一条;两边都在发,有状态的防火墙会把对方的包当回包放行。+- **跨网段**:mDNS 过不去时,配对时输入对方配对码下面显示的地址。双方都把对方的地址记进地址簿,之后任一方换了地址,只要另一方没换就能重新找到。Tailscale 的 100.x 地址也这样用。+- **配对**:配对码在局域网里开放,连着服务器时同一个码也在服务器上开放,一边用掉另一边就失效;错 10 次作废。配对请求与回复各自用发送方的公钥签名,防中间人仍靠人工核对指纹。++设计、实测与验证见 [局域网直连](../design/lan-mode.md)。+## 多出口网络的打洞公司双线、运营商 NAT 地址池这类网络有多个出口,按目标 IP 选择走哪一个。实测一个公司网络有 4 个出口:@@ -68,7 +82,7 @@ flowchart LR实测公司 4 个出口与家用宽带之间直连,连上服务器后约 3 秒建立。设计细节、测量过程与验证见 [多出口网络的 NAT 打洞](../design/nat-traversal.md)。-**NAT 打洞实验室**(`tools/natlab`)用 Linux 网络命名空间与 iptables 搭出真实拓扑,用 CopySync 真实的连接代码验证 11 种场景,每次提交都在 CI 里运行:+**NAT 打洞实验室**(`tools/natlab`)用 Linux 网络命名空间与 iptables 搭出真实拓扑,用 CopySync 真实的连接代码验证 16 种场景,每次提交都在 CI 里运行:| 场景 | 结果 ||---|---|@@ -82,12 +96,18 @@ flowchart LR| 一开始打不通,之后网络恢复 | 先中转,随后换成直连 || 公司路由器会为外来的包占住端口 | 直连 || 家用路由器会为外来的包占住端口 | 先中转,第一次重试后直连 |+| 没有服务器,同一网段,靠 mDNS 发现 | 直连 |+| 没有服务器,两个网段,一边记得对方地址 | 直连 |+| 没有服务器,两台都挡入站连接,都记得地址 | 直连 |+| 没有服务器,两台都挡入站连接,只有一边记得 | 连不上(已知限制) |+| 没有服务器,两个网段之间被隔离 | 连不上 |## 安全模型- **服务器不存账号**。设备身份是一把 Ed25519 密钥,设备 ID 由公钥派生,服务器据此就能验证"这个 ID 确实属于这把公钥",无需用户表。- **配对时人工核对指纹**。两台设备显示同样的两行:双方各自公钥的指纹(SHA-256 的前 60 位,形如 `R8NF-2WTC-QL5J`),按固定顺序排列。服务器可以在配对时替换转发中的公钥,但替换后两块屏幕上的内容就对不上了,这一步就是防中间人的闸门。两个指纹分开显示而不是合成一串短码,是因为攻击者同时控制两把伪造公钥时,凑出一串相同的短码只需生日攻击;分开显示则要为每把公钥各做一次原像攻击,难度高出约十亿倍。-- **之后的每条信令都带签名**,服务器无法伪造设备。直连通道的 DTLS 证书指纹也经签名传递,握手后比对实际证书,不一致立即断开。+- **之后的每条信令都带签名**,服务器无法伪造设备。直连通道的 DTLS 证书指纹也经签名传递,握手后比对实际证书,不一致立即断开。收件人不是本机的信令一律拒收:局域网里谁都能把截到的消息转发给第三台设备。+- **局域网里也一样**。广播里只有每天都变的匿名令牌,同一网络里的其他人看不出是谁的电脑;未配对设备发来的消息一律丢弃,配对同样要核对指纹。- **中转也看不到内容**。TURN 只转发加密后的 UDP 包。中转凭证按设备单独签发,12 小时过期。- **公共 STUN 服务器只看到公网 IP**。为了在多出口网络里找到每个出口,默认会向几台公共 STUN 服务器探测,它们能看到你的公网 IP(与任何 WebRTC 应用一样),看不到内容。介意的话在设置里关掉「用公共服务器探测网络出口」,只用自己的服务器。- **设备私钥**:Mac 上以仅本人可读的权限存放;Windows 上另用系统的 DPAPI 加密,换个用户、或把文件拷到别的电脑上都解不开。@@ -97,13 +117,16 @@ flowchart LR| 情况 | 处理方式 ||---|---|+| 同一网络里找不到对方(不同网段、访客网络、AP 隔离) | 配对时输入对方配对码下面显示的地址;之后地址会被记住,两边都换了地址时在设备菜单里「输入它的地址」 |+| Windows 防火墙挡住入站(弹窗时点了取消) | 本机主动发包照样能通;被连的一方是 Windows 时,在「设置 → 局域网」里点「放行」,一次 UAC 删掉阻止规则、加一条允许规则 |+| macOS 15 不允许后台服务访问本地网络 | 发往局域网的包被系统拦下(`EHOSTUNREACH`),界面提示去「系统设置 → 隐私与安全性 → 本地网络」打开 CopySync Daemon || 两端打不通直连(对称 NAT、公司防火墙) | 自动改走服务器的 TURN 中转,内容依然加密;界面上显示「中转」 || 公共 STUN 在国内时通时断 | 服务器自带 STUN,客户端优先用它 || 公司双线等多出口网络(按目标地址选出口) | 所有连接共用一个本地端口,在这个端口上向多台服务器探测每个出口的地址,全部发给对端由它逐个尝试;探测漏掉的出口按历史推算。`copysync-cli nat` 可以看到探测结果 || 先落到了中转,其实打得通(对端刚启动、出口地址晚到一步) | 发起方在空闲时用 ICE 重启再打一次洞,打通就换成直连;有传输在进行时不重启。重启期间连接不断,只停顿几秒 || 对方睡眠、断网、重启,连接悄悄断了 | 发现连接失效立即关闭、重连;对方重建了连接,本端也随之换新 || 复制时对方连不上 | 记下最近 20 条,连接恢复后补发。补发的只进复制记录,不写进对方的剪贴板,免得覆盖对方此刻正在用的内容 |-| 信令服务器断开 | 指数退避自动重连(1 秒起,最长 30 秒,带随机抖动),界面实时显示连接状态 |+| 信令服务器断开 | 指数退避自动重连(1 秒起,最长 30 秒,带随机抖动),界面实时显示连接状态;同一网络里的设备照常同步 || 配对时两端确认有先后 | 先确认一方发来的握手消息会被暂存,另一方确认后重放,配对完成几十毫秒内即可直连 || 大文件 | 超过阈值只同步记录,按需拉取;拉取时源文件已被删除会明确提示,而不是失败得不明不白 || 只认纯文本的输入框 | 带格式的文本同时写入 HTML 与纯文本两份,粘贴到哪里都不会出现标签 |@@ -125,6 +148,7 @@ flowchart LR- **谁先发包很重要。**有的路由器(实测公司那台)收到对方先到的包,会留下一条连接记录、占住端口,本端随后往外发只好换端口,打洞就失败了。这解释了为什么本机重启时总能直连、家里那台一重启就中转:本机重启时出口要现探测,地址晚发出,本机反而先发包。现在由规则决定谁先发包,换直连的重试里两种顺序轮流用。- **连接失效后要自己清理。**pion 报告「失败」后不会关闭连接,控制通道看上去还是打开的,写进去的消息石沉大海;上层以为连接还在,也不会重连。1.1.0 曾因此在对方断线后,把 6 个文件「发」进了一条死连接,对方一个也没收到。- **公共 STUN 域名可能被 DNS 污染**,实测被解析到 `192.0.2.42`。这类保留地址和代理软件的 fake-ip 网段在探测前就过滤掉。+- **macOS 15 会拦下后台服务发往局域网的包。**由 launchd 启动的后台服务往局域网地址发包,没经用户允许时直接返回 `no route to host`;对方先发来的包仍能收到、能回复。在 Parallels 虚拟机里测不出来:虚拟机的包经 NAT 后看起来来自 Mac 自己的 IP。- **测试用的模拟路由器要有防火墙。**两端同时打洞时,对方的包若被放行到路由器本机,Linux 会为它留下一条连接记录,本端随后往外发时只好换端口,打洞就失败了。真实路由器直接丢弃这类包,实验室也照此配置。局域网直连实测:20 MB 文件约 330 毫秒传完,校验和一致。diff --git a/guide/troubleshooting.md b/guide/troubleshooting.mdindex 1619b66..930e177 100644--- a/guide/troubleshooting.md+++ b/guide/troubleshooting.md@@ -2,14 +2,17 @@[简体中文](troubleshooting.zh-CN.md) · [Back to README](../README.md)+**The other computer can't be found on the same network**+Make sure both have background sync on and are on the same network. Wired and Wi‑Fi in many offices, guest networks and Wi‑Fi with client isolation don't let devices see each other: on the computer entering the code, click **On a different subnet?** and enter the address shown under the other computer's code. Still nothing? Check the other computer's firewall: on Windows, click **Allow** under Settings → Local network (one administrator prompt); on a Mac, turn on CopySync Daemon in System Settings → Privacy & Security → Local Network. The Local network part of `copysync-cli nat` shows this computer's port, how many CopySync devices it found, whether each paired device is reachable and which addresses it remembers. See the [same network guide](https://baiyuze.github.io/copysync/en/lan/).+**Settings → Connection stays at Not connected**-Check that the address starts with `ws://`, uses port 8787 and ends in `/signal`, then open `http://<server address>:8787/healthz` in a browser on that computer. If it doesn't load, the network path is broken: the server isn't running, its computer is asleep, a firewall blocks it, or its address changed. The Windows and Linux install scripts print the firewall commands you need; see [Server deployment](../server/deploy/README.md) and the [LAN guide](https://baiyuze.github.io/copysync/en/server/).+This only applies when a server address is set; on the same network you can leave it empty. Check that the address starts with `ws://`, uses port 8787 and ends in `/signal`, then open `http://<server address>:8787/healthz` in a browser on that computer. If it doesn't load, the network path is broken: the server isn't running, its computer is asleep, a firewall blocks it, or its address changed. The Windows and Linux install scripts print the firewall commands you need; see [Server deployment](../server/deploy/README.md) and the [LAN guide](https://baiyuze.github.io/copysync/en/server/).**A cloud server in mainland China works by IP but not by domain**Providers in mainland China intercept plain HTTP requests for domains without an ICP filing, on any port, and answer with a redirect to a block page. The WebSocket handshake is a plain HTTP request, so it's intercepted too. Enter the IP, as in `ws://<server IP>:8787/signal`, or file the domain. See the [public server guide](https://baiyuze.github.io/copysync/en/cloud/).**Using Tailscale: devices show Direct, but transfers are slow**-Direct means the two computers connect directly on the Tailscale network. When Tailscale can't connect them peer to peer, it relays through its DERP servers, which can be far away. Run `tailscale ping <other device>`: "via DERP" means Tailscale is relaying, "via <IP>:<port>" means peer to peer. Also make sure the server was installed on its Tailscale address and every computer uses `ws://<Tailscale address>:8787/signal`; see the [Tailscale guide](https://baiyuze.github.io/copysync/en/tailscale/).+Direct means the two computers connect directly on the Tailscale network. When Tailscale can't connect them peer to peer, it relays through its DERP servers, which can be far away. Run `tailscale ping <other device>`: "via DERP" means Tailscale is relaying, "via <IP>:<port>" means peer to peer. See the [Tailscale guide](https://baiyuze.github.io/copysync/en/tailscale/).**`.uuremote_…` file records keep appearing while UU Remote is running**Upgrade both clients to 1.3.2 or later. UU Remote puts temporary placeholder files on the system clipboard; older CopySync clients recorded and forwarded them as ordinary files. The new version filters the confirmed `.uuremote_aeawv` followed by digits before scanning, recording or sending, keeps ordinary files in mixed selections, ignores placeholder-only incoming offers, and removes placeholder-only history on startup without deleting UU's source files. Ordinary empty, hidden and large files are unaffected. The 50 MB threshold controls automatic transfer; there is no need to disable UU's UDP P2P. Other clipboard sync tools can still duplicate ordinary content; use one clipboard sync provider if needed. See the [investigation and validation notes](../design/uu-remote-clipboard.md).@@ -18,7 +21,7 @@ Upgrade both clients to 1.3.2 or later. UU Remote puts temporary placeholder filThe system pasteboard service may be stuck: an app declared clipboard content and then crashed, leaving types without data. Run `killall pboard` and copy again.**A device stays offline**-Check **Settings → Connection** on both computers. If it isn't connected, verify the server address and that port 8787 is reachable.+On the same network, see "The other computer can't be found" above; if both computers changed addresses, open the device's … menu and choose **Enter its address…**. Across networks, check **Settings → Connection** on both computers; if it isn't connected, verify the server address and that port 8787 is reachable.**Always "relay", never "direct"**Showing "relay" right after connecting and "direct" a little later is normal: the relay makes things work first, and the direct path takes over when the link is idle. If it stays "relay", NAT traversal didn't succeed, which is common with NATs that randomize ports or strict firewalls. Everything still works; speed is limited by the server's bandwidth. Run `copysync-cli nat` to see how many uplinks were found; zero means UDP is blocked.@@ -33,3 +36,5 @@ The background service logs to `~/Library/Logs/CopySync/daemon.log` on Mac and `- **The Mac app doesn't skip password-manager content yet**; the Windows app does.- **Items aren't resent after a long absence.** The server stores nothing. While the other Mac is unreachable, this Mac keeps the latest 20 items (from the last 24 hours) in memory, and they're lost if its background service restarts.- **Relayed transfers are limited by your server's bandwidth.** Direct connections aren't.+- **On different subnets, if both computers change addresses**, you enter the address once more in the device menu; CopySync doesn't scan subnets. Two Windows PCs that both block inbound traffic, where only one knows the other's address, can't connect until the one being reached clicks **Allow**.+- **macOS 15 needs the Local Network permission**, or the background service can't reach devices on your network (it still connects when the other side reaches out first). Current builds are ad-hoc signed, so macOS may ask again after an update.diff --git a/guide/troubleshooting.zh-CN.md b/guide/troubleshooting.zh-CN.mdindex c070f0f..97502ee 100644--- a/guide/troubleshooting.zh-CN.md+++ b/guide/troubleshooting.zh-CN.md@@ -2,14 +2,17 @@[English](troubleshooting.md) · [回到 README](../README.zh-CN.md)+**同一网络里找不到另一台电脑**+先确认两台都启用了后台同步、连着同一个网络。公司里有线和无线、访客网络、开了「AP 隔离」的 Wi‑Fi 常常不互通:在输入配对码的那台点「不在同一网段?」,填上对方配对码下面显示的地址。还是找不到就看对方的防火墙:Windows 上在「设置 → 局域网」里点「放行」(会请求一次管理员权限);Mac 上到「系统设置 → 隐私与安全性 → 本地网络」打开 CopySync Daemon。`copysync-cli nat` 的「局域网」一节能看到本机的端口、发现了几台 CopySync、每台设备能否找到、记住了哪些地址。见[同一网络教程](https://baiyuze.github.io/copysync/lan/)。+**「设置 → 连接状态」一直是「未连接」**-先核对地址:以 `ws://` 开头、端口 8787、以 `/signal` 结尾;再在这台电脑的浏览器里打开 `http://<服务器地址>:8787/healthz`。打不开说明到服务器的网络不通:服务器没在运行、那台电脑睡眠了、被防火墙拦住了,或者它的地址变了。Windows 与 Linux 的安装脚本会给出需要的防火墙命令,见[服务器部署说明](../server/deploy/README.md)与[局域网部署教程](https://baiyuze.github.io/copysync/server/)。+只在填了服务器地址时才有这个问题;同一网络里不需要服务器,地址留空即可。先核对地址:以 `ws://` 开头、端口 8787、以 `/signal` 结尾;再在这台电脑的浏览器里打开 `http://<服务器地址>:8787/healthz`。打不开说明到服务器的网络不通:服务器没在运行、那台电脑睡眠了、被防火墙拦住了,或者它的地址变了。Windows 与 Linux 的安装脚本会给出需要的防火墙命令,见[服务器部署说明](../server/deploy/README.md)与[局域网部署教程](https://baiyuze.github.io/copysync/server/)。**国内云服务器:填域名连不上,填 IP 能连**域名没有备案时,国内云厂商会拦截访问它的明文 HTTP 请求,任何端口都一样,返回一个跳转到拦截页的响应。WebSocket 握手就是明文 HTTP 请求,所以同样被拦。地址里直接填 IP(`ws://<服务器IP>:8787/signal`),或者给域名备案。见[公网服务器部署教程](https://baiyuze.github.io/copysync/cloud/)。**用 Tailscale 时显示「直连」,传输却很慢**-「直连」指两台电脑在 Tailscale 的虚拟网里直接相连。Tailscale 自己打不通两台电脑时,会经它在境外的中转服务器(DERP)转发,在国内用就会慢。运行 `tailscale ping <对方>`:显示 via DERP 说明 Tailscale 在中转,显示 via <IP>:<端口> 才是点对点。另外确认服务器是用 Tailscale 地址安装的,每台电脑填的都是 `ws://<Tailscale 地址>:8787/signal`,见 [Tailscale 教程](https://baiyuze.github.io/copysync/tailscale/)。+「直连」指两台电脑在 Tailscale 的虚拟网里直接相连。Tailscale 自己打不通两台电脑时,会经它在境外的中转服务器(DERP)转发,在国内用就会慢。运行 `tailscale ping <对方>`:显示 via DERP 说明 Tailscale 在中转,显示 via <IP>:<端口> 才是点对点。见 [Tailscale 教程](https://baiyuze.github.io/copysync/tailscale/)。**UU 远程开启时不断新增 `.uuremote_…` 文件记录**升级两端客户端到 1.3.2 或更新的版本。UU 远程会把临时占位文件写入系统剪贴板,旧版 CopySync 会把它们当成普通文件再次转发。新版在扫描、入库和发送之前过滤已确认的 `.uuremote_aeawv` 加数字命名;混合选择保留正常文件,接收端忽略纯占位记录,启动时清理历史里的纯占位记录(不删除 UU 的源文件)。普通空文件、隐藏文件和大文件不受这条规则影响。50 MB 是自动传输阈值,不是故障原因;无需关闭 UU 的 UDP P2P。其他剪贴板同步工具仍可能造成普通内容重复,可只保留一个工具负责剪贴板同步。技术与验证记录见 [UU 远程兼容修复](../design/uu-remote-clipboard.md)。@@ -18,7 +21,7 @@系统的剪贴板服务可能卡住了:某个程序声明了剪贴板内容后异常退出,会留下一个"有类型声明、没有数据"的空壳。执行 `killall pboard`,再复制一次即可。**设备一直显示「离线」**-检查两台电脑的 **设置 → 连接状态** 是否都是「已连接」。不是的话,确认服务器地址正确、8787 端口可以访问。+在同一网络里:看上面「同一网络里找不到另一台电脑」。两台都换过地址时,在设备列表里点那台设备的「…」菜单,选「输入它的地址」。跨网络时:检查两台电脑的 **设置 → 连接状态** 是否都是「已连接」,不是的话确认服务器地址正确、8787 端口可以访问。**一直显示「中转」而不是「直连」**刚连上时显示中转、过一会儿变成直连是正常的:先用中转保证能用,空闲时再换直连。一直是中转,说明 NAT 打洞没成功,常见于端口随机分配的 NAT 或严格的防火墙。功能不受影响,只是速度受服务器带宽限制。运行 `copysync-cli nat` 看本机探测到了几个出口:出口为 0 说明 UDP 被拦截了。@@ -33,3 +36,5 @@- **Mac 版还不会跳过密码管理器复制的内容**,Windows 版已经会。- **对方离线太久的内容不会补发**。服务器不存数据;对方暂时连不上时,本机只在内存里记下最近 20 条(24 小时内的),本机的后台服务重启后就清空了。- **中转模式的速度取决于服务器带宽**。直连时不受影响。+- **不在同一网段、两台都换了地址时**,要在设备菜单里重新输入一次地址;CopySync 不扫描网段。两台都是没放行防火墙的 Windows、又只有一边知道对方地址时连不上,要在被连的一方点「放行」。+- **macOS 15 要允许「本地网络」权限**,否则后台服务连不到局域网里的设备(对方先发来时仍能连上)。目前的版本是 ad-hoc 签名,更新后系统可能会再问一次。diff --git a/server/deploy/README.md b/server/deploy/README.mdindex ac172ac..ec190b7 100644--- a/server/deploy/README.md+++ b/server/deploy/README.md@@ -4,11 +4,16 @@ The server only does two things: it lets your devices find each other (signalingCopySync 的服务器只做两件事:让你的设备找到彼此(信令),以及在设备之间打不通直连时转发加密后的数据(TURN 中转)。它不存账号,也看不到你复制的内容。+**You may not need one.** Since 1.4.0, computers on the same network find each other and pair without a server, and computers on Tailscale pair by entering each other's Tailscale address. A server is for syncing across networks, or for subnets that can't reach each other.++**你可能用不着服务器。**从 1.4.0 起,同一网络里的电脑不用服务器就能互相发现、配对;装了 Tailscale 的电脑,配对时输入对方的 Tailscale 地址即可。服务器只在跨网络同步、或两个网段互相访问不到时需要。+Step-by-step guides with screenshots / 带截图的图文教程:+- Same network, no server / 同一网络,不需要服务器:<https://baiyuze.github.io/copysync/lan/>- On a public server / 公网服务器:<https://baiyuze.github.io/copysync/cloud/>-- On your LAN / 局域网:<https://baiyuze.github.io/copysync/server/>-- LAN + Tailscale, across networks without a public server / 局域网 + Tailscale,跨网络但没有公网服务器:<https://baiyuze.github.io/copysync/tailscale/>+- Tailscale, no server / Tailscale,不需要服务器:<https://baiyuze.github.io/copysync/tailscale/>+- On your LAN, for subnets that can't reach each other / 在局域网里部署,网段之间互相访问不到时:<https://baiyuze.github.io/copysync/server/>## Where to run it / 放在哪里@@ -16,7 +21,7 @@ Step-by-step guides with screenshots / 带截图的图文教程:|---|---|| **Public server** 公网服务器 | A Linux machine with a public IP; the smallest VPS is enough. Reachable from any network. 一台有公网 IP 的 Linux 机器,最低配的云主机就够,任何网络都能连上。 || **On your LAN** 局域网 | Any always-on Windows 10/11, macOS 13+ or Linux computer on the same network, one of your own computers included. Reserve its address in the router. 同一网络里任意一台常开的 Windows 10/11、macOS 13 以上或 Linux 电脑,自己的电脑也行;在路由器里给它固定地址。 |-| **LAN + Tailscale** 局域网 + Tailscale | Across networks without a public server: an always-on computer at home, with [Tailscale](https://tailscale.com) on it and on every client; see [Tailscale](#tailscale) below. 跨网络但没有公网服务器:家里一台常开的电脑,它和每台客户端都装上 Tailscale,见下面的 [Tailscale](#tailscale)。 |+| **LAN + Tailscale** 局域网 + Tailscale | Usually unnecessary now: computers on Tailscale pair by Tailscale address without a server. If you still want one, use an always-on computer at home with [Tailscale](https://tailscale.com); see [Tailscale](#tailscale) below. 现在一般用不着:装了 Tailscale 的电脑输入 Tailscale 地址就能配对,不需要服务器。仍想用服务器的话,放在家里一台常开、装了 Tailscale 的电脑上,见下面的 [Tailscale](#tailscale)。 |It uses about 15 MB of RAM. 内存占用约 15 MB。@@ -101,6 +106,10 @@ docker compose up -d## Tailscale+Since 1.4.0 you don't need a server for this: join every computer to the same [Tailscale](https://tailscale.com) network and enter the other computer's Tailscale address when pairing ([guide](https://baiyuze.github.io/copysync/en/tailscale/)). The setup below still works if you prefer a server, for example so that the TURN relay is available.++从 1.4.0 起这种情况不需要服务器:每台电脑加入同一个 Tailscale 网络,配对时输入对方的 Tailscale 地址即可([教程](https://baiyuze.github.io/copysync/tailscale/))。下面的做法仍然可用,比如你希望有 TURN 中转兜底。+Without a public server you can still sync across networks: keep the server at home and join every computer, the server's included, to the same [Tailscale](https://tailscale.com) network. Each device gets a fixed `100.x.y.z` address that the others can reach from anywhere. Install the server on that address, so the TURN relay is reachable through Tailscale too, and enter it in every app.没有公网服务器也能跨网络使用:服务器照样放在家里,所有电脑(包括服务器所在的那台)加入同一个 [Tailscale](https://tailscale.com) 网络。每台设备会分到一个固定的 `100.x.y.z` 地址,在哪儿都能互相访问。服务器用这个地址安装(TURN 中转也就能通过 Tailscale 访问到),每台电脑也填这个地址。@@ -132,7 +141,9 @@ On the server computer: turn on **Run unattended** in Tailscale on Windows (othe## Client setup / 客户端设置-On each computer (Mac or Windows), open CopySync → Settings → Signaling server and enter the address the script printed:+The server field is empty by default, which means "this network only". On each computer (Mac or Windows), open CopySync → Settings → Signaling server and enter the address the script printed:++「信令服务器地址」默认是空的,表示只在局域网里同步。在每台电脑(Mac 或 Windows)上打开 CopySync →「设置」→「信令服务器地址」,填入脚本打印的地址: