Skip to content

Commit 8a7797d

Browse files
Jianhui Zhaoyousong
authored andcommitted
rtty: Add package
A reverse proxy WebTTY. It is composed of the client and the server. Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
1 parent 4d5c752 commit 8a7797d

File tree

4 files changed

+245
-0
lines changed

4 files changed

+245
-0
lines changed

libs/libuwsc/Makefile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#
2+
# Copyright (C) 2018 Jianhui Zhao
3+
#
4+
# This is free software, licensed under the GNU General Public License v2.
5+
# See /LICENSE for more information.
6+
#
7+
8+
include $(TOPDIR)/rules.mk
9+
10+
PKG_NAME:=libuwsc
11+
PKG_VERSION:=1.1.0
12+
PKG_RELEASE:=1
13+
14+
PKG_SOURCE_PROTO:=git
15+
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
16+
PKG_SOURCE_URL=https://github.com/zhaojh329/libuwsc.git
17+
PKG_MIRROR_HASH:=4aada7e2941fb9f099869c9dc10ef6411f1c355c3b2f570011b91e42feffbfdd
18+
CMAKE_INSTALL:=1
19+
20+
PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_SOURCE_SUBDIR)
21+
22+
PKG_LICENSE:=GPL-3.0
23+
PKG_LICENSE_FILES:=LICENSE
24+
25+
PKG_MAINTAINER:=Jianhui Zhao <jianhuizhao329@gmail.com>
26+
27+
include $(INCLUDE_DIR)/package.mk
28+
include $(INCLUDE_DIR)/cmake.mk
29+
30+
define Package/libuwsc/default
31+
SECTION:=libs
32+
CATEGORY:=Libraries
33+
SUBMENU:=Networking
34+
TITLE:=Lightweight WebSocket client library
35+
DEPENDS:=+libubox
36+
endef
37+
38+
define Package/libuwsc-nossl
39+
$(Package/libuwsc/default)
40+
TITLE += (NO SSL)
41+
VARIANT:=nossl
42+
endef
43+
44+
define Package/libuwsc-openssl
45+
$(Package/libuwsc/default)
46+
TITLE += (openssl)
47+
DEPENDS += +libustream-openssl
48+
VARIANT:=openssl
49+
endef
50+
51+
define Package/libuwsc-wolfssl
52+
$(Package/libuwsc/default)
53+
TITLE += (wolfssl)
54+
DEPENDS += +libustream-wolfssl
55+
VARIANT:=wolfssl
56+
endef
57+
58+
define Package/libuwsc-mbedtls
59+
$(Package/libuwsc/default)
60+
TITLE += (mbedtls)
61+
DEPENDS += +libustream-mbedtls
62+
VARIANT:=mbedtls
63+
endef
64+
65+
ifeq ($(BUILD_VARIANT),nossl)
66+
CMAKE_OPTIONS += -DUWSC_SSL_SUPPORT=off
67+
endif
68+
69+
define Package/libuwsc/default/install
70+
$(INSTALL_DIR) $(1)/usr/lib/
71+
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libuwsc.so* $(1)/usr/lib/
72+
endef
73+
74+
Package/libuwsc-nossl/install = $(Package/libuwsc/default/install)
75+
Package/libuwsc-openssl/install = $(Package/libuwsc/default/install)
76+
Package/libuwsc-wolfssl/install = $(Package/libuwsc/default/install)
77+
Package/libuwsc-mbedtls/install = $(Package/libuwsc/default/install)
78+
79+
$(eval $(call BuildPackage,libuwsc-nossl))
80+
$(eval $(call BuildPackage,libuwsc-mbedtls))
81+
$(eval $(call BuildPackage,libuwsc-wolfssl))
82+
$(eval $(call BuildPackage,libuwsc-openssl))

