2.1.2 • Published 2 years ago

rsh-ws v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Remote Shell - WebSocket

rsh-ws


协议:MIT


怎么使用?

  1. 首先,全局安装此项目,运行npm i rsh-ws -g
  2. 使用rsh-ws来启动服务
  3. 服务会在终端打印连接代码,例如0O0P5D99,前4位是端口号码,后4位是连接密码,端口号码请使用36进制解析,在这个例子中,端口号码是31129
  4. 使用WebSocket连接ws://ip:31129,如果是本机,ip可以为127.9.9.9
  5. 执行命令,例如,在本例子中,连接密码是5D99,你可以发送JSON命令
{
    "do": "login",
    "passwd": "5D99"
}

来登录

  1. 创建终端
{
    "do": "createTerminal",
    "cwd": "./", //终端目录
}

返回值中有 data.pid 参数,用来标识终端 7. 发送命令

{
    "pid": "<pid>",
    "do": "write-to-terminal",
    "data": "ls"
}

这会向终端的stdin写入data 8. 返回命令结果
格式为

{
    "status": "ok",
    "data": {
        "type": "Received data",
        "data": "<data here>"
    }
}
  1. 获得rsh-ws版本
    发送命令
{
    "do": "get-version"
}

返回结果

{
    "status": "ok",
    "data": {
        "type":"version",
        "version": "<version here>"
    }
}
  1. 文件处理
    发送命令
{
    "do": "file-operation",
    "path": "<path here>"
}

将会返回

{
    "status": "ok",
    "data": {
        "port": "<port here>",
        "file_id": "<file_id here>",
        "path": "<path here>"
    }
}

文件传输使用HTTP协议
支持以下方法

  • GET http://ip:port/<file_id> 下载文件,响应数据为文件内容
  • PUT http://ip:port/<file_id> 上传文件,Body负载为文件内容
  • DELETE http://ip:port/<file_id> 删除文件

port请使用返回数据中的port

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago