From cc4c4ba9a846e28729aa4105ef018a066f2198de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 20:29:07 +0800 Subject: [PATCH] update 2023-04-26 20:29:07 --- luci-app-passwall2/Makefile | 2 +- .../luasrc/model/cbi/passwall2/client/global.lua | 7 +++++++ luci-app-passwall2/po/zh-cn/passwall2.po | 6 ++++++ .../root/usr/share/passwall2/app.sh | 16 ++++++++++++++-- .../root/usr/share/passwall2/iptables.sh | 14 ++++++++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/luci-app-passwall2/Makefile b/luci-app-passwall2/Makefile index 6c88ee78..7a6029eb 100644 --- a/luci-app-passwall2/Makefile +++ b/luci-app-passwall2/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall2 -PKG_VERSION:=1.12-1 +PKG_VERSION:=1.13-1 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua index 8bf3e4ae..199e3ee5 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua @@ -263,6 +263,13 @@ hosts = s:taboption("DNS", TextValue, "dns_hosts", translate("Domain Override")) hosts.rows = 5 hosts.wrap = "off" +o = s:taboption("DNS", Button, "clear_ipset", translate("Clear IPSET"), translate("Try this feature if the rule modification does not take effect.")) +o.inputstyle = "remove" +function o.write(e, e) + luci.sys.call("sh /usr/share/" .. appname .. "/iptables.sh flush_ipset > /dev/null 2>&1 &") + luci.http.redirect(api.url("log")) +end + s:tab("log", translate("Log")) o = s:taboption("log", Flag, "close_log", translate("Close Node Log")) o.rmempty = false diff --git a/luci-app-passwall2/po/zh-cn/passwall2.po b/luci-app-passwall2/po/zh-cn/passwall2.po index b67fbe8d..a5897722 100644 --- a/luci-app-passwall2/po/zh-cn/passwall2.po +++ b/luci-app-passwall2/po/zh-cn/passwall2.po @@ -142,6 +142,12 @@ msgstr "远程查询策略" msgid "Domain Override" msgstr "域名重写" +msgid "Clear IPSET" +msgstr "清空 IPSET" + +msgid "Try this feature if the rule modification does not take effect." +msgstr "如果修改规则后没有生效,请尝试此功能。" + msgid "About DNS issues:" msgstr "关于DNS问题:" diff --git a/luci-app-passwall2/root/usr/share/passwall2/app.sh b/luci-app-passwall2/root/usr/share/passwall2/app.sh index ad362530..ae2a27e3 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/app.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/app.sh @@ -348,13 +348,16 @@ run_v2ray() { lua $UTIL_XRAY gen_dns_config ${V2RAY_DNS_DIRECT_ARGS} > $V2RAY_DNS_DIRECT_CONFIG ln_run "$(first_type $(config_t_get global_app ${type}_file) ${type})" ${type} $V2RAY_DNS_DIRECT_LOG run -c "$V2RAY_DNS_DIRECT_CONFIG" + + direct_dnsmasq_listen_port=$(get_new_port $(expr $dns_direct_listen_port + 1) udp) + run_direct_ipset_dnsmasq listen_port=${direct_dnsmasq_listen_port} server_dns=127.0.0.1#${dns_direct_listen_port} ipset=whitelist,whitelist6 config_file=$TMP_PATH/dnsmasq_global_direct.conf [ "$remote_dns_protocol" != "fakedns" ] && { V2RAY_DNS_REMOTE_CONFIG="${TMP_PATH}/${flag}_dns_remote.json" V2RAY_DNS_REMOTE_LOG="${TMP_PATH}/${flag}_dns_remote.log" V2RAY_DNS_REMOTE_LOG="/dev/null" V2RAY_DNS_REMOTE_ARGS="-dns_out_tag remote" - dns_remote_listen_port=$(get_new_port $(expr $dns_listen_port + 2) udp) + dns_remote_listen_port=$(get_new_port $(expr $direct_dnsmasq_listen_port + 1) udp) V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -dns_listen_port ${dns_remote_listen_port}" case "$remote_dns_protocol" in udp) @@ -398,7 +401,7 @@ run_v2ray() { [ -n "$dns_listen_port" ] && _extra_param="${_extra_param} -dns_listen_port ${dns_listen_port}" [ -n "$dns_cache" ] && _extra_param="${_extra_param} -dns_cache ${dns_cache}" _extra_param="${_extra_param} -dns_query_strategy UseIP" - _extra_param="${_extra_param} -direct_dns_port ${dns_direct_listen_port} -direct_dns_udp_server 127.0.0.1" + _extra_param="${_extra_param} -direct_dns_port ${direct_dnsmasq_listen_port} -direct_dns_udp_server 127.0.0.1" if [ "$remote_dns_protocol" == "fakedns" ]; then _extra_param="${_extra_param} -remote_dns_fake 1" else @@ -779,6 +782,15 @@ stop_crontab() { #echolog "清除定时执行命令。" } +run_direct_ipset_dnsmasq() { + local listen_port server_dns ipset config_file + eval_set_val $@ + echo "port=${listen_port}" >> $config_file + echo "server=${server_dns}" >> $config_file + echo "ipset=${ipset}" >> $config_file + ln_run "$(first_type dnsmasq)" "dnsmasq" "/dev/null" -C $config_file +} + kill_all() { kill -9 $(pidof "$@") >/dev/null 2>&1 } diff --git a/luci-app-passwall2/root/usr/share/passwall2/iptables.sh b/luci-app-passwall2/root/usr/share/passwall2/iptables.sh index a4e30746..e90b3c8c 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/iptables.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/iptables.sh @@ -4,9 +4,11 @@ DIR="$(cd "$(dirname "$0")" && pwd)" MY_PATH=$DIR/iptables.sh IPSET_LANIPLIST="laniplist" IPSET_VPSIPLIST="vpsiplist" +IPSET_WHITELIST="whitelist" IPSET_LANIPLIST6="laniplist6" IPSET_VPSIPLIST6="vpsiplist6" +IPSET_WHITELIST6="whitelist6" FORCE_INDEX=2 @@ -502,9 +504,11 @@ add_firewall_rule() { echolog "开始加载防火墙规则..." ipset -! create $IPSET_LANIPLIST nethash maxelem 1048576 ipset -! create $IPSET_VPSIPLIST nethash maxelem 1048576 + ipset -! create $IPSET_WHITELIST nethash maxelem 1048576 ipset -! create $IPSET_LANIPLIST6 nethash family inet6 maxelem 1048576 ipset -! create $IPSET_VPSIPLIST6 nethash family inet6 maxelem 1048576 + ipset -! create $IPSET_WHITELIST6 nethash family inet6 maxelem 1048576 ipset -! -R <<-EOF $(gen_laniplist | sed -e "s/^/add $IPSET_LANIPLIST /") @@ -564,6 +568,7 @@ add_firewall_rule() { $ipt_n -N PSW2 $ipt_n -A PSW2 $(dst $IPSET_LANIPLIST) -j RETURN $ipt_n -A PSW2 $(dst $IPSET_VPSIPLIST) -j RETURN + $ipt_n -A PSW2 $(dst $IPSET_WHITELIST) ! -d $FAKE_IP -j RETURN WAN_IP=$(get_wan_ip) [ ! -z "${WAN_IP}" ] && $ipt_n -A PSW2 $(comment "WAN_IP_RETURN") -d "${WAN_IP}" -j RETURN @@ -574,6 +579,7 @@ add_firewall_rule() { $ipt_n -N PSW2_OUTPUT $ipt_n -A PSW2_OUTPUT $(dst $IPSET_LANIPLIST) -j RETURN $ipt_n -A PSW2_OUTPUT $(dst $IPSET_VPSIPLIST) -j RETURN + $ipt_n -A PSW2_OUTPUT $(dst $IPSET_WHITELIST) ! -d $FAKE_IP -j RETURN $ipt_n -A PSW2_OUTPUT -m mark --mark 0xff -j RETURN $ipt_n -N PSW2_REDIRECT @@ -593,6 +599,7 @@ add_firewall_rule() { $ipt_m -N PSW2 $ipt_m -A PSW2 $(dst $IPSET_LANIPLIST) -j RETURN $ipt_m -A PSW2 $(dst $IPSET_VPSIPLIST) -j RETURN + $ipt_m -A PSW2 $(dst $IPSET_WHITELIST) ! -d $FAKE_IP -j RETURN [ ! -z "${WAN_IP}" ] && $ipt_m -A PSW2 $(comment "WAN_IP_RETURN") -d "${WAN_IP}" -j RETURN unset WAN_IP @@ -604,6 +611,7 @@ add_firewall_rule() { $ipt_m -A PSW2_OUTPUT -m mark --mark 0xff -j RETURN $ipt_m -A PSW2_OUTPUT $(dst $IPSET_LANIPLIST) -j RETURN $ipt_m -A PSW2_OUTPUT $(dst $IPSET_VPSIPLIST) -j RETURN + $ipt_m -A PSW2_OUTPUT $(dst $IPSET_WHITELIST) ! -d $FAKE_IP -j RETURN ip rule add fwmark 1 lookup 100 ip route add local 0.0.0.0/0 dev lo table 100 @@ -612,11 +620,13 @@ add_firewall_rule() { $ip6t_n -N PSW2 $ip6t_n -A PSW2 $(dst $IPSET_LANIPLIST6) -j RETURN $ip6t_n -A PSW2 $(dst $IPSET_VPSIPLIST6) -j RETURN + $ip6t_n -A PSW2 $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP6 -j RETURN $ip6t_n -A PREROUTING -p ipv6-icmp -j PSW2 $ip6t_n -N PSW2_OUTPUT $ip6t_n -A PSW2_OUTPUT $(dst $IPSET_LANIPLIST6) -j RETURN $ip6t_n -A PSW2_OUTPUT $(dst $IPSET_VPSIPLIST6) -j RETURN + $ip6t_n -A PSW2_OUTPUT $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP6 -j RETURN $ip6t_n -A PSW2_OUTPUT -m mark --mark 0xff -j RETURN } @@ -634,6 +644,7 @@ add_firewall_rule() { $ip6t_m -N PSW2 $ip6t_m -A PSW2 $(dst $IPSET_LANIPLIST6) -j RETURN $ip6t_m -A PSW2 $(dst $IPSET_VPSIPLIST6) -j RETURN + $ip6t_m -A PSW2 $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP6 -j RETURN WAN6_IP=$(get_wan6_ip) [ ! -z "${WAN6_IP}" ] && $ip6t_m -A PSW2 $(comment "WAN6_IP_RETURN") -d ${WAN6_IP} -j RETURN @@ -646,6 +657,7 @@ add_firewall_rule() { $ip6t_m -A PSW2_OUTPUT -m mark --mark 0xff -j RETURN $ip6t_m -A PSW2_OUTPUT $(dst $IPSET_LANIPLIST6) -j RETURN $ip6t_m -A PSW2_OUTPUT $(dst $IPSET_VPSIPLIST6) -j RETURN + $ip6t_m -A PSW2_OUTPUT $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP6 -j RETURN ip -6 rule add fwmark 1 table 100 ip -6 route add local ::/0 dev lo table 100 @@ -795,6 +807,8 @@ del_firewall_rule() { flush_ipset() { del_firewall_rule + destroy_ipset $IPSET_WHITELIST $IPSET_VPSIPLIST $IPSET_LANIPLIST + destroy_ipset $IPSET_WHITELIST6 $IPSET_VPSIPLIST6 $IPSET_LANIPLIST6 /etc/init.d/passwall2 reload }