update 2024-02-28 19:18:59

This commit is contained in:
github-actions[bot] 2024-02-28 19:18:59 +08:00
parent 839b7da236
commit dba5e20f66
7 changed files with 72 additions and 45 deletions

View File

@ -3,7 +3,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-natmap
PKG_VERSION:=1.4.0
PKG_VERSION:=1.4.1
PKG_RELEASE:=2
LUCI_TITLE:=LuCI Support for natmap

View File

@ -175,7 +175,7 @@ return view.extend({
o.value("ikuai", _("ikuai"));
// o.depends('forward_enable', '1');
// forward_natmap
// forward_natmap, forward_ikuai, forward_firewall
o = s.taboption(
"forward",
form.Value,
@ -201,10 +201,11 @@ return view.extend({
o.depends("forward_mode", "natmap");
o.depends("forward_mode", "ikuai");
// forward_firewall
o = s.taboption(
"forward",
widgets.NetworkSelect,
"forward_natmap_target_interface",
"forward_firewall_target_interface",
_("Target_Interface")
);
o.modalonly = true;
@ -367,7 +368,12 @@ return view.extend({
o.depends("notify_mode", "telegram_bot");
//notify_pushplus
o = s.taboption("notify", form.Value, "notify_pushplus_token", _("PushPlus Token"));
o = s.taboption(
"notify",
form.Value,
"notify_pushplus_token",
_("PushPlus Token")
);
o.description =
_("Get Instructions") +
' <a href="http://www.pushplus.plus/" target="_blank">' +

View File

@ -12,7 +12,7 @@ config natmap
option forward_target_ip ''
option forward_target_port ''
option forward_mode 'firewall'
option forward_natmap_target_interface ''
option forward_firewall_target_interface ''
option forward_ikuai_web_url ''
option forward_ikuai_username ''
option forward_ikuai_password ''

View File

@ -30,7 +30,7 @@ validate_section_natmap() {
'forward_target_ip:host' \
'forward_target_port:port' \
'forward_mode:string' \
'forward_natmap_target_interface:string' \
'forward_firewall_target_interface:string' \
'forward_ikuai_web_url:string' \
'forward_ikuai_username:string' \
'forward_ikuai_password:string' \
@ -109,10 +109,10 @@ natmap_instance() {
procd_append_param netdev "$ifname"
}
[ -n "${forward_natmap_target_interface}" ] && {
[ -n "${forward_firewall_target_interface}" ] && {
local ifname
network_get_device ifname "$forward_natmap_target_interface" || ifname="$forward_natmap_target_interface"
network_get_device ifname "$forward_firewall_target_interface" || ifname="$forward_firewall_target_interface"
procd_append_param command -i "$ifname"
procd_append_param netdev "$ifname"
}

View File

@ -12,22 +12,22 @@ if [ -z "$FORWARD_TARGET_PORT" ] || [ -z "$FORWARD_TARGET_IP" ]; then
fi
forward_script=""
# case $FORWARD_MODE in
# "firewall")
# forward_script="/usr/share/natmap/plugin-forward/firewall-forward.sh"
# ;;
# "ikuai")
# forward_script="/usr/share/natmap/plugin-forward/ikuai-forward.sh"
# ;;
# *)
# forward_script=""
# ;;
# esac
case $FORWARD_MODE in
"firewall")
forward_script="/usr/share/natmap/plugin-forward/firewall-forward.sh"
;;
"ikuai")
forward_script="/usr/share/natmap/plugin-forward/ikuai-forward.sh"
;;
*)
forward_script=""
;;
esac
# 如果$FORWARD_MODE非空则执行对应的脚本
if [ -n "${FORWARD_MODE}" ]; then
forward_script="/usr/share/natmap/plugin-forward/${FORWARD_MODE}-forward.sh"
fi
# # 如果$FORWARD_MODE非空则执行对应的脚本
# if [ -n "${FORWARD_MODE}" ]; then
# forward_script="/usr/share/natmap/plugin-forward/${FORWARD_MODE}-forward.sh"
# fi
if [ -n "${forward_script}" ]; then
# echo "$GENERAL_NAT_NAME execute forward script"

View File

@ -10,36 +10,55 @@ protocol=$5
# exit 0
# fi
# 如果$forward_target_port为空则退出
if [ -z "$FORWARD_TARGET_PORT" ]; then
# echo "FORWARD_TARGET_PORT is empty,firewall forward exit"
exit 0
fi
# 如果$forward_target_ip为空则退出
if [ -z "$FORWARD_TARGET_IP" ]; then
# echo "FORWARD_TARGET_IP is empty"
exit 0
fi
# get forward target port
# final_forward_target_port=$([ "${FORWARD_TARGET_PORT}" == 0 ] ? $outter_port : "${FORWARD_TARGET_PORT}")
# if [ "${FORWARD_TARGET_PORT}" == 0 ]; then
# echo "FORWARD_TARGET_PORT is 0"
# final_forward_target_port=$outter_port
# else
# echo "FORWARD_TARGET_PORT is not 0"
# final_forward_target_port=$FORWARD_TARGET_PORT
# fi
final_forward_target_port=$((FORWARD_TARGET_PORT == 0 ? outter_port : FORWARD_TARGET_PORT))
# echo "firewall_final_forward_target_port: $final_forward_target_port"
# ipv4 firewall
rule_name_v4=$(echo "${GENERAL_NAT_NAME}_v4" | sed 's/[^a-zA-Z0-9]/_/g' | awk '{print tolower($0)}')
echo "firewall_rule_name_v4: $rule_name_v4"
# ipv4 redirect
uci set firewall.$rule_name_v4=redirect
uci set firewall.$rule_name_v4.name="$rule_name_v4"
uci set firewall.$rule_name_v4.proto="$protocol"
uci set firewall.$rule_name_v4.src="$GENERAL_WAN_INTERFACE"
uci set firewall.$rule_name_v4.dest="$FORWOARD_TARGET_INTERFACE"
uci set firewall.$rule_name_v4.target='DNAT'
uci set firewall.$rule_name_v4.src_dport="${inner_port}"
uci set firewall.$rule_name_v4.dest_ip="${FORWARD_TARGET_IP}"
uci set firewall.$rule_name_v4.dest_port="${final_forward_target_port}"
uci set firewall.$rule_name_v4.name=$rule_name_v4
uci set firewall.$rule_name_v4.proto=$protocol
uci set firewall.$rule_name_v4.src=$GENERAL_WAN_INTERFACE
uci set firewall.$rule_name_v4.dest=$FORWARD_FIREWALL_TARGET_INTERFACE
uci set firewall.$rule_name_v4.target=DNAT
uci set firewall.$rule_name_v4.src_dport=$inner_port
uci set firewall.$rule_name_v4.dest_ip=$FORWARD_TARGET_IP
uci set firewall.$rule_name_v4.dest_port=$final_forward_target_port
# reload
uci commit firewall
/etc/init.d/firewall reload
# --------------------------------------------------------------------------------------------
# QB and TR ipv6 forward
# 检测link_enable
if [ "${LINK_ENABLE}" != 1 ]; then
echo "LINK_ENABLE is not 1,exit,don't forward ipv6"
exit 0
fi
@ -48,16 +67,16 @@ if [ [ "${LINK_MODE}" = transmission ] && [ "${LINK_TR_ALLOW_IPV6}" = 1 ] ] || [
# get rule name
rule_name_v6=$(echo "${GENERAL_NAT_NAME}_v6_allow" | sed 's/[^a-zA-Z0-9]/_/g' | awk '{print tolower($0)}')
# echo "rule_name_v6: $rule_name_v6"
echo "firewall_rule_name_v6: $rule_name_v6"
# ipv6 allow
uci set firewall.$rule_name_v6=rule
uci set firewall.$rule_name_v6.name="$rule_name_v6"
uci set firewall.$rule_name_v6.src="$GENERAL_WAN_INTERFACE"
uci set firewall.$rule_name_v6.dest="$FORWOARD_TARGET_INTERFACE"
uci set firewall.$rule_name_v6.target='ACCEPT'
uci set firewall.$rule_name_v6.proto="$protocol"
uci set firewall.$rule_name_v6.family='ipv6'
uci set firewall.$rule_name_v6.dest_port="$final_forward_target_port"
uci set firewall.$rule_name_v6.name=$rule_name_v6
uci set firewall.$rule_name_v6.src=$GENERAL_WAN_INTERFACE
uci set firewall.$rule_name_v6.dest=$FORWARD_FIREWALL_TARGET_INTERFACE
uci set firewall.$rule_name_v6.target=ACCEPT
uci set firewall.$rule_name_v6.proto=$protocol
uci set firewall.$rule_name_v6.family=ipv6
uci set firewall.$rule_name_v6.dest_port=$final_forward_target_port
# check if dest_ip is already set with return code
if uci get firewall.$rule_name_v6.dest_ip >/dev/null 2>&1; then
@ -68,17 +87,17 @@ if [ [ "${LINK_MODE}" = transmission ] && [ "${LINK_TR_ALLOW_IPV6}" = 1 ] ] || [
case "${LINK_MODE}" in
"transmission")
for ip in $LINK_TR_IPV6_ADDRESS; do
uci add_list firewall.$rule_name_v6.dest_ip="${ip}"
uci add_list firewall.$rule_name_v6.dest_ip=$ip
done
;;
"qbittorrent")
for ip in $LINK_QB_IPV6_ADDRESS; do
uci add_list firewall.$rule_name_v6.dest_ip="${ip}"
uci add_list firewall.$rule_name_v6.dest_ip=$ip
done
;;
esac
fi
# reload
uci commit firewall
/etc/init.d/firewall reload
# reload
uci commit firewall
/etc/init.d/firewall reload
fi

View File

@ -11,7 +11,9 @@ protocol=$5
## ikuai参数获取
# lan_port
mapping_lan_port=""
# 如果$FORWARD_TARGET_PORT为空或者$FORWARD_TARGET_PORT为0则退出
if [ -z "${FORWARD_TARGET_PORT}" ] || [ "${FORWARD_TARGET_PORT}" -eq 0 ]; then
echo "FORWARD_TARGET_PORT is empty,set to outter_port"
mapping_lan_port=$outter_port
else
mapping_lan_port=${FORWARD_TARGET_PORT}