mirror of
https://github.com/kenzok8/small-package
synced 2025-01-07 07:06:58 +08:00
update 2024-09-05 20:36:23
This commit is contained in:
parent
3336fac4af
commit
8cc08d0dd3
@ -24,7 +24,6 @@ PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_binary
|
|||||||
define Package/luci-app-adguardhome/conffiles
|
define Package/luci-app-adguardhome/conffiles
|
||||||
/usr/share/AdGuardHome/links.txt
|
/usr/share/AdGuardHome/links.txt
|
||||||
/etc/config/AdGuardHome
|
/etc/config/AdGuardHome
|
||||||
/etc/AdGuardHome.yaml
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/luci-app-adguardhome/postinst
|
define Package/luci-app-adguardhome/postinst
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-natmap
|
PKG_NAME:=luci-app-natmap
|
||||||
PKG_VERSION:=1.5.1
|
PKG_VERSION:=1.5.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI Support for natmap
|
LUCI_TITLE:=LuCI Support for natmap
|
||||||
|
@ -291,6 +291,7 @@ return view.extend({
|
|||||||
o.datatype = "uinteger";
|
o.datatype = "uinteger";
|
||||||
o.default = 10;
|
o.default = 10;
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
o.rmempty = false;
|
||||||
o.depends("forward_advanced_enable", "1");
|
o.depends("forward_advanced_enable", "1");
|
||||||
|
|
||||||
o = s.taboption(
|
o = s.taboption(
|
||||||
@ -303,6 +304,7 @@ return view.extend({
|
|||||||
o.datatype = "uinteger";
|
o.datatype = "uinteger";
|
||||||
o.default = 3;
|
o.default = 3;
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
o.rmempty = false;
|
||||||
o.depends("forward_advanced_enable", "1");
|
o.depends("forward_advanced_enable", "1");
|
||||||
|
|
||||||
// **********************************************************************
|
// **********************************************************************
|
||||||
@ -485,6 +487,7 @@ return view.extend({
|
|||||||
o.datatype = "uinteger";
|
o.datatype = "uinteger";
|
||||||
o.default = 10;
|
o.default = 10;
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
o.rmempty = false;
|
||||||
o.depends("notify_advanced_enable", "1");
|
o.depends("notify_advanced_enable", "1");
|
||||||
|
|
||||||
o = s.taboption(
|
o = s.taboption(
|
||||||
@ -497,6 +500,7 @@ return view.extend({
|
|||||||
o.datatype = "uinteger";
|
o.datatype = "uinteger";
|
||||||
o.default = 3;
|
o.default = 3;
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
o.rmempty = false;
|
||||||
o.depends("notify_advanced_enable", "1");
|
o.depends("notify_advanced_enable", "1");
|
||||||
|
|
||||||
// **********************************************************************
|
// **********************************************************************
|
||||||
@ -815,6 +819,7 @@ return view.extend({
|
|||||||
o.datatype = "uinteger";
|
o.datatype = "uinteger";
|
||||||
o.default = 10;
|
o.default = 10;
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
o.rmempty = false;
|
||||||
o.depends("link_advanced_enable", "1");
|
o.depends("link_advanced_enable", "1");
|
||||||
|
|
||||||
o = s.taboption(
|
o = s.taboption(
|
||||||
@ -827,6 +832,7 @@ return view.extend({
|
|||||||
o.datatype = "uinteger";
|
o.datatype = "uinteger";
|
||||||
o.default = 3;
|
o.default = 3;
|
||||||
o.modalonly = true;
|
o.modalonly = true;
|
||||||
|
o.rmempty = false;
|
||||||
o.depends("link_advanced_enable", "1");
|
o.depends("link_advanced_enable", "1");
|
||||||
|
|
||||||
// **********************************************************************
|
// **********************************************************************
|
||||||
|
@ -11,6 +11,20 @@ if [ -z "$FORWARD_TARGET_PORT" ] || [ -z "$FORWARD_TARGET_IP" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 设置重试次数和时间间隔
|
||||||
|
max_retries=1
|
||||||
|
sleep_time=1
|
||||||
|
|
||||||
|
# 判断是否开启高级功能
|
||||||
|
if [ "${FORWARD_ADVANCED_ENABLE}" == 1 ]; then
|
||||||
|
max_retries=$FORWARD_ADVANCED_MAX_RETRIES
|
||||||
|
sleep_time=$FORWARD_ADVANCED_SLEEP_TIME
|
||||||
|
else
|
||||||
|
# 默认重试次数为1,休眠时间为1s
|
||||||
|
max_retries=1
|
||||||
|
sleep_time=1
|
||||||
|
fi
|
||||||
|
|
||||||
forward_script=""
|
forward_script=""
|
||||||
case $FORWARD_MODE in
|
case $FORWARD_MODE in
|
||||||
"firewall")
|
"firewall")
|
||||||
@ -24,13 +38,8 @@ case $FORWARD_MODE in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# # 如果$FORWARD_MODE非空则执行对应的脚本
|
|
||||||
# if [ -n "${FORWARD_MODE}" ]; then
|
|
||||||
# forward_script="/usr/share/natmap/plugin-forward/${FORWARD_MODE}-forward.sh"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
if [ -n "${forward_script}" ]; then
|
if [ -n "${forward_script}" ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute forward script" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute forward script" >>/var/log/natmap/natmap.log
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute forward script"
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute forward script"
|
||||||
bash "$forward_script" "$@"
|
bash "$forward_script" "$outter_ip" "$outter_port" "$ip4p" "$inner_port" "$protocol" "$max_retries" "$sleep_time"
|
||||||
fi
|
fi
|
||||||
|
@ -9,13 +9,51 @@ protocol=$5
|
|||||||
link_script=""
|
link_script=""
|
||||||
# echo "LINK_MODE: $LINK_MODE"
|
# echo "LINK_MODE: $LINK_MODE"
|
||||||
|
|
||||||
# 如果$LINK_MODE非空则执行对应的脚本
|
# 设置重试次数和时间间隔
|
||||||
if [ -n "${LINK_MODE}" ]; then
|
max_retries=1
|
||||||
link_script="/usr/share/natmap/plugin-link/${LINK_MODE}.sh"
|
sleep_time=1
|
||||||
|
|
||||||
|
# 判断是否开启高级功能
|
||||||
|
if [ "${LINK_ADVANCED_ENABLE}" == 1 ]; then
|
||||||
|
max_retries=$LINK_ADVANCED_MAX_RETRIES
|
||||||
|
sleep_time=$LINK_ADVANCED_SLEEP_TIME
|
||||||
|
else
|
||||||
|
# 默认重试次数为1,休眠时间为1s
|
||||||
|
max_retries=1
|
||||||
|
sleep_time=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 如果$LINK_MODE非空则执行对应的脚本
|
||||||
|
case "${LINK_MODE}" in
|
||||||
|
"cloudflare_ddns")
|
||||||
|
link_script="/usr/share/natmap/plugin-link/cloudflare_ddns.sh"
|
||||||
|
;;
|
||||||
|
"cloudflare_origin_rule")
|
||||||
|
link_script="/usr/share/natmap/plugin-link/cloudflare_origin_rule.sh"
|
||||||
|
;;
|
||||||
|
"cloudflare_redirect_rule")
|
||||||
|
link_script="/usr/share/natmap/plugin-link/cloudflare_redirect_rule.sh"
|
||||||
|
;;
|
||||||
|
"emby")
|
||||||
|
link_script="/usr/share/natmap/plugin-link/emby.sh"
|
||||||
|
;;
|
||||||
|
"qbittorrent")
|
||||||
|
link_script="/usr/share/natmap/plugin-link/qbittorrent.sh"
|
||||||
|
;;
|
||||||
|
"transmission")
|
||||||
|
link_script="/usr/share/natmap/plugin-link/transmission.sh"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
link_script=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# if [ -n "${LINK_MODE}" ]; then
|
||||||
|
# link_script="/usr/share/natmap/plugin-link/${LINK_MODE}.sh"
|
||||||
|
# fi
|
||||||
|
|
||||||
if [ -n "${link_script}" ]; then
|
if [ -n "${link_script}" ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute link script" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute link script" >>/var/log/natmap/natmap.log
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute link script"
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute link script"
|
||||||
bash "${link_script}" "$@"
|
bash "${link_script}" "$outter_ip" "$outter_port" "$ip4p" "$inner_port" "$protocol" "$max_retries" "$sleep_time"
|
||||||
fi
|
fi
|
||||||
|
@ -6,6 +6,7 @@ ip4p=$3
|
|||||||
inner_port=$4
|
inner_port=$4
|
||||||
protocol=$(echo $5 | tr 'a-z' 'A-Z')
|
protocol=$(echo $5 | tr 'a-z' 'A-Z')
|
||||||
|
|
||||||
|
# 构建消息内容
|
||||||
msg="${GENERAL_NAT_NAME}
|
msg="${GENERAL_NAT_NAME}
|
||||||
New ${protocol} port mapping: ${inner_port} -> ${outter_ip}:${outter_port}
|
New ${protocol} port mapping: ${inner_port} -> ${outter_ip}:${outter_port}
|
||||||
IP4P: ${ip4p}"
|
IP4P: ${ip4p}"
|
||||||
@ -13,33 +14,47 @@ if [ ! -z "$MSG_OVERRIDE" ]; then
|
|||||||
msg="$MSG_OVERRIDE"
|
msg="$MSG_OVERRIDE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 设置重试次数和时间间隔
|
||||||
|
max_retries=1
|
||||||
|
sleep_time=1
|
||||||
|
|
||||||
|
# 判断是否开启高级功能
|
||||||
|
if [ "${NOTIFY_ADVANCED_ENABLE}" == 1 ]; then
|
||||||
|
max_retries=$NOTIFY_ADVANCED_MAX_RETRIES
|
||||||
|
sleep_time=$NOTIFY_ADVANCED_SLEEP_TIME
|
||||||
|
else
|
||||||
|
# 默认重试次数为1,休眠时间为1s
|
||||||
|
max_retries=1
|
||||||
|
sleep_time=1
|
||||||
|
fi
|
||||||
|
|
||||||
# notify_mode 判断
|
# notify_mode 判断
|
||||||
notify_script=""
|
notify_script=""
|
||||||
# case $NOTIFY_MODE in
|
case $NOTIFY_MODE in
|
||||||
# "telegram_bot")
|
"telegram_bot")
|
||||||
# notify_script="/usr/share/natmap/plugin-notify/telegram_bot.sh"
|
notify_script="/usr/share/natmap/plugin-notify/telegram_bot.sh"
|
||||||
# ;;
|
;;
|
||||||
# "pushplus")
|
"pushplus")
|
||||||
# notify_script="/usr/share/natmap/plugin-notify/pushplus.sh"
|
notify_script="/usr/share/natmap/plugin-notify/pushplus.sh"
|
||||||
# ;;
|
;;
|
||||||
# "serverchan")
|
"serverchan")
|
||||||
# notify_script="/usr/share/natmap/plugin-notify/serverchan.sh"
|
notify_script="/usr/share/natmap/plugin-notify/serverchan.sh"
|
||||||
# ;;
|
;;
|
||||||
# "gotify")
|
"gotify")
|
||||||
# notify_script="/usr/share/natmap/plugin-notify/gotify.sh"
|
notify_script="/usr/share/natmap/plugin-notify/gotify.sh"
|
||||||
# ;;
|
;;
|
||||||
# *)
|
*)
|
||||||
# notify_script=""
|
notify_script=""
|
||||||
# ;;
|
;;
|
||||||
# esac
|
esac
|
||||||
|
|
||||||
# 如果$NOTIFY_MODE非空则执行对应的脚本
|
# # 如果$NOTIFY_MODE非空则执行对应的脚本
|
||||||
if [ -n "${NOTIFY_MODE}" ]; then
|
# if [ -n "${NOTIFY_MODE}" ]; then
|
||||||
notify_script="/usr/share/natmap/plugin-notify/$NOTIFY_MODE.sh"
|
# notify_script="/usr/share/natmap/plugin-notify/$NOTIFY_MODE.sh"
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
if [ -n "${notify_script}" ]; then
|
if [ -n "${notify_script}" ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute notify script" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute notify script" >>/var/log/natmap/natmap.log
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute notify script"
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME execute notify script"
|
||||||
bash "$notify_script" "$msg"
|
bash "$notify_script" "$msg" "$max_retries" "$sleep_time"
|
||||||
fi
|
fi
|
||||||
|
@ -7,20 +7,10 @@ outter_port=$2
|
|||||||
ip4p=$3
|
ip4p=$3
|
||||||
inner_port=$4
|
inner_port=$4
|
||||||
protocol=$5
|
protocol=$5
|
||||||
|
max_retries=$6
|
||||||
# 默认重试次数为1,休眠时间为3s
|
sleep_time=$7
|
||||||
max_retries=1
|
|
||||||
sleep_time=3
|
|
||||||
retry_count=0
|
retry_count=0
|
||||||
|
|
||||||
# 判断是否开启高级功能
|
|
||||||
if [ "${FORWARD_ADVANCED_ENABLE}" == 1 ] && [ -n "$FORWARD_ADVANCED_MAX_RETRIES" ] && [ -n "$FORWARD_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((FORWARD_ADVANCED_MAX_RETRIES == "0" ? 1 : FORWARD_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((FORWARD_ADVANCED_SLEEP_TIME == "0" ? 3 : FORWARD_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# lan_port
|
# lan_port
|
||||||
mapping_lan_port=""
|
mapping_lan_port=""
|
||||||
# 如果$FORWARD_TARGET_PORT为空或者$FORWARD_TARGET_PORT为0则退出
|
# 如果$FORWARD_TARGET_PORT为空或者$FORWARD_TARGET_PORT为0则退出
|
||||||
@ -140,7 +130,7 @@ function call_action() {
|
|||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
# ------------------------------------------------------------------------
|
# ------------------------------------------------------------------------
|
||||||
# 端口映射处理开始
|
# 端口映射处理开始
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
while (true); do
|
||||||
#
|
#
|
||||||
# 登录
|
# 登录
|
||||||
login_payload="$(create_payload "login")"
|
login_payload="$(create_payload "login")"
|
||||||
@ -155,68 +145,73 @@ for (( ; retry_count < max_retries; retry_count++)); do
|
|||||||
show_response="$(call_action "$cookie" "$show_payload")"
|
show_response="$(call_action "$cookie" "$show_payload")"
|
||||||
# 获取dnat_id
|
# 获取dnat_id
|
||||||
mapping_record_ids=()
|
mapping_record_ids=()
|
||||||
[ "$(echo "$show_response" | jq -r '.ErrMsg')" = "Success" ] && mapping_record_ids=($(echo "$show_response" | jq -r '.Data.data[].id'))
|
if [ "$(echo "$show_response" | jq -r '.ErrMsg')" = "Success" ]; then
|
||||||
# echo "mapping_record_ids: ${mapping_record_ids[@]}"
|
mapping_record_ids=($(echo "$show_response" | jq -r '.Data.data[].id'))
|
||||||
|
|
||||||
#
|
# echo "mapping_record_ids: ${mapping_record_ids[@]}"
|
||||||
# 如果存在record_id,则删除所有端口映射
|
|
||||||
[ ${#mapping_record_ids[@]} -gt 0 ] &&
|
|
||||||
for id in "${mapping_record_ids[@]}"; do
|
|
||||||
# echo "mapping_record_id: $id"
|
|
||||||
del_payload="$(create_payload "del" "$id")"
|
|
||||||
del_response="$(call_action "$cookie" "$del_payload")"
|
|
||||||
if [ "$(echo "$del_response" | jq -r '.ErrMsg')" = "Success" ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Port mapping deleted successfully" >>/var/log/natmap/natmap.log
|
|
||||||
# echo "delete successfully"
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Failed to delete the port mapping" >>/var/log/natmap/natmap.log
|
|
||||||
# echo "delete failed"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
#
|
# 如果存在record_id,则删除所有端口映射
|
||||||
# 再次查询端口映射id
|
if [ ${#mapping_record_ids[@]} -gt 0 ]; then
|
||||||
show_response="$(call_action "$cookie" "$show_payload")"
|
for id in "${mapping_record_ids[@]}"; do
|
||||||
# 预设值mapping_record_ids数组变量,用于后续判断
|
# echo "mapping_record_id: $id"
|
||||||
mapping_record_ids=(1 2)
|
del_payload="$(create_payload "del" "$id")"
|
||||||
# echo "mapping_record_ids: ${mapping_record_ids[@]}"
|
del_response="$(call_action "$cookie" "$del_payload")"
|
||||||
[ "$(echo "$show_response" | jq -r '.ErrMsg')" = "Success" ] && mapping_record_ids=($(echo "$show_response" | jq -r '.Data.data[].id'))
|
if [ "$(echo "$del_response" | jq -r '.ErrMsg')" = "Success" ]; then
|
||||||
# 验证对应端口映射是否存在
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Port mapping deleted successfully" >>/var/log/natmap/natmap.log
|
||||||
if [ ${#mapping_record_ids[@]} -eq 0 ]; then
|
# echo "delete successfully"
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE all Port mapping deleted successfully" >>/var/log/natmap/natmap.log
|
else
|
||||||
#
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Failed to delete the port mapping" >>/var/log/natmap/natmap.log
|
||||||
# 添加端口映射
|
# echo "delete failed"
|
||||||
# echo "adding mapping record..."
|
fi
|
||||||
add_payload="$(create_payload "add")"
|
done
|
||||||
# echo "add_payload: $add_payload"
|
fi
|
||||||
add_response="$(call_action "$cookie" "$add_payload")"
|
|
||||||
# echo "add_response: $add_response"
|
# 再次查询端口映射id
|
||||||
#
|
show_response="$(call_action "$cookie" "$show_payload")"
|
||||||
# Check if the modification was successful
|
# 预设值mapping_record_ids数组变量,用于后续判断
|
||||||
if [ "$(echo "$add_response" | jq -r '.ErrMsg')" = "Success" ]; then
|
mapping_record_ids=(1 2)
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Port mapping add successfully" >>/var/log/natmap/natmap.log
|
# echo "mapping_record_ids: ${mapping_record_ids[@]}"
|
||||||
# echo "add successfully"
|
[ "$(echo "$show_response" | jq -r '.ErrMsg')" = "Success" ] && mapping_record_ids=($(echo "$show_response" | jq -r '.Data.data[].id'))
|
||||||
break
|
|
||||||
else
|
# 验证对应端口映射是否存在
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Failed to add" >>/var/log/natmap/natmap.log
|
if [ ${#mapping_record_ids[@]} -eq 0 ]; then
|
||||||
# echo "add failed"
|
|
||||||
|
# 旧端口映射记录已经全部删除,开始创建新纪录
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE all Port mapping deleted successfully" >>/var/log/natmap/natmap.log
|
||||||
|
#
|
||||||
|
# 添加端口映射
|
||||||
|
# echo "adding mapping record..."
|
||||||
|
add_payload="$(create_payload "add")"
|
||||||
|
# echo "add_payload: $add_payload"
|
||||||
|
add_response="$(call_action "$cookie" "$add_payload")"
|
||||||
|
# echo "add_response: $add_response"
|
||||||
|
#
|
||||||
|
# Check if the modification was successful
|
||||||
|
if [ "$(echo "$add_response" | jq -r '.ErrMsg')" = "Success" ]; then
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Port mapping add successfully" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 修改成功"
|
||||||
|
# echo "add successfully"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Failed to add" >>/var/log/natmap/natmap.log
|
||||||
|
# echo "add failed"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Failed to delete all of old record" >>/var/log/natmap/natmap.log
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE Failed to delete all of old record" >>/var/log/natmap/natmap.log
|
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 达到最大重试次数,无法修改,请检测是否设置正确" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 达到最大重试次数,无法修改,请检测是否设置正确"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
# Check if maximum retries reached
|
done
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 达到最大重试次数,无法修改,请检测是否设置正确" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 达到最大重试次数,无法修改,请检测是否设置正确"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 修改成功" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $FORWARD_MODE 修改成功"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
@ -6,19 +6,11 @@ outter_port=$2
|
|||||||
ip4p=$3
|
ip4p=$3
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 默认重试次数为1,休眠时间为3s
|
||||||
max_retries=1
|
max_retries=$6
|
||||||
sleep_time=3
|
sleep_time=$7
|
||||||
|
retry_count=0
|
||||||
# 判断是否开启高级功能
|
|
||||||
if [ "$LINK_ADVANCED_ENABLE" == 1 ] && [ -n "$LINK_ADVANCED_MAX_RETRIES" ] && [ -n "$LINK_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((LINK_ADVANCED_MAX_RETRIES == "0" ? 1 : LINK_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((LINK_ADVANCED_SLEEP_TIME == "0" ? 3 : LINK_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 初始化参数
|
# 初始化参数
|
||||||
retry_count=0
|
|
||||||
dns_type=$LINK_CLOUDFLARE_DDNS_TYPE
|
dns_type=$LINK_CLOUDFLARE_DDNS_TYPE
|
||||||
dns_record_id=""
|
dns_record_id=""
|
||||||
|
|
||||||
@ -29,26 +21,20 @@ dns_record_id=""
|
|||||||
function get_dns_record_id() {
|
function get_dns_record_id() {
|
||||||
local local_ddns_domain="$1"
|
local local_ddns_domain="$1"
|
||||||
local local_dns_types="$2"
|
local local_dns_types="$2"
|
||||||
|
local local_dns_record_id=""
|
||||||
|
|
||||||
# 获取cloudflare dns记录的dns_record
|
# 获取cloudflare dns记录的dns_record
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
local local_dns_record=$(curl --request GET \
|
||||||
# 发送GET请求
|
--url "https://api.cloudflare.com/client/v4/zones/$LINK_CLOUDFLARE_ZONE_ID/dns_records?name=$local_ddns_domain&type=$local_dns_types" \
|
||||||
local local_dns_record=$(curl --request GET \
|
--header "Authorization: Bearer $LINK_CLOUDFLARE_TOKEN" \
|
||||||
--url "https://api.cloudflare.com/client/v4/zones/$LINK_CLOUDFLARE_ZONE_ID/dns_records?name=$local_ddns_domain&type=$local_dns_types" \
|
--header "Content-Type: application/json")
|
||||||
--header "Authorization: Bearer $LINK_CLOUDFLARE_TOKEN" \
|
|
||||||
--header "Content-Type: application/json")
|
|
||||||
|
|
||||||
# 判断是否成功获取响应
|
# 判断是否成功获取响应
|
||||||
if [ "$(echo "$local_dns_record" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
if [ "$(echo "$local_dns_record" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
||||||
# 获取与dns_type匹配的dns_record_id
|
# 获取与dns_type匹配的dns_record_id
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
||||||
local local_dns_record_id=$(echo "$local_dns_record" | jq ".result[0].id" | sed 's/"//g')
|
local_dns_record_id=$(echo "$local_dns_record" | jq ".result[0].id" | sed 's/"//g')
|
||||||
break
|
fi
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
|
||||||
sleep $sleep_time
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# 返回dns记录的id
|
# 返回dns记录的id
|
||||||
echo "$local_dns_record_id"
|
echo "$local_dns_record_id"
|
||||||
@ -57,7 +43,7 @@ function get_dns_record_id() {
|
|||||||
# 创建请求数据
|
# 创建请求数据
|
||||||
# @param {string} local_dns_type - dns记录类型
|
# @param {string} local_dns_type - dns记录类型
|
||||||
# @return {string} - 请求数据
|
# @return {string} - 请求数据
|
||||||
function create_request_data() {
|
function generate_request_data() {
|
||||||
local local_dns_type="$1"
|
local local_dns_type="$1"
|
||||||
|
|
||||||
# 构建请求数据
|
# 构建请求数据
|
||||||
@ -124,27 +110,15 @@ function create_request_data() {
|
|||||||
function update_dns_record() {
|
function update_dns_record() {
|
||||||
local local_dns_record_id="$1"
|
local local_dns_record_id="$1"
|
||||||
local local_request_data="$2"
|
local local_request_data="$2"
|
||||||
local local_result=""
|
local local_result==$(
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
curl --request PUT \
|
||||||
local_result=$(
|
--url "https://api.cloudflare.com/client/v4/zones/$LINK_CLOUDFLARE_ZONE_ID/dns_records/$local_dns_record_id" \
|
||||||
curl --request PUT \
|
--header "Authorization: Bearer $LINK_CLOUDFLARE_TOKEN" \
|
||||||
--url "https://api.cloudflare.com/client/v4/zones/$LINK_CLOUDFLARE_ZONE_ID/dns_records/$local_dns_record_id" \
|
--header "Content-Type: application/json" \
|
||||||
--header "Authorization: Bearer $LINK_CLOUDFLARE_TOKEN" \
|
--data "$local_request_data"
|
||||||
--header "Content-Type: application/json" \
|
)
|
||||||
--data "$local_request_data"
|
|
||||||
)
|
|
||||||
|
|
||||||
# 判断api是否调用成功,返回参数success是否为true
|
# 判断api是否调用成功,返回参数success是否为true
|
||||||
if [ "$(echo "$local_result" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 更新成功" >>/var/log/natmap/natmap.log
|
|
||||||
break
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
|
||||||
sleep $sleep_time
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# 返回值
|
|
||||||
if [ "$(echo "$local_result" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
if [ "$(echo "$local_result" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
||||||
echo "true"
|
echo "true"
|
||||||
else
|
else
|
||||||
@ -153,42 +127,78 @@ function update_dns_record() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 开始运行
|
# 开始运行
|
||||||
|
# 初始化输出参数
|
||||||
|
result="false"
|
||||||
# 更新cloudflare的dns记录
|
# 更新cloudflare的dns记录
|
||||||
case $dns_type in
|
while (true); do
|
||||||
"AAAA")
|
case $dns_type in
|
||||||
# 更新 AAAA 记录
|
"AAAA")
|
||||||
dns_record_id=$(get_dns_record_id "$LINK_CLOUDFLARE_DDNS_DOMAIN" "$dns_type")
|
# 更新 AAAA 记录
|
||||||
request_data="$(create_request_data "$dns_type")"
|
request_data="$(generate_request_data "$dns_type")"
|
||||||
result=$(update_dns_record "$dns_record_id" "$request_data")
|
dns_record_id="$(get_dns_record_id "$LINK_CLOUDFLARE_DDNS_DOMAIN" "$dns_type")"
|
||||||
;;
|
result="$(update_dns_record "$dns_record_id" "$request_data")"
|
||||||
"HTTPS")
|
|
||||||
dns_record_id=$(get_dns_record_id "$LINK_CLOUDFLARE_DDNS_DOMAIN" "$dns_type")
|
|
||||||
request_data="$(create_request_data "$dns_type")"
|
|
||||||
result=$(update_dns_record "$dns_record_id" "$request_data")
|
|
||||||
;;
|
|
||||||
"SRV")
|
|
||||||
# 更新target_domain的A记录
|
|
||||||
dns_type="A"
|
|
||||||
dns_record_id=$(get_dns_record_id "$LINK_CLOUDFLARE_DDNS_SRV_TARGET_DOMAIN" "$dns_type")
|
|
||||||
request_data="$(create_request_data "$dns_type")"
|
|
||||||
result=$(update_dns_record "$dns_record_id" "$request_data")
|
|
||||||
|
|
||||||
# 更新SRV记录
|
# 判断api是否调用成功
|
||||||
dns_type="SRV"
|
if [ "$result" == "true" ]; then
|
||||||
dns_record_id=$(get_dns_record_id "$LINK_CLOUDFLARE_DDNS_DOMAIN" "$dns_type")
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
||||||
request_data="$(create_request_data "$dns_type")"
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
result=$(update_dns_record "$dns_record_id" "$request_data")
|
break
|
||||||
;;
|
else
|
||||||
*) ;;
|
echo "$LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
esac
|
fi
|
||||||
|
;;
|
||||||
|
"HTTPS")
|
||||||
|
# 更新 HTTPS 记录
|
||||||
|
request_data="$(generate_request_data "$dns_type")"
|
||||||
|
dns_record_id="$(get_dns_record_id "$LINK_CLOUDFLARE_DDNS_DOMAIN" "$dns_type")"
|
||||||
|
result="$(update_dns_record "$dns_record_id" "$request_data")"
|
||||||
|
|
||||||
# Check if maximum retries reached
|
# 判断api是否调用成功
|
||||||
if [ $retry_count -ge $max_retries ]; then
|
if [ "$result" == "true" ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
exit 1
|
break
|
||||||
else
|
else
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 更新成功" >>/var/log/natmap/natmap.log
|
echo "$LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 更新成功"
|
fi
|
||||||
exit 0
|
;;
|
||||||
fi
|
"SRV")
|
||||||
|
# 更新target_domain的A记录
|
||||||
|
dns_type="A"
|
||||||
|
request_data="$(generate_request_data "$dns_type")"
|
||||||
|
dns_record_id="$(get_dns_record_id "$LINK_CLOUDFLARE_DDNS_SRV_TARGET_DOMAIN" "$dns_type")"
|
||||||
|
result="$(update_dns_record "$dns_record_id" "$request_data")"
|
||||||
|
|
||||||
|
# 判断api是否调用成功,成功则继续下一步,更新SRV记录
|
||||||
|
if [ "$result" == "true" ]; then
|
||||||
|
# 更新SRV记录
|
||||||
|
dns_type="SRV"
|
||||||
|
request_data="$(generate_request_data "$dns_type")"
|
||||||
|
dns_record_id="$(get_dns_record_id "$LINK_CLOUDFLARE_DDNS_DOMAIN" "$dns_type")"
|
||||||
|
result="$(update_dns_record "$dns_record_id" "$request_data")"
|
||||||
|
|
||||||
|
# 判断api是否调用成功
|
||||||
|
if [ "$result" == "true" ]; then
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "$LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
@ -16,60 +16,56 @@ function get_current_rule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 默认重试次数为1,休眠时间为3s
|
||||||
max_retries=1
|
max_retries=$6
|
||||||
sleep_time=3
|
sleep_time=$7
|
||||||
|
retry_count=0
|
||||||
# 判断是否开启高级功能
|
|
||||||
if [ "$LINK_ADVANCED_ENABLE" == 1 ] && [ -n "$LINK_ADVANCED_MAX_RETRIES" ] && [ -n "$LINK_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((LINK_ADVANCED_MAX_RETRIES == "0" ? 1 : LINK_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((LINK_ADVANCED_SLEEP_TIME == "0" ? 3 : LINK_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 初始化参数
|
# 初始化参数
|
||||||
|
|
||||||
retry_count=0
|
|
||||||
currrent_rule=""
|
currrent_rule=""
|
||||||
cloudflare_ruleset_id=""
|
cloudflare_ruleset_id=""
|
||||||
|
|
||||||
# 获取cloudflare origin rule id
|
# 获取cloudflare origin rule id
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
while (true); do
|
||||||
currrent_rule=$(get_current_rule)
|
currrent_rule=$(get_current_rule)
|
||||||
cloudflare_ruleset_id=$(echo "$currrent_rule" | jq '.result.id' | sed 's/"//g')
|
cloudflare_ruleset_id=$(echo "$currrent_rule" | jq '.result.id' | sed 's/"//g')
|
||||||
|
|
||||||
if [ -z "$cloudflare_ruleset_id" ]; then
|
if [ -n "$cloudflare_ruleset_id" ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
|
||||||
sleep $sleep_time
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# 修改 origin rule
|
# 修改 origin rule
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
origin_rule_name="\"$LINK_CLOUDFLARE_ORIGIN_RULE_NAME\""
|
||||||
|
new_rule=$(echo "$currrent_rule" | jq '.result.rules| to_entries | map(select(.value.description == '"$origin_rule_name"')) | .[].key')
|
||||||
|
new_rule=$(echo "$currrent_rule" | jq '.result.rules['"$new_rule"'].action_parameters.origin.port = '"$outter_port"'')
|
||||||
|
|
||||||
origin_rule_name="\"$LINK_CLOUDFLARE_ORIGIN_RULE_NAME\""
|
# delete last_updated
|
||||||
new_rule=$(echo "$currrent_rule" | jq '.result.rules| to_entries | map(select(.value.description == '"$origin_rule_name"')) | .[].key')
|
request_data=$(echo "$new_rule" | jq '.result | del(.last_updated)')
|
||||||
new_rule=$(echo "$currrent_rule" | jq '.result.rules['"$new_rule"'].action_parameters.origin.port = '"$outter_port"'')
|
result=$(curl --request PUT \
|
||||||
|
--url "https://api.cloudflare.com/client/v4/zones/$LINK_CLOUDFLARE_ZONE_ID/rulesets/$cloudflare_ruleset_id" \
|
||||||
|
--header "Authorization: Bearer $LINK_CLOUDFLARE_TOKEN" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--data "$request_data")
|
||||||
|
|
||||||
# delete last_updated
|
if [ "$(echo "$result" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
||||||
request_data=$(echo "$new_rule" | jq '.result | del(.last_updated)')
|
# echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 更新成功" >>/var/log/natmap/natmap.log4
|
||||||
result=$(curl --request PUT \
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
--url "https://api.cloudflare.com/client/v4/zones/$LINK_CLOUDFLARE_ZONE_ID/rulesets/$cloudflare_ruleset_id" \
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
||||||
--header "Authorization: Bearer $LINK_CLOUDFLARE_TOKEN" \
|
break
|
||||||
--header "Content-Type: application/json" \
|
else
|
||||||
--data "$request_data")
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
|
fi
|
||||||
if [ "$(echo "$result" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 更新成功" >>/var/log/natmap/natmap.log
|
|
||||||
break
|
|
||||||
else
|
else
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
sleep $sleep_time
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if maximum retries reached
|
# Check if maximum retries reached
|
||||||
|
@ -12,72 +12,59 @@ function get_current_rule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 默认重试次数为1,休眠时间为3s
|
||||||
max_retries=1
|
max_retries=$6
|
||||||
sleep_time=3
|
sleep_time=$7
|
||||||
|
retry_count=0
|
||||||
# 判断是否开启高级功能
|
|
||||||
if [ "$LINK_ADVANCED_ENABLE" == 1 ] && [ -n "$LINK_ADVANCED_MAX_RETRIES" ] && [ -n "$LINK_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((LINK_ADVANCED_MAX_RETRIES == "0" ? 1 : LINK_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((LINK_ADVANCED_SLEEP_TIME == "0" ? 3 : LINK_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 初始化参数
|
# 初始化参数
|
||||||
|
|
||||||
retry_count=0
|
|
||||||
currrent_rule=""
|
currrent_rule=""
|
||||||
cloudflare_ruleset_id=""
|
cloudflare_ruleset_id=""
|
||||||
|
|
||||||
# 获取cloudflare redirect rule id
|
# 获取cloudflare redirect rule id
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
while (true); do
|
||||||
currrent_rule=$(get_current_rule)
|
currrent_rule=$(get_current_rule)
|
||||||
cloudflare_ruleset_id=$(echo "$currrent_rule" | jq '.result.id' | sed 's/"//g')
|
cloudflare_ruleset_id=$(echo "$currrent_rule" | jq '.result.id' | sed 's/"//g')
|
||||||
|
|
||||||
if [ -z "$cloudflare_ruleset_id" ]; then
|
if [ -n "$cloudflare_ruleset_id" ]; then
|
||||||
echo "$LINK_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
|
||||||
sleep $sleep_time
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# update cloudflare redirect rule
|
# update cloudflare redirect rule
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
cloudflare_redirect_rule_name="\"$LINK_CLOUDFLARE_REDIRECT_RULE_NAME\""
|
||||||
cloudflare_redirect_rule_name="\"$LINK_CLOUDFLARE_REDIRECT_RULE_NAME\""
|
|
||||||
# replace NEW_PORT with outter_port
|
|
||||||
redirect_rule_target_url=$(echo $LINK_CLOUDFLARE_REDIRECT_RULE_TARGET_URL | sed 's/NEW_PORT/'"$outter_port"'/g')
|
|
||||||
new_rule=$(echo "$currrent_rule" | jq '.result.rules| to_entries | map(select(.value.description == '"$cloudflare_redirect_rule_name"')) | .[].key')
|
|
||||||
new_rule=$(echo "$currrent_rule" | jq '.result.rules['"$new_rule"'].action_parameters.from_value.target_url.value = "'"$redirect_rule_target_url"'"')
|
|
||||||
|
|
||||||
request_data=$(echo "$new_rule" | jq '.result')
|
# replace NEW_PORT with outter_port
|
||||||
|
redirect_rule_target_url=$(echo $LINK_CLOUDFLARE_REDIRECT_RULE_TARGET_URL | sed 's/NEW_PORT/'"$outter_port"'/g')
|
||||||
|
new_rule=$(echo "$currrent_rule" | jq '.result.rules| to_entries | map(select(.value.description == '"$cloudflare_redirect_rule_name"')) | .[].key')
|
||||||
|
new_rule=$(echo "$currrent_rule" | jq '.result.rules['"$new_rule"'].action_parameters.from_value.target_url.value = "'"$redirect_rule_target_url"'"')
|
||||||
|
|
||||||
# delete last_updated
|
request_data=$(echo "$new_rule" | jq '.result')
|
||||||
request_data=$(echo "$request_data" | jq 'del(.last_updated)')
|
|
||||||
result=$(curl --request PUT \
|
|
||||||
--url "https://api.cloudflare.com/client/v4/zones/$LINK_CLOUDFLARE_ZONE_ID/rulesets/$cloudflare_ruleset_id" \
|
|
||||||
--header "Authorization: Bearer $LINK_CLOUDFLARE_TOKEN" \
|
|
||||||
--header "Content-Type: application/json" \
|
|
||||||
--data "$request_data")
|
|
||||||
|
|
||||||
if [ "$(echo "$result" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
# delete last_updated
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 更新成功" >>/var/log/natmap/natmap.log
|
request_data=$(echo "$request_data" | jq 'del(.last_updated)')
|
||||||
|
result=$(curl --request PUT \
|
||||||
|
--url "https://api.cloudflare.com/client/v4/zones/$LINK_CLOUDFLARE_ZONE_ID/rulesets/$cloudflare_ruleset_id" \
|
||||||
|
--header "Authorization: Bearer $LINK_CLOUDFLARE_TOKEN" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--data "$request_data")
|
||||||
|
|
||||||
break
|
if [ "$(echo "$result" | jq '.success' | sed 's/"//g')" == "true" ]; then
|
||||||
|
# echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 更新成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if maximum retries reached
|
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
@ -6,28 +6,17 @@ outter_port=$2
|
|||||||
LINK_EMBY_URL=$(echo $LINK_EMBY_URL | sed 's/\/$//')
|
LINK_EMBY_URL=$(echo $LINK_EMBY_URL | sed 's/\/$//')
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 默认重试次数为1,休眠时间为3s
|
||||||
max_retries=1
|
max_retries=$6
|
||||||
sleep_time=3
|
sleep_time=$7
|
||||||
|
retry_count=0
|
||||||
# 判断是否开启高级功能
|
|
||||||
if [ "$LINK_ADVANCED_ENABLE" == 1 ] && [ -n "$LINK_ADVANCED_MAX_RETRIES" ] && [ -n "$LINK_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((LINK_ADVANCED_MAX_RETRIES == "0" ? 1 : LINK_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((LINK_ADVANCED_SLEEP_TIME == "0" ? 3 : LINK_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 初始化参数
|
# 初始化参数
|
||||||
current_cfg=""
|
current_cfg=""
|
||||||
retry_count=0
|
|
||||||
|
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
while (true); do
|
||||||
current_cfg=$(curl -v $LINK_EMBY_URL/emby/System/Configuration?api_key=$LINK_EMBY_API_KEY)
|
current_cfg=$(curl -v $LINK_EMBY_URL/emby/System/Configuration?api_key=$LINK_EMBY_API_KEY)
|
||||||
|
|
||||||
if [ -z "$current_cfg" ]; then
|
if [ -n "$current_cfg" ]; then
|
||||||
echo "$LINK_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
|
||||||
sleep $sleep_time
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
||||||
new_cfg=$current_cfg
|
new_cfg=$current_cfg
|
||||||
if [ ! -z $LINK_EMBY_USE_HTTPS ] && [ $LINK_EMBY_USE_HTTPS = '1' ]; then
|
if [ ! -z $LINK_EMBY_USE_HTTPS ] && [ $LINK_EMBY_USE_HTTPS = '1' ]; then
|
||||||
@ -40,18 +29,26 @@ for (( ; retry_count < max_retries; retry_count++)); do
|
|||||||
new_cfg=$(echo $new_cfg | jq ".WanDdns = \"$outter_ip\"")
|
new_cfg=$(echo $new_cfg | jq ".WanDdns = \"$outter_ip\"")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl -X POST "$LINK_EMBY_URL/emby/System/Configuration?api_key=$LINK_EMBY_API_KEY" -H "accept: */*" -H "Content-Type: application/json" -d "$new_cfg"
|
response=$(curl -X POST "$LINK_EMBY_URL/emby/System/Configuration?api_key=$LINK_EMBY_API_KEY" -H "accept: */*" -H "Content-Type: application/json" -d "$new_cfg" -w "%{http_code}")
|
||||||
|
|
||||||
|
if [ "$response" -eq 200 ]; then
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "$LINK_MODE 修改失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$LINK_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if maximum retries reached
|
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
@ -10,23 +10,15 @@ ip4p=$3
|
|||||||
LINK_QB_WEB_URL=$(echo $LINK_QB_WEB_URL | sed 's/\/$//')
|
LINK_QB_WEB_URL=$(echo $LINK_QB_WEB_URL | sed 's/\/$//')
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 默认重试次数为1,休眠时间为3s
|
||||||
max_retries=1
|
max_retries=$6
|
||||||
sleep_time=3
|
sleep_time=$7
|
||||||
|
retry_count=0
|
||||||
# 判断是否开启高级功能
|
|
||||||
if [ "$LINK_ADVANCED_ENABLE" == 1 ] && [ -n "$LINK_ADVANCED_MAX_RETRIES" ] && [ -n "$LINK_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((LINK_ADVANCED_MAX_RETRIES == "0" ? 1 : LINK_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((LINK_ADVANCED_SLEEP_TIME == "0" ? 3 : LINK_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 初始化参数
|
# 初始化参数
|
||||||
# 获取qbcookie,直至重试次数用尽
|
# 获取qbcookie,直至重试次数用尽
|
||||||
qbcookie=""
|
qbcookie=""
|
||||||
retry_count=0
|
|
||||||
|
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
while (true); do
|
||||||
# 获取qbcookie
|
# 获取qbcookie
|
||||||
qbcookie=$(
|
qbcookie=$(
|
||||||
curl -Ssi -X POST \
|
curl -Ssi -X POST \
|
||||||
@ -36,27 +28,28 @@ for (( ; retry_count < max_retries; retry_count++)); do
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 如果qbcookie为空,则重试
|
# 如果qbcookie为空,则重试
|
||||||
if [ -z "$qbcookie" ]; then
|
if [ -n "$qbcookie" ]; then
|
||||||
|
# 修改端口
|
||||||
|
response=$(curl -s -X POST \
|
||||||
|
-b "$qbcookie" \
|
||||||
|
-d 'json={"listen_port":"'$outter_port'"}' \
|
||||||
|
"$LINK_QB_WEB_URL/api/v2/app/setPreferences" -w "%{http_code}")
|
||||||
|
|
||||||
|
if [ "$response" -eq 200 ]; then
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录失败,正在重试..." >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录失败,正在重试..." >>/var/log/natmap/natmap.log
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
else
|
else
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
||||||
# 修改端口
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
||||||
curl -s -X POST \
|
|
||||||
-b "$qbcookie" \
|
|
||||||
-d 'json={"listen_port":"'$outter_port'"}' \
|
|
||||||
"$LINK_QB_WEB_URL/api/v2/app/setPreferences"
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if maximum retries reached
|
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
@ -12,23 +12,15 @@ url="$LINK_TR_RPC_URL/transmission/rpc"
|
|||||||
trauth="-u $LINK_TR_USERNAME:$LINK_TR_PASSWORD"
|
trauth="-u $LINK_TR_USERNAME:$LINK_TR_PASSWORD"
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 默认重试次数为1,休眠时间为3s
|
||||||
max_retries=1
|
max_retries=$6
|
||||||
sleep_time=3
|
sleep_time=$7
|
||||||
|
retry_count=0
|
||||||
# 判断是否开启高级功能
|
|
||||||
if [ "$LINK_ADVANCED_ENABLE" == 1 ] && [ -n "$LINK_ADVANCED_MAX_RETRIES" ] && [ -n "$LINK_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((LINK_ADVANCED_MAX_RETRIES == "0" ? 1 : LINK_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((LINK_ADVANCED_SLEEP_TIME == "0" ? 3 : LINK_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 初始化参数
|
# 初始化参数
|
||||||
# # 获取trsid,直至重试次数用尽
|
# # 获取trsid,直至重试次数用尽
|
||||||
trsid=""
|
trsid=""
|
||||||
retry_count=0
|
|
||||||
|
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
while (true); do
|
||||||
trsid=$(curl -s $trauth $url | sed 's/.*<code>//g;s/<\/code>.*//g')
|
trsid=$(curl -s $trauth $url | sed 's/.*<code>//g;s/<\/code>.*//g')
|
||||||
|
|
||||||
# Check if the provided session ID contains the header "X-Transmission-Session-Id"
|
# Check if the provided session ID contains the header "X-Transmission-Session-Id"
|
||||||
@ -43,28 +35,23 @@ for (( ; retry_count < max_retries; retry_count++)); do
|
|||||||
|
|
||||||
# Check if the port modification was successful
|
# Check if the port modification was successful
|
||||||
if [[ $(echo "$tr_result" | jq -r '.result') == "success" ]]; then
|
if [[ $(echo "$tr_result" | jq -r '.result') == "success" ]]; then
|
||||||
echo "transmission port modified successfully" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
||||||
break
|
break
|
||||||
else
|
|
||||||
echo "transmission Failed to modify the port" >>/var/log/natmap/natmap.log
|
|
||||||
# Sleep for a specified amount of time
|
|
||||||
sleep $sleep_time
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# Sleep for a specified amount of time
|
|
||||||
sleep $sleep_time
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sleep for a specified amount of time
|
# Sleep for a specified amount of time
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
done
|
|
||||||
|
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
# 检测剩余重试次数
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
let retry_count++
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
exit 1
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 登录失败,正在重试..." >>/var/log/natmap/natmap.log
|
||||||
else
|
sleep $sleep_time
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功" >>/var/log/natmap/natmap.log
|
else
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 修改成功"
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改" >>/var/log/natmap/natmap.log
|
||||||
exit 0
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $LINK_MODE 达到最大重试次数,无法修改"
|
||||||
fi
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
@ -7,40 +7,58 @@ gotify_url="${NOTIFY_GOTIFY_URL}"
|
|||||||
priority="${NOTIFY_GOTIFY_PRIORITY:-5}"
|
priority="${NOTIFY_GOTIFY_PRIORITY:-5}"
|
||||||
token="${NOTIFY_GOTIFY_TOKEN}"
|
token="${NOTIFY_GOTIFY_TOKEN}"
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 获取最大重试次数和间隔时间
|
||||||
max_retries=1
|
# 默认重试次数为1,休眠时间为1s
|
||||||
sleep_time=3
|
max_retries=$2
|
||||||
|
sleep_time=$3
|
||||||
retry_count=0
|
retry_count=0
|
||||||
|
|
||||||
# 判断是否开启高级功能
|
# # # 判断是否开启高级功能
|
||||||
if [ "${NOTIFY_ADVANCED_ENABLE}" == 1 ] && [ -n "$NOTIFY_ADVANCED_MAX_RETRIES" ] && [ -n "$NOTIFY_ADVANCED_SLEEP_TIME" ]; then
|
# # if [ "${NOTIFY_ADVANCED_ENABLE}" == 1 ] && [ -n "$NOTIFY_ADVANCED_MAX_RETRIES" ] && [ -n "$NOTIFY_ADVANCED_SLEEP_TIME" ]; then
|
||||||
# 获取最大重试次数
|
# # # 获取最大重试次数
|
||||||
max_retries=$((NOTIFY_ADVANCED_MAX_RETRIES == "0" ? 1 : NOTIFY_ADVANCED_MAX_RETRIES))
|
# # max_retries=$((NOTIFY_ADVANCED_MAX_RETRIES == "0" ? 1 : NOTIFY_ADVANCED_MAX_RETRIES))
|
||||||
# 获取休眠时间
|
# # # 获取休眠时间
|
||||||
sleep_time=$((NOTIFY_ADVANCED_SLEEP_TIME == "0" ? 3 : NOTIFY_ADVANCED_SLEEP_TIME))
|
# # sleep_time=$((NOTIFY_ADVANCED_SLEEP_TIME == "0" ? 1 : NOTIFY_ADVANCED_SLEEP_TIME))
|
||||||
fi
|
# # fi
|
||||||
|
|
||||||
|
# # 判断是否开启高级功能
|
||||||
|
# if [ "${NOTIFY_ADVANCED_ENABLE}" == 1 ]; then
|
||||||
|
# # 获取最大重试次数
|
||||||
|
# max_retries=$NOTIFY_ADVANCED_MAX_RETRIES
|
||||||
|
# # 获取休眠时间
|
||||||
|
# sleep_time=$NOTIFY_ADVANCED_SLEEP_TIME
|
||||||
|
# fi
|
||||||
|
|
||||||
|
while (true); do
|
||||||
|
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
|
||||||
# Send the message using curl
|
# Send the message using curl
|
||||||
curl -s -X POST -H "Content-Type: multipart/form-data" -F "token=$token" -F "title=$title" -F "message=$message" -F "priority=$priority" "$gotify_url/message"
|
curl -s -X POST -H "Content-Type: multipart/form-data" -F "token=$token" -F "title=$title" -F "message=$message" -F "priority=$priority" "$gotify_url/message"
|
||||||
status=$?
|
status=$?
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功"
|
||||||
break
|
break
|
||||||
else
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
echo "$NOTIFY_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
echo "$NOTIFY_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if maximum retries reached
|
# # Check if maximum retries reached
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
# if [ $retry_count -eq $max_retries ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
# echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
# echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
||||||
exit 1
|
# exit 1
|
||||||
else
|
# else
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
# echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功"
|
# echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功"
|
||||||
exit 0
|
# exit 0
|
||||||
fi
|
# fi
|
||||||
|
@ -4,20 +4,13 @@ text="$1"
|
|||||||
title="natmap - ${GENERAL_NAT_NAME} 更新"
|
title="natmap - ${GENERAL_NAT_NAME} 更新"
|
||||||
token="${NOTIFY_PUSHPLUS_TOKEN}"
|
token="${NOTIFY_PUSHPLUS_TOKEN}"
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 获取最大重试次数和间隔时间
|
||||||
max_retries=1
|
max_retries=$2
|
||||||
sleep_time=3
|
sleep_time=$3
|
||||||
retry_count=0
|
retry_count=0
|
||||||
|
|
||||||
# 判断是否开启高级功能
|
while (true); do
|
||||||
if [ "${NOTIFY_ADVANCED_ENABLE}" == 1 ] && [ -n "$NOTIFY_ADVANCED_MAX_RETRIES" ] && [ -n "$NOTIFY_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((NOTIFY_ADVANCED_MAX_RETRIES == "0" ? 1 : NOTIFY_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((NOTIFY_ADVANCED_SLEEP_TIME == "0" ? 3 : NOTIFY_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
|
||||||
curl -4 -Ss -X POST \
|
curl -4 -Ss -X POST \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d '{"token": "'"${token}"'", "content": "'"${text}"'", "title": "'"${title}"'"}' \
|
-d '{"token": "'"${token}"'", "content": "'"${text}"'", "title": "'"${title}"'"}' \
|
||||||
@ -25,20 +18,18 @@ for (( ; retry_count < max_retries; retry_count++)); do
|
|||||||
status=$?
|
status=$?
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功"
|
||||||
break
|
break
|
||||||
else
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
echo "$NOTIFY_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
echo "$NOTIFY_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if maximum retries reached
|
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
@ -17,37 +17,29 @@ if [ "${NOTIFY_SERVERCHAN_ADVANCED_ENABLE}" == 1 ] && [ -n "$NOTIFY_SERVERCHAN_A
|
|||||||
else
|
else
|
||||||
url="https://sctapi.ftqq.com/${NOTIFY_SERVERCHAN_SENDKEY}.send"
|
url="https://sctapi.ftqq.com/${NOTIFY_SERVERCHAN_SENDKEY}.send"
|
||||||
fi
|
fi
|
||||||
# 默认重试次数为1,休眠时间为3s
|
|
||||||
max_retries=1
|
# 获取最大重试次数和间隔时间
|
||||||
sleep_time=3
|
max_retries=$2
|
||||||
|
sleep_time=$3
|
||||||
retry_count=0
|
retry_count=0
|
||||||
|
|
||||||
# 判断是否开启高级功能
|
while (true); do
|
||||||
if [ "${NOTIFY_ADVANCED_ENABLE}" == 1 ] && [ -n "$NOTIFY_ADVANCED_MAX_RETRIES" ] && [ -n "$NOTIFY_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((NOTIFY_ADVANCED_MAX_RETRIES == "0" ? 1 : NOTIFY_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((NOTIFY_ADVANCED_SLEEP_TIME == "0" ? 3 : NOTIFY_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
|
||||||
result=$(curl -X POST -s -o /dev/null -w "%{http_code}" "$url" "${message[@]}")
|
result=$(curl -X POST -s -o /dev/null -w "%{http_code}" "$url" "${message[@]}")
|
||||||
if [ $result -eq 200 ]; then
|
if [ $result -eq 200 ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功"
|
||||||
break
|
break
|
||||||
else
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
echo "$NOTIFY_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
echo "$NOTIFY_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if maximum retries reached
|
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 通知成功" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 通知成功"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
@ -13,28 +13,13 @@ function curl_proxy() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 默认重试次数为1,休眠时间为3s
|
# 获取最大重试次数和间隔时间
|
||||||
max_retries=1
|
max_retries=$2
|
||||||
sleep_time=3
|
sleep_time=$3
|
||||||
retry_count=0
|
retry_count=0
|
||||||
|
|
||||||
# 判断是否开启高级功能
|
while (true); do
|
||||||
if [ "${NOTIFY_ADVANCED_ENABLE}" == 1 ] && [ -n "$NOTIFY_ADVANCED_MAX_RETRIES" ] && [ -n "$NOTIFY_ADVANCED_SLEEP_TIME" ]; then
|
|
||||||
# 获取最大重试次数
|
|
||||||
max_retries=$((NOTIFY_ADVANCED_MAX_RETRIES == "0" ? 1 : NOTIFY_ADVANCED_MAX_RETRIES))
|
|
||||||
# 获取休眠时间
|
|
||||||
sleep_time=$((NOTIFY_ADVANCED_SLEEP_TIME == "0" ? 3 : NOTIFY_ADVANCED_SLEEP_TIME))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# # 判断是否开启高级功能
|
|
||||||
# if [ "$NOTIFY_ADVANCED_ENABLE" == 1 ]; then
|
|
||||||
# # 获取最大重试次数
|
|
||||||
# max_retries="${NOTIFY_ADVANCED_MAX_RETRIES%/:-$max_retries}"
|
|
||||||
# # 获取休眠时间
|
|
||||||
# sleep_time="${NOTIFY_ADVANCED_SLEEP_TIME%/:-$sleep_time}"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
for (( ; retry_count < max_retries; retry_count++)); do
|
|
||||||
curl_proxy -4 -Ss -o /dev/null -X POST \
|
curl_proxy -4 -Ss -o /dev/null -X POST \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d '{"chat_id": "'"${chat_id}"'", "text": "'"${title}\n\n${text}"'", "parse_mode": "HTML", "disable_notification": "false"}' \
|
-d '{"chat_id": "'"${chat_id}"'", "text": "'"${title}\n\n${text}"'", "parse_mode": "HTML", "disable_notification": "false"}' \
|
||||||
@ -42,20 +27,18 @@ for (( ; retry_count < max_retries; retry_count++)); do
|
|||||||
status=$?
|
status=$?
|
||||||
if [ $status -eq 0 ]; then
|
if [ $status -eq 0 ]; then
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 发送成功"
|
||||||
break
|
break
|
||||||
else
|
fi
|
||||||
|
|
||||||
|
# 检测剩余重试次数
|
||||||
|
let retry_count++
|
||||||
|
if [ $retry_count -lt $max_retries ] || [ $max_retries -eq 0 ]; then
|
||||||
echo "$NOTIFY_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
echo "$NOTIFY_MODE 登录失败,休眠$sleep_time秒" >>/var/log/natmap/natmap.log
|
||||||
sleep $sleep_time
|
sleep $sleep_time
|
||||||
|
else
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
||||||
|
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if maximum retries reached
|
|
||||||
if [ $retry_count -eq $max_retries ]; then
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 达到最大重试次数,无法通知"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 通知成功" >>/var/log/natmap/natmap.log
|
|
||||||
echo "$(date +'%Y-%m-%d %H:%M:%S') : $GENERAL_NAT_NAME - $NOTIFY_MODE 通知成功"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
@ -796,7 +796,7 @@ add_firewall_rule() {
|
|||||||
|
|
||||||
# 过滤所有节点IP
|
# 过滤所有节点IP
|
||||||
filter_vpsip > /dev/null 2>&1 &
|
filter_vpsip > /dev/null 2>&1 &
|
||||||
filter_haproxy > /dev/null 2>&1 &
|
# filter_haproxy > /dev/null 2>&1 &
|
||||||
|
|
||||||
accept_icmp=$(config_t_get global_forwarding accept_icmp 0)
|
accept_icmp=$(config_t_get global_forwarding accept_icmp 0)
|
||||||
accept_icmpv6=$(config_t_get global_forwarding accept_icmpv6 0)
|
accept_icmpv6=$(config_t_get global_forwarding accept_icmpv6 0)
|
||||||
|
@ -858,7 +858,7 @@ add_firewall_rule() {
|
|||||||
|
|
||||||
# 过滤所有节点IP
|
# 过滤所有节点IP
|
||||||
filter_vpsip > /dev/null 2>&1 &
|
filter_vpsip > /dev/null 2>&1 &
|
||||||
filter_haproxy > /dev/null 2>&1 &
|
# filter_haproxy > /dev/null 2>&1 &
|
||||||
# Prevent some conditions
|
# Prevent some conditions
|
||||||
filter_vps_addr $(config_n_get $TCP_NODE address) $(config_n_get $UDP_NODE address) > /dev/null 2>&1 &
|
filter_vps_addr $(config_n_get $TCP_NODE address) $(config_n_get $UDP_NODE address) > /dev/null 2>&1 &
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ define Download/geoip
|
|||||||
HASH:=944465ad5f3a3cccebf2930624f528cae3ca054f69295979cf4c4e002a575e90
|
HASH:=944465ad5f3a3cccebf2930624f528cae3ca054f69295979cf4c4e002a575e90
|
||||||
endef
|
endef
|
||||||
|
|
||||||
GEOSITE_VER:=20240903080831
|
GEOSITE_VER:=20240905081929
|
||||||
GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
|
GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
|
||||||
define Download/geosite
|
define Download/geosite
|
||||||
URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
|
URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
|
||||||
URL_FILE:=dlc.dat
|
URL_FILE:=dlc.dat
|
||||||
FILE:=$(GEOSITE_FILE)
|
FILE:=$(GEOSITE_FILE)
|
||||||
HASH:=6a6a39a121a59efaf6bb7a3dd304266df0b4f8b470a84fc9614299f228ff4c2a
|
HASH:=a5bcc1c67fade6d63a6b8f23b8ad952e9dae80ad208d8522f0b6d719cce24262
|
||||||
endef
|
endef
|
||||||
|
|
||||||
GEOSITE_IRAN_VER:=202409020032
|
GEOSITE_IRAN_VER:=202409020032
|
||||||
|
Loading…
Reference in New Issue
Block a user