SECURE PIPES 2 使用者指南

截圖使用英文介面,圖表隨指南語言切換。控制項名稱可能因您選擇的應用程式語言而異。

AppleScript — 命令參考

使用與 Mac App 自動化頁面一致的命令說明及可複製範例,涵蓋既有命令與 2.0.17 新增命令。

AppleScript 指令參考

以下章節同步自 Mac App 內建自動化資料,包含逐項說明及完整指令碼。執行前請替換範例名稱與 ID。範例可能修改實際連線及設定,請勿一次執行整頁。

命令參考

依照此處的指令片語呼叫。連線名稱或群組標籤需以引號括住。

start

啟動 Secure Pipes,但不顯示視窗。

tell application "Secure Pipes" to start

show

顯示 Secure Pipes 視窗。

tell application "Secure Pipes" to show

hide

隱藏視窗,Secure Pipes 和連線會繼續執行。

tell application "Secure Pipes" to hide

shutdown

結束 Secure Pipes 並停止作用中的連線。

tell application "Secure Pipes" to shutdown

list connections

列出已儲存的連線。

tell application "Secure Pipes" to list connections

list connection groups

列出做為連線群組的標籤。

tell application "Secure Pipes" to list connection groups

connect connection "Build Tunnel (Local Forward)"

啟動已儲存的連線。

tell application "Secure Pipes" to connect connection "Build Tunnel (Local Forward)"

disconnect connection "Build Tunnel (Local Forward)"

停止已儲存的連線。

tell application "Secure Pipes" to disconnect connection "Build Tunnel (Local Forward)"

connection status "Build Tunnel (Local Forward)"

讀取連線目前狀態。

tell application "Secure Pipes" to connection status "Build Tunnel (Local Forward)"

connect group "engineering"

依已儲存的啟動設定啟動群組。

tell application "Secure Pipes" to connect group "engineering"

disconnect group "engineering"

停止群組及其成員連線。

tell application "Secure Pipes" to disconnect group "engineering"

建議在腳本中使用連線 UUID,重新命名後仍然有效。也支援唯一名稱或含類型的完整名稱;名稱重複時請使用 UUID。

遠端桌面

list remote desktops

列出已儲存的 RDP/VNC 連線。

tell application "Secure Pipes" to list remote desktops

get remote desktop "<ID>"

依 ID 讀取連線,不傳回認證資料。

tell application "Secure Pipes" to get remote desktop "DESKTOP-ID"

create remote desktop <JSON>

提供 name 和 values 建立連線。使用 hostProfileUUID 參照預設主機。

tell application "Secure Pipes" to create remote desktop "{\"name\":\"Office desktop\",\"values\":{\"hostProfileUUID\":\"PRESET-HOST-ID\",\"remoteDesktopType\":\"rdp\",\"remoteDesktopUsername\":\"alice\",\"remoteHost\":\"192.168.1.91\"}}"
tell application "Secure Pipes" to create remote desktop "{\"name\":\"Office VNC\",\"values\":{\"hostProfileUUID\":\"PRESET-HOST-ID\",\"remoteDesktopType\":\"vnc\",\"remoteDesktopVNCOpenMode\":\"screenSharing\"}}"

update remote desktop <JSON>

依 id 更新;name 和 values 為選填。

tell application "Secure Pipes" to update remote desktop "{\"id\":\"DESKTOP-ID\",\"values\":{\"remoteDesktopOptions\":{\"screen mode id\":1,\"audiomode\":2}}}"

open remote desktop "<ID>"

必要時先啟動 SSH 通道,再開啟已選的 RDP/VNC 用戶端。

tell application "Secure Pipes" to open remote desktop "DESKTOP-ID"

delete remote desktop "<ID>"

依 ID 刪除未連線的遠端桌面連線。

tell application "Secure Pipes" to delete remote desktop "DESKTOP-ID"

允許寫入使用者名稱,但不會讀取既有使用者名稱。SSH 密碼和身分檔案請在 Secure Pipes 中設定;遠端桌面密碼請在用戶端輸入。

任務計畫

建立與控制排程動作。讀取已隱去敏感資料,絕不返回密碼或私鑰內容。

list task plans

以隱去敏感資料的 JSON 列出計畫。

tell application "Secure Pipes" to list task plans

get task plan "work-start"

依 ID 讀取已隱去敏感資料的計畫 JSON。

tell application "Secure Pipes" to get task plan "work-start"

create task plan <JSON>

建立經驗證的計畫。動作使用連線或群組 ID,勿包含憑證資料。

tell application "Secure Pipes"
    create task plan "{\"id\":\"work-start\",\"hour\":9,\"minute\":0,\"repeat\":2,\"actions\":[{\"type\":\"start_group\",\"id\":\"work\"}]}"
end tell

update task plan <JSON>

以既有 ID 及要修改的欄位更新計畫。

tell application "Secure Pipes"
    update task plan "{\"id\":\"work-start\",\"hour\":8,\"minute\":45,\"repeat\":2,\"actions\":[{\"type\":\"start_group\",\"id\":\"work\"}]}"
end tell

set task plan enabled "work-start"

啟用或停用計畫而不改排程;參數預設 true。

tell application "Secure Pipes" to set task plan enabled "work-start" enabled false
tell application "Secure Pipes" to set task plan enabled "work-start" enabled true

run task plan "work-start"

立即執行既有計畫並返回 JSON 結果。

tell application "Secure Pipes" to run task plan "work-start"

delete task plan "work-start"

依 ID 刪除已存計畫。

tell application "Secure Pipes" to delete task plan "work-start"

JSON 支援 repeat 0–6、自訂星期、ISO 8601 或 YYYY-MM-DD 日期範圍及經驗證的動作。先用 list connections 與 list connection groups 取得 ID。

規則與使用場景

修改規則或切換場景時,可使用 ID 或唯一名稱。切換場景會中斷作用中的連線,然後重新連線。刪除場景不會刪除規則;沒有其他所屬場景的規則會變為通用規則。

list proxy rules

依順序列出規則的 ID、名稱、啟用狀態、動作和關聯場景 ID。

tell application "Secure Pipes" to list proxy rules

list scenarios

列出場景(包括通用場景)的 ID、名稱及是否正在使用。

tell application "Secure Pipes" to list scenarios

current scenario

顯示目前使用場景的名稱。

tell application "Secure Pipes" to current scenario

switch scenario "Office"

依 ID 或唯一名稱切換場景,並依新規則重新連線受影響的連線。

tell application "Secure Pipes" to switch scenario "Office"

enable proxy rule "Work websites"

依 ID 或唯一名稱啟用規則。

tell application "Secure Pipes" to enable proxy rule "Work websites"

disable proxy rule "Work websites"

停用規則,但不刪除規則。

tell application "Secure Pipes" to disable proxy rule "Work websites"

set rule scenarios "Work websites" scenarios {"Office", "Travel"}

取代規則關聯的場景。指定 Universal 可將其設為通用規則。

tell application "Secure Pipes" to set rule scenarios "Work websites" scenarios {"Office", "Travel"}

create scenario "Travel"

使用唯一名稱建立場景,並傳回其 ID。

tell application "Secure Pipes" to create scenario "Travel"

rename scenario "Travel" to "Mobile work"

重新命名場景,保留現有規則關聯。

tell application "Secure Pipes" to rename scenario "Travel" to "Mobile work"

delete scenario "Travel"

刪除場景,但保留規則。未關聯其他場景的規則將變為通用規則。

tell application "Secure Pipes" to delete scenario "Travel"

綜合範例

tell application "Secure Pipes"
    set savedRules to list proxy rules
    set savedScenarios to list scenarios
    set selectedScenario to current scenario
    switch scenario "Office"
    enable proxy rule "Work websites"
    disable proxy rule "Work websites"
    set rule scenarios "Work websites" scenarios {"Office", "Travel"}
    set rule scenarios "Work websites" scenarios {}
    set newScenarioID to create scenario "Travel"
    rename scenario newScenarioID to "Mobile work"
    delete scenario newScenarioID
end tell

代理與網路共享

共享沿用已儲存的位址、連接埠和驗證設定。啟動時會視需要開啟現有確認視窗;閘道模式仍需風險確認和 macOS 授權。

list proxy servers

列出代理伺服器的 ID、名稱、類型和位址,不包含驗證資訊。

tell application "Secure Pipes" to list proxy servers

transparent proxy status

查看透明代理的執行狀態、系統延伸功能狀態及版本是否相符。

tell application "Secure Pipes" to transparent proxy status

initialize transparent proxy

安裝或修復系統延伸功能。macOS 可能要求核准;此命令不會啟動透明代理。

tell application "Secure Pipes" to initialize transparent proxy

start transparent proxy

系統延伸功能就緒後,依目前路由規則啟動透明代理。

tell application "Secure Pipes" to start transparent proxy

stop transparent proxy

停止透明代理。網路共享依賴此服務執行。

tell application "Secure Pipes" to stop transparent proxy

network sharing status

查看共享和閘道狀態。執行時顯示實際生效的模式,停止時顯示已儲存的模式。

tell application "Secure Pipes" to network sharing status

set sharing modes "both"

選擇下次手動啟動時的代理模式、閘道模式、兩者同時啟用或全部關閉。變更前須停止共享。

tell application "Secure Pipes" to set sharing modes "both"

start network sharing

依所選模式及已儲存的位址、連接埠和驗證設定啟動共享。可能需要確認。

tell application "Secure Pipes" to start network sharing

stop network sharing

停止閘道及共享代理監聽器。透明代理會繼續執行。

tell application "Secure Pipes" to stop network sharing

綜合範例

