rtty: Add package

A reverse proxy WebTTY. It is composed of the client and the server.

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao
2018-01-18 18:07:14 +08:00
committed by Yousong Zhou
parent 4d5c752f45
commit 8a7797d67a
4 changed files with 245 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
# You must specify an interface or id,
# If the id is not specified, RTTY will uses the MAC address
# of the interface you specify as its ID, otherwise the id
# you specify is used as its ID
#config rtty
# option interface 'lan'
# option id 'My-Device'
# option description 'Description of my device'
# option host 'your-server-host' # Server host
# option port '5912' # Server Port
# option ssl 1 # Whether to use ssl
+58
View File
@@ -0,0 +1,58 @@
#!/bin/sh /etc/rc.common
. /lib/functions/network.sh
USE_PROCD=1
START=99
BIN=/usr/sbin/rtty
start_rtty() {
local cfg="$1"
local interface ifname id description host port ssl
uci_validate_section rtty rtty "${1}" \
'interface:uci("network", "@interface"):lan' \
'id:maxlength(63)' \
'description:maxlength(126)' \
'host:host' \
'port:port' \
'ssl:bool:0'
[ $? -eq 1 ] && {
echo "validation failed" >&2
return 1
}
[ -n "$interface" ] && network_get_device ifname "$interface"
[ -z "$ifname" -a -z "$id" ] && {
echo "You must specify an interface or ID" >&2
return 1
}
[ -z "$host" ] && {
echo "host required" >&2
return 1
}
[ -z "$port" ] && {
echo "port required" >&2
return 1
}
procd_open_instance
procd_set_param command $BIN -h $host -p $port -a
[ -n "$ifname" ] && procd_append_param command -i "$ifname"
[ -n "$id" ] && procd_append_param command -I "$id"
[ -n "$description" ] && procd_append_param command -d "$description"
[ "$ssl" = "1" ] && procd_append_param command -s
procd_set_param respawn
procd_close_instance
}
start_service() {
config_load rtty
config_foreach start_rtty rtty
}