Skip to content

Commit

Permalink
v0.26.10.3
Browse files Browse the repository at this point in the history
  - 添加自定义端口范围以及自定端口的自动添加防火墙放行、允许多用户登录、允许用户注册的配置
  • Loading branch information
cdwangtao committed Aug 14, 2021
1 parent 5f077e2 commit 4026209
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 26 deletions.
8 changes: 5 additions & 3 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Koolshare Nps Changelog
===========================================
v0.26.10.1
2020-08-13: v0.26.10.1
- 第一个beta版本
v0.26.10.2
2020-08-13: v0.26.10.2
- 添加端口防火墙设置
v0.26.10.3
2020-08-13: v0.26.10.3
- 添加自定义端口范围以及自定端口的自动添加防火墙放行、允许多用户登录、允许用户注册的配置
2020-08-14: v0.26.10.4
- 添加配置文件自动备份任务(同步时间可自定义),解决路由器重启后,配置丢失的问题
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Koolshare Nps Changelog
- 第一个beta版本
- v0.26.10.2
- 添加端口防火墙设置
- v0.26.10.3
- v0.26.10.4
- 添加自定义端口范围以及自定端口的自动添加防火墙放行、允许多用户登录、允许用户注册的配置
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="v0.26.10.3"
VERSION="v0.26.10.4"
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":"v0.26.10.3",
"version":"v0.26.10.4",
"md5":"a50806415e3d615822b91518a56c26d5",
"home_url":"Module_nps.asp",
"title":"nps",
Expand Down
24 changes: 15 additions & 9 deletions nps/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ install_now(){
if [ ! -d "/etc/${module}/" ];then
echo_date "文件[/etc/${module}/]不存在, 开始拷贝[/koolshare/res/${module}/]到[/etc/]"
# mkdir -p /etc/nps/
# cp -rf /koolshare/res/${module}/* /etc/nps/
cp -rf /koolshare/res/${module}/ /etc/
# cp -rf /koolshare/res/${module}/* /etc/nps/
cp -rf /koolshare/res/${module}/ /etc/
fi
pause "拷贝资源完成"

Expand Down Expand Up @@ -239,7 +239,13 @@ install_now(){
dbus set ${module}_common_cron_hour_min="hour"
fi
if [ "$(dbus get ${module}_common_cron_time)" == "" ];then
dbus set ${module}_common_cron_time="12"
dbus set ${module}_common_cron_time="0"
fi
if [ "$(dbus get ${module}_common_cron2_hour_min)" == "" ];then
dbus set ${module}_common_cron2_hour_min="min"
fi
if [ "$(dbus get ${module}_common_cron2_time)" == "" ];then
dbus set ${module}_common_cron2_time="5"
fi


Expand All @@ -257,12 +263,12 @@ install_now(){
}

install(){
if [ ! -d "/tmp/${module}/" ];then
echo_date "文件夹[/tmp/${module}/]不存在, 即将开始拷贝[/tmp/home/root/${module}/]到[/tmp/]"
# mkdir -p /tmp/nps/
# cp -rf /tmp/home/root/${module}/* /tmp/nps/
cp -rf /tmp/home/root/${module}/ /tmp/
fi
# if [ ! -d "/tmp/${module}/" ];then
# echo_date "文件夹[/tmp/${module}/]不存在, 即将开始拷贝[/tmp/home/root/${module}/]到[/tmp/]"
# # mkdir -p /tmp/nps/
# # cp -rf /tmp/home/root/${module}/* /tmp/nps/
# cp -rf /tmp/home/root/${module}/ /tmp/
# fi
# 1.获取路由器机型名称: 如:RT-AX86U
get_model
# 2.获取固件类型 如: FW_TYPE_CODE="1" FW_TYPE_NAME="华硕官方固件"
Expand Down
59 changes: 54 additions & 5 deletions nps/scripts/nps_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source /koolshare/scripts/base.sh
eval $(dbus export nps_)
CONF_FILE=/koolshare/configs/nps.conf
CONF_FILE=/koolshare/configs/nps/nps.conf
CONF_REAL_FILE=/etc/nps/conf/nps.conf
LOG_FILE=/tmp/upload/nps_log.txt
LOCK_FILE=/var/lock/nps.lock
Expand Down Expand Up @@ -67,6 +67,9 @@ onstart() {
echo_date "当前插件nps主程序版本号:${nps_client_version}"

# nps配置文件
if [ ! -d "/koolshare/configs/nps/" ];then
mkdir -p "/koolshare/configs/nps/"
fi
echo_date "生成nps配置文件到 ${CONF_FILE}"
cat >${CONF_FILE} <<-EOF
appname = nps
Expand Down Expand Up @@ -156,18 +159,44 @@ http_add_origin_header=false
disconnect_timeout=60
EOF
# 拷贝配置文件到 nps实际读取的 真实的配置文件位置
if [ ! -d "/etc/nps/conf/" ];then
echo_date "文件[/etc/nps/conf/]不存在, 开始拷贝[/koolshare/res/nps/conf/]到[/etc/nps/]"
mkdir -p "/etc/nps/conf/"
cp -rf /koolshare/res/nps/conf/ /etc/nps/
fi
if [ ! -d "/etc/nps/web/" ];then
echo_date "文件[/etc/nps/web/]不存在, 开始拷贝[/koolshare/res/nps/web/]到[/etc/nps/]"
mkdir -p "/etc/nps/web/"
cp -rf /koolshare/res/nps/web/ /etc/nps/
fi
cp -rf ${CONF_FILE} ${CONF_REAL_FILE}
cp -rf /koolshare/configs/nps/clients.json /etc/nps/conf/clients.json
cp -rf /koolshare/configs/nps/hosts.json /etc/nps/conf/hosts.json
cp -rf /koolshare/configs/nps/tasks.json /etc/nps/conf/tasks.json

# 定时任务
# 定时任务 1
if [ "${nps_common_cron_time}" == "0" ]; then
cru d nps_monitor >/dev/null 2>&1
else
if [ "${nps_common_cron_hour_min}" == "min" ]; then
echo_date "设置定时任务:每隔${nps_common_cron_time}分钟注册一次nps服务..."
cru a nps_monitor "*/"${nps_common_cron_time}" * * * * /bin/sh /koolshare/scripts/nps_config.sh"
cru a nps_monitor "*/"${nps_common_cron_time}" * * * * /bin/sh /koolshare/scripts/nps_config.sh restart"
elif [ "${nps_common_cron_hour_min}" == "hour" ]; then
echo_date "设置定时任务:每隔${nps_common_cron_time}小时注册一次nps服务..."
cru a nps_monitor "0 */"${nps_common_cron_time}" * * * /bin/sh /koolshare/scripts/nps_config.sh"
cru a nps_monitor "0 */"${nps_common_cron_time}" * * * /bin/sh /koolshare/scripts/nps_config.sh restart"
fi
echo_date "定时任务设置完成!"
fi
# 定时任务 2 定时备份配置文件
if [ "${nps_common_cron1_time}" == "0" ]; then
cru d nps_monitor >/dev/null 2>&1
else
if [ "${nps_common_cron1_hour_min}" == "min" ]; then
echo_date "设置定时任务:每隔${nps_common_cron2_time}分钟备份一次nps配置文件..."
cru a nps_monitor "*/"${nps_common_cron2_time}" * * * * /bin/sh /koolshare/scripts/nps_config.sh backconf"
elif [ "${nps_common_cron2_hour_min}" == "hour" ]; then
echo_date "设置定时任务:每隔${nps_common_cron2_time}小时备份一次nps配置文件..."
cru a nps_monitor "0 */"${nps_common_cron2_time}" * * * /bin/sh /koolshare/scripts/nps_config.sh backconf"
fi
echo_date "定时任务设置完成!"
fi
Expand Down Expand Up @@ -283,10 +312,16 @@ stop() {
killall nps >/dev/null 2>&1
fi

# 删除定时任务1
if [ -n "$(cru l|grep nps_monitor)" ];then
echo_date "删除定时任务..."
echo_date "删除定时任务1..."
cru d nps_monitor >/dev/null 2>&1
fi
# 删除定时任务2
if [ -n "$(cru l|grep nps_monitor2)" ];then
echo_date "删除定时任务2..."
cru d nps_monitor2 >/dev/null 2>&1
fi

if [ -L "/koolshare/init.d/N95nps.sh" ];then
echo_date "删除nat触发..."
Expand All @@ -295,6 +330,13 @@ stop() {
# 关闭端口
close_port
}
# 执行备份配置文件
onbackconf() {
echo_date "执行备份nps配置文件"
cp -rf /etc/nps/conf/clients.json /koolshare/configs/nps/clients.json
cp -rf /etc/nps/conf/hosts.json /koolshare/configs/nps/hosts.json
cp -rf /etc/nps/conf/tasks.json /koolshare/configs/nps/tasks.json
}

# 功能
case $1 in
Expand Down Expand Up @@ -330,6 +372,13 @@ start_nat)
fi
unset_lock
;;
backconf)
set_lock
if [ "${nps_enable}" == "1" ]; then
onbackconf
fi
unset_lock
;;
esac

# 查看日志
Expand Down
2 changes: 1 addition & 1 deletion nps/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.26.10.3
v0.26.10.4
26 changes: 22 additions & 4 deletions nps/webs/Module_nps.asp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ var params_input = [
"nps_common_allow_user_login",
"nps_common_allow_user_register",
"nps_common_cron_time",
"nps_common_cron_hour_min"
"nps_common_cron_hour_min",
"nps_common_cron2_time",
"nps_common_cron2_hour_min"
];
var params_check = ["nps_enable"];
Expand Down Expand Up @@ -156,8 +158,13 @@ function save() {
|| !E(nps_common_web_password).value
|| !E(nps_common_http_proxy_port).value
|| !E(nps_common_https_proxy_port).value
|| !E(nps_common_allow_ports).value
|| !E(nps_common_allow_user_login).value
|| !E(nps_common_allow_user_register).value
|| !E(nps_common_cron_time).value
|| !E(nps_common_cron_hour_min).value
|| !E(nps_common_cron2_time).value
|| !E(nps_common_cron2_hour_min).value
){
alert("提交的表单不能为空!");
return false;
Expand Down Expand Up @@ -563,17 +570,28 @@ function get_log(action){
</td>
</tr>
-->

<tr>
<th width="20%"><a class="hintstyle" href="javascript:void(0);" onclick="openssHint(10)">定时注册服务</a>(<i>0为关闭</i>)</th>
<th width="20%"><a class="hintstyle" href="javascript:void(0);" onclick="openssHint(10)">定时重启服务</a>(<i>0为关闭</i>)</th>
<td>
<input type="text" id="nps_common_cron_time" name="nps_common_cron_time" class="input_ss_table" style="width:30px" value="30" placeholder="" />
<select id="nps_common_cron_hour_min" name="nps_common_cron_hour_min" style="width:60px;vertical-align: middle;" class="input_option">
<option value="min" selected="selected">分钟</option>
<option value="hour">小时</option>
</select>
重新注册一次服务
重启一次服务
</td>
</tr>
<tr>
<th width="20%"><a class="hintstyle" href="javascript:void(0);" onclick="openssHint(11)">定时备份配置(建议开启)</a>(<i>0为关闭</i>)</th>
<td>
<input type="text" id="nps_common_cron2_time" name="nps_common_cron2_time" class="input_ss_table" style="width:30px" value="30" placeholder="" />
<select id="nps_common_cron2_hour_min" name="nps_common_cron2_hour_min" style="width:60px;vertical-align: middle;" class="input_option">
<option value="min" selected="selected">分钟</option>
<option value="hour">小时</option>
</select>
备份一次配置 (解决/nps/etc/配置文件重启丢失的问题)
</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
v0.26.10.3
v0.26.10.4
a50806415e3d615822b91518a56c26d5

0 comments on commit 4026209

Please sign in to comment.