luci-app-passwall: sync with upstream source
Signed-off-by: CN_SZTL <cnsztl@project-openwrt.eu.org>
This commit is contained in:
parent
cef6593412
commit
d7d07fdeaf
@ -57,6 +57,7 @@ end
|
||||
function get_valid_nodes()
|
||||
local nodes = {}
|
||||
uci:foreach(appname, "nodes", function(e)
|
||||
e.id = e[".name"]
|
||||
if e.type and e.remarks then
|
||||
if e.protocol and (e.protocol == "_balancing" or e.protocol == "_shunt") then
|
||||
e.remarks_name = "%s:[%s] " % {i18n.translatef(e.type .. e.protocol), e.remarks}
|
||||
|
||||
@ -7,31 +7,20 @@ m = Map(appname)
|
||||
|
||||
local nodes_table = {}
|
||||
for k, e in ipairs(api.get_valid_nodes()) do
|
||||
nodes_table[#nodes_table + 1] = {
|
||||
id = e[".name"],
|
||||
remarks = e.remarks_name,
|
||||
type = e["type"]
|
||||
}
|
||||
nodes_table[#nodes_table + 1] = e
|
||||
end
|
||||
|
||||
local socks_table = {}
|
||||
if tonumber(m:get("@global[0]", "tcp_node_socks") or 0) == 1 then
|
||||
local id = "127.0.0.1" .. ":" .. m:get("@global[0]", "tcp_node_socks_port")
|
||||
socks_table[#socks_table + 1] = {
|
||||
id = id,
|
||||
remarks = id .. " - " .. translate("TCP Node")
|
||||
}
|
||||
end
|
||||
uci:foreach(appname, "socks", function(s)
|
||||
if s.enabled == "1" and s.node then
|
||||
local id, remarks
|
||||
local same, i = s.node:match("^(tcp)([1-9])$")
|
||||
local same, i = s.node:match("^(tcp)")
|
||||
if same then
|
||||
remarks = translatef("Same as the tcp %s node", i)
|
||||
remarks = translatef("Same as the tcp node")
|
||||
else
|
||||
for k, n in pairs(nodes_table) do
|
||||
if (s.node == n.id) then
|
||||
remarks = n.remarks; break
|
||||
remarks = n.remarks_name; break
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -65,6 +54,18 @@ local doh_validate = function(self, value, t)
|
||||
return nil, translate("DoH request address") .. " " .. translate("Format must be:") .. " URL,IP"
|
||||
end
|
||||
|
||||
local redir_mode_validate = function(self, value, t)
|
||||
local tcp_proxy_mode_v = tcp_proxy_mode:formvalue(t) or ""
|
||||
local udp_proxy_mode_v = udp_proxy_mode:formvalue(t) or ""
|
||||
local localhost_tcp_proxy_mode_v = localhost_tcp_proxy_mode:formvalue(t) or ""
|
||||
local localhost_udp_proxy_mode_v = localhost_udp_proxy_mode:formvalue(t) or ""
|
||||
local s = tcp_proxy_mode_v .. udp_proxy_mode_v .. localhost_tcp_proxy_mode_v .. localhost_udp_proxy_mode_v
|
||||
if s:find("chnroute") and s:find("returnhome") then
|
||||
return nil, translate("China list cannot be used together with outside China list!")
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
local status = m:get("@global_other[0]", "status") or ""
|
||||
if status:find("big_icon") then
|
||||
m:append(Template(appname .. "/global/status"))
|
||||
@ -83,8 +84,7 @@ o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
|
||||
o.rmempty = false
|
||||
|
||||
---- TCP Node
|
||||
tcp_node = s:taboption("Main", ListValue, "tcp_node", translate("TCP Node"))
|
||||
tcp_node.title = translate("TCP Node")
|
||||
tcp_node = s:taboption("Main", ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>")
|
||||
tcp_node.description = ""
|
||||
--tcp_node.description = translate("For proxy specific list.")
|
||||
--tcp_node.description = o.description .. "<br />"
|
||||
@ -97,55 +97,82 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
|
||||
local url = api.url("node_config", current_node)
|
||||
tcp_node.description = tcp_node.description .. translatef("Current node: %s", string.format('<a href="%s">%s</a>', url, remarks)) .. "<br />"
|
||||
end
|
||||
if n.protocol and n.protocol == "_shunt" then
|
||||
uci:foreach(appname, "shunt_rules", function(e)
|
||||
local id = e[".name"]
|
||||
local remarks = translate(e.remarks)
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = api.url("node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
tcp_node.description = tcp_node.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
end)
|
||||
local id = "default_node"
|
||||
local remarks = translate("Default")
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = api.url("node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
tcp_node.description = tcp_node.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
local id = "main_node"
|
||||
local remarks = translate("Default") .. translate("Preproxy")
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = api.url("node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
tcp_node.description = tcp_node.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
tcp_node:value("nil", translate("Close"))
|
||||
|
||||
udp_node = s:taboption("Main", ListValue, "udp_node", translate("UDP Node"))
|
||||
-- 分流
|
||||
if has_xray and #nodes_table > 0 then
|
||||
local normal_list = {}
|
||||
local shunt_list = {}
|
||||
for k, v in pairs(nodes_table) do
|
||||
if v.node_type == "normal" then
|
||||
normal_list[#normal_list + 1] = v
|
||||
end
|
||||
if v.type == "Xray" and v.protocol == "_shunt" then
|
||||
shunt_list[#shunt_list + 1] = v
|
||||
end
|
||||
end
|
||||
if #normal_list > 0 and #shunt_list > 0 then
|
||||
uci:foreach(appname, "shunt_rules", function(e)
|
||||
local id = e[".name"]
|
||||
o = s:taboption("Main", ListValue, id .. "_node", string.format('* <a href="%s">%s</a>', api.url("shunt_rules", id), translate(e.remarks)))
|
||||
for k, v in pairs(shunt_list) do
|
||||
o:depends("tcp_node", v.id)
|
||||
o.cfgvalue = function(self, section)
|
||||
return m:get(v.id, id) or "nil"
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
m:set(v.id, id, value)
|
||||
end
|
||||
end
|
||||
o:value("nil", translate("Close"))
|
||||
for k, v in pairs(normal_list) do
|
||||
o:value(v.id, v.remarks_name)
|
||||
end
|
||||
end)
|
||||
|
||||
local id = "default_node"
|
||||
o = s:taboption("Main", ListValue, id, "* " .. translate("Default"))
|
||||
for k, v in pairs(shunt_list) do
|
||||
o:depends("tcp_node", v.id)
|
||||
o.cfgvalue = function(self, section)
|
||||
return m:get(v.id, id) or "nil"
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
m:set(v.id, id, value)
|
||||
end
|
||||
end
|
||||
o:value("nil", translate("Close"))
|
||||
for k, v in pairs(normal_list) do
|
||||
o:value(v.id, v.remarks_name)
|
||||
end
|
||||
|
||||
local id = "main_node"
|
||||
o = s:taboption("Main", ListValue, id, "* " .. translate("Default") .. translate("Preproxy"))
|
||||
for k, v in pairs(shunt_list) do
|
||||
o:depends("tcp_node", v.id)
|
||||
o.cfgvalue = function(self, section)
|
||||
return m:get(v.id, id) or "nil"
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
m:set(v.id, id, value)
|
||||
end
|
||||
end
|
||||
o:value("nil", translate("Close"))
|
||||
for k, v in pairs(normal_list) do
|
||||
o:value(v.id, v.remarks_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
udp_node = s:taboption("Main", ListValue, "udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
|
||||
udp_node:value("nil", translate("Close"))
|
||||
udp_node.title = translate("UDP Node")
|
||||
--udp_node.description = translate("For proxy game network, DNS hijack etc.") .. "<br />" .. translate("The selected server will not use Kcptun.")
|
||||
udp_node:value("tcp_", translate("Same as the tcp node"))
|
||||
--udp_node:value("tcp", translate("Same as the tcp node"))
|
||||
--udp_node:value("tcp_", translate("Same as the tcp node") .. "(" .. translate("New process") .. ")")
|
||||
|
||||
tcp_node_socks = s:taboption("Main", Flag, "tcp_node_socks", translate("Enable") .. translate("TCP Node") .. "Socks")
|
||||
o = s:taboption("Main", Value, "tcp_node_socks_port", "Socks" .. translate("Listen Port"))
|
||||
o.default = 1080
|
||||
o.datatype = "port"
|
||||
o:depends("tcp_node_socks", true)
|
||||
|
||||
tcp_node_http = s:taboption("Main", Flag, "tcp_node_http", translate("Enable") .. translate("TCP Node") .. "Http")
|
||||
o = s:taboption("Main", Value, "tcp_node_http_port", "HTTP" .. translate("Listen Port"))
|
||||
o.default = 1180
|
||||
o.datatype = "port"
|
||||
o:depends("tcp_node_http", true)
|
||||
|
||||
s:tab("DNS", translate("DNS"))
|
||||
|
||||
if api.is_finded("chinadns-ng") then
|
||||
@ -273,47 +300,47 @@ end
|
||||
s:tab("Proxy", translate("Mode"))
|
||||
|
||||
---- TCP Default Proxy Mode
|
||||
o = s:taboption("Proxy", ListValue, "tcp_proxy_mode", "TCP" .. translate("Default") .. translate("Proxy Mode"))
|
||||
tcp_proxy_mode = s:taboption("Proxy", ListValue, "tcp_proxy_mode", "TCP" .. translate("Default") .. translate("Proxy Mode"))
|
||||
-- o.description = translate("If not available, try clearing the cache.")
|
||||
o.default = "chnroute"
|
||||
o.rmempty = false
|
||||
o:value("disable", translate("No Proxy"))
|
||||
o:value("global", translate("Global Proxy"))
|
||||
o:value("gfwlist", translate("GFW List"))
|
||||
o:value("chnroute", translate("Not China List"))
|
||||
o:value("returnhome", translate("China List"))
|
||||
tcp_proxy_mode:value("disable", translate("No Proxy"))
|
||||
tcp_proxy_mode:value("global", translate("Global Proxy"))
|
||||
tcp_proxy_mode:value("gfwlist", translate("GFW List"))
|
||||
tcp_proxy_mode:value("chnroute", translate("Not China List"))
|
||||
tcp_proxy_mode:value("returnhome", translate("China List"))
|
||||
tcp_proxy_mode.default = "chnroute"
|
||||
--tcp_proxy_mode.validate = redir_mode_validate
|
||||
|
||||
---- UDP Default Proxy Mode
|
||||
o = s:taboption("Proxy", ListValue, "udp_proxy_mode", "UDP" .. translate("Default") .. translate("Proxy Mode"))
|
||||
o.default = "chnroute"
|
||||
o.rmempty = false
|
||||
o:value("disable", translate("No Proxy"))
|
||||
o:value("global", translate("Global Proxy"))
|
||||
o:value("gfwlist", translate("GFW List"))
|
||||
o:value("chnroute", translate("Game Mode"))
|
||||
o:value("returnhome", translate("China List"))
|
||||
udp_proxy_mode = s:taboption("Proxy", ListValue, "udp_proxy_mode", "UDP" .. translate("Default") .. translate("Proxy Mode"))
|
||||
udp_proxy_mode:value("disable", translate("No Proxy"))
|
||||
udp_proxy_mode:value("global", translate("Global Proxy"))
|
||||
udp_proxy_mode:value("gfwlist", translate("GFW List"))
|
||||
udp_proxy_mode:value("chnroute", translate("Game Mode"))
|
||||
udp_proxy_mode:value("returnhome", translate("China List"))
|
||||
udp_proxy_mode.default = "chnroute"
|
||||
--udp_proxy_mode.validate = redir_mode_validate
|
||||
|
||||
---- Localhost TCP Proxy Mode
|
||||
o = s:taboption("Proxy", ListValue, "localhost_tcp_proxy_mode", translate("Router Localhost") .. "TCP" .. translate("Proxy Mode"))
|
||||
localhost_tcp_proxy_mode = s:taboption("Proxy", ListValue, "localhost_tcp_proxy_mode", translate("Router Localhost") .. "TCP" .. translate("Proxy Mode"))
|
||||
-- o.description = translate("The server client can also use this rule to scientifically surf the Internet.")
|
||||
o:value("default", translate("Default"))
|
||||
o:value("global", translate("Global Proxy"))
|
||||
o:value("gfwlist", translate("GFW List"))
|
||||
o:value("chnroute", translate("Not China List"))
|
||||
o:value("returnhome", translate("China List"))
|
||||
o.default = "default"
|
||||
o.rmempty = false
|
||||
localhost_tcp_proxy_mode:value("default", translate("Default"))
|
||||
localhost_tcp_proxy_mode:value("global", translate("Global Proxy"))
|
||||
localhost_tcp_proxy_mode:value("gfwlist", translate("GFW List"))
|
||||
localhost_tcp_proxy_mode:value("chnroute", translate("Not China List"))
|
||||
localhost_tcp_proxy_mode:value("returnhome", translate("China List"))
|
||||
localhost_tcp_proxy_mode.default = "default"
|
||||
--localhost_tcp_proxy_mode.validate = redir_mode_validate
|
||||
|
||||
---- Localhost UDP Proxy Mode
|
||||
o = s:taboption("Proxy", ListValue, "localhost_udp_proxy_mode", translate("Router Localhost") .. "UDP" .. translate("Proxy Mode"))
|
||||
o:value("default", translate("Default"))
|
||||
o:value("global", translate("Global Proxy"))
|
||||
o:value("gfwlist", translate("GFW List"))
|
||||
o:value("chnroute", translate("Game Mode"))
|
||||
o:value("returnhome", translate("China List"))
|
||||
o:value("disable", translate("No Proxy"))
|
||||
o.default = "default"
|
||||
o.rmempty = false
|
||||
localhost_udp_proxy_mode = s:taboption("Proxy", ListValue, "localhost_udp_proxy_mode", translate("Router Localhost") .. "UDP" .. translate("Proxy Mode"))
|
||||
localhost_udp_proxy_mode:value("default", translate("Default"))
|
||||
localhost_udp_proxy_mode:value("global", translate("Global Proxy"))
|
||||
localhost_udp_proxy_mode:value("gfwlist", translate("GFW List"))
|
||||
localhost_udp_proxy_mode:value("chnroute", translate("Game Mode"))
|
||||
localhost_udp_proxy_mode:value("returnhome", translate("China List"))
|
||||
localhost_udp_proxy_mode:value("disable", translate("No Proxy"))
|
||||
localhost_udp_proxy_mode.default = "default"
|
||||
localhost_udp_proxy_mode.validate = redir_mode_validate
|
||||
|
||||
s:tab("log", translate("Log"))
|
||||
o = s:taboption("log", Flag, "close_log_tcp", translate("Close") .. translate("Log") .. " " .. translate("TCP Node"))
|
||||
@ -366,6 +393,7 @@ o.default = 1
|
||||
o.rmempty = false
|
||||
|
||||
socks_node = s:option(ListValue, "node", translate("Socks Node"))
|
||||
socks_node:value("tcp", translate("Same as the tcp node"))
|
||||
|
||||
o = s:option(Value, "port", "Socks" .. translate("Listen Port"))
|
||||
o.default = 9050
|
||||
@ -379,32 +407,17 @@ if has_xray then
|
||||
end
|
||||
|
||||
for k, v in pairs(nodes_table) do
|
||||
tcp_node:value(v.id, v.remarks)
|
||||
tcp_node_socks:depends("tcp_node", v.id)
|
||||
if v.type == "Xray" then
|
||||
if has_xray then
|
||||
tcp_node_http:depends("tcp_node", v.id)
|
||||
end
|
||||
else
|
||||
tcp_node_http:depends("tcp_node_socks", true)
|
||||
end
|
||||
udp_node:value(v.id, v.remarks)
|
||||
tcp_node:value(v.id, v.remarks_name)
|
||||
udp_node:value(v.id, v.remarks_name)
|
||||
if v.type == "Socks" then
|
||||
if has_xray then
|
||||
socks_node:value(v.id, v.remarks)
|
||||
socks_node:value(v.id, v.remarks_name)
|
||||
end
|
||||
else
|
||||
socks_node:value(v.id, v.remarks)
|
||||
socks_node:value(v.id, v.remarks_name)
|
||||
end
|
||||
end
|
||||
|
||||
m:append(Template(appname .. "/global/footer"))
|
||||
|
||||
--[[
|
||||
local apply = luci.http.formvalue("cbi.apply")
|
||||
if apply then
|
||||
os.execute("/etc/init.d/" .. appname .." restart")
|
||||
end
|
||||
--]]
|
||||
|
||||
return m
|
||||
|
||||
@ -232,6 +232,9 @@ msgstr "DoH Bootstrap DNS"
|
||||
msgid "The Bootstrap DNS server is used to resolve the IP address of the DoH resolver you specify as the upstream."
|
||||
msgstr "Bootstrap DNS 服务器用于解析您指定为上游的 DoH 解析器的 IP 地址。"
|
||||
|
||||
msgid "China list cannot be used together with outside China list!"
|
||||
msgstr "中国列表不能和中国列表外一起使用!"
|
||||
|
||||
msgid "Cache Resolved"
|
||||
msgstr "缓存解析结果"
|
||||
|
||||
|
||||
@ -286,6 +286,8 @@ LOCALHOST_TCP_PROXY_MODE=$(config_t_get global localhost_tcp_proxy_mode default)
|
||||
LOCALHOST_UDP_PROXY_MODE=$(config_t_get global localhost_udp_proxy_mode default)
|
||||
[ "$LOCALHOST_TCP_PROXY_MODE" == "default" ] && LOCALHOST_TCP_PROXY_MODE=$TCP_PROXY_MODE
|
||||
[ "$LOCALHOST_UDP_PROXY_MODE" == "default" ] && LOCALHOST_UDP_PROXY_MODE=$UDP_PROXY_MODE
|
||||
RESOLVFILE=/tmp/resolv.conf.d/resolv.conf.auto
|
||||
[ -f "${RESOLVFILE}" ] && [ -s "${RESOLVFILE}" ] || RESOLVFILE=/tmp/resolv.conf.auto
|
||||
|
||||
load_config() {
|
||||
[ "$ENABLED" != 1 ] && NO_PROXY=1
|
||||
@ -304,8 +306,6 @@ load_config() {
|
||||
if [ -n "${DEFAULT_DNS}" ]; then
|
||||
IS_DEFAULT_DNS=1
|
||||
else
|
||||
RESOLVFILE=/tmp/resolv.conf.d/resolv.conf.auto
|
||||
[ -f "${RESOLVFILE}" ] && [ -s "${RESOLVFILE}" ] || RESOLVFILE=/tmp/resolv.conf.auto
|
||||
DEFAULT_DNS=$(echo -n $(sed -n 's/^nameserver[ \t]*\([^ ]*\)$/\1/p' "${RESOLVFILE}" | grep -v "0.0.0.0" | grep -v "127.0.0.1" | grep -v "^::$" | head -2) | tr ' ' ',')
|
||||
fi
|
||||
LOCAL_DNS="${DEFAULT_DNS:-119.29.29.29}"
|
||||
@ -501,13 +501,15 @@ run_redir() {
|
||||
local proto="-proto tcp"
|
||||
[ "$UDP_NODE" == "tcp" ] && proto="-proto tcp,udp"
|
||||
local extra_param="${proto}"
|
||||
[ "$(config_t_get global tcp_node_socks 0)" = "1" ] && {
|
||||
local socks_param="-socks_proxy_port $(config_t_get global tcp_node_socks_port 1080)"
|
||||
[ "$tcp_node_socks" = "1" ] && {
|
||||
local socks_param="-socks_proxy_port $tcp_node_socks_port"
|
||||
extra_param="${extra_param} ${socks_param}"
|
||||
config_file=$(echo $config_file | sed "s/TCP/TCP_SOCKS_$tcp_node_socks_id/g")
|
||||
}
|
||||
[ "$(config_t_get global tcp_node_http 0)" = "1" ] && {
|
||||
local http_param="-http_proxy_port $(config_t_get global tcp_node_http_port 1180)"
|
||||
[ "$tcp_node_http" = "1" ] && {
|
||||
local http_param="-http_proxy_port $tcp_node_http_port"
|
||||
extra_param="${extra_param} ${http_param}"
|
||||
config_file=$(echo $config_file | sed "s/TCP/TCP_HTTP_$tcp_node_http_id/g")
|
||||
}
|
||||
lua $API_GEN_XRAY -node $node -redir_port $local_port -loglevel $loglevel $extra_param > $config_file
|
||||
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $log_file -config="$config_file"
|
||||
@ -566,14 +568,14 @@ run_redir() {
|
||||
unset _socks_flag _socks_address _socks_port _socks_username _socks_password
|
||||
|
||||
[ "$type" != "xray" ] && {
|
||||
[ "$(config_t_get global tcp_node_socks 0)" = "1" ] && {
|
||||
local port=$(config_t_get global tcp_node_socks_port 1080)
|
||||
local config_file=$TMP_PATH/SOCKS_TCP.json
|
||||
local log_file=$TMP_PATH/SOCKS_TCP.log
|
||||
[ "$tcp_node_socks" = "1" ] && {
|
||||
local port=$tcp_node_socks_port
|
||||
local config_file=$TMP_PATH/SOCKS_$tcp_node_socks_id.json
|
||||
local log_file=$TMP_PATH/SOCKS_$tcp_node_socks_id.log
|
||||
local http_port=0
|
||||
local http_config_file=$TMP_PATH/HTTP2SOCKS_TCP.json
|
||||
[ "$(config_t_get global tcp_node_http 0)" = "1" ] && {
|
||||
http_port=$(config_t_get global tcp_node_http_port 1180)
|
||||
local http_config_file=$TMP_PATH/HTTP2SOCKS_$tcp_node_http_id.json
|
||||
[ "$tcp_node_http" = "1" ] && {
|
||||
http_port=$tcp_node_http_port
|
||||
}
|
||||
run_socks TCP $TCP_NODE "0.0.0.0" $port $config_file $http_port $http_config_file
|
||||
}
|
||||
@ -629,6 +631,17 @@ start_socks() {
|
||||
local log_file=$TMP_PATH/SOCKS_${id}.log
|
||||
local http_port=$(config_n_get $id http_port 0)
|
||||
local http_config_file=$TMP_PATH/HTTP2SOCKS_${id}.json
|
||||
[ "$node" == "tcp" ] && {
|
||||
tcp_node_socks=1
|
||||
tcp_node_socks_port=$port
|
||||
tcp_node_socks_id=$id
|
||||
[ "$http_port" != "0" ] && {
|
||||
tcp_node_http=1
|
||||
tcp_node_http_port=$http_port
|
||||
tcp_node_http_id=$id
|
||||
}
|
||||
continue
|
||||
}
|
||||
run_socks $id $node "0.0.0.0" $port $config_file $http_port $http_config_file
|
||||
done
|
||||
}
|
||||
|
||||
@ -177,9 +177,9 @@ load_acl() {
|
||||
msg2="${msg2}[$?]除${udp_no_redir_ports}外的"
|
||||
}
|
||||
msg2="${msg2}所有端口"
|
||||
$ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $udp_port TPROXY)
|
||||
$ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $udp_port TPROXY)
|
||||
$ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(get_redirect_ipt $udp_proxy_mode $udp_port TPROXY)
|
||||
$ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $udp_redir_ports "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $udp_port TPROXY)
|
||||
$ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $udp_redir_ports "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $udp_port TPROXY)
|
||||
$ipt_m -A PSW $(comment "$remarks") -p udp $(factor $ip "-s") $(factor $mac "-m mac --mac-source") $(factor $udp_redir_ports "-m multiport --dport") $(get_redirect_ipt $udp_proxy_mode $udp_port TPROXY)
|
||||
}
|
||||
echolog " - ${msg2}"
|
||||
}
|
||||
@ -300,12 +300,12 @@ filter_node() {
|
||||
msg2="直连代理"
|
||||
}
|
||||
$_ipt -I PSW_OUTPUT $ADD_INDEX $(comment "${address}:${port}") -p $stream -d $address --dport $port $dst_rule 2>/dev/null
|
||||
#else
|
||||
# msg2="已配置过的节点,"
|
||||
else
|
||||
msg2="已配置过的节点,"
|
||||
fi
|
||||
done
|
||||
msg="[$?]$(echo ${2} | tr 'a-z' 'A-Z')${msg2}使用链${ADD_INDEX},节点(${type}):${address}:${port}"
|
||||
echolog " - ${msg}"
|
||||
#echolog " - ${msg}"
|
||||
}
|
||||
|
||||
local proxy_protocol=$(config_n_get $proxy_node protocol)
|
||||
@ -517,7 +517,7 @@ add_firewall_rule() {
|
||||
# 过滤Socks节点
|
||||
[ "$SOCKS_ENABLED" = "1" ] && {
|
||||
local ids=$(uci show $CONFIG | grep "=socks" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
|
||||
echolog "分析 Socks 服务所使用节点..."
|
||||
#echolog "分析 Socks 服务所使用节点..."
|
||||
local id enabled node port msg num
|
||||
for id in $ids; do
|
||||
enabled=$(config_n_get $id enabled 0)
|
||||
@ -534,7 +534,7 @@ add_firewall_rule() {
|
||||
filter_node $node TCP > /dev/null 2>&1 &
|
||||
filter_node $node UDP > /dev/null 2>&1 &
|
||||
fi
|
||||
echolog " - ${msg}"
|
||||
#echolog " - ${msg}"
|
||||
done
|
||||
}
|
||||
|
||||
@ -543,16 +543,13 @@ add_firewall_rule() {
|
||||
for stream in TCP UDP; do
|
||||
eval "node=\${${stream}_NODE}"
|
||||
eval "port=\${${stream}_REDIR_PORT}"
|
||||
echolog "分析 $stream 代理自动切换..."
|
||||
#echolog "分析 $stream 代理自动切换..."
|
||||
[ "$node" == "tcp" ] && [ "$stream" == "UDP" ] && {
|
||||
eval "node=\${TCP_NODE}"
|
||||
eval "port=\${TCP_REDIR_PORT}"
|
||||
echolog " - 采用 TCP 代理的配置"
|
||||
}
|
||||
if [ "$node" != "nil" ]; then
|
||||
filter_node $node $stream $port > /dev/null 2>&1 &
|
||||
else
|
||||
echolog " - 忽略无效的 $stream 代理自动切换"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user