🛸 Sync 2024-03-10 09:23

This commit is contained in:
github-actions[bot] 2024-03-10 09:23:11 +08:00
parent a5b5770f91
commit 2913f75614
32 changed files with 115 additions and 102 deletions

View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=4.75-6
PKG_VERSION:=4.75-7
PKG_RELEASE:=
PKG_CONFIG_DEPENDS:= \

View File

@ -3,14 +3,14 @@
module("luci.controller.passwall", package.seeall)
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local ucic = luci.model.uci.cursor()
local http = require "luci.http"
local util = require "luci.util"
local i18n = require "luci.i18n"
function index()
appname = require "luci.passwall.api".appname
appname = "passwall"
entry({"admin", "services", appname}).dependent = true
entry({"admin", "services", appname, "reset_config"}, call("reset_config")).leaf = true
entry({"admin", "services", appname, "show"}, call("show_menu")).leaf = true
@ -148,12 +148,13 @@ function socks_autoswitch_remove_node()
end
function get_now_use_node()
local path = "/tmp/etc/passwall/acl/default"
local e = {}
local data, code, msg = nixio.fs.readfile("/tmp/etc/passwall/id/TCP")
local data, code, msg = nixio.fs.readfile(path .. "/TCP.id")
if data then
e["TCP"] = util.trim(data)
end
local data, code, msg = nixio.fs.readfile("/tmp/etc/passwall/id/UDP")
local data, code, msg = nixio.fs.readfile(path .. "/UDP.id")
if data then
e["UDP"] = util.trim(data)
end
@ -162,13 +163,15 @@ function get_now_use_node()
end
function get_redir_log()
local name = luci.http.formvalue("name")
local proto = luci.http.formvalue("proto")
local path = "/tmp/etc/passwall/acl/" .. name
proto = proto:upper()
if proto == "UDP" and (ucic:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" and not nixio.fs.access("/tmp/etc/passwall/" .. proto .. ".log") then
if proto == "UDP" and (ucic:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" and not nixio.fs.access(path .. "/" .. proto .. ".log") then
proto = "TCP"
end
if nixio.fs.access("/tmp/etc/passwall/" .. proto .. ".log") then
local content = luci.sys.exec("cat /tmp/etc/passwall/" .. proto .. ".log")
if nixio.fs.access(path .. "/" .. proto .. ".log") then
local content = luci.sys.exec("cat ".. path .. "/" .. proto .. ".log")
content = content:gsub("\n", "<br />")
luci.http.write(content)
else

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local sys = api.sys
m = Map(appname)

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local uci = api.uci
local sys = api.sys
local has_singbox = api.finded_com("singbox")
@ -152,25 +152,30 @@ o.validate = port_validate
---- UDP No Redir Ports
local UDP_NO_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_no_redir_ports")
o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"))
o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"),
"<font color='red'>" .. translate(
"Fill in the ports you don't want to be forwarded by the agent, with the highest priority.") ..
"</font>")
o.default = "default"
o:value("disable", translate("No patterns are used"))
o:value("default", translate("Use global config") .. "(" .. UDP_NO_REDIR_PORTS .. ")")
o:value("1:65535", translate("All"))
o.validate = port_validate
--local TCP_NODE = uci:get(appname, "@global[0]", "tcp_node")
tcp_node = s:option(ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>")
tcp_node.default = "nil"
tcp_node:value("nil", translate("Close"))
--tcp_node:value("default", translate("Use global config") .. "(" .. TCP_NODE .. ")")
o = s:option(Flag, "use_global_config", translatef("Use global config"))
o.default = "0"
o.rmempty = false
tcp_node = s:option(ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>")
tcp_node.default = ""
tcp_node:value("", translate("Close"))
tcp_node:depends("use_global_config", false)
--local UDP_NODE = uci:get(appname, "@global[0]", "udp_node")
udp_node = s:option(ListValue, "udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
udp_node.default = "nil"
udp_node:value("nil", translate("Close"))
--udp_node:value("default", translate("Use global config") .. "(" .. UDP_NODE .. ")")
udp_node.default = ""
udp_node:value("", translate("Close"))
udp_node:value("tcp", translate("Same as the tcp node"))
udp_node:depends({ tcp_node = "", ['!reverse'] = true })
for k, v in pairs(nodes_table) do
tcp_node:value(v.id, v["remark"])
@ -185,7 +190,7 @@ o:value("disable", translate("No patterns are used"))
o:value("default", translate("Default"))
o.validate = port_validate
o:value("default", translate("Use global config") .. "(" .. TCP_PROXY_DROP_PORTS .. ")")
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
---- UDP Proxy Drop Ports
local UDP_PROXY_DROP_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_proxy_drop_ports")
@ -195,7 +200,7 @@ o:value("disable", translate("No patterns are used"))
o:value("default", translate("Use global config") .. "(" .. UDP_PROXY_DROP_PORTS .. ")")
o:value("80,443", translate("QUIC"))
o.validate = port_validate
o:depends({ udp_node = "nil", ['!reverse'] = true })
o:depends({ udp_node = "", ['!reverse'] = true })
---- TCP Redir Ports
local TCP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_redir_ports")
@ -207,7 +212,7 @@ o:value("80,443", "80,443")
o:value("80:65535", "80 " .. translate("or more"))
o:value("1:443", "443 " .. translate("or less"))
o.validate = port_validate
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
---- UDP Redir Ports
local UDP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_redir_ports")
@ -217,24 +222,24 @@ o:value("default", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. "
o:value("1:65535", translate("All"))
o:value("53", "53")
o.validate = port_validate
o:depends({ udp_node = "nil", ['!reverse'] = true })
o:depends({ udp_node = "", ['!reverse'] = true })
o = s:option(Flag, "use_direct_list", translatef("Use %s", translate("Direct List")))
o.default = "1"
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
o = s:option(Flag, "use_proxy_list", translatef("Use %s", translate("Proxy List")))
o.default = "1"
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
o = s:option(Flag, "use_block_list", translatef("Use %s", translate("Block List")))
o.default = "1"
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
if has_gfwlist then
o = s:option(Flag, "use_gfw_list", translatef("Use %s", translate("GFW List")))
o.default = "1"
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
end
if has_chnlist or has_chnroute then
@ -243,29 +248,30 @@ if has_chnlist or has_chnroute then
o:value("direct", translate("Direct Connection"))
o:value("proxy", translate("Proxy"))
o.default = "direct"
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
end
o = s:option(ListValue, "tcp_proxy_mode", "TCP " .. translate("Proxy Mode"))
o:value("disable", translate("No Proxy"))
o:value("proxy", translate("Proxy"))
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
o = s:option(ListValue, "udp_proxy_mode", "UDP " .. translate("Proxy Mode"))
o:value("disable", translate("No Proxy"))
o:value("proxy", translate("Proxy"))
o:depends({ udp_node = "nil", ['!reverse'] = true })
o:depends({ udp_node = "", ['!reverse'] = true })
o = s:option(DummyValue, "", " ")
o = s:option(DummyValue, "switch_mode", " ")
o.template = appname .. "/global/proxy"
o:depends({ tcp_node = "", ['!reverse'] = true })
o = s:option(Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"), translate("Experimental feature."))
o.default = "0"
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
---- DNS Forward Mode
o = s:option(ListValue, "dns_mode", translate("Filter Mode"))
o:depends({ tcp_node = "nil", ['!reverse'] = true })
o:depends({ tcp_node = "", ['!reverse'] = true })
if api.is_finded("dns2socks") then
o:value("dns2socks", "dns2socks")
end

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
m = Map(appname)
api.set_apply_on_parse(m)

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local uci = api.uci
local datatypes = api.datatypes
local has_singbox = api.finded_com("singbox")
@ -444,7 +444,7 @@ udp_proxy_mode:value("disable", translate("No Proxy"))
udp_proxy_mode:value("proxy", translate("Proxy"))
udp_proxy_mode.default = "proxy"
o = s:taboption("Proxy", DummyValue, "", " ")
o = s:taboption("Proxy", DummyValue, "switch_mode", " ")
o.template = appname .. "/global/proxy"
o = s:taboption("Proxy", Flag, "localhost_proxy", translate("Localhost Proxy"), translate("When selected, localhost can transparent proxy."))

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local sys = api.sys
local net = require "luci.model.network".init()
local datatypes = api.datatypes

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
f = SimpleForm(appname)
f.reset = false

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local uci = api.uci
local fs = require "nixio.fs"
local types_dir = "/usr/lib/lua/luci/model/cbi/passwall/client/type/"

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local sys = api.sys
local datatypes = api.datatypes

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local has_ss = api.is_finded("ss-redir")
local has_ss_rust = api.is_finded("sslocal")
local has_trojan_plus = api.is_finded("trojan-plus")

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local has_ss = api.is_finded("ss-redir")
local has_ss_rust = api.is_finded("sslocal")
local has_trojan_plus = api.is_finded("trojan-plus")

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local fs = api.fs
local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray")

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local has_xray = api.finded_com("xray")
local has_singbox = api.finded_com("singbox")

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local fs = api.fs
local sys = api.sys
local datatypes = api.datatypes

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local datatypes = api.datatypes
m = Map(appname, "Sing-Box/Xray " .. translate("Shunt Rule"))

View File

@ -1,5 +1,5 @@
local api = require "luci.passwall.api"
local appname = api.appname
local appname = "passwall"
local uci = api.uci
local has_xray = api.finded_com("xray")

View File

@ -6,7 +6,7 @@ if not api.finded_com("xray") then
return
end
local appname = api.appname
local appname = "passwall"
local uci = api.uci
local type_name = "Xray"

View File

@ -10,7 +10,7 @@ end
local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'")
local appname = api.appname
local appname = "passwall"
local uci = api.uci
local type_name = "sing-box"

View File

@ -73,7 +73,7 @@ end
function curl_proxy(url, file, args)
--使用代理
local socks_server = luci.sys.exec("[ -f /tmp/etc/passwall/TCP_SOCKS_server ] && echo -n $(cat /tmp/etc/passwall/TCP_SOCKS_server) || echo -n ''")
local socks_server = luci.sys.exec("[ -f /tmp/etc/passwall/acl/default/TCP_SOCKS_server ] && echo -n $(cat /tmp/etc/passwall/acl/default/TCP_SOCKS_server) || echo -n ''")
if socks_server ~= "" then
if not args then args = {} end
local tmp_args = clone(args)
@ -919,7 +919,7 @@ function to_move(app_name,file)
sys.call(cmd_rm_tmp)
return {
code = 1,
error = i18n.translate("The client file is not suitable for current device.")..app_name.."__"..bin_path
error = i18n.translate("The client file is not suitable for current device.") .. app_name .. "__" .. bin_path
}
end

View File

@ -62,14 +62,15 @@ _M["chinadns-ng"] = {
default_path = "/usr/bin/chinadns-ng",
match_fmt_str = "%s$",
file_tree = {
x86_64 = "x86_64",
x86 = "i686",
mipsel = "mipsel",
aarch64 = "aarch64",
armv5 = "arm%-eabi",
armv6 = "armv6%-eabihf",
armv7 = "armv7l%-eabihf",
armv8 = "aarch64"
x86_64 = "@x86_64@",
x86 = "@i686@",
mips = "mips-linux-musl@mips32@",
mipsel = "mipsel-linux-musl@mips32@",
aarch64 = "aarch64-linux-musl@generic+v8a",
armv5 = "arm-linux-musleabi@generic+v5te",
armv6 = "arm-linux-musleabi@generic+v6t2",
armv7 = "arm-linux-musleabihf@generic+v7a",
armv8 = "aarch64-linux-musl@generic+v8a"
}
}

View File

@ -3,7 +3,7 @@ local api = require "luci.passwall.api"
local uci = api.uci
local sys = api.sys
local jsonc = api.jsonc
local appname = api.appname
local appname = "passwall"
local fs = api.fs
local new_port

View File

@ -3,7 +3,7 @@ local api = require "luci.passwall.api"
local uci = api.uci
local sys = api.sys
local jsonc = api.jsonc
local appname = api.appname
local appname = "passwall"
local fs = api.fs
local new_port

View File

@ -78,7 +78,7 @@ local api = require "luci.passwall.api"
var log_a = document.createElement("a");
log_a.innerHTML = "<%:Log%>";
log_a.href = "#";
log_a.setAttribute("onclick", "window.open('" + '<%=api.url("get_redir_log")%>' + "?proto=" + s[0] + "', '_blank')");
log_a.setAttribute("onclick", "window.open('" + '<%=api.url("get_redir_log")%>' + "?name=default&proto=" + s[0] + "', '_blank')");
new_html += "&nbsp&nbsp" + log_a.outerHTML;
}

View File

@ -1,4 +1,4 @@
<div class="cbi-value">
<div class="cbi-value" id="cbi-<%=self.config.."-"..section.."-"..self.option%>" data-index="<%=self.index%>" data-depends="<%=pcdata(self:deplist2json(section))%>">
<label class="cbi-value-title">
<%:Switch Mode%>
</label>

View File

@ -97,7 +97,7 @@ local api = require "luci.passwall.api"
<div class="cbi-value">
<label class="cbi-value-title"></label>
<div class="cbi-value-field">
<input class="btn cbi-button cbi-button-add" type="submit" name="cbi.cts.<%=api.appname%>.nodes." value="<%:Add%>" />
<input class="btn cbi-button cbi-button-add" type="submit" name="cbi.cts.passwall.nodes." value="<%:Add%>" />
<input class="btn cbi-button cbi-button-add" type="button" onclick="open_add_link_div()" value="<%:Add the node via the link%>" />
<input class="btn cbi-button cbi-button-remove" type="button" onclick="clear_all_nodes()" value="<%:Clear all nodes%>" />
<input class="btn cbi-button cbi-button-remove" type="button" onclick="delete_select_nodes()" value="<%:Delete select nodes%>" />

View File

@ -10,7 +10,6 @@ TMP_PATH=/tmp/etc/$CONFIG
TMP_BIN_PATH=$TMP_PATH/bin
TMP_SCRIPT_FUNC_PATH=$TMP_PATH/script_func
TMP_ID_PATH=$TMP_PATH/id
TMP_PORT_PATH=$TMP_PATH/port
TMP_ROUTE_PATH=$TMP_PATH/route
TMP_ACL_PATH=$TMP_PATH/acl
TMP_IFACE_PATH=$TMP_PATH/iface
@ -672,9 +671,9 @@ run_redir() {
local node proto bind local_port config_file log_file
eval_set_val $@
local tcp_node_socks_flag tcp_node_http_flag
[ -n "$config_file" ] && [ -z "$(echo ${config_file} | grep $TMP_PATH)" ] && config_file=$TMP_PATH/$config_file
[ -n "$config_file" ] && [ -z "$(echo ${config_file} | grep $TMP_PATH)" ] && config_file=${TMP_ACL_PATH}/default/${config_file}
if [ -n "$log_file" ] && [ -z "$(echo ${log_file} | grep $TMP_PATH)" ]; then
log_file=$TMP_PATH/$log_file
log_file=${TMP_ACL_PATH}/default/${log_file}
else
log_file="/dev/null"
fi
@ -982,7 +981,8 @@ run_redir() {
}
[ "$tcp_node_socks" = "1" ] && {
echo "127.0.0.1:$tcp_node_socks_port" > $TMP_PATH/TCP_SOCKS_server
TCP_SOCKS_server="127.0.0.1:$tcp_node_socks_port"
echo "${TCP_SOCKS_server}" > $TMP_ACL_PATH/default/TCP_SOCKS_server
}
;;
esac
@ -1001,15 +1001,7 @@ start_redir() {
local port=$(echo $(get_new_port $current_port $proto))
eval ${proto}_REDIR=$port
run_redir node=$node proto=${proto} bind=0.0.0.0 local_port=$port config_file=$config_file log_file=$log_file
#eval ip=\$${proto}_NODE_IP
echo $port > $TMP_PORT_PATH/${proto}
echo $node > $TMP_ID_PATH/${proto}
[ "$(config_n_get $node protocol nil)" = "_shunt" ] && {
local default_node=$(config_n_get $node default_node nil)
local main_node=$(config_n_get $node main_node nil)
echo $default_node > $TMP_ID_PATH/${proto}_default
echo $main_node > $TMP_ID_PATH/${proto}_main
}
echo $node > $TMP_ACL_PATH/default/${proto}.id
else
[ "${proto}" = "UDP" ] && [ "$TCP_UDP" = "1" ] && return
echolog "${proto}节点没有选择或为空,不代理${proto}"
@ -1344,8 +1336,6 @@ acl_app() {
dnsmasq_port=11400
chinadns_port=11500
for item in $items; do
local enabled sid remarks sources tcp_proxy_mode udp_proxy_mode tcp_node udp_node filter_proxy_ipv6 dns_mode remote_dns v2ray_dns_mode remote_dns_doh dns_client_ip
local _ip _mac _iprange _ipset _ip_or_mac rule_list tcp_port udp_port config_file _extra_param
sid=$(uci -q show "${CONFIG}.${item}" | grep "=acl_rule" | awk -F '=' '{print $1}' | awk -F '.' '{print $2}')
eval $(uci -q show "${CONFIG}.${item}" | cut -d'.' -sf 3-)
[ "$enabled" = "1" ] || continue
@ -1370,8 +1360,9 @@ acl_app() {
mkdir -p $TMP_ACL_PATH/$sid
echo -e "${rule_list}" | sed '/^$/d' > $TMP_ACL_PATH/$sid/rule_list
tcp_node=${tcp_node:-default}
udp_node=${udp_node:-default}
use_global_config=${use_global_config}
tcp_node=${tcp_node:-nil}
udp_node=${udp_node:-nil}
use_direct_list=${use_direct_list:-1}
use_proxy_list=${use_proxy_list:-1}
use_block_list=${use_block_list:-1}
@ -1387,8 +1378,11 @@ acl_app() {
[ "$dns_mode" = "sing-box" ] && {
[ "$v2ray_dns_mode" = "doh" ] && remote_dns=${remote_dns_doh:-https://1.1.1.1/dns-query}
}
[ "$tcp_proxy_mode" = "default" ] && tcp_proxy_mode=$TCP_PROXY_MODE
[ "$udp_proxy_mode" = "default" ] && udp_proxy_mode=$UDP_PROXY_MODE
[ "${use_global_config}" = "1" ] & {
tcp_node="default"
udp_node="default"
}
[ "$tcp_node" != "nil" ] && {
if [ "$tcp_node" = "default" ]; then
@ -1569,7 +1563,7 @@ acl_app() {
udp_flag=1
}
[ -n "$redirect_dns_port" ] && echo "${redirect_dns_port}" > $TMP_ACL_PATH/$sid/var_redirect_dns_port
unset enabled sid remarks sources tcp_proxy_mode udp_proxy_mode tcp_node udp_node filter_proxy_ipv6 dns_mode remote_dns v2ray_dns_mode remote_dns_doh dns_client_ip
unset enabled sid remarks sources use_global_config tcp_node udp_node use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode filter_proxy_ipv6 dns_mode remote_dns v2ray_dns_mode remote_dns_doh dns_client_ip
unset _ip _mac _iprange _ipset _ip_or_mac rule_list tcp_port udp_port config_file _extra_param
unset _china_ng_listen _china_ng_chn _china_ng_gfw _gfwlist_file _chnlist_file _china_ng_log_file _no_ipv6_rules _china_ng_extra_param
unset redirect_dns_port
@ -1616,6 +1610,7 @@ start() {
}
[ "$ENABLED_DEFAULT_ACL" == 1 ] && {
mkdir -p $TMP_ACL_PATH/default
start_redir TCP
start_redir UDP
start_dns
@ -1716,7 +1711,7 @@ DNS_QUERY_STRATEGY="UseIPv4"
export V2RAY_LOCATION_ASSET=$(config_t_get global_rules v2ray_location_asset "/usr/share/v2ray/")
export XRAY_LOCATION_ASSET=$V2RAY_LOCATION_ASSET
mkdir -p /tmp/etc $TMP_PATH $TMP_BIN_PATH $TMP_SCRIPT_FUNC_PATH $TMP_ID_PATH $TMP_PORT_PATH $TMP_ROUTE_PATH $TMP_ACL_PATH $TMP_IFACE_PATH $TMP_PATH2
mkdir -p /tmp/etc $TMP_PATH $TMP_BIN_PATH $TMP_SCRIPT_FUNC_PATH $TMP_ID_PATH $TMP_ROUTE_PATH $TMP_ACL_PATH $TMP_IFACE_PATH $TMP_PATH2
arg1=$1
shift

View File

@ -1,7 +1,7 @@
#!/usr/bin/lua
local api = require ("luci.passwall.api")
local appname = api.appname
local appname = "passwall"
local fs = api.fs
local jsonc = api.jsonc
local uci = api.uci

View File

@ -1,5 +1,6 @@
require "luci.sys"
local api = require "luci.passwall.api"
local appname = "passwall"
local var = api.get_args(arg)
local FLAG = var["-FLAG"]
@ -28,7 +29,6 @@ local CACHE_TEXT_FILE = CACHE_DNS_PATH .. ".txt"
local uci = api.uci
local sys = api.sys
local appname = api.appname
local fs = api.fs
local datatypes = api.datatypes

View File

@ -186,12 +186,13 @@ load_acl() {
tcp_no_redir_ports=${tcp_no_redir_ports:-default}
udp_no_redir_ports=${udp_no_redir_ports:-default}
use_global_config=${use_global_config:-0}
tcp_proxy_drop_ports=${tcp_proxy_drop_ports:-default}
udp_proxy_drop_ports=${udp_proxy_drop_ports:-default}
tcp_redir_ports=${tcp_redir_ports:-default}
udp_redir_ports=${udp_redir_ports:-default}
tcp_node=${tcp_node:-default}
udp_node=${udp_node:-default}
tcp_node=${tcp_node:-nil}
udp_node=${udp_node:-nil}
use_direct_list=${use_direct_list:-1}
use_proxy_list=${use_proxy_list:-1}
use_block_list=${use_block_list:-1}
@ -206,6 +207,11 @@ load_acl() {
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
[ "${use_global_config}" = "1" ] & {
tcp_node="default"
udp_node="default"
}
tcp_node_remark=$(config_n_get $TCP_NODE remarks)
udp_node_remark=$(config_n_get $UDP_NODE remarks)
[ -s "${TMP_ACL_PATH}/${sid}/var_tcp_node" ] && tcp_node=$(cat ${TMP_ACL_PATH}/${sid}/var_tcp_node)
@ -243,11 +249,11 @@ load_acl() {
[ "$tcp_no_redir_ports" != "disable" ] && {
if [ "$tcp_no_redir_ports" != "1:65535" ]; then
#结束时return无需多余的规则。
$ip6t_m -A PSW $(comment "$remarks") ${_ipt_source} -p tcp -m multiport --dport $tcp_no_redir_ports -j RETURN 2>/dev/null
$ipt_tmp -A PSW $(comment "$remarks") ${_ipt_source} -p tcp -m multiport --dport $tcp_no_redir_ports -j RETURN
echolog " - ${msg}不代理TCP端口[${tcp_no_redir_ports}]"
else
#结束时会return无需加多余的规则。
unset tcp_port
echolog " - ${msg}不代理所有TCP端口"
fi
@ -255,11 +261,11 @@ load_acl() {
[ "$udp_no_redir_ports" != "disable" ] && {
if [ "$udp_no_redir_ports" != "1:65535" ]; then
#结束时return无需多余的规则。
$ip6t_m -A PSW $(comment "$remarks") ${_ipt_source} -p udp -m multiport --dport $udp_no_redir_ports -j RETURN 2>/dev/null
$ipt_m -A PSW $(comment "$remarks") ${_ipt_source} -p udp -m multiport --dport $udp_no_redir_ports -j RETURN
echolog " - ${msg}不代理UDP端口[${udp_no_redir_ports}]"
else
#结束时会return无需加多余的规则。
unset udp_port
echolog " - ${msg}不代理所有UDP端口"
fi
@ -399,7 +405,7 @@ load_acl() {
$ip6t_m -A PSW $(comment "$remarks") ${_ipt_source} -p udp -j RETURN 2>/dev/null
$ipt_m -A PSW $(comment "$remarks") ${_ipt_source} -p udp -j RETURN
done
unset enabled sid remarks sources use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports tcp_node udp_node
unset enabled sid remarks sources use_global_config use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports tcp_node udp_node
unset _ip _mac _iprange _ipset _ip_or_mac rule_list tcp_port udp_port tcp_node_remark udp_node_remark
unset ipt_tmp msg msg2
done

View File

@ -2,9 +2,7 @@
CONFIG=passwall
TMP_PATH=/tmp/etc/$CONFIG
TMP_BIN_PATH=$TMP_PATH/bin
TMP_SCRIPT_FUNC_PATH=$TMP_PATH/script_func
TMP_ID_PATH=$TMP_PATH/id
LOCK_FILE_DIR=/tmp/lock
LOCK_FILE=${LOCK_FILE_DIR}/${CONFIG}_script.lock

View File

@ -221,12 +221,13 @@ load_acl() {
tcp_no_redir_ports=${tcp_no_redir_ports:-default}
udp_no_redir_ports=${udp_no_redir_ports:-default}
use_global_config=${use_global_config:-0}
tcp_proxy_drop_ports=${tcp_proxy_drop_ports:-default}
udp_proxy_drop_ports=${udp_proxy_drop_ports:-default}
tcp_redir_ports=${tcp_redir_ports:-default}
udp_redir_ports=${udp_redir_ports:-default}
tcp_node=${tcp_node:-default}
udp_node=${udp_node:-default}
tcp_node=${tcp_node:-nil}
udp_node=${udp_node:-nil}
use_direct_list=${use_direct_list:-1}
use_proxy_list=${use_proxy_list:-1}
use_block_list=${use_block_list:-1}
@ -240,8 +241,11 @@ load_acl() {
[ "$udp_proxy_drop_ports" = "default" ] && udp_proxy_drop_ports=$UDP_PROXY_DROP_PORTS
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
[ "$tcp_no_redir_ports" = "1:65535" ] && tcp_proxy_mode="disable"
[ "$udp_no_redir_ports" = "1:65535" ] && udp_proxy_mode="disable"
[ "${use_global_config}" = "1" ] & {
tcp_node="default"
udp_node="default"
}
tcp_node_remark=$(config_n_get $TCP_NODE remarks)
udp_node_remark=$(config_n_get $UDP_NODE remarks)
@ -277,11 +281,11 @@ load_acl() {
[ "$tcp_no_redir_ports" != "disable" ] && {
if [ "$tcp_no_redir_ports" != "1:65535" ]; then
#结束时return无需多余的规则。
nft "add rule inet fw4 $nft_prerouting_chain ${_ipt_source} ip protocol tcp $(factor $tcp_no_redir_ports "tcp dport") counter return comment \"$remarks\""
nft "add rule inet fw4 PSW_MANGLE_V6 ${_ipt_source} meta l4proto tcp $(factor $tcp_no_redir_ports "tcp dport") counter return comment \"$remarks\""
echolog " - ${msg}不代理TCP端口[${tcp_no_redir_ports}]"
else
#结束时会return无需加多余的规则。
unset tcp_port
echolog " - ${msg}不代理所有TCP端口"
fi
@ -289,11 +293,11 @@ load_acl() {
[ "$udp_no_redir_ports" != "disable" ] && {
if [ "$udp_no_redir_ports" != "1:65535" ]; then
#结束时return无需多余的规则。
nft "add rule inet fw4 PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_no_redir_ports "udp dport") counter return comment \"$remarks\""
nft "add rule inet fw4 PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_no_redir_ports "udp dport") counter return comment \"$remarks\"" 2>/dev/null
echolog " - ${msg}不代理UDP端口[${udp_no_redir_ports}]"
else
#结束时会return无需加多余的规则。
unset udp_port
echolog " - ${msg}不代理所有UDP端口"
fi
@ -438,7 +442,7 @@ load_acl() {
nft "add rule inet fw4 PSW_MANGLE ip protocol udp ${_ipt_source} counter return comment \"$remarks\""
nft "add rule inet fw4 PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} counter return comment \"$remarks\"" 2>/dev/null
done
unset enabled sid remarks sources use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports tcp_node udp_node
unset enabled sid remarks sources use_global_config use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports tcp_node udp_node
unset _ip _mac _iprange _ipset _ip_or_mac rule_list tcp_port udp_port tcp_node_remark udp_node_remark
unset msg msg2
done