tell application "Secure Pipes"
    set servers to list proxy servers
    set proxyState to transparent proxy status
    initialize transparent proxy
    start transparent proxy
    set sharing modes "both"
    set sharingState to network sharing status
    start network sharing
    stop network sharing
    stop transparent proxy
end tell

連線、活動與日誌

使用清單傳回的 ID 精確查詢;詳細資料以 JSON 文字傳回。

group status "engineering"

查看群組結果及各成員的連線狀態。

tell application "Secure Pipes" to group status "engineering"

wait for connection "Build Tunnel" timeout 30

等待連線就緒;失敗或逾時會傳回錯誤。

tell application "Secure Pipes" to wait for connection "Build Tunnel" timeout 30

preview route "example.com" port 443

預測目前情境下的本機規則比對;不測試實際連通性。

tell application "Secure Pipes" to preview route "example.com" port 443 application "com.apple.Safari" transport "TCP"

test proxy server "proxy-id"

測試已儲存的代理伺服器,傳回結果、原因及耗時。

tell application "Secure Pipes" to test proxy server "proxy-id"

list active flows "PROXY"

查看代理活動;LAN 查看共享,ALL 查看兩者。

tell application "Secure Pipes" to list active flows "PROXY"

list active flows "LAN"

查看網路共享連線。

tell application "Secure Pipes" to list active flows "LAN"

end active flow "flow-id"

依 ID 關閉一條已連線的流。

tell application "Secure Pipes" to end active flow "flow-id"

list recent logs

查看最近最多 200 筆已遮蔽敏感資訊的日誌,最新的在前。

tell application "Secure Pipes" to list recent logs

log detail "log-id"

依 ID 查看近期日誌的完整紀錄。

tell application "Secure Pipes" to log detail "log-id"

終端機範例

在終端機使用 osascript 執行 AppleScript 指令。macOS 可能會詢問是否允許終端機控制 Secure Pipes。

列出連線群組

osascript -e 'tell application "Secure Pipes" to list connection groups'

輸出範例

engineering, on-call

連線標籤決定群組成員。啟動群組時會遵循已儲存的順序、並行或循序模式及錯誤處理設定。

啟動或停止連線群組

osascript -e 'tell application "Secure Pipes" to connect group "engineering"'
osascript -e 'tell application "Secure Pipes" to disconnect group "engineering"'

檢視並控制連線

osascript -e 'tell application "Secure Pipes" to list connections'
osascript -e 'tell application "Secure Pipes" to connection status "Build Tunnel (Local Forward)"'
osascript -e 'tell application "Secure Pipes" to connect connection "Build Tunnel (Local Forward)"'

從終端機執行

儲存檔案後,將檔案路徑傳給 osascript:

osascript ~/Scripts/Connect\ Tunnel.applescript

以指令碼檔案執行

將範例儲存為 .applescript 檔案,然後在「指令碼編輯器」中執行,或使用 osascript 執行。

依名稱連線

將範例連線名稱替換為 list connections 傳回的名稱。

on run
    -- Leave this blank to skip opening a URL after connecting.
    set postConnectURL to ""
    -- Get the saved connections.
    tell application "Secure Pipes"
        set availableConnections to list connections
    end tell
    if (count of availableConnections) is 0 then return

    set selectedConnection to choose from list availableConnections
    if selectedConnection is false then return
    set targetConnection to item 1 of selectedConnection

    -- Start the selected connection and wait up to 90 seconds.
    tell application "Secure Pipes"
        connect connection targetConnection
        set currentState to "connecting"
        repeat with attempt from 1 to 90
            set currentState to connection status targetConnection
            if currentState is "connected" then exit repeat
            if currentState is "authentication failed" or currentState is "unknown host key" or currentState is "host key changed" or currentState is "invalid" or currentState is "error" then exit repeat
            delay 1
        end repeat
    end tell
    -- Open the URL only if the connection comes up.
    if currentState is "connected" and postConnectURL is not "" then
        open location postConnectURL
    end if
    return currentState
end run

選取並啟動連線群組

列出可用標籤、選取群組,並啟動其中的所有連線。

on run
    -- Get the groups saved in Secure Pipes.
    tell application "Secure Pipes"
        set availableGroups to list connection groups
    end tell
    -- Let the user know if there are no groups to choose from.
    if (count of availableGroups) is 0 then
        display dialog "No tagged connection groups are available." buttons {"OK"}
        return
    end if

    -- Ask which group to start.
    set selectedGroup to choose from list availableGroups
    if selectedGroup is false then return
    set targetGroup to item 1 of selectedGroup

    tell application "Secure Pipes"
        connect group targetGroup
    end tell
end run

自動化權限

macOS 詢問時,請在「系統設定」>「隱私權與安全性」>「自動化」中,允許執行指令碼的 App(例如終端機或指令碼編輯器)控制 Secure Pipes。

基於 Secure Pipes 2.0.17 · 更新於 2026 年 11 月 9 日