Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Ops Console CLIProxyAPI Plugin

ops-console 是一个 CLIProxyAPI 动态库插件,提供:

  1. SOCKS5 Proxy 控制:启停开关、listen ip:port、可选用户名/密码鉴权
  2. 本机交互 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: ""   # 留空则插件启动时自动生成

Resource 页面

/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 安全说明

  • 当前使用 ssh.InsecureIgnoreHostKey(),适用于受控运维环境
  • 私钥/密码只经浏览器 → Terminal sidecar,不写入插件 YAML 配置

Management API

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

SOCKS5 POST body

{
  "enabled": true,
  "listen": "127.0.0.1:1080",
  "username": "user",
  "password": "pass",
  "clear_auth": false
}

Terminal POST body

{
  "enabled": true,
  "listen": "127.0.0.1:17891",
  "token": "optional-new-token",
  "rotate_token": false
}

本机 Shell(推荐)

本机 Shell 默认走 CPA Management API(与页面同源),不依赖 17891 WebSocket 端口,因此远端打开管理页也能用。

  • POST /v0/management/ops-console/shell/open
  • POST /v0/management/ops-console/shell/input
  • GET /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。

Terminal WebSocket 协议

连接:

ws://<terminal_listen>/ws?token=<terminal_token>
  1. 首帧 JSON:
{
  "host": "192.168.1.10",
  "port": 22,
  "user": "root",
  "password": "...",
  "private_key": "...",
  "passphrase": "...",
  "cols": 120,
  "rows": 36
}
  1. 随后二进制帧:终端双向字节流
  2. 文本 JSON 控制:{"type":"resize","cols":120,"rows":40}、{"type":"ping"}
  3. 服务端文本: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)

Build

make test
make build
make package

macOS 产物示例:

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

Plugin Store 安装(registry)

本仓库提供 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

说明:

  1. registry.json 只负责「商店列表识别」;真正安装仍从
    https://github.com/YuniqueCore/cpa-plugin 的 GitHub Releases 下载
    ops-console_<version>_<goos>_<goarch>.zip + checksums.txt。
  2. repository 字段必须是 https://github.com/{owner}/{repo}(无 .git)。
  3. 发版后请同步更新本文件的 version 字段(展示用;安装以 release tag 为准)。

版本

0.1.0 — 从 codex-invite 参考项目改造为 Ops Console。

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages