Skip to content

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.

18.6 KB
Raw Blame
<!doctype html>
<html lang="zh-TW">
<head>
  <meta charset="utf-8">
  <script>
    (function () {
      if (location.hostname !== "baiyuze.github.io") return;
      var prefix = /^\/(?:pasteferry|copysync)(?=\/|$)/.exec(location.pathname);
      if (!prefix) return;
      var path = location.pathname.slice(prefix[0].length) || "/";
      location.replace("https://pasteferry.cc" + path + location.search + location.hash);
    })();
  </script>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>運作原理:直連、多出口探測與出問題時的處理 — 隔空貼</title>
  <meta name="description" content="複製之後發生了什麼,兩台電腦怎麼連上,連不上怎麼辦。">
  <link rel="canonical" href="https://pasteferry.cc/zh-tw/how/">
  <link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/how/">
  <link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/how/">
  <link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/how/">
  <link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/how/">
  <link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/how/">
  <meta name="theme-color" content="#141416">
  <meta property="og:type" content="article">
  <meta property="og:site_name" content="隔空貼">
  <meta property="og:title" content="運作原理:直連、多出口探測與出問題時的處理 — 隔空貼">
  <meta property="og:description" content="複製之後發生了什麼,兩台電腦怎麼連上,連不上怎麼辦。">
  <meta property="og:url" content="https://pasteferry.cc/zh-tw/how/">
  <meta property="og:image" content="https://pasteferry.cc/assets/og-zh-hant.png">
  <meta property="og:locale" content="zh_TW">
  <meta name="twitter:card" content="summary_large_image">
  <link rel="icon" href="../../assets/favicon.svg?v=df696024d8" type="image/svg+xml">
  <link rel="icon" href="../../assets/favicon-32.png?v=8e9afa506d" sizes="32x32" type="image/png">
  <link rel="apple-touch-icon" href="../../assets/apple-touch-icon.png?v=bcbf406cb8">
  <link rel="stylesheet" href="../../assets/site.css?v=dbae55d27c">
  <script>document.documentElement.classList.add("js");if (!/Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent)) document.documentElement.classList.add("pc");</script>
