RustMinerSystem

文档

群控与远程转发 API

RustMinerSystem 群控 TOKEN、客户端列表、远程客户端维护和 Base64 路径转发接口。

群控与远程转发 API

群控接口让一个 RustMinerSystem 实例读取其他实例的状态。群控 API 属于高权限凭据,应只在受信任实例之间使用。

群控凭据和客户端

方法 路径 用途
GET /api/remote/token 获取当前实例的群控 API。
GET /api/remote/refresh/token 刷新群控 API,旧值立即失效。
GET /api/remote/list 获取已添加的远程客户端。
POST /api/remote/new 添加远程客户端。
POST /api/remote/{id} 更新远程客户端。
DELETE /api/remote/{id} 删除远程客户端。

添加和更新请求:

{
  "name": "Hong Kong Proxy 01",
  "endpoint": "https://proxy.example.com/safe-route",
  "token": "<远程实例群控 API>"
}

endpoint 应包含远程实例的协议、端口和安全路径,但末尾不需要 /

返回结构:

  • /api/remote/token/api/remote/refresh/token 直接返回群控 TOKEN 字符串。刷新接口会修改凭据,不能作为状态查询调用。
  • /api/remote/list 返回 RemoteClient[]
  • 新增、更新和删除成功时返回字符串 Ok

RemoteClient 字段:

字段 类型 说明
id string 本地远程客户端记录 ID,供 {id} 路径参数使用。
name string 客户端显示名称。
endpoint string 远程实例基础地址,包含安全路径。
token string 远程实例的群控 TOKEN,必须脱敏。
time string 创建或更新时间。

转发远程请求

POST /api/remote/q/{id}/{m}/{p}
X-ACCESS-TOKEN: <Access Token>
Content-Type: application/json
路径参数 说明
id 远程客户端记录 ID。
m 请求模式;当前前端固定为 0
p 远程 API 路径去掉 /api/ 后的 Base64 编码。

例如远程路径 /api/ports 先转换为 ports,再编码为 Base64,放入 {p}

当前前端通过该接口读取:

/api/ports
/api/stat/currency/{currency}
/api/device/stats
/api/currency/online/stat/{coin}
/api/sys/stat
/api/sys/base/info
/api/local/version
/api/sys/starttime

外层请求始终为 POST,当前读取请求的主体通常是空对象。远程请求失败时,前端会把客户端标记为部分可用或离线。

转发接口不会增加统一包装,HTTP 200 时 res.data 就是远端接口的原始响应。因此:

远程路径 返回模型
/api/ports PortRecord[]
/api/stat/currency/{currency} ChartPoint[]
/api/device/stats DevicePoint[]
/api/currency/online/stat/{coin} CoinDevicePoint[]
/api/sys/stat SystemPoint[]
/api/sys/base/info 系统信息对象
/api/local/version { version: string }
/api/sys/starttime number 时间戳。

{p} 应只由预先允许的路径生成。Base64 只是路径编码,不是权限控制。

安全建议

  • 群控 API 与通用 X-ACCESS-TOKEN 用途不同,应分别保存和轮换。
  • 刷新群控 API 后,立即更新所有上级管理实例。
  • 对远程 endpoint 使用 HTTPS,并限制来源 IP。
  • 禁止让不可信用户控制 {p},否则可能扩大可转发接口范围。
  • 日志中应隐藏客户端 token 和完整转发路径参数。