Skip to content

Commit

Permalink
- 2020-08-16: v1.2.1
Browse files Browse the repository at this point in the history
  - 优化插件兼容armv7,手中没有armv7路由器,欢迎测试反馈
  - 面板证书和域名解析的默认证书,支持设置web面板访问前缀,支持证书文本自动转换为文件路径。
  • Loading branch information
cdwangtao committed Aug 16, 2021
1 parent 8f5b581 commit eef676c
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 102 deletions.
5 changes: 4 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ Koolshare Nps Changelog
- 1.软件停止时,检测配置文件是否变化,如果有变化实时备份配置文件。在软件启动时,还原配置文件到/etc/nps/。
- 2.建议开启[定时备份配置]功能,开启后,会定时检查配置文件是否变化,如果有变化实时备份配置文件。
- 2020-08-16: v1.1.2
- 优化重启路由后,页面为空的问题
- 优化重启路由后,页面为空的问题
- 2020-08-16: v1.2.1
- 优化插件兼容armv7,手中没有armv7路由器,欢迎测试反馈
- 面板证书和域名解析的默认证书,支持设置web面板访问前缀,支持证书文本自动转换为文件路径。
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ nps server for Koolshare

本插件参考了[frps插件](https://github.com/koolshare/rogsoft)的代码,根据[nps插件](https://github.com/ehang-io/nps)编译好的的包,进行封装成路由器插件。

本机基于AX86U进行测试,适用于koolshare 梅林改/官改 hnd/axhnd/axhnd.675x固件平台,其他机型未测试
本机基于AX86U进行测试,适用于koolshare 梅林改/官改 hnd/axhnd/axhnd.675x固件平台,优化插件兼容armv7,手中没有armv7路由器,欢迎测试反馈

这是本人第一次尝试编写路由器插件,本打算开发自用的,现在分享出来,如果能帮到大家,那就更好了。

Expand All @@ -30,6 +30,9 @@ Koolshare Nps Changelog
- 2.建议开启[定时备份配置]功能,开启后,会定时检查配置文件是否变化,如果有变化实时备份配置文件。
- 2020-08-16: v1.1.2
- 优化重启路由后,页面为空的问题
- 2020-08-16: v1.2.1
- 优化插件兼容armv7,手中没有armv7路由器,欢迎测试反馈
- 面板证书和域名解析的默认证书,支持设置web面板访问前缀,支持证书文本自动转换为文件路径。


## 运行图:
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

MODULE="nps"
VERSION="v1.1.2"
VERSION="v1.2.1"
TITLE="nps"
DESCRIPTION="一款轻量级、高性能、功能强大的内网穿透代理服务器。"
HOME_URL="Module_nps.asp"
Expand Down
2 changes: 1 addition & 1 deletion config.json.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version":"v1.1.2",
"version":"v1.2.1",
"md5":"a50806415e3d615822b91518a56c26d5",
"home_url":"Module_nps.asp",
"title":"nps",
Expand Down
12 changes: 6 additions & 6 deletions nps-set.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ http_proxy_port=${nps_common_http_proxy_port}
https_proxy_port=${nps_common_https_proxy_port}
https_just_proxy=true
#default https certificate setting
https_default_cert_file=conf/server.pem
https_default_key_file=conf/server.key
https_default_cert_file=${nps_common_https_default_cert_file}
https_default_key_file=${nps_common_https_default_key_file}

##bridge
bridge_type=tcp
Expand Down Expand Up @@ -41,10 +41,10 @@ web_username=${nps_common_web_username}
web_password=${nps_common_web_password}
web_port=${nps_common_web_port}
web_ip=0.0.0.0
web_base_url=
web_open_ssl=false
web_cert_file=conf/server.pem
web_key_file=conf/server.key
web_base_url=${nps_common_web_base_url}
web_open_ssl=${nps_common_web_open_ssl}
web_cert_file=${nps_common_web_cert_file}
web_key_file=${nps_common_web_key_file}
# if web under proxy use sub path. like http://host/nps need this.
#web_base_url=/nps

Expand Down
26 changes: 24 additions & 2 deletions nps/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ platform_test(){
if [ -d "/koolshare" -a -f "/usr/bin/skipd" -a "${LINUX_VER}" -ge "41" ];then
echo_date 机型:"${MODEL} ${FW_TYPE_NAME} 符合安装要求,开始安装插件!"
else
exit_install 1
if [ -d "/koolshare" -a -f "/usr/bin/skipd" -a "${LINUX_VER}" -eq "26" ];then
echo_date 机型:"${MODEL} ${FW_TYPE_NAME} 符合安装要求,开始安装插件!"
else
exit_install 1
fi
fi
}

Expand Down Expand Up @@ -247,8 +251,26 @@ install_now(){
if [ "$(dbus get ${module}_common_cron2_time)" == "" ];then
dbus set ${module}_common_cron2_time="5"
fi
# 增强参数
if [ "$(dbus get ${module}_common_https_default_key_file)" == "" ];then
dbus set ${module}_common_https_default_key_file="/koolshare/configs/nps/https_default_key_file.key"
fi
if [ "$(dbus get ${module}_common_https_default_cert_file)" == "" ];then
dbus set ${module}_common_https_default_cert_file="/koolshare/configs/nps/https_default_cert_file.pem"
fi
if [ "$(dbus get ${module}_common_web_base_url)" == "" ];then
dbus set ${module}_common_web_base_url=""
fi
if [ "$(dbus get ${module}_common_web_open_ssl)" == "" ];then
dbus set ${module}_common_web_open_ssl="false"
fi
if [ "$(dbus get ${module}_common_web_key_file)" == "" ];then
dbus set ${module}_common_web_key_file="/koolshare/configs/nps/web_key_file.key"
fi
if [ "$(dbus get ${module}_common_web_cert_file)" == "" ];then
dbus set ${module}_common_web_cert_file="/koolshare/configs/nps/web_cert_file.pem"
fi


# 10.安装完毕 重启插件
# re-enable
if [ "${ENABLE}" == "1" -a -f "/koolshare/scripts/${module}_config.sh" ];then
Expand Down
64 changes: 58 additions & 6 deletions nps/scripts/nps_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ http_proxy_port=${nps_common_http_proxy_port}
https_proxy_port=${nps_common_https_proxy_port}
https_just_proxy=true
#default https certificate setting
https_default_cert_file=conf/server.pem
https_default_key_file=conf/server.key
https_default_cert_file=${nps_common_https_default_cert_file}
https_default_key_file=${nps_common_https_default_key_file}
##bridge
bridge_type=tcp
Expand Down Expand Up @@ -120,10 +120,10 @@ web_username=${nps_common_web_username}
web_password=${nps_common_web_password}
web_port=${nps_common_web_port}
web_ip=0.0.0.0
web_base_url=
web_open_ssl=false
web_cert_file=conf/server.pem
web_key_file=conf/server.key
web_base_url=${nps_common_web_base_url}
web_open_ssl=${nps_common_web_open_ssl}
web_cert_file=${nps_common_web_cert_file}
web_key_file=${nps_common_web_key_file}
# if web under proxy use sub path. like http://host/nps need this.
#web_base_url=/nps
Expand Down Expand Up @@ -183,6 +183,19 @@ disconnect_timeout=60
fi
# wt增强1.还原配置文件 参数1(是否比较时间拷贝文件 1:比较时间 0:不比较)
on_restore_conf 0
# 4个ssl文件默认值
if [ ! -f "${CONF_BAK_DIR}/https_default_key_file.key" ];then
cp -rf ${CONF_BAKALL_DIR}/server.key ${CONF_BAK_DIR}/https_default_key_file.key
fi
if [ ! -f "${CONF_BAK_DIR}/https_default_cert_file.pem" ];then
cp -rf ${CONF_BAKALL_DIR}/server.pem ${CONF_BAK_DIR}/https_default_cert_file.pem
fi
if [ ! -f "${CONF_BAK_DIR}/web_key_file.key" ];then
cp -rf ${CONF_BAKALL_DIR}/server.key ${CONF_BAK_DIR}/web_key_file.key
fi
if [ ! -f "${CONF_BAK_DIR}/web_cert_file.pem" ];then
cp -rf ${CONF_BAKALL_DIR}/server.pem ${CONF_BAK_DIR}/web_cert_file.pem
fi

# 定时任务 1
if [ "${nps_common_cron_time}" == "0" ]; then
Expand Down Expand Up @@ -371,6 +384,42 @@ on_back_conf() {
cp -rf "${CONF_REAL_DIR}/tasks.json" "${CONF_BAK_DIR}/tasks.json"
fi
}
# wt增强3.web提交时 更新ssl
on_web_submit_updatessl() {
# echo_date "web提交时 更新ssl"
echo_date "web提交时 更新ssl" | tee -a $LOG_FILE
nps_common_https_default_key_file="$(dbus get nps_common_https_default_key_file)"
nps_common_https_default_cert_file="$(dbus get nps_common_https_default_cert_file)"
nps_common_web_key_file="$(dbus get nps_common_web_key_file)"
nps_common_web_cert_file="$(dbus get nps_common_web_cert_file)"
# [[ $str == h*]] # ==比较
# [[ "$str" =~ ^he.* ]] # =~正则比较
# [[ "$str" =~ ^"${JAR_NAME}".* ]] # 包含变量时,变量使用双引号括起来
if [[ "${nps_common_https_default_key_file:0:1}" != "/" ]]; then
echo_date "转换密钥文本为文件:[https_default_key_file.key]" | tee -a $LOG_FILE
echo -e "${nps_common_https_default_key_file}">${CONF_BAK_DIR}/https_default_key_file.key
nps_common_https_default_key_file="/koolshare/configs/nps/https_default_key_file.key"
dbus set nps_common_https_default_key_file="/koolshare/configs/nps/https_default_key_file.key"
fi
if [[ "${nps_common_https_default_cert_file:0:1}" != "/" ]]; then
echo_date "转换证书文本为文件:[https_default_cert_file.pem]" | tee -a $LOG_FILE
echo -e "${nps_common_https_default_cert_file}">${CONF_BAK_DIR}/https_default_cert_file.pem
nps_common_https_default_cert_file="/koolshare/configs/nps/https_default_cert_file.pem"
dbus set nps_common_https_default_cert_file="/koolshare/configs/nps/https_default_cert_file.pem"
fi
if [[ "${nps_common_web_key_file:0:1}" != "/" ]]; then
echo_date "转换密钥文本为文件:[web_key_file.key]" | tee -a $LOG_FILE
echo -e "${nps_common_web_key_file}">${CONF_BAK_DIR}/web_key_file.key
nps_common_web_key_file="/koolshare/configs/nps/web_key_file.key"
dbus set nps_common_web_key_file="/koolshare/configs/nps/web_key_file.key"
fi
if [[ "${nps_common_web_cert_file:0:1}" != "/" ]]; then
echo_date "转换证书文本为文件:[web_cert_file.pem]" | tee -a $LOG_FILE
echo -e "${nps_common_web_cert_file}">${CONF_BAK_DIR}/web_cert_file.pem
nps_common_web_cert_file="/koolshare/configs/nps/web_cert_file.pem"
dbus set nps_common_web_cert_file="/koolshare/configs/nps/web_cert_file.pem"
fi
}
# wt增强3 比较两个文件时间并复制
compareTwoFileTimesAndCopy() {
fileTimes1=$(date +%s -r ${1})
Expand Down Expand Up @@ -435,6 +484,9 @@ web_submit)
set_lock
# 清空日志
true > $LOG_FILE
# web提交时 更新ssl
echo "111.web提交时 更新ssl" >> $LOG_FILE
on_web_submit_updatessl
http_response "$1"
if [ "${nps_enable}" == "1" ]; then
stop | tee -a $LOG_FILE
Expand Down
2 changes: 1 addition & 1 deletion nps/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.1.2
v1.2.1
Loading

0 comments on commit eef676c

Please sign in to comment.