mirror of
https://github.com/zhaojh329/rtty.git
synced 2026-02-27 09:53:17 +08:00
76
COMMAND.md
76
COMMAND.md
@@ -1,76 +0,0 @@
|
||||
# Instructions
|
||||
API Path
|
||||
|
||||
/cmd/:devid?wait=10
|
||||
|
||||
The wait parameter is optional and defaults to 30s, or 0 if you do not care about the execution of the command
|
||||
|
||||
Request message format
|
||||
|
||||
{
|
||||
"username": "test",
|
||||
"password": "test",
|
||||
"cmd": "echo",
|
||||
"params": ["hello rtty"]
|
||||
}
|
||||
|
||||
The username, cmd in the message must be provided. The password, params are optional. The params is a JSON array.
|
||||
|
||||
If the command is executed finish, the server will return the command execution result in json format.
|
||||
|
||||
{
|
||||
"code": 0,
|
||||
"stdout": "aGVsbG8gcnR0eQo=",
|
||||
"stderr": ""
|
||||
}
|
||||
|
||||
The stdout and stderr in the response are base64 encoded.
|
||||
|
||||
If any of the steps fail, the server will return an error message in json format.
|
||||
|
||||
{
|
||||
"err": 1002,
|
||||
"msg": "device offline"
|
||||
}
|
||||
|
||||
|
||||
All error codes are as follows
|
||||
|
||||
1001 invalid format
|
||||
1002 device offline
|
||||
1003 timeout
|
||||
1 operation not permitted
|
||||
2 not found
|
||||
3 no mem
|
||||
4 sys error
|
||||
5 stdout+stderr is too big
|
||||
|
||||
# Example
|
||||
## [Shell](/tools/sendcmd.sh)
|
||||
|
||||
## Jquery
|
||||
|
||||
```javascript
|
||||
var data = {username: 'test', password: 'test', cmd: 'echo', params: ['hello rtty']};
|
||||
$.post('http://your-server:5913/cmd/test', JSON.stringify(data), function(r) {
|
||||
if (r.stdout) {
|
||||
console.log(window.atob(r.stdout))
|
||||
} else {
|
||||
console.log(r)
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Axios
|
||||
|
||||
```javascript
|
||||
var data = {username: 'test', password: 'test', cmd: 'echo', params: ['hello rtty']};
|
||||
axios.post('http://your-server:5913/cmd/test', data).then(function(r) {
|
||||
var resp = r.data;
|
||||
if (resp.stdout) {
|
||||
console.log(window.atob(resp.stdout))
|
||||
} else {
|
||||
console.log(resp)
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -1,76 +0,0 @@
|
||||
# 说明
|
||||
API 路径
|
||||
|
||||
/cmd/:devid?wait=10
|
||||
|
||||
wait 参数为可选,默认等待 30s,如果不关心命令执行结果,可设置为 0
|
||||
|
||||
请求消息格式
|
||||
|
||||
{
|
||||
"username": "test",
|
||||
"password": "test",
|
||||
"cmd": "echo",
|
||||
"params": ["hello rtty"]
|
||||
}
|
||||
|
||||
其中 username、cmd 必须提供。password、params 为可选项。params 为一个 JSON 数组。
|
||||
|
||||
如果命令执行完成,服务器将返回 json 格式的命令执行结果:
|
||||
|
||||
{
|
||||
"code": 0,
|
||||
"stdout": "aGVsbG8gcnR0eQo=",
|
||||
"stderr": ""
|
||||
}
|
||||
|
||||
响应中的 stdout 和 stderr 是经过 base64 编码的。
|
||||
|
||||
如果任何一步操作失败,服务器都将返回 json 格式的错误信息:
|
||||
|
||||
{
|
||||
"err": 1002,
|
||||
"msg": "device offline"
|
||||
}
|
||||
|
||||
|
||||
所有错误码如下
|
||||
|
||||
1001 invalid format
|
||||
1002 device offline
|
||||
1003 timeout
|
||||
1 operation not permitted
|
||||
2 not found
|
||||
3 no mem
|
||||
4 sys error
|
||||
5 stdout+stderr is too big
|
||||
|
||||
# Example
|
||||
## [Shell](/tools/sendcmd.sh)
|
||||
|
||||
## Jquery
|
||||
|
||||
```javascript
|
||||
var data = {username: 'test', password: 'test', cmd: 'echo', params: ['hello rtty']};
|
||||
$.post('http://your-server:5913/cmd/test', JSON.stringify(data), function(r) {
|
||||
if (r.stdout) {
|
||||
console.log(window.atob(r.stdout))
|
||||
} else {
|
||||
console.log(r)
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Axios
|
||||
|
||||
```javascript
|
||||
var data = {username: 'test', password: 'test', cmd: 'echo', params: ['hello rtty']};
|
||||
axios.post('http://your-server:5913/cmd/test', data).then(function(r) {
|
||||
var resp = r.data;
|
||||
if (resp.stdout) {
|
||||
console.log(window.atob(resp.stdout))
|
||||
} else {
|
||||
console.log(resp)
|
||||
}
|
||||
});
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
# Build libev
|
||||
|
||||
git clone https://github.com/enki/libev.git
|
||||
cd libev
|
||||
./configure --host=arm-linux-gnueabi
|
||||
DESTDIR=/tmp/rtty_install make install
|
||||
|
||||
# Build rtty
|
||||
|
||||
git clone --recursive https://github.com/zhaojh329/rtty.git
|
||||
cd rtty
|
||||
cmake . -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_FIND_ROOT_PATH=/tmp/rtty_install
|
||||
DESTDIR=/tmp/rtty_install make install
|
||||
|
||||
# Copy these files to your device's corresponding directory
|
||||
|
||||
/tmp/rtty_install/
|
||||
└── usr
|
||||
└── local
|
||||
├── bin
|
||||
│ └── rtty
|
||||
└── lib
|
||||
├── libev.so -> libev.so.4.0.0
|
||||
├── libev.so.4 -> libev.so.4.0.0
|
||||
├── libev.so.4.0.0
|
||||
53
OPENWRT.md
53
OPENWRT.md
@@ -1,53 +0,0 @@
|
||||
# Install directly in the device
|
||||
|
||||
opkg update
|
||||
opkg list | grep rtty
|
||||
opkg install rtty-nossl
|
||||
|
||||
# Compile it yourself
|
||||
## Update feed
|
||||
|
||||
./scripts/feeds update packages
|
||||
./scripts/feeds install -a -p packages
|
||||
|
||||
***If the rtty is not the latest version in your openwrt, you can get the latest package from here***
|
||||
|
||||
https://github.com/zhaojh329/rtty/tree/openwrt-package
|
||||
|
||||
## Select rtty in menuconfig and compile new image
|
||||
|
||||
Utilities --->
|
||||
Terminal --->
|
||||
<*> rtty-mbedtls................. Access your terminals from anywhere via the web
|
||||
< > rtty-nossl................... Access your terminals from anywhere via the web
|
||||
< > rtty-openssl................. Access your terminals from anywhere via the web
|
||||
< > rtty-wolfssl................. Access your terminals from anywhere via the web
|
||||
|
||||
# Configure
|
||||
Configuring the server parameter
|
||||
|
||||
uci add rtty rtty # If it is configured for the first time
|
||||
uci set rtty.@rtty[0].host='your server host'
|
||||
uci set rtty.@rtty[0].port='your server port'
|
||||
|
||||
You can customize an ID for your device. If the ID is not configured, rtty will use
|
||||
the MAC address of the specified network interface as the ID.
|
||||
|
||||
uci set rtty.@rtty[0].id='your-device-id'
|
||||
|
||||
You can add a description to your device
|
||||
|
||||
uci set rtty.@rtty[0].description='My device'
|
||||
|
||||
Use SSL
|
||||
|
||||
uci set rtty.@rtty[0].ssl='1'
|
||||
|
||||
Authorization
|
||||
|
||||
uci set rtty.@rtty[0].token='your-token'
|
||||
|
||||
Save configuration and apply
|
||||
|
||||
uci commit
|
||||
/etc/init.d/rtty start
|
||||
@@ -1,52 +0,0 @@
|
||||
# 直接在设备里面安装
|
||||
|
||||
opkg update
|
||||
opkg list | grep rtty
|
||||
opkg install rtty-nossl
|
||||
|
||||
# 自己编译
|
||||
## 更新feed
|
||||
|
||||
./scripts/feeds update packages
|
||||
./scripts/feeds install -a -p packages
|
||||
|
||||
***如果您的openwrt中的rtty不是最新版本,您可以从这里获取最新的package***
|
||||
|
||||
https://gitee.com/zhaojh329/rtty/tree/openwrt-package
|
||||
|
||||
## 在menuconfig中选择rtty,然后重新编译固件。
|
||||
|
||||
Utilities --->
|
||||
Terminal --->
|
||||
<*> rtty-mbedtls................. Access your terminals from anywhere via the web
|
||||
< > rtty-nossl................... Access your terminals from anywhere via the web
|
||||
< > rtty-openssl................. Access your terminals from anywhere via the web
|
||||
< > rtty-wolfssl................. Access your terminals from anywhere via the web
|
||||
|
||||
# 配置
|
||||
配置服务器参数
|
||||
|
||||
uci add rtty rtty # 如果是第一次配置
|
||||
uci set rtty.@rtty[0].host='your server host'
|
||||
uci set rtty.@rtty[0].port='your server port'
|
||||
|
||||
你可以给你的设备自定义一个ID。如果未指定,RTTY将使用指定的网络接口的MAC地址作为其ID
|
||||
|
||||
uci set rtty.@rtty[0].id='your-device-id'
|
||||
|
||||
给你的设备添加一个描述
|
||||
|
||||
uci set rtty.@rtty[0].description='My device'
|
||||
|
||||
使用SSL
|
||||
|
||||
uci set rtty.@rtty[0].ssl='1'
|
||||
|
||||
认证
|
||||
|
||||
uci set rtty.@rtty[0].token='your-token'
|
||||
|
||||
保存配置并应用
|
||||
|
||||
uci commit
|
||||
/etc/init.d/rtty restart
|
||||
86
README.md
86
README.md
@@ -79,92 +79,6 @@ the world.
|
||||
* [libev] - A full-featured and high-performance event loop
|
||||
* [mbedtls(polarssl)] or [CyaSSl(wolfssl)] or [openssl] - If you want to support SSL
|
||||
|
||||
## [Deploying the server side](https://github.com/zhaojh329/rttys)
|
||||
|
||||
## How to install rtty
|
||||
### For Linux distribution
|
||||
|
||||
Install Dependencies
|
||||
|
||||
sudo apt install -y libev-dev libssl-dev # Ubuntu, Debian
|
||||
sudo pacman -S --noconfirm libev openssl # ArchLinux
|
||||
sudo yum install -y libev-devel openssl-devel # Centos
|
||||
|
||||
Clone the code of rtty
|
||||
|
||||
git clone --recursive https://github.com/zhaojh329/rtty.git
|
||||
|
||||
Build
|
||||
|
||||
cd rtty && mkdir build && cd build
|
||||
cmake .. && make install
|
||||
|
||||
### For Buildroot
|
||||
Select rtty in menuconfig and compile it
|
||||
|
||||
Target packages --->
|
||||
Shell and utilities --->
|
||||
[*] rtty
|
||||
|
||||
### [For OpenWRT](/OPENWRT.md)
|
||||
|
||||
### [For Other Embedded Linux Platform](/CROSS_COMPILE.md)
|
||||
|
||||
## Command-line Options
|
||||
|
||||
Usage: rtty [option]
|
||||
-I, --id=string Set an ID for the device(Maximum 63 bytes, valid
|
||||
character:letter, number, underline and short line)
|
||||
-h, --host=string Server's host or ipaddr(Default is localhost)
|
||||
-p, --port=number Server port(Default is 5912)
|
||||
-d, --description=string Add a description to the device(Maximum 126 bytes)
|
||||
-a Auto reconnect to the server
|
||||
-i number Set heartbeat interval in seconds(Default is 5s)
|
||||
-s SSL on
|
||||
-C, --cacert CA certificate to verify peer against
|
||||
-x, --insecure Allow insecure server connections when using SSL
|
||||
-c, --cert Certificate file to use"
|
||||
-k, --key Private key file to use"
|
||||
-D Run in the background
|
||||
-t, --token=string Authorization token
|
||||
-f username Skip a second login authentication. See man login(1) about the details
|
||||
-R Receive file
|
||||
-S file Send file
|
||||
-v, --verbose verbose
|
||||
-V, --version Show version
|
||||
--help Show usage
|
||||
|
||||
## How to run rtty
|
||||
Replace the following parameters with your own parameters
|
||||
|
||||
sudo rtty -I 'My-device-ID' -h 'your-server' -p 5912 -a -v -d 'My Device Description'
|
||||
|
||||
If your [rttys](https://github.com/zhaojh329/rttys) is configured with mTLS enabled (device key and certificate required),
|
||||
add the following parameters(Replace the following with valid paths to your own)
|
||||
|
||||
-k /etc/ssl/private/abc.pem -c /etc/ssl/certs/abc.pem
|
||||
|
||||
You can generate them e.g. via openssl tool
|
||||
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:secp521r1 -keyout /tmp/key.pem -out /tmp/cert.pem -days 18262 -nodes -subj "/C=CZ/O=Acme Inc./OU=ACME/CN=ACME-DEV-123"
|
||||
|
||||
If your rttys is configured with a token, add the following parameter(Replace the following token with your own)
|
||||
|
||||
-t 34762d07637276694b938d23f10d7164
|
||||
|
||||
## Usage
|
||||
Use your web browser to access your server: `http://your-server-host:5913`, then click the connection button
|
||||
|
||||
### Transfer file
|
||||
Transfer file from local to remote device
|
||||
|
||||
rtty -R
|
||||
|
||||
Transfer file from remote device to the local
|
||||
|
||||
rtty -S test.txt
|
||||
|
||||
### [Execute command remotely](/COMMAND.md)
|
||||
|
||||
## Star History
|
||||
[](https://www.star-history.com/#zhaojh329/rtty&Date)
|
||||
|
||||
|
||||
77
README_ZH.md
77
README_ZH.md
@@ -78,83 +78,6 @@ rtty非常适合远程维护您的或者您的公司的部署在全球各地的
|
||||
* [libev] - 高性能的事件循环库
|
||||
* [mbedtls(polarssl)]、[CyaSSl(wolfssl)]或者[openssl] - 如果您需要支持SSL
|
||||
|
||||
## [部署服务端](https://github.com/zhaojh329/rttys/blob/master/README_ZH.md)
|
||||
|
||||
## 如何安装rtty
|
||||
### 针对Linux发行版
|
||||
安装依赖
|
||||
|
||||
sudo apt install -y libev-dev libssl-dev # Ubuntu, Debian
|
||||
sudo pacman -S --noconfirm libev openssl # ArchLinux
|
||||
sudo yum install -y libev-devel openssl-devel # Centos
|
||||
|
||||
克隆rtty代码
|
||||
|
||||
git clone --recursive https://github.com/zhaojh329/rtty.git
|
||||
|
||||
编译
|
||||
|
||||
cd rtty && mkdir build && cd build
|
||||
cmake .. && make install
|
||||
|
||||
### 如何在Buildroot中使用
|
||||
在menuconfig中选中rtty然后编译
|
||||
|
||||
Target packages --->
|
||||
Shell and utilities --->
|
||||
[*] rtty
|
||||
|
||||
### [如何在OpenWRT中使用](/OPENWRT_ZH.md)
|
||||
|
||||
### [其它嵌入式Linux平台](/CROSS_COMPILE.md)
|
||||
|
||||
## 命令行选项
|
||||
|
||||
Usage: rtty [option]
|
||||
-I, --id=string Set an ID for the device(Maximum 63 bytes, valid
|
||||
character:letter, number, underline and short line)
|
||||
-h, --host=string Server's host or ipaddr(Default is localhost)
|
||||
-p, --port=number Server port(Default is 5912)
|
||||
-d, --description=string Add a description to the device(Maximum 126 bytes)
|
||||
-a Auto reconnect to the server
|
||||
-i number Set heartbeat interval in seconds(Default is 5s)
|
||||
-s SSL on
|
||||
-C, --cacert CA certificate to verify peer against
|
||||
-x, --insecure Allow insecure server connections when using SSL
|
||||
-c, --cert Certificate file to use"
|
||||
-k, --key Private key file to use"
|
||||
-D Run in the background
|
||||
-t, --token=string Authorization token
|
||||
-f username Skip a second login authentication. See man login(1) about the details
|
||||
-R Receive file
|
||||
-S file Send file
|
||||
-v, --verbose verbose
|
||||
-V, --version Show version
|
||||
--help Show usage
|
||||
|
||||
## 运行rtty
|
||||
将下面的参数替换为您自己的参数
|
||||
|
||||
sudo rtty -I 'My-device-ID' -h 'your-server' -p 5912 -a -v -d 'My Device Description'
|
||||
|
||||
如果您的 [rttys](https://gitee.com/zhaojh329/rttys) 配置了一个 token,请加上如下参数(将下面的 token 替换为您自己生成的)
|
||||
|
||||
-t 34762d07637276694b938d23f10d7164
|
||||
|
||||
## 如何使用
|
||||
使用您的 Web 浏览器访问您的服务器: `http://your-server-host:5913`,然后点击连接按钮。
|
||||
|
||||
### 传输文件
|
||||
从本地传输文件到远程设备
|
||||
|
||||
rtty -R
|
||||
|
||||
从远程设备传输文件到本地
|
||||
|
||||
rtty -S test.txt
|
||||
|
||||
### [远程执行命令](/COMMAND_ZH.md)
|
||||
|
||||
## Star History
|
||||
[](https://www.star-history.com/#zhaojh329/rtty&Date)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user