feat: enable Taildrive via ACL policy (full-mesh preserved)

新增 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 <noreply@anthropic.com>
This commit is contained in:
2026-06-18 18:33:08 +08:00
parent e404dd9036
commit 5e48016852
2 changed files with 53 additions and 1 deletions

View File

@@ -151,7 +151,7 @@ policy:
# mode: ACL 政策儲存方式(可選 file 或 database # mode: ACL 政策儲存方式(可選 file 或 database
mode: file mode: file
# path: 當 mode=file 時ACL HuJSON 檔案的路徑 # path: 當 mode=file 時ACL HuJSON 檔案的路徑
path: "" path: /etc/headscale/policy.hujson
dns: dns:

52
config/policy.hujson Normal file
View File

@@ -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"
}
]
}
}
]
}