云控 (RWMC) API
接口地址:
/rwmc.php请求方式:
POSTContent-Type:application/x-www-form-urlencoded(push除外,用 JSON)页面入口:
/cloud-control(别名/rwmc_oauth)
模式
云控设备首次激活后会拿到一个设备码(如 dev_001)。用户在控制台把设备码提交给 accept 完成绑定,之后即可远程下发命令、读取日志、配置开机自启。
API 列表
| 序号 | 接口 | type 值 | 请求格式 | 需要 CSRF |
|---|---|---|---|---|
| 1 | 列出设备 | list | form | 是 |
| 2 | 接受设备 | accept | form | 是 |
| 3 | 推送命令 | push | JSON | 是 |
| 4 | 获取日志 | getresp | form | 是 |
| 5 | 获取指定日志 | getrespid | form | 是 |
| 6 | 设置自启 | autorun | form | 是 |
| 7 | 获取设备状态 | status | form | 是 |
| 8 | 解绑设备 | unbind | form | 是 |
| 9 | 触发自启 | devautorun | form | 否 |
1. 列出设备 type=list
bash
curl -X POST https://api.hayfrp.1zyq1.com/rwmc.php \
-H "waf: off" \
-d "type=list&csrf=Token值"设备对象字段:
| 字段 | 说明 |
|---|---|
device | 设备码 |
hostname | 主机名 |
system | 操作系统 |
cpusage / ramusage / diskusage | CPU / 内存 / 磁盘占用 |
status | 在线状态:online / offline |
action | 当前动作,free 表示空闲 |
autorun | 自动命令内容 |
2. 接受设备 type=accept
bash
curl -X POST https://api.hayfrp.1zyq1.com/rwmc.php \
-H "waf: off" \
-d "type=accept&csrf=Token值&device=dev_001"从授权链接(
/rwmc_oauth别名)进入时,前端会先弹窗询问「是否绑定设备码 xxx」,确认后才调用该接口。
3. 推送命令 type=push
只有这个接口用 JSON
push 使用 application/json,其余 rwmc.php 接口都是表单格式。
| 参数 | 必填 | 说明 |
|---|---|---|
csrf | 是 | CSRF Token |
device | 是 | 设备码 |
action | 是 | 动作类型,runcmd 表示执行命令;也可传自定义动作名 |
cmd | 否 | 具体命令内容,action=runcmd 时必填 |
json
{
"type": "push",
"csrf": "Token值",
"device": "dev_001",
"action": "runcmd",
"cmd": "ipconfig /all"
}前端在 CloudControl.vue 中:
- 动作下拉:
runcmd(执行命令)/custom(自定义动作名) - 「快捷截屏」按钮下发截图类动作
- 提交前做危险命令拦截(命中则提示「命令包含危险内容,已拦截」)
4. 获取日志 type=getresp
bash
curl -X POST https://api.hayfrp.1zyq1.com/rwmc.php \
-H "waf: off" \
-d "type=getresp&csrf=Token值&device=dev_001"返回日志列表;status: 204 表示暂无日志。图片类日志会在前端以缩略图展示,点击查看详情。
5. 获取指定日志 type=getrespid
bash
curl -X POST https://api.hayfrp.1zyq1.com/rwmc.php \
-H "waf: off" \
-d "type=getrespid&csrf=Token值&device=dev_001&id=日志ID"6. 设置自启 type=autorun
bash
curl -X POST https://api.hayfrp.1zyq1.com/rwmc.php \
-H "waf: off" \
-d "type=autorun&csrf=Token值&device=dev_001&autorun=ipconfig"autorun为「设备上线后自动执行的命令」- 前端会把最近保存的自动命令缓存在
localStorage的cloud-control-autorun-cache(后端未返回autorun时用于回填输入框)
7. 获取设备状态 type=status
bash
curl -X POST https://api.hayfrp.1zyq1.com/rwmc.php \
-H "waf: off" \
-d "type=status&csrf=Token值&device=dev_001"返回 { status, message, action, cmd },用于展示设备当前正在执行 / 待执行的命令。
8. 解绑设备 type=unbind
bash
curl -X POST https://api.hayfrp.1zyq1.com/rwmc.php \
-H "waf: off" \
-d "type=unbind&csrf=Token值&device=dev_001"9. 触发自启 type=devautorun
无需 CSRF
该接口不需要 CSRF Token,仅凭设备码触发。
bash
curl -X POST https://api.hayfrp.1zyq1.com/rwmc.php \
-H "waf: off" \
-d "type=devautorun&device=dev_001"前端封装
typescript
const devices = await api.listCloudDevices(csrf)
await api.acceptCloudDevice(csrf, device)
await api.pushCloudCommand(csrf, device, action, cmd)
const logs = await api.getCloudLogs(csrf, device)
const log = await api.getCloudLogById(csrf, device, id)
await api.setCloudAutorun(csrf, device, 'true')
const status = await api.getCloudDeviceStatus(csrf, device)
await api.unbindCloudDevice(csrf, device)
await api.triggerCloudAutorun(device)页面能力对照
| 页面能力 | 使用接口 |
|---|---|
| 设备列表 / 排序(在线优先) | list |
| 绑定设备 / 从授权链接进入 | accept(list 校验) |
| 下发命令 / 快捷截屏 / 自定义动作 | push |
| 执行日志列表 / 日志详情 | getresp / getrespid |
| 自动命令保存 / 立即触发 | autorun / devautorun |
| 设备详情与当前命令 | status(定时刷新) |
| 解绑 | unbind |