From 5e48016852385bc3b1ee7c59be91953ec33bd4c2 Mon Sep 17 00:00:00 2001 From: Timmy Date: Thu, 18 Jun 2026 18:33:08 +0800 Subject: [PATCH] feat: enable Taildrive via ACL policy (full-mesh preserved) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 config/policy.hujson 並啟用 policy.path: - acls 保留 allow-all,維持原本全互通行為 - nodeAttrs 授予所有節點 drive:share / drive:access - grants 開放 tailscale.com/cap/drive(所有 share, rw) 已部署至伺服器並驗證:policy valid、14 節點 online、peer ping 正常、 drive 能力出現在 netmap。 Co-Authored-By: Claude Opus 4.8 --- config/config.yaml | 2 +- config/policy.hujson | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 config/policy.hujson diff --git a/config/config.yaml b/config/config.yaml index 2d3c174..e5786d4 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -151,7 +151,7 @@ policy: # mode: ACL 政策儲存方式(可選 file 或 database) mode: file # path: 當 mode=file 時,ACL HuJSON 檔案的路徑 - path: "" + path: /etc/headscale/policy.hujson dns: diff --git a/config/policy.hujson b/config/policy.hujson new file mode 100644 index 0000000..4dd6c94 --- /dev/null +++ b/config/policy.hujson @@ -0,0 +1,52 @@ +// Headscale ACL policy —— 全互通 + Taildrive 範本 +// 適用 headscale v0.29.0(首度支援 nodeAttrs / Taildrive policy)。 +// +// 套用方式: +// 1) 把本檔放到容器看得到的路徑(config 目錄會掛載為 /etc/headscale)。 +// 2) 在 config/config.yaml 設定: +// policy: +// mode: file +// path: /etc/headscale/policy.hujson +// 3) 重啟容器後驗證:docker exec headscale headscale policy check --file /etc/headscale/policy.hujson +// +// ⚠️ 重要:沒有 policy 檔時 headscale 預設「全部互通」。一旦啟用 policy, +// acls 變成唯一授權來源;下面這條 allow-all 規則務必保留,否則所有節點立即斷線。 + +{ + // ---- 連線授權:維持目前的全互通行為 ---- + "acls": [ + { + "action": "accept", + "src": ["*"], + "dst": ["*:*"] + } + ], + + // ---- Taildrive:開啟「分享 / 存取」能力 ---- + // drive:share = 可把本機目錄分享出去(伺服器端僅 Linux/macOS/Windows 支援) + // drive:access = 可掛載並讀寫他人分享的目錄(iOS/Android 也能存取) + "nodeAttrs": [ + { + "target": ["*"], + "attr": ["drive:share", "drive:access"] + } + ], + + // ---- Taildrive:用 grant 指定可存取哪些 share 與讀寫權限 ---- + // shares: ["*"] 代表所有 share;可改成特定名稱清單。 + // access: "rw" 讀寫 / "ro" 唯讀。 + "grants": [ + { + "src": ["*"], + "dst": ["*"], + "app": { + "tailscale.com/cap/drive": [ + { + "shares": ["*"], + "access": "rw" + } + ] + } + } + ] +}