File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed
Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change 1- # MQTT-SHELL
1+ # MQTT-EXEC
22本项目解决的问题:在浏览器里远程执行 Shell 命令,并查看执行结果。
33
4- 相比于VPN,该项目代码可集成到其他 MQTT 客户端逻辑上 ,本项目的价值在于参考实现。
4+ 相比于VPN,该项目代码可集成到只有 MQTT 交互的设备上 ,本项目的价值在于参考实现。
55
66## 实现原理
77
8- 在宿主上运行 ` mshell ` 命令行可执行程序,通过 MQTT 连接 MQTT Server,并订阅 command 主题消息。
9-
8+ 在宿主上运行 ` mproxy ` 命令行可执行程序,通过 MQTT 连接 MQTT Server,并订阅 command 主题消息。
9+
1010浏览器通过 MQTT Websocket 连接 MQTT,获取订阅消息并展示。
1111
1212
13+ ### 协议交互
14+ 交互协议走 json 字符串。
15+ ``` json5
16+ # Web websocket- mqtt send
17+ # publish topic: $clientId/ cmd
18+ {
19+ cmd: " ls" ,
20+ requestId: " random_to_track" ,
21+ #stream: false , # can be empty, default is false . this project now only support false .
22+ }
23+
24+ # mproxy response
25+ # publish topic: $client/ cmd/ resp
26+ {
27+ data: " abc.txt/nccn.txt" ,
28+ requestId: " random_to_track" ,
29+ pid: 39512 , #process id
30+ seq: 1 #some may resp more than one time, so set seq to keep order.
31+ }
32+ ```
33+
1334### 应用场景举例
14351 . 执行 ` sshx ` , 暴露 shell 给远端。
15362 . 执行 ` free -h ` , 查看当前服务状况。
You can’t perform that action at this time.
0 commit comments