</head>
<body>
  <a class="skip" href="#main">跳到主要內容</a>

  <header class="bar">
    <div class="wrap">
      <a class="brand" href="../../zh-tw/" aria-label="隔空貼首頁"><img src="../../assets/icon.svg?v=65a69999e0" alt="" width="26" height="26">隔空貼</a>
      <nav aria-label="頁面導覽">
        <a href="../../zh-tw/features/">功能</a>
        <a class="mid" href="../../zh-tw/start/">快速入門</a>
        <a class="wide" href="../../zh-tw/start/#server">連線方式</a>
        <a href="../../zh-tw/download/">下載</a>
        <details class="menu">
          <summary aria-label="更多頁面" class="current"><span>更多</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
          <ul>
            <li class="narrow"><a href="../../zh-tw/start/">快速入門</a></li>
            <li class="narrow"><a href="../../zh-tw/start/#server">連線方式</a></li>
            <li><a href="../../zh-tw/themes/">主題教學</a></li>
            <li><a href="./" aria-current="page">運作原理</a></li>
            <li><a href="../../zh-tw/security/">安全與隱私</a></li>
            <li><a href="../../zh-tw/faq/">常見問題</a></li>
            <li><a href="../../zh-tw/feedback/">討論與回饋</a></li>
            <li class="sep" role="separator"></li>
            <li><a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">更新記錄</a></li>
            <li class="narrow-gh"><a href="https://github.com/baiyuze/pasteferry">GitHub</a></li>
          </ul>
        </details>
        <a class="gh" href="https://github.com/baiyuze/pasteferry" data-gh-stars aria-label="在 GitHub 上給隔空貼點 Star"><svg class="gh-mark" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg><span class="gh-label">Star</span><span class="gh-count" hidden><svg class="gh-star" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.751.751 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z"/></svg><b></b></span></a>
        <details class="lang">
          <summary aria-label="語言:繁體中文(台灣)"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="10" cy="10" r="7.25"/><path d="M2.75 10h14.5M10 2.75c-2.1 2-3.1 4.4-3.1 7.25s1 5.25 3.1 7.25M10 2.75c2.1 2 3.1 4.4 3.1 7.25s-1 5.25-3.1 7.25"/></svg><span>繁體中文(台灣)</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
          <ul>
            <li><a href="../../how/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a></li>
            <li><a href="../../zh-tw/how/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw" aria-current="page">繁體中文(台灣)</a></li>
            <li><a href="../../zh-hk/how/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a></li>
            <li><a href="../../en/how/" hreflang="en" lang="en" data-lang="en">English</a></li>
            <li><a href="../../ja/how/" hreflang="ja" lang="ja" data-lang="ja">日本語</a></li>
          </ul>
        </details>
      </nav>
    </div>
  </header>

  <main id="main">
    <section class="hero guide-hero">
      <div class="wrap">
        <p class="crumb"><a href="../../zh-tw/">隔空貼</a></p>
        <h1 class="display">運作原理</h1>
        <p class="lede">複製之後發生了什麼,兩台電腦怎麼連上,連不上怎麼辦。</p>
      </div>
    </section>

    <section class="section" aria-labelledby="flow-title">
      <div class="wrap">
        <h2 id="flow-title">按下複製之後</h2>
        <p class="intro">文字、圖片、檔案都走同一條路。</p>
        <ol class="flow">
          <li><h3>偵測</h3><p>背景服務察覺剪貼簿變了。</p></li>
          <li><h3>傳輸</h3><p>文字和 50 MB 以內的檔案馬上送過去,更大的先送一筆記錄。</p></li>
          <li><h3>貼上</h3><p>另一台存到本機再放進剪貼簿,貼上的就是真正的檔案。</p></li>
        </ol>
      </div>
    </section>

    <section class="section" id="diagram" aria-labelledby="how-title">
      <div class="wrap">
        <h2 id="how-title">隔空貼的連線方式</h2>
        <p class="intro">同一個網路裡直接找到對方;不在同一個網路時,由伺服器牽線後盡量直連,連不上才中繼。內容始終加密。</p>
        <figure class="diagram">
          <svg viewBox="0 0 960 400" role="img" aria-labelledby="diagram-title diagram-desc">
            <title id="diagram-title">隔空貼的連線方式</title>
            <desc id="diagram-desc">電腦 A 與電腦 B 之間是 WebRTC 直連;兩台電腦都透過信令連到伺服器;直連失敗時,資料經伺服器的 TURN 中繼。</desc>
            <rect class="d-box" x="360" y="24" width="240" height="96" rx="14"/>
            <text class="d-title" x="480" y="64" text-anchor="middle">信令與中繼服務</text>
            <text class="d-sub" x="480" y="92" text-anchor="middle">信令、STUN、TURN 中繼</text>
            <path class="d-sig" d="M140 210V58H360"/>
            <path class="d-sig" d="M820 210V58H600"/>
            <path class="d-relay" d="M196 210V100H360"/>
            <path class="d-relay" d="M764 210V100H600"/>
            <text class="d-note" x="210" y="50">信令:交換連線資訊</text>
            <text class="d-note" x="210" y="128">中繼:只在直連不通時</text>
            <rect class="d-box" x="40" y="210" width="240" height="120" rx="14"/>
            <text class="d-title" x="160" y="262" text-anchor="middle">Mac</text>
            <text class="d-sub" x="160" y="290" text-anchor="middle">在這裡複製</text>
            <rect class="d-box" x="680" y="210" width="240" height="120" rx="14"/>
            <text class="d-title" x="800" y="262" text-anchor="middle">Mac、Windows 或 Linux</text>
            <text class="d-sub" x="800" y="290" text-anchor="middle">在這裡貼上</text>
            <path class="d-direct" d="M280 270H680"/>
            <text class="d-label" x="480" y="256" text-anchor="middle">WebRTC 直連,DTLS 加密</text>
            <text class="d-note" x="480" y="298" text-anchor="middle">資料只在兩台電腦之間傳</text>
            <g class="d-legend" transform="translate(40 372)">
              <path class="d-direct" d="M0 0H28"/><text x="38" y="5">資料(直連)</text>
              <path class="d-relay" d="M210 0H238"/><text x="248" y="5">資料(中繼,備用)</text>
              <path class="d-sig" d="M470 0H498"/><text x="508" y="5">信令</text>
            </g>
          </svg>
          <ul class="points diagram-text">
            <li><strong>WebRTC 直連,DTLS 加密</strong> 資料只在兩台電腦之間傳</li>
            <li><strong>信令與中繼服務</strong> 信令、STUN、TURN 中繼</li>
            <li>中繼:只在直連不通時</li>
          </ul>
        </figure>
      </div>
    </section>

    <section class="section" id="multi-uplink" aria-labelledby="multi-title">
      <div class="wrap">
        <h2 id="multi-title">公司網路也能直連</h2>
        <p class="intro">多出口的公司網路以前只能中繼。隔空貼會偵測出每個出口,讓對方逐一嘗試。</p>
        <div class="cols">
          <div>
            <h3>做了什麼</h3>
            <ul class="points">
              <li><strong>共用一個連接埠。</strong>所有連線走同一個 UDP 連接埠。</li>
              <li><strong>偵測每個出口。</strong>同時詢問 7 台伺服器,有幾個出口就拿到幾個位址。</li>
              <li><strong>全部告訴對方。</strong>對方逐一嘗試,對上的那個就能連通。</li>
              <li><strong>閒置時再試直連。</strong>先用中繼確保能用,閒置時再換成直連。</li>
            </ul>
          </div>
          <div>
            <h3>用真實的網路拓撲測試</h3>
            <p class="small">每次提交程式碼都會在模擬的網路裡自動跑一遍。</p>
            <div class="table-scroll">
              <table>
                <thead><tr><th scope="col">情境</th><th scope="col">結果</th></tr></thead>
                <tbody>
                <tr><td>單一出口 ↔ 家用路由器</td><td>直連</td></tr>
                <tr><td>兩個出口,舊版本(對照)</td><td>中繼</td></tr>
                <tr><td>四個出口 ↔ 家用路由器</td><td>直連</td></tr>
                <tr><td>兩個出口 ↔ 兩個出口</td><td>直連</td></tr>
                <tr><td>兩個出口 ↔ 連接埠隨機分配的 NAT</td><td>中繼</td></tr>
                <tr><td>一開始打不通,之後網路恢復</td><td>先中繼,隨後直連</td></tr>
                <tr><td>沒有伺服器,同一個網段</td><td>直連</td></tr>
                <tr><td>沒有伺服器,兩個網段之間被隔離</td><td>連不上</td></tr>
                </tbody>
              </table>
            </div>
            <p class="small">實測:公司 4 個出口的 Mac 和家裡的 Mac,以前中繼 0.6 MB/s,現在直連。</p>
            <p class="small">細節見<a href="../../design/nat-traversal.html">技術說明</a>。</p>
          </div>
        </div>
      </div>
    </section>

    <section class="section" id="fallbacks" aria-labelledby="fallback-title">
      <div class="wrap">
        <h2 id="fallback-title">出問題的時候</h2>
        <p class="intro">常見的情況,都有處理。</p>
        <dl class="fallbacks">
          <div><dt>在同一個網路裡找不到對方</dt><dd>配對時填上對方的位址,之後會記住。</dd></div>
          <div><dt>打不通直連</dt><dd>經伺服器中繼,內容一樣加密。</dd></div>
          <div><dt>對方睡眠或斷線</dt><dd>醒來後自動重新連線。</dd></div>
          <div><dt>傳檔案時中斷</dt><dd>連上後從中斷處接著傳。</dd></div>
          <div><dt>檔名在 Windows 上不合法</dt><dd>換成全形字元,檔名照樣看得懂。</dd></div>
          <div><dt>複製的是密碼</dt><dd>Windows 上密碼管理工具複製的內容會被跳過。</dd></div>
        </dl>
      </div>
    </section>

    <section class="section" id="specs" aria-labelledby="specs-title">
      <div class="wrap">
        <h2 id="specs-title">技術規格</h2>
        <div class="table-scroll">
          <table class="specs">
            <tbody>
            <tr><th scope="row">版本</th><td>2.10.1,<time datetime="2026-11-07">2026 年 11 月 7 日</time>發布</td></tr>
            <tr><th scope="row">Mac 用戶端</th><td>macOS 13 Ventura 以上;Apple 晶片與 Intel 晶片各有一個安裝檔,約 25 MB,不需要 Rosetta;也有兩種晶片通用的版本,約 47 MB</td></tr>
            <tr><th scope="row">Windows 用戶端</th><td>Windows 10 與 Windows 11,x64;只為目前使用者安裝,不需要系統管理員權限;安裝檔約 23 MB</td></tr>
            <tr><th scope="row">Linux 用戶端</th><td>x64 與 ARM64;.deb(Debian、Ubuntu 等)或 tar.gz(其他發行版),約 22 MB;需要 X11 桌面,或附有 XWayland 的 Wayland 桌面(GNOME、KDE 等預設都有);GTK 3</td></tr>
            <tr><th scope="row">伺服器</th><td>用「服務」或在同一個網路裡都不需要。自建的話,支援 Linux x86_64/ARM64、macOS 與 Windows 10/11 x64。</td></tr>
            <tr><th scope="row">介面語言</th><td>簡體中文、繁體中文(台灣、香港)、English、日本語,預設跟隨系統,可在設定裡切換</td></tr>
            <tr><th scope="row">同步的內容</th><td>純文字、帶格式的文字、圖片與螢幕截圖、檔案、資料夾,可依類型個別關閉</td></tr>
            <tr><th scope="row">傳輸</th><td>WebRTC 資料通道,優先直連,打不通時經 TURN 中繼;同一個網路裡透過 mDNS 探索、UDP 8788 交換連線資訊;多出口網路逐一偵測每個出口;檔案以 tar + zstd 串流打包</td></tr>
            <tr><th scope="row">加密與身分</th><td>DTLS 端對端加密;裝置身分為 Ed25519 金鑰;信令訊息逐則簽章</td></tr>
            <tr><th scope="row">配對</th><td>6 碼配對碼,5 分鐘內有效,字元集去掉了 0/O、1/I 等容易混淆的字元;配對時人工核對安全指紋</td></tr>
            <tr><th scope="row">自動同步上限</th><td>預設 50 MB,可在 1 MB 到 1 GB 之間調整</td></tr>
            <tr><th scope="row">隔空傳送</th><td>傳給一台裝置,不限大小,檔案和整個資料夾都行;區域網路裡走加密的 TCP 通道(兩端需 2.5.1),用不了時退回 WebRTC;外網和中繼用 WebRTC;斷了接著傳,每個檔案用 SHA-256 校驗。Mac 傳 1 GB 到 Linux 虛擬機實測 144.3 MB/s,實際速度看網路和磁碟。</td></tr>
            <tr><th scope="row">好友</th><td>F 開頭的 7 位好友碼,經區域網路或「服務」交換,可以核對安全碼;好友之間只能互傳檔案和圖片,可附 200 字以內的備註,每批都要對方接受;好友看不到你的剪貼簿、複製記錄和裝置;收到的檔案去掉可執行權限,Mac 上加上隔離標記;兩端需 2.6 或更新版本</td></tr>
            <tr><th scope="row">記錄保留</th><td>預設 3 天,可在 1 小時到 30 天之間調整,到期自動清除</td></tr>
            <tr><th scope="row">實測速度</th><td>區域網路直連傳輸 20 MB 檔案約 330 毫秒,檢查碼一致</td></tr>
            <tr><th scope="row">技術堆疊</th><td>背景服務與伺服器用 Go(Windows 上以純 Go 呼叫 Win32,Linux 上以純 Go 走 X11 協定),介面用 Flutter(三個系統共用一套程式碼),訊息定義用 Protocol Buffers</td></tr>
            <tr><th scope="row">授權</th><td><a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">GNU AGPL-3.0</a></td></tr>
            </tbody>
          </table>
        </div>
      </div>
    </section>
  </main>

  <footer class="footer">
    <div class="wrap">
      <p>隔空貼以 GNU AGPL-3.0 授權開源。</p>
      <nav aria-label="頁尾連結">
        <a href="https://github.com/baiyuze/pasteferry/releases">所有版本</a>
        <a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">更新記錄</a>
        <a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
        <a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
        <a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
        <a href="../../zh-tw/privacy/">隱私權說明</a>
        <a href="../../zh-tw/feedback/">討論與回饋</a>
      </nav>
      <nav aria-label="語言">
        <a href="../../how/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
        <a href="../../zh-tw/how/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw" aria-current="page">繁體中文(台灣)</a>
        <a href="../../zh-hk/how/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a>
        <a href="../../en/how/" hreflang="en" lang="en" data-lang="en">English</a>
        <a href="../../ja/how/" hreflang="ja" lang="ja" data-lang="ja">日本語</a>
      </nav>
    </div>
  </footer>

  <script src="../../assets/site.js?v=fb60f6e5ce" defer></script>
  <script src="/assets/analytics.js?v=e2777f714d" defer></script>
  <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "7ee226baf4a949a397c4bfd69a9e7461"}'></script>
</body>
</html>