diff --git a/Changelog.txt b/Changelog.txt
index edec77d..45841a0 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,5 +1,11 @@
KoolCenter RustDesk Server Changelog
===========================================
+1.3
+ - add 新增强制使用中继服务器选项
+
+1.2
+ - fix 插件icon大小的问题
+
1.1
- fix 修复无法使用加密连接的问题
- add 重新生成加密证书功能
diff --git a/config.json.js b/config.json.js
index 5f36aec..a40e4a2 100644
--- a/config.json.js
+++ b/config.json.js
@@ -3,9 +3,9 @@
"description": "RustDesk是一款优秀的免费开源的远程控制软件,此插件提供RustDesk自建服务器功能。",
"home_url": "Module_rustdesk.asp",
"link": "https://github.com/everstu/Koolcenter_rustdesk",
- "md5": "9598e0bf7f96e918726a18bbcdfd8615",
+ "md5": "52a5fc7d286f79c3c13718e4f0e820a5",
"module": "rustdesk",
"tags": "穿透",
"title": "RustDesk Server",
- "version": "1.2"
+ "version": "1.3"
}
\ No newline at end of file
diff --git a/rustdesk/install.sh b/rustdesk/install.sh
index 9c9c6c7..a504767 100644
--- a/rustdesk/install.sh
+++ b/rustdesk/install.sh
@@ -4,13 +4,16 @@ 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)
+DIR=$(
+ cd $(dirname $0)
+ pwd
+)
module=${DIR##*/}
-get_model(){
+get_model() {
local ODMPID=$(nvram get odmpid)
local PRODUCTID=$(nvram get productid)
- if [ -n "${ODMPID}" ];then
+ if [ -n "${ODMPID}" ]; then
MODEL="${ODMPID}"
else
MODEL="${PRODUCTID}"
@@ -18,9 +21,9 @@ get_model(){
}
get_fw_type() {
- local KS_TAG=$(nvram get extendno|grep -Eo "kool.+")
- if [ -d "/koolshare" ];then
- if [ -n "${KS_TAG}" ];then
+ 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
@@ -28,7 +31,7 @@ get_fw_type() {
FW_TYPE_NAME="koolshare梅林改版固件"
fi
else
- if [ "$(uname -o|grep Merlin)" ];then
+ if [ "$(uname -o | grep Merlin)" ]; then
FW_TYPE_CODE="3"
FW_TYPE_NAME="梅林原版固件"
else
@@ -38,40 +41,40 @@ get_fw_type() {
fi
}
-platform_test(){
- local LINUX_VER=$(uname -r|awk -F"." '{print $1$2}')
+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
+ 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(){
+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)
- local TS_FLAG=$(grep -o "2ED9C3" /www/css/difference.css 2>/dev/null|head -n1)
- if [ -n "${ROG_FLAG}" ];then
+ local ROG_FLAG=$(grep -o "680516" /www/form_style.css | head -n1)
+ local TUF_FLAG=$(grep -o "D0982C" /www/form_style.css | head -n1)
+ local TS_FLAG=$(grep -o "2ED9C3" /www/css/difference.css 2>/dev/null | head -n1)
+ if [ -n "${ROG_FLAG}" ]; then
UI_TYPE="ROG"
fi
- if [ -n "${TUF_FLAG}" ];then
+ if [ -n "${TUF_FLAG}" ]; then
UI_TYPE="TUF"
fi
- if [ -n "${TS_FLAG}" ];then
+ if [ -n "${TS_FLAG}" ]; then
UI_TYPE="TS"
fi
- if [ -z "${SC_SKIN}" -o "${SC_SKIN}" != "${UI_TYPE}" ];then
+ 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(){
+exit_install() {
local state=$1
case $state in
1)
@@ -81,23 +84,22 @@ exit_install(){
echo_date "退出安装!"
rm -rf /tmp/rustdesk* >/dev/null 2>&1
exit 1
- ;;
- 0|*)
+ ;;
+ 0 | *)
rm -rf /tmp/rustdesk* >/dev/null 2>&1
exit 0
- ;;
+ ;;
esac
}
-dbus_nset(){
+dbus_nset() {
# set key when value not exist
local ret=$(dbus get $1)
- if [ -z "${ret}" ];then
+ if [ -z "${ret}" ]; then
dbus set $1=$2
fi
}
-
install_now() {
# default value
local TITLE="RustDesk Server"
@@ -105,18 +107,18 @@ install_now() {
local PLVER=$(cat ${DIR}/version)
# 生成默认目录
- if [ ! -d /koolshare/configs/rustdesk ];then
- mkdir -p /koolshare/configs/rustdesk
+ if [ ! -d /koolshare/configs/rustdesk ]; then
+ mkdir -p /koolshare/configs/rustdesk
fi
# stop signdog first
local rustEnable=$(dbus get rustdesk_enable)
- if [ "${rustEnable}" == "1" ];then
+ if [ "${rustEnable}" == "1" ]; then
echo_date "先关闭RustDesk插件!以保证更新成功!"
sh /koolshare/scripts/rustdesk_config.sh stop
dbus set rustdesk_enable=1
fi
-
+
# remove some files first
find /koolshare/init.d/ -name "*rustdesk*" | xargs rm -rf
@@ -128,7 +130,7 @@ install_now() {
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
@@ -149,8 +151,8 @@ install_now() {
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}');
+ 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"
@@ -162,21 +164,21 @@ install_now() {
# 设置证书信息
rustdesk_key_pub_tmp=$(dbus get rustdesk_key_pub)
rustdesk_key_priv_tmp=$(dbus get rustdesk_key_priv)
- /koolshare/bin/rustdesk-utils genkeypair |awk '{print $3}' > /tmp/upload/rustdesk_key_cert.tmp
- if [ -z "${rustdesk_key_pub_tmp}" -o -z "${rustdesk_key_priv_tmp}" ];then
- rustdesk_key_pub_tmp=$(cat /tmp/upload/rustdesk_key_cert.tmp |awk 'FNR == 1')
- rustdesk_key_priv_tmp=$(cat /tmp/upload/rustdesk_key_cert.tmp |awk 'FNR == 2')
+ /koolshare/bin/rustdesk-utils genkeypair | awk '{print $3}' >/tmp/upload/rustdesk_key_cert.tmp
+ if [ -z "${rustdesk_key_pub_tmp}" -o -z "${rustdesk_key_priv_tmp}" ]; then
+ rustdesk_key_pub_tmp=$(cat /tmp/upload/rustdesk_key_cert.tmp | awk 'FNR == 1')
+ rustdesk_key_priv_tmp=$(cat /tmp/upload/rustdesk_key_cert.tmp | awk 'FNR == 2')
fi
rm -f /tmp/upload/rustdesk_key_cert.tmp >/dev/null 2>&1
# 写入证书
- echo -n $rustdesk_key_pub_tmp > /koolshare/configs/rustdesk/id_ed25519.pub
- echo -n $rustdesk_key_priv_tmp > /koolshare/configs/rustdesk/id_ed25519
+ echo -n $rustdesk_key_pub_tmp >/koolshare/configs/rustdesk/id_ed25519.pub
+ echo -n $rustdesk_key_priv_tmp >/koolshare/configs/rustdesk/id_ed25519
# 设置证书
dbus set rustdesk_key_pub=$rustdesk_key_pub_tmp
dbus set rustdesk_key_priv=$rustdesk_key_priv_tmp
# reenable
- if [ "${rustEnable}" == "1" ];then
+ if [ "${rustEnable}" == "1" ]; then
echo_date "重新启动RustDesk插件!"
sh /koolshare/scripts/rustdesk_config.sh boot_up
fi
diff --git a/rustdesk/scripts/rustdesk_config.sh b/rustdesk/scripts/rustdesk_config.sh
index 209da38..87ce6c0 100644
--- a/rustdesk/scripts/rustdesk_config.sh
+++ b/rustdesk/scripts/rustdesk_config.sh
@@ -12,6 +12,7 @@ ARGS=$@
connect_key=
hbbsCMD="/koolshare/bin/hbbs"
hbbrCMD="/koolshare/bin/hbbr"
+ALWAYS_USE_RELAY="N"
set_lock() {
exec 233>${LOCK_FILE}
@@ -29,12 +30,12 @@ unset_lock() {
number_test() {
case $1 in
- '' | *[!0-9]*)
+ '' | *[!0-9]*)
echo 1
- ;;
+ ;;
*)
echo 0
- ;;
+ ;;
esac
}
@@ -60,10 +61,13 @@ start() {
configServerEnv
# 1. stop first
+ local pidHbbs=$(pidof hbbs)
stop_process
- echo_date "ℹ️即将休眠 5 秒,等待端口释放..."
- sleep 5
- echo_date "ℹ️休眠结束,开启插件..."
+ if [ "z${pidHbbs}" != "z" ]; then
+ echo_date "ℹ️插件重启,即将休眠 10 秒,等待端口释放..."
+ sleep 10
+ echo_date "ℹ️休眠结束,开启插件..."
+ fi
# 2. start process
start_process
@@ -75,7 +79,7 @@ start() {
echo_date "✅️插件已成功开启!"
}
-stop_plugin(){
+stop_plugin() {
# 1. stop process
stop_process
# 2.close prot
@@ -86,18 +90,22 @@ stop_plugin(){
echo_date "❌️插件已停止运行!"
}
-configServerEnv(){
- if [ "$rustdesk_is_encrypted" == "1" ];then
+configServerEnv() {
+ if [ "$rustdesk_is_encrypted" == "1" ]; then
connect_key=$rustdesk_key_pub
hbbsCMD="${hbbsCMD} -k _"
hbbrCMD="${hbbrCMD} -k _"
fi
+
+ if [ "$rustdesk_always_use_relay" == "1" ]; then
+ ALWAYS_USE_RELAY="Y"
+ fi
}
start_process() {
start_hbbs
start_hbbr
- if [ -z ${bin_all_run} ];then
+ if [ -z ${bin_all_run} ]; then
echo_date "❌️进程启动失败,停止插件..."
stop_plugin
exit
@@ -121,7 +129,7 @@ detect_running_status() {
echo_date "🟢$1启动成功,pid:${PID}"
}
-start_hbbs(){
+start_hbbs() {
HBBS_RUN_LOG=/tmp/upload/rustdesk_hbbs_run_log.txt
rm -rf ${HBBS_RUN_LOG}
echo_date "🟠启动 hbbs 进程,开启进程实时守护..."
@@ -132,12 +140,13 @@ start_hbbs(){
export DB_URL=${rustdesk_db_flie_path}db_v2.sqlite3
export PORT=$rustdesk_hbbs_port
export RELAY_SERVERS=$rustdesk_hbbr_host
+ export ALWAYS_USE_RELAY=$ALWAYS_USE_RELAY
CMD="${hbbsCMD}"
if test \${1} = 'start' ; then
- cd /koolshare/configs/rustdesk/
- exec >${HBBS_RUN_LOG} 2>&1
- exec \$CMD
+ cd /koolshare/configs/rustdesk/
+ exec >${HBBS_RUN_LOG} 2>&1
+ exec \$CMD
fi
exit 0
@@ -150,7 +159,7 @@ start_hbbs(){
detect_running_status hbbs
}
-start_hbbr(){
+start_hbbr() {
HBBR_RUN_LOG=/tmp/upload/rustdesk_hbbr_run_log.txt
rm -rf ${HBBR_RUN_LOG}
echo_date "🟠启动 hbbr 进程,开启进程实时守护..."
@@ -166,8 +175,8 @@ start_hbbr(){
CMD="${hbbrCMD}"
if test \${1} = 'start' ; then
cd /koolshare/configs/rustdesk/
- exec >${HBBR_RUN_LOG} 2>&1
- exec \$CMD
+ exec >${HBBR_RUN_LOG} 2>&1
+ exec \$CMD
fi
exit 0
@@ -180,7 +189,7 @@ start_hbbr(){
detect_running_status hbbr
}
-stop_process(){
+stop_process() {
kill_process "hbbs"
kill_process "hbbr"
}
@@ -238,7 +247,7 @@ close_port() {
fi
}
-check_status(){
+check_status() {
local HBBR_PID=$(pidof hbbr)
local HBBS_PID=$(pidof hbbs)
local status_text="插件未启用"
@@ -258,19 +267,19 @@ check_status(){
http_response $status_text
}
-regenerateKey(){
- echo_date "ℹ️开始重新生成安全密钥对..."
- /koolshare/bin/rustdesk-utils genkeypair |awk '{print $3}' > /tmp/upload/rustdesk_key_cert.tmp
- rustdesk_key_pub_tmp=$(cat /tmp/upload/rustdesk_key_cert.tmp |awk 'FNR == 1')
- rustdesk_key_priv_tmp=$(cat /tmp/upload/rustdesk_key_cert.tmp |awk 'FNR == 2')
+regenerateKey() {
+ echo_date "ℹ️开始重新生成安全密钥对..."
+ /koolshare/bin/rustdesk-utils genkeypair | awk '{print $3}' >/tmp/upload/rustdesk_key_cert.tmp
+ rustdesk_key_pub_tmp=$(cat /tmp/upload/rustdesk_key_cert.tmp | awk 'FNR == 1')
+ rustdesk_key_priv_tmp=$(cat /tmp/upload/rustdesk_key_cert.tmp | awk 'FNR == 2')
rm -f /tmp/upload/rustdesk_key_cert.tmp >/dev/null 2>&1
# 写入证书
- echo -n $rustdesk_key_pub_tmp > /koolshare/configs/rustdesk/id_ed25519.pub
- echo -n $rustdesk_key_priv_tmp > /koolshare/configs/rustdesk/id_ed25519
+ echo -n $rustdesk_key_pub_tmp >/koolshare/configs/rustdesk/id_ed25519.pub
+ echo -n $rustdesk_key_priv_tmp >/koolshare/configs/rustdesk/id_ed25519
# 设置证书
dbus set rustdesk_key_pub=$rustdesk_key_pub_tmp
dbus set rustdesk_key_priv=$rustdesk_key_priv_tmp
- echo_date "🟢安全密钥对生成成功,即将重新启动插件..."
+ echo_date "🟢安全密钥对生成成功,即将重新启动插件..."
start
@@ -283,19 +292,19 @@ start)
sleep 20 #延迟启动等待虚拟内存挂载
true >${LOG_FILE}
start | tee -a ${LOG_FILE}
- echo XU6J03M16 >> ${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}
+ echo XU6J03M16 >>${LOG_FILE}
fi
-;;
+ ;;
start_nat)
if [ "${rustdesk_enable}" == "1" ]; then
logger "[软件中心-NAT重启]: 打开RustDesk Server防火墙端口!"
@@ -304,10 +313,10 @@ start_nat)
sleep 2
open_port
fi
-;;
+ ;;
stop)
stop_plugin
-;;
+ ;;
esac
case $2 in
@@ -328,13 +337,13 @@ web_submit)
fi
echo XU6J03M16 | tee -a ${LOG_FILE}
unset_lock
-;;
+ ;;
regenerateKey)
true >/tmp/upload/rustdesk_regenerate_key_log.txt
http_response "$1"
- regenerateKey | tee -a /tmp/upload/rustdesk_regenerate_key_log.txt
-;;
+ regenerateKey | tee -a /tmp/upload/rustdesk_regenerate_key_log.txt
+ ;;
status)
check_status
-;;
-esac
\ No newline at end of file
+ ;;
+esac
diff --git a/rustdesk/uninstall.sh b/rustdesk/uninstall.sh
index b2b4e58..c64d5f2 100644
--- a/rustdesk/uninstall.sh
+++ b/rustdesk/uninstall.sh
@@ -14,4 +14,4 @@ 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
+echo_date "已成功移除插件... Bye~Bye~"
diff --git a/rustdesk/version b/rustdesk/version
index b123147..a58941b 100644
--- a/rustdesk/version
+++ b/rustdesk/version
@@ -1 +1 @@
-1.1
\ No newline at end of file
+1.3
\ No newline at end of file
diff --git a/rustdesk/webs/Module_rustdesk.asp b/rustdesk/webs/Module_rustdesk.asp
index 86341e0..414d39f 100644
--- a/rustdesk/webs/Module_rustdesk.asp
+++ b/rustdesk/webs/Module_rustdesk.asp
@@ -87,7 +87,7 @@ var count_down;
var _responseLen;
var STATUS_FLAG;
var noChange = 0;
-var params_check = ['rustdesk_is_encrypted'];
+var params_check = ['rustdesk_is_encrypted','rustdesk_always_use_relay'];
var params_input = ['rustdesk_hbbr_port', 'rustdesk_hbbs_port', 'rustdesk_hbbr_host','rustdesk_key_pub'];
String.prototype.myReplace = function(f, e){
@@ -451,6 +451,13 @@ function open_rustdesk_hint(itemNum) {
statusmenu += " 示例2:rustdesk.example.com:11115
"
_caption = "中继服务器地址";
}
+ if (itemNum == 9) {
+ statusmenu = " 强制使用中继服务器
"
+ statusmenu += " 强制使用中继服务器可减少链接等待时间。
"
+ statusmenu += " 默认rustdesk会优先使用打洞连接双方机器,但打洞可能会耗费更多时间去尝试。
"
+ statusmenu += " 强制使用中继服务器能减少设备连接时间,但同时可能对带宽要求较高,请慎重开启!!
"
+ _caption = "强制使用中继服务器";
+ }
return overlib(statusmenu, OFFSETX, 10, OFFSETY, 10, RIGHT, STICKY, WIDTH, 'width', CAPTION, _caption, CLOSETITLE, '');
@@ -600,12 +607,18 @@ function guessHbbrPort(obj){