utils/rtty/Makefile

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#
2+
# Copyright (C) 2018 Jianhui Zhao
3+
#
4+
# This is free software, licensed under the GNU General Public License v2.
5+
# See /LICENSE for more information.
6+
#
7+
8+
include $(TOPDIR)/rules.mk
9+
10+
PKG_NAME:=rtty
11+
PKG_VERSION:=2.2.0
12+
PKG_RELEASE:=1
13+
14+
PKG_SOURCE_PROTO:=git
15+
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
16+
PKG_SOURCE_URL=https://github.com/zhaojh329/rtty.git
17+
PKG_MIRROR_HASH:=23a203351fdd47acfd16d3c3b3e3d51dd65a5d9e8ca89d4b1521d40c40616102
18+
19+
PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_SOURCE_SUBDIR)
20+
21+
PKG_LICENSE:=GPL-3.0
22+
PKG_LICENSE_FILES:=LICENSE
23+
24+
PKG_MAINTAINER:=Jianhui Zhao <jianhuizhao329@gmail.com>
25+
26+
include $(INCLUDE_DIR)/package.mk
27+
include $(INCLUDE_DIR)/cmake.mk
28+
29+
define Package/rtty/default
30+
SECTION:=utils
31+
CATEGORY:=Utilities
32+
SUBMENU:=Terminal
33+
TITLE:=A reverse proxy WebTTY
34+
DEPENDS:=+libblobmsg-json
35+
endef
36+
37+
define Package/rtty/default/description
38+
A reverse proxy WebTTY. This is the client part running on devices to be managed.
39+
endef
40+
41+
define Package/rtty-nossl
42+
$(Package/rtty/default)
43+
TITLE += (NO SSL)
44+
DEPENDS += +libuwsc-nossl
45+
VARIANT:=nossl
46+
CONFLICTS:=rtty-openssl rtty-wolfssl rtty-mbedtls
47+
endef
48+
49+
define Package/rtty-openssl
50+
$(Package/rtty/default)
51+
TITLE += (openssl)
52+
DEPENDS += +libuwsc-openssl
53+
VARIANT:=openssl
54+
CONFLICTS:=rtty-wolfssl rtty-mbedtls
55+
endef
56+
57+
define Package/rtty-wolfssl
58+
$(Package/rtty/default)
59+
TITLE += (wolfssl)
60+
DEPENDS += +libuwsc-wolfssl
61+
VARIANT:=wolfssl
62+
CONFLICTS:=rtty-mbedtls
63+
endef
64+
65+
define Package/rtty-mbedtls
66+
$(Package/rtty/default)
67+
TITLE += (mbedtls)
68+
DEPENDS += +libuwsc-mbedtls
69+
VARIANT:=mbedtls
70+
endef
71+
72+
Package/rtty-nossl/description = $(Package/rtty/default/description)
73+
Package/rtty-openssl/description = $(Package/rtty/default/description)
74+
Package/rtty-wolfssl/description = $(Package/rtty/default/description)
75+
Package/rtty-mbedtls/description = $(Package/rtty/default/description)
76+
77+
define Package/rtty/default/install
78+
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config
79+
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/rtty $(1)/usr/sbin
80+
$(INSTALL_BIN) ./files/rtty.init $(1)/etc/init.d/rtty
81+
$(INSTALL_CONF) ./files/rtty.config $(1)/etc/config/rtty
82+
endef
83+
84+
Package/rtty-nossl/install = $(Package/rtty/default/install)
85+
Package/rtty-openssl/install = $(Package/rtty/default/install)
86+
Package/rtty-wolfssl/install = $(Package/rtty/default/install)
87+
Package/rtty-mbedtls/install = $(Package/rtty/default/install)
88+
89+
$(eval $(call BuildPackage,rtty-nossl))
90+
$(eval $(call BuildPackage,rtty-mbedtls))
91+
$(eval $(call BuildPackage,rtty-wolfssl))
92+
$(eval $(call BuildPackage,rtty-openssl))
93+

utils/rtty/files/rtty.config

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# You must specify an interface or id,
2+
# If the id is not specified, RTTY will uses the MAC address
3+
# of the interface you specify as its ID, otherwise the id
4+
# you specify is used as its ID
5+
6+
#config rtty
7+
# option interface 'lan'
8+
# option id 'My-Device'
9+
# option description 'Description of my device'
10+
# option host 'your-server-host' # Server host
11+
# option port '5912' # Server Port
12+
# option ssl 1 # Whether to use ssl

utils/rtty/files/rtty.init

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh /etc/rc.common
2+
3+
. /lib/functions/network.sh
4+
5+
USE_PROCD=1
6+
START=99
7+
8+
BIN=/usr/sbin/rtty
9+
10+
start_rtty() {
11+
local cfg="$1"
12+
local interface ifname id description host port ssl
13+
14+
uci_validate_section rtty rtty "${1}" \
15+
'interface:uci("network", "@interface"):lan' \
16+
'id:maxlength(63)' \
17+
'description:maxlength(126)' \
18+
'host:host' \
19+
'port:port' \
20+
'ssl:bool:0'
21+
22+
[ $? -eq 1 ] && {
23+
echo "validation failed" >&2
24+
return 1
25+
}
26+
27+
[ -n "$interface" ] && network_get_device ifname "$interface"
28+
29+
[ -z "$ifname" -a -z "$id" ] && {
30+
echo "You must specify an interface or ID" >&2
31+
return 1
32+
}
33+
34+
[ -z "$host" ] && {
35+
echo "host required" >&2
36+
return 1
37+
}
38+
39+
[ -z "$port" ] && {
40+
echo "port required" >&2
41+
return 1
42+
}
43+
44+
procd_open_instance
45+
procd_set_param command $BIN -h $host -p $port -a
46+
[ -n "$ifname" ] && procd_append_param command -i "$ifname"
47+
[ -n "$id" ] && procd_append_param command -I "$id"
48+
[ -n "$description" ] && procd_append_param command -d "$description"
49+
[ "$ssl" = "1" ] && procd_append_param command -s
50+
procd_set_param respawn
51+
procd_close_instance
52+
}
53+
54+
start_service() {
55+
config_load rtty
56+
config_foreach start_rtty rtty
57+
}
58+

0 commit comments

Comments
 (0)