diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b61f2a8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea
+*.tar.gz
diff --git a/Changelog.txt b/Changelog.txt
new file mode 100644
index 0000000..008a5c3
--- /dev/null
+++ b/Changelog.txt
@@ -0,0 +1,10 @@
+KoolCenter RustDesk Server Changelog
+===========================================
+
+1.0
+ - add rustdesk_server二进v1.1.7版本(armv7版本,采用upx --lzma --best压缩)
+ - add 使用perp实时启动进程并守护
+ - add 新增了帮助界面,鼠标移动到左侧栏文字即可见
+ - add 可设置强制使用加密方式
+ - add 可配置hbbs服务器端口
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9cad1a6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,54 @@
+# RustDesk 远程控制
+
+## 是什么?
+`RustDesk是一款优秀的免费开源的远程控制软件,适合所有人的虚拟/远程桌面基础设施! 开源 TeamViewer / Citrix 替代品。`
+
+
+## 项目地址
+https://github.com/rustdesk/rustdesk
+
+## 官方信息
+
+官网地址:https://rustdesk.com/
+
+官方Github:https://github.com/rustdesk/rustdesk
+
+官网文档 https://rustdesk.com/docs/zh-cn/
+
+---
+
+## 机型支持
+
+在asuswrt为基础的固件上,Rustdesk Server插件目前仅支持如下架构的路由器:
+
+- 部分及其未列出,请根据CPU型号和支持软件中心与否自行判断
+- 使用Rustdesk Server建议配置1G及以上的虚拟内存,特别是小内存的路由器
+
+| 机型 | 内存 | CPU/SOC | 架构 | 核心 | 频率 | 支持alist插件 |
+| ---------------- | ----- | ------- | ----- | ---- | ------- | ------------- |
+| RT-AC86U | 512MB | BCM4906 | armv8 | 2 | 1.8 GHz | ✔️ |
+| GT-AC2900 | 512MB | BCM4906 | armv8 | 2 | 1.8 GHz | ✔️ |
+| RT-AX92U | 512MB | BCM4906 | armv8 | 2 | 1.8 GHz | ✔️ |
+| GT-AC5300 | 1GB | BCM4908 | armv8 | 4 | 1.8 GHz | ✔️ |
+| RT-AX88U | 1GB | BCM4908 | armv8 | 4 | 1.8 GHz | ✔️ |
+| GT-AX11000 | 1GB | BCM4908 | armv8 | 4 | 1.8 GHz | ✔️ |
+| NetGear RAX80 | 1GB | BCM4908 | armv8 | 4 | 1.8 GHz | ✔️ |
+| RT-AX68U | 512MB | BCM4906 | armv8 | 2 | 1.8 GHz | ✔️ |
+| RT-AX86U | 1GB | BCM4908 | armv8 | 4 | 1.8 GHz | ✔️ |
+| GT-AXE11000 | 1GB | BCM4908 | armv8 | 4 | 1.8 GHz | ✔️ |
+| ZenWiFi_Pro_XT12 | 1GB | BCM4912 | armv8 | 4 | 2.0GHz | ✔️ |
+| GT-AX6000 | 1GB | BCM4912 | armv8 | 4 | 2.0GHz | ✔️ |
+| GT-AX11000_PRO | 1GB | BCM4912 | armv8 | 4 | 2.0GHz | ✔️ |
+| RT-AX86U_PRO | 1GB | BCM4912 | armv8 | 4 | 2.0GHz | ✔️ |
+| RAX50 | 512MB | BCM6750 | armv7 | 3 | 1.5 GHz | ✔️ |
+| RAX70 | 512MB | BCM6755 | armv7 | 4 | 1.5 GHz | ✔️ |
+| RT-AX56U | 512MB | BCM6755 | armv7 | 4 | 1.5 GHz | ✔️ |
+| RT-AX56U_V2 | 256MB | BCM6755 | armv7 | 4 | 1.5 GHz | ✔️ |
+| RT-AX58U | 512MB | BCM6750 | armv7 | 3 | 1.5 GHz | ✔️ |
+| RT-AX82U | 512MB | BCM6750 | armv7 | 3 | 1.5 GHz | ✔️ |
+| TUF-AX3000 | 512MB | BCM6750 | armv7 | 3 | 1.5 GHz | ✔️ |
+| TUF-AX5400 | 512MB | BCM6750 | armv7 | 3 | 1.5 GHz | ✔️ |
+| ZenWiFi_XT8 | 512MB | BCM6755 | armv7 | 4 | 1.5 GHz | ✔️ |
+| ZenWiFi_XD4 | 256MB | BCM6755 | armv7 | 4 | 1.5 GHz | ✔️ |
+| TUF-AX3000_V2 | 512MB | BCM6756 | armv7 | 4 | 1.7GHz | ✔️ |
+| RT-AX57 | 256MB | BCM6756 | armv7 | 4 | 1.7GHz | ✔️ |
diff --git a/build.py b/build.py
new file mode 100644
index 0000000..8e024fa
--- /dev/null
+++ b/build.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# _*_ coding:utf-8 _*_
+
+import os
+import json
+import codecs
+import hashlib
+from string import Template
+
+parent_path = os.path.dirname(os.path.realpath(__file__))
+
+def md5sum(full_path):
+ with open(full_path, 'rb') as rf:
+ return hashlib.md5(rf.read()).hexdigest()
+
+def get_or_create():
+ conf_path = os.path.join(parent_path, "config.json.js")
+ conf = {}
+ if not os.path.isfile(conf_path):
+ print u"config.json.js not found,build.py is root path. auto write config.json.js"
+ module_name = os.path.basename(parent_path)
+ conf["module"] = module_name
+ conf["version"] = "0.0.1"
+ conf["home_url"] = ("Module_%s.asp" % module_name)
+ conf["title"] = "title of " + module_name
+ conf["description"] = "description of " + module_name
+ else:
+ with codecs.open(conf_path, "r", "utf-8") as fc:
+ conf = json.loads(fc.read())
+ return conf
+
+def build_module():
+ try:
+ conf = get_or_create()
+ except:
+ print u"config.json.js file format is incorrect"
+ traceback.print_exc()
+ if "module" not in conf:
+ print u" module is not in config.json.js"
+ return
+ module_path = os.path.join(parent_path, conf["module"])
+ if not os.path.isdir(module_path):
+ print u"not found %s dir,check config.json.js is module ?" % module_path
+ return
+ install_path = os.path.join(parent_path, conf["module"], "install.sh")
+ if not os.path.isfile(install_path):
+ print u"not found %s file,check install.sh file"
+ return
+ print u"build..."
+
+ open(parent_path + "/" + conf["module"] + "/" +"version", "w").write(conf["version"])
+
+ t = Template("cd $parent_path && rm -f $module.tar.gz && tar -zcf $module.tar.gz $module")
+ os.system(t.substitute({"parent_path": parent_path, "module": conf["module"]}))
+ conf["md5"] = md5sum(os.path.join(parent_path, conf["module"] + ".tar.gz"))
+ conf_path = os.path.join(parent_path, "config.json.js")
+ with codecs.open(conf_path, "w", "utf-8") as fw:
+ json.dump(conf, fw, sort_keys = True, indent = 4, ensure_ascii=False, encoding='utf8')
+ print u"build done", conf["module"] + ".tar.gz"
+ #hook_path = os.path.join(parent_path, "backup.sh")
+ #if os.path.isfile(hook_path):
+ # os.system(hook_path)
+
+build_module()
+
diff --git a/config.json.js b/config.json.js
new file mode 100644
index 0000000..8f03057
--- /dev/null
+++ b/config.json.js
@@ -0,0 +1,11 @@
+{
+ "author": "fiswonder",
+ "description": "RustDesk是一款优秀的免费开源的远程控制软件,此插件提供RustDesk自建服务器功能。",
+ "home_url": "Module_rustdesk.asp",
+ "link": "https://github.com/everstu/Koolcenter_rustdesk",
+ "md5": "88d9bd9e93f31fe0ea4a90ee992a8d77",
+ "module": "rustdesk",
+ "tags": "穿透",
+ "title": "RustDesk Server",
+ "version": "1.0"
+}
\ No newline at end of file
diff --git a/rustdesk/.valid b/rustdesk/.valid
new file mode 100644
index 0000000..2d1662a
--- /dev/null
+++ b/rustdesk/.valid
@@ -0,0 +1,2 @@
+hnd
+mtk
\ No newline at end of file
diff --git a/rustdesk/bin/hbbr b/rustdesk/bin/hbbr
new file mode 100644
index 0000000..62c67ae
Binary files /dev/null and b/rustdesk/bin/hbbr differ
diff --git a/rustdesk/bin/hbbs b/rustdesk/bin/hbbs
new file mode 100644
index 0000000..b3e321a
Binary files /dev/null and b/rustdesk/bin/hbbs differ
diff --git a/rustdesk/bin/rustdesk-utils b/rustdesk/bin/rustdesk-utils
new file mode 100644
index 0000000..1cba72e
Binary files /dev/null and b/rustdesk/bin/rustdesk-utils differ
diff --git a/rustdesk/install.sh b/rustdesk/install.sh
new file mode 100644
index 0000000..ee01294
--- /dev/null
+++ b/rustdesk/install.sh
@@ -0,0 +1,186 @@
+#!/bin/sh
+source /koolshare/scripts/base.sh
+alias echo_date='echo 【$(TZ=UTC-8 date -R +%Y年%m月%d日\ %X)】:'
+MODEL=
+FW_TYPE_CODE=
+FW_TYPE_NAME=
+DIR=$(cd $(dirname $0); pwd)
+module=${DIR##*/}
+
+get_model(){
+ local ODMPID=$(nvram get odmpid)
+ local PRODUCTID=$(nvram get productid)
+ if [ -n "${ODMPID}" ];then
+ MODEL="${ODMPID}"
+ else
+ MODEL="${PRODUCTID}"
+ fi
+}
+
+get_fw_type() {
+ local KS_TAG=$(nvram get extendno|grep -Eo "kool.+")
+ if [ -d "/koolshare" ];then
+ if [ -n "${KS_TAG}" ];then
+ FW_TYPE_CODE="2"
+ FW_TYPE_NAME="${KS_TAG}官改固件"
+ else
+ FW_TYPE_CODE="4"
+ FW_TYPE_NAME="koolshare梅林改版固件"
+ fi
+ else
+ if [ "$(uname -o|grep Merlin)" ];then
+ FW_TYPE_CODE="3"
+ FW_TYPE_NAME="梅林原版固件"
+ else
+ FW_TYPE_CODE="1"
+ FW_TYPE_NAME="华硕官方固件"
+ fi
+ fi
+}
+
+platform_test(){
+ local LINUX_VER=$(uname -r|awk -F"." '{print $1$2}')
+ local ARCH=$(uname -m)
+ if [ -d "/koolshare" -a -f "/usr/bin/skipd" -a "${LINUX_VER}" -ge "41" ];then
+ echo_date 机型:"${MODEL} ${FW_TYPE_NAME} 符合安装要求,开始安装插件!"
+ else
+ exit_install 1
+ fi
+}
+
+set_skin(){
+ local UI_TYPE=ASUSWRT
+ local SC_SKIN=$(nvram get sc_skin)
+ local ROG_FLAG=$(grep -o "680516" /www/form_style.css|head -n1)
+ local TUF_FLAG=$(grep -o "D0982C" /www/form_style.css|head -n1)
+ if [ -n "${ROG_FLAG}" ];then
+ UI_TYPE="ROG"
+ fi
+ if [ -n "${TUF_FLAG}" ];then
+ UI_TYPE="TUF"
+ fi
+
+ if [ -z "${SC_SKIN}" -o "${SC_SKIN}" != "${UI_TYPE}" ];then
+ echo_date "安装${UI_TYPE}皮肤!"
+ nvram set sc_skin="${UI_TYPE}"
+ nvram commit
+ fi
+}
+
+exit_install(){
+ local state=$1
+ case $state in
+ 1)
+ echo_date "本插件适用于【koolshare 梅林改/官改 hnd/axhnd/axhnd.675x】固件平台!"
+ echo_date "你的固件平台不能安装!!!"
+ echo_date "本插件支持机型/平台:https://github.com/koolshare/rogsoft#rogsoft"
+ echo_date "退出安装!"
+ rm -rf /tmp/rustdesk* >/dev/null 2>&1
+ exit 1
+ ;;
+ 0|*)
+ rm -rf /tmp/rustdesk* >/dev/null 2>&1
+ exit 0
+ ;;
+ esac
+}
+
+dbus_nset(){
+ # set key when value not exist
+ local ret=$(dbus get $1)
+ if [ -z "${ret}" ];then
+ dbus set $1=$2
+ fi
+}
+
+
+install_now() {
+ # default value
+ local TITLE="RustDesk Server"
+ local DESCR="RustDesk是一款优秀的免费开源的远程控制软件,此插件提供RustDesk自建服务器功能。"
+ local PLVER=$(cat ${DIR}/version)
+
+ # 生成默认目录
+ if [ ! -d /koolshare/configs/rustdesk ];then
+ mkdir -p /koolshare/configs/rustdesk
+ fi
+
+ # stop signdog first
+ enable=$(dbus get rustdesk_enable)
+ if [ "${enable}" == "1" ];then
+ echo_date "先关闭RustDesk插件!以保证更新成功!"
+ sh /koolshare/scripts/rustdesk_config.sh stop
+ fi
+
+ # remove some files first
+ find /koolshare/init.d/ -name "*rustdesk*" | xargs rm -rf
+
+ # isntall file
+ echo_date "安装插件相关文件..."
+ cp -rf /tmp/${module}/bin/* /koolshare/bin/
+ cp -rf /tmp/${module}/res/* /koolshare/res/
+ cp -rf /tmp/${module}/scripts/* /koolshare/scripts/
+ cp -rf /tmp/${module}/webs/* /koolshare/webs/
+ cp -rf /tmp/${module}/uninstall.sh /koolshare/scripts/uninstall_${module}.sh
+ mkdir -p /koolshare/configs/rustdesk
+
+ #创建开机自启任务
+ [ ! -L "/koolshare/init.d/S99rustdesk.sh" ] && ln -sf /koolshare/scripts/rustdesk_config.sh /koolshare/init.d/S99rustdesk.sh
+ [ ! -L "/koolshare/init.d/N99rustdesk.sh" ] && ln -sf /koolshare/scripts/rustdesk_config.sh /koolshare/init.d/N99rustdesk.sh
+
+ # Permissions
+ chmod +x /koolshare/scripts/* >/dev/null 2>&1
+ chmod +x /koolshare/bin/hbbr >/dev/null 2>&1
+ chmod +x /koolshare/bin/hbbs >/dev/null 2>&1
+ chmod +x /koolshare/bin/rustdesk-utils >/dev/null 2>&1
+
+ # dbus value
+ echo_date "设置插件默认参数..."
+ dbus set ${module}_version="${PLVER}"
+ dbus set softcenter_module_${module}_version="${PLVER}"
+ dbus set softcenter_module_${module}_install="1"
+ dbus set softcenter_module_${module}_name="${module}"
+ dbus set softcenter_module_${module}_title="${TITLE}"
+ dbus set softcenter_module_${module}_description="${DESCR}"
+
+ # 获取安装包二进制
+ local rustdesk_hbbr_version=$(echo $(/koolshare/bin/hbbr --version) |awk '{print $2}');
+ local rustdesk_hbbs_version=$(echo $(/koolshare/bin/hbbs --version) |awk '{print $2}');
+
+ # 检查插件默认dbus值
+ dbus_nset rustdesk_hbbs_port "21116"
+ dbus_nset rustdesk_hbbr_port "21117"
+ dbus_nset rustdesk_is_encrypted "0"
+ dbus_nset rustdesk_hbbr_version "$rustdesk_hbbr_version"
+ dbus_nset rustdesk_hbbs_version "$rustdesk_hbbs_version"
+
+ # 设置证书信息
+ /koolshare/bin/rustdesk-utils genkeypair |awk '{print $3}' > /tmp/upload/rustdesk_key_cert.tmp
+ local rustdesk_key_pub=$(cat /tmp/upload/rustdesk_key_cert.tmp |awk 'FNR == 1')
+ local rustdesk_key_priv=$(cat /tmp/upload/rustdesk_key_cert.tmp |awk 'FNR == 2')
+ # 写入证书
+ echo $rustdesk_key_pub > /koolshare/configs/rustdesk/id_ed25519.pub
+ echo $rustdesk_key_priv > /koolshare/configs/rustdesk/id_ed25519
+ # 设置证书
+ dbus_nset rustdesk_key_pub "$rustdesk_key_pub"
+ dbus_nset rustdesk_key_priv "$rustdesk_key_priv"
+
+ # reenable
+ if [ "${enable}" == "1" ];then
+ echo_date "重新启动RustDesk插件!"
+ sh /koolshare/scripts/rustdesk_config.sh boot_up
+ fi
+
+ # finish
+ echo_date "${TITLE}插件安装完毕!"
+ exit_install
+}
+
+install() {
+ get_model
+ get_fw_type
+ platform_test
+ install_now
+}
+
+install
diff --git a/rustdesk/res/icon-rustdesk.png b/rustdesk/res/icon-rustdesk.png
new file mode 100644
index 0000000..abc8560
Binary files /dev/null and b/rustdesk/res/icon-rustdesk.png differ
diff --git a/rustdesk/scripts/rustdesk_config.sh b/rustdesk/scripts/rustdesk_config.sh
new file mode 100644
index 0000000..17ea768
--- /dev/null
+++ b/rustdesk/scripts/rustdesk_config.sh
@@ -0,0 +1,298 @@
+#!/bin/sh
+
+source /koolshare/scripts/base.sh
+eval $(dbus export rustdesk_)
+alias echo_date='echo 【$(TZ=UTC-8 date -R +%Y年%m月%d日\ %X)】:'
+LOG_FILE=/tmp/upload/rustdesk_log.txt
+LOCK_FILE=/var/lock/rustdesk.lock
+rustdesk_db_flie_path=/koolshare/configs/rustdesk/
+bin_all_run="1"
+BASH=${0##*/}
+ARGS=$@
+
+set_lock() {
+ exec 233>${LOCK_FILE}
+ flock -n 233 || {
+ # bring back to original log
+ http_response "$ACTION"
+ exit 1
+ }
+}
+
+unset_lock() {
+ flock -u 233
+ rm -rf ${LOCK_FILE}
+}
+
+number_test() {
+ case $1 in
+ '' | *[!0-9]*)
+ echo 1
+ ;;
+ *)
+ echo 0
+ ;;
+ esac
+}
+
+detect_url() {
+ local fomart_1=$(echo $1 | grep -E "^https://|^http://")
+ local fomart_2=$(echo $1 | grep -E "\.")
+ if [ -n "${fomart_1}" -a -n "${fomart_2}" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+dbus_rm() {
+ # remove key when value exist
+ if [ -n "$1" ]; then
+ dbus remove $1
+ fi
+}
+
+start() {
+ # 1. stop first
+ stop_process "hbbs"
+ stop_process "hbbr"
+
+ # 2. start process
+ start_process
+
+ # 3. open port
+ close_port >/dev/null 2>&1
+ open_port
+
+ echo_date "插件已成功开启!"
+}
+
+stop_plugin(){
+ # 1. stop process
+ stop_process "hbbs"
+ stop_process "hbbr"
+ # 2.close prot
+ close_port >/dev/null 2>&1
+
+ echo_date "插件已关闭!"
+}
+
+start_process() {
+ start_hbbs
+ usleep 250000
+ start_hbbr
+ if [ -z ${bin_all_run} ];then
+ echo_date "进程启动失败,停止插件..."
+ stop_plugin
+ exit
+ fi
+}
+
+detect_running_status() {
+ local BINNAME=$1
+ local PID
+ local i=40
+ until [ -n "${PID}" ]; do
+ usleep 250000
+ i=$(($i - 1))
+ PID=$(pidof ${BINNAME})
+ if [ "$i" -lt 1 ]; then
+ echo_date "🔴$1进程启动失败,请检查你的配置!"
+ bin_all_run=""
+ return
+ fi
+ done
+ echo_date "🟢$1启动成功,pid:${PID}"
+}
+
+start_hbbs(){
+ HBBS_RUN_LOG=/tmp/upload/rustdesk_hbbs_run_log.txt
+ rm -rf ${HBBS_RUN_LOG}
+ echo_date "🟠启动 hbbs 进程,开启进程实时守护..."
+ mkdir -p /koolshare/perp/hbbs
+ cat >/koolshare/perp/hbbs/rc.main <<-EOF
+ #!/bin/sh
+ source /koolshare/scripts/base.sh
+ export ENCRYPTED_ONLY=$rustdesk_is_encrypted
+ export DB_URL=${rustdesk_db_flie_path}db_v2.sqlite3
+ export KEY=$rustdesk_key_pub
+ export KEY_PUB=$rustdesk_key_pub
+ export KEY_PRIV=$rustdesk_key_priv
+ export PORT=$rustdesk_hbbs_port
+ export RELAY_SERVERS=$rustdesk_hbbr_host
+ CMD="/koolshare/bin/hbbs"
+ if test \${1} = 'start' ; then
+ exec >${HBBS_RUN_LOG} 2>&1
+ exec \$CMD
+ fi
+ exit 0
+
+ EOF
+ chmod +x /koolshare/perp/hbbs/rc.main
+ chmod +t /koolshare/perp/hbbs/
+ sync
+ perpctl A hbbs >/dev/null 2>&1
+ perpctl u hbbs >/dev/null 2>&1
+ detect_running_status hbbs
+}
+
+start_hbbr(){
+ HBBR_RUN_LOG=/tmp/upload/rustdesk_hbbr_run_log.txt
+ rm -rf ${HBBR_RUN_LOG}
+ echo_date "🟠启动 hbbr 进程,开启进程实时守护..."
+ mkdir -p /koolshare/perp/hbbr
+ cat >/koolshare/perp/hbbr/rc.main <<-EOF
+ #!/bin/sh
+ source /koolshare/scripts/base.sh
+ export ENCRYPTED_ONLY=$rustdesk_is_encrypted
+ export KEY=$rustdesk_key_pub
+ export KEY_PUB=$rustdesk_key_pub
+ export KEY_PRIV=$rustdesk_key_priv
+ export PORT=$rustdesk_hbbs_port
+ #export LIMIT_SPEED=$rustdesk_speed_limit
+ #export SINGLE_BANDWIDTH=$rustdesk_hbbr_single_bandwidth
+ #export TOTAL_BANDWIDTH=$rustdesk_hbbr_total_bandwidth
+ CMD="/koolshare/bin/hbbr"
+ if test \${1} = 'start' ; then
+ exec >${HBBR_RUN_LOG} 2>&1
+ exec \$CMD
+ fi
+ exit 0
+
+ EOF
+ chmod +x /koolshare/perp/hbbr/rc.main
+ chmod +t /koolshare/perp/hbbr/
+ sync
+ perpctl A hbbr >/dev/null 2>&1
+ perpctl u hbbr >/dev/null 2>&1
+ detect_running_status hbbr
+}
+
+stop_process() {
+ local PROCESS_PID=$(pidof $1)
+ if [ -n "${PROCESS_PID}" ]; then
+ echo_date "⛔关闭 $1 进程..."
+ if [ -f "/koolshare/perp/$1/rc.main" ]; then
+ perpctl d $1 >/dev/null 2>&1
+ fi
+ rm -rf /koolshare/perp/$1
+ killall $1 >/dev/null 2>&1
+ kill -9 "${PROCESS_PID}" >/dev/null 2>&1
+ fi
+}
+
+open_port() {
+ local CM=$(lsmod | grep xt_comment)
+ local OS=$(uname -r)
+ if [ -z "${CM}" -a -f "/lib/modules/${OS}/kernel/net/netfilter/xt_comment.ko" ]; then
+ echo_date "ℹ️加载xt_comment.ko内核模块!"
+ insmod /lib/modules/${OS}/kernel/net/netfilter/xt_comment.ko
+ fi
+
+ if [ $(number_test ${rustdesk_hbbs_port}) != "0" ]; then
+ dbus set rustdesk_hbbs_port="21116"
+ fi
+ local HBBSMATCH=$(iptables -t filter -S INPUT | grep "rustdesk_rule")
+ if [ -z "${HBBSMATCH}" ]; then
+ local rustdesk_hbbs_port1=$(($rustdesk_hbbs_port - 1))
+ local rustdesk_hbbs_port2=$(($rustdesk_hbbs_port + 2))
+ local rustdesk_hbbr_port=$(($rustdesk_hbbs_port + 1))
+ local rustdesk_hbbr_port1=$((rustdesk_hbbr_port + 2))
+ echo_date "🧱添加防火墙入站规则,打开RustDesk 服务端口:"
+ echo_date "${rustdesk_hbbs_port1} ${rustdesk_hbbs_port1} ${rustdesk_hbbr_port} ${rustdesk_hbbs_port2} ${rustdesk_hbbr_port1}"
+ iptables -I INPUT -p tcp --dport ${rustdesk_hbbs_port1} -j ACCEPT -m comment --comment "rustdesk_rule" >/dev/null 2>&1
+ iptables -I INPUT -p tcp --dport ${rustdesk_hbbs_port} -j ACCEPT -m comment --comment "rustdesk_rule" >/dev/null 2>&1
+ iptables -I INPUT -p udp --dport ${rustdesk_hbbs_port} -j ACCEPT -m comment --comment "rustdesk_rule" >/dev/null 2>&1
+ iptables -I INPUT -p tcp --dport ${rustdesk_hbbs_port2} -j ACCEPT -m comment --comment "rustdesk_rule" >/dev/null 2>&1
+ iptables -I INPUT -p tcp --dport ${rustdesk_hbbr_port} -j ACCEPT -m comment --comment "rustdesk_rule" >/dev/null 2>&1
+ iptables -I INPUT -p tcp --dport ${rustdesk_hbbr_port1} -j ACCEPT -m comment --comment "rustdesk_rule" >/dev/null 2>&1
+ fi
+}
+
+close_port() {
+ local IPTS=$(iptables -t filter -S | grep "rustdesk_rule" | sed 's/-A/iptables -t filter -D/g')
+ if [ -n "${IPTS}" ]; then
+ echo_date "🧱关闭本插件在防火墙上打开的所有端口!"
+ iptables -t filter -S | grep "rustdesk_rule" | sed 's/-A/iptables -t filter -D/g' >/tmp/rustdesk_clean.sh
+ chmod +x /tmp/rustdesk_clean.sh
+ sh /tmp/rustdesk_clean.sh >/dev/null 2>&1
+ rm /tmp/rustdesk_clean.sh
+ fi
+}
+
+check_status(){
+ local HBBR_PID=$(pidof hbbr)
+ local HBBS_PID=$(pidof hbbs)
+ local status_text="插件未启用"
+ if [ "${rustdesk_enable}" == "1" ]; then
+ if [ -n "${HBBS_PID}" ]; then
+ status_text="hbbs 进程运行正常!(PID:${HBBS_PID})
"
+ else
+ status_text="hbbs 进程未运行!
"
+ fi
+ if [ -n "${HBBR_PID}" ]; then
+ status_text=$status_text"hbbr 进程运行正常!(PID:${HBBR_PID}) "
+ else
+ status_text=$status_text"hbbr 进程未运行!"
+ fi
+ fi
+
+ http_response $status_text
+}
+
+case $1 in
+start)
+ if [ "${rustdesk_enable}" == "1" ]; then
+ sleep 20 #延迟启动等待虚拟内存挂载
+ true >${LOG_FILE}
+ start | tee -a ${LOG_FILE}
+ echo XU6J03M16 >> ${LOG_FILE}
+ logger "[软件中心-开机自启]: RustDesk Server自启动成功!"
+ else
+ logger "[软件中心-开机自启]: RustDesk Server未开启,不自动启动!"
+ fi
+ ;;
+boot_up)
+ if [ "${rustdesk_enable}" == "1" ]; then
+ true >${LOG_FILE}
+ start | tee -a ${LOG_FILE}
+ echo XU6J03M16 >> ${LOG_FILE}
+ fi
+ ;;
+start_nat)
+ if [ "${rustdesk_enable}" == "1" ]; then
+ logger "[软件中心-NAT重启]: 打开RustDesk Server防火墙端口!"
+ sleep 10
+ close_port
+ sleep 2
+ open_port
+ fi
+ ;;
+stop)
+ stop_plugin
+ ;;
+esac
+
+case $2 in
+web_submit)
+ set_lock
+ true >${LOG_FILE}
+ http_response "$1"
+ if [ "${rustdesk_enable}" == "1" ]; then
+ echo_date "▶️开启RustDesk Server!" | tee -a ${LOG_FILE}
+ start | tee -a ${LOG_FILE}
+ elif [ "${rustdesk_enable}" == "2" ]; then
+ echo_date "🔁重启RustDesk Server!" | tee -a ${LOG_FILE}
+ dbus set rustdesk_enable=1
+ start | tee -a ${LOG_FILE}
+ else
+ echo_date "ℹ️停止RustDesk Server!" | tee -a ${LOG_FILE}
+ stop_plugin | tee -a ${LOG_FILE}
+ fi
+ echo XU6J03M16 | tee -a ${LOG_FILE}
+ unset_lock
+ ;;
+status)
+ check_status
+ ;;
+esac
\ No newline at end of file
diff --git a/rustdesk/uninstall.sh b/rustdesk/uninstall.sh
new file mode 100644
index 0000000..b2b4e58
--- /dev/null
+++ b/rustdesk/uninstall.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+alias echo_date='echo 【$(TZ=UTC-8 date -R +%Y年%m月%d日\ %X)】:'
+
+echo_date "正在删除插件资源文件..."
+sh /koolshare/scripts/rustdesk_config.sh stop
+rm -rf /koolshare/scripts/rustdesk_config.sh
+rm -rf /koolshare/webs/Module_rustdesk.asp
+rm -rf /koolshare/res/*rustdesk*
+rm -rf /koolshare/configs/rustdesk
+find /koolshare/init.d/ -name "*rustdesk*" | xargs rm -rf
+rm -rf /koolshare/bin/hbbr >/dev/null 2>&1
+rm -rf /koolshare/bin/hbbs >/dev/null 2>&1
+rm -rf /koolshare/bin/rustdesk-utils >/dev/null 2>&1
+echo_date "插件资源文件删除成功..."
+
+rm -rf /koolshare/scripts/uninstall_rustdesk.sh
+echo_date "已成功移除插件... Bye~Bye~"
\ No newline at end of file
diff --git a/rustdesk/version b/rustdesk/version
new file mode 100644
index 0000000..9f8e9b6
--- /dev/null
+++ b/rustdesk/version
@@ -0,0 +1 @@
+1.0
\ No newline at end of file
diff --git a/rustdesk/webs/Module_rustdesk.asp b/rustdesk/webs/Module_rustdesk.asp
new file mode 100644
index 0000000..baeb8e2
--- /dev/null
+++ b/rustdesk/webs/Module_rustdesk.asp
@@ -0,0 +1,632 @@
+
+
+
+
+
+
+
+
+
+软件中心 - RustDesk Server
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+ |
+
+
+
+
+
+