ops-console 是一个 CLIProxyAPI 动态库插件,提供:
- SOCKS5 Proxy 控制:启停开关、listen
ip:port、可选用户名/密码鉴权 - 本机交互 Shell(默认)+ 可选 SSH:侧车 WebSocket + xterm.js,支持密码/私钥、PTY、窗口 resize
CPA 的 Management/Resource 路由是完整 request/response,不支持 WebSocket upgrade。
因此 Terminal 走插件进程内的侧车端口;控制面仍走 CPA Management API。
plugins:
enabled: true
configs:
ops-console:
enabled: true
priority: 1
socks5_enabled: false
socks5_listen: "127.0.0.1:1080"
socks5_username: ""
socks5_password: ""
terminal_enabled: true
terminal_listen: "127.0.0.1:17891"
terminal_token: "" # 留空则插件启动时自动生成/v0/resource/plugins/ops-console/console
页面能力:
- 填写 CPA management key 后调用控制 API
- SOCKS5 启停 / listen / auth
- Terminal sidecar 启停 / listen / token 轮换
- SSH 连接参数 + xterm 实时交互
- 默认 listen
127.0.0.1:仅本机浏览器可连 sidecar - 若从远端打开 CPA 管理页,请把
terminal_listen设为可从浏览器访问的地址(如0.0.0.0:17891),并设置强terminal_token - 页面里的 WS Host 覆盖 可指定浏览器实际连接的主机名/IP
- 当前使用
ssh.InsecureIgnoreHostKey(),适用于受控运维环境 - 私钥/密码只经浏览器 → Terminal sidecar,不写入插件 YAML 配置
| Method | Path | 说明 |
|---|---|---|
| GET | /v0/management/ops-console/status |
总状态 |
| GET/POST | /v0/management/ops-console/socks5 |
查询 / 更新 SOCKS5 |
| GET/POST | /v0/management/ops-console/terminal |
查询 / 更新 Terminal sidecar |
{
"enabled": true,
"listen": "127.0.0.1:1080",
"username": "user",
"password": "pass",
"clear_auth": false
}{
"enabled": true,
"listen": "127.0.0.1:17891",
"token": "optional-new-token",
"rotate_token": false
}本机 Shell 默认走 CPA Management API(与页面同源),不依赖 17891 WebSocket 端口,因此远端打开管理页也能用。
POST /v0/management/ops-console/shell/openPOST /v0/management/ops-console/shell/inputGET /v0/management/ops-console/shell/poll?id=...POST /v0/management/ops-console/shell/resize|close
SSH 模式仍使用 Terminal Sidecar WebSocket;若从远端访问,请把 Terminal Listen 设为 0.0.0.0:17891。
默认 本机 Shell(CPA 进程所在机器):
{"mode":"local","shell":"/bin/bash","cwd":"/tmp","cols":120,"rows":36}可选 SSH(需要凭证):
{"mode":"ssh","host":"...","port":22,"user":"...","password":"...","cols":120,"rows":36}SOCKS5 / Terminal 启停状态写入 ~/.config/ops-console/ops-console.state.json,刷新网页不会停掉已启动的 SOCKS5。
连接:
ws://<terminal_listen>/ws?token=<terminal_token>
- 首帧 JSON:
{
"host": "192.168.1.10",
"port": 22,
"user": "root",
"password": "...",
"private_key": "...",
"passphrase": "...",
"cols": 120,
"rows": 36
}- 随后二进制帧:终端双向字节流
- 文本 JSON 控制:
{"type":"resize","cols":120,"rows":40}、{"type":"ping"} - 服务端文本:
ready/error/exit/pong
- SOCKS5:
github.com/things-go/go-socks5 - SSH:
golang.org/x/crypto/ssh - WebSocket:
github.com/gorilla/websocket - 前端终端:xterm.js(CDN)
make test
make build
make packagemacOS 产物示例:
dist/ops-console.dylib
dist/ops-console_0.1.0_darwin_arm64.zip
安装到 CPA 插件目录:
mkdir -p /path/to/CLIProxyAPI/plugins/darwin/arm64
cp dist/ops-console.dylib /path/to/CLIProxyAPI/plugins/darwin/arm64/ops-console.dylib本仓库提供 CPA 可识别的商店源:
https://raw.githubusercontent.com/YuniqueCore/cpa-plugin/main/registry.json
在 CPA config.yaml 中(参考 TizenryA/cpa-plugin-grok-panel):
plugins:
enabled: true
dir: "plugins"
store-sources:
- https://raw.githubusercontent.com/YuniqueCore/cpa-plugin/main/registry.json说明:
registry.json只负责「商店列表识别」;真正安装仍从
https://github.com/YuniqueCore/cpa-plugin的 GitHub Releases 下载
ops-console_<version>_<goos>_<goarch>.zip+checksums.txt。repository字段必须是https://github.com/{owner}/{repo}(无.git)。- 发版后请同步更新本文件的
version字段(展示用;安装以 release tag 为准)。
0.1.0 — 从 codex-invite 参考项目改造为 Ops Console。