mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-29 06:55:13 +08:00
update 2026-08-23 04:16:16
This commit is contained in:
1 parent
9028e829a1
commit
24130de823
25 files changed
+839
-1306
No files matched your search
@@ -248,57 +248,39 @@ end
|
||||
function get_now_use_node()
|
||||
local path = api.TMP_PATH .. "/acl/default"
|
||||
local e = {}
|
||||
local tcp_node = api.get_cache_var("ACL_GLOBAL_TCP_node")
|
||||
if tcp_node then
|
||||
e["TCP"] = tcp_node
|
||||
end
|
||||
local udp_node = api.get_cache_var("ACL_GLOBAL_UDP_node")
|
||||
if udp_node then
|
||||
e["UDP"] = udp_node
|
||||
local node = api.get_cache_var("ACL_GLOBAL_node")
|
||||
if node then
|
||||
e["global"] = node
|
||||
end
|
||||
http_write_json(e)
|
||||
end
|
||||
|
||||
function get_redir_log()
|
||||
local name = http.formvalue("name")
|
||||
local proto = http.formvalue("proto"):upper()
|
||||
local path = api.TMP_PATH .. "/acl/" .. name
|
||||
local id = http.formvalue("id")
|
||||
local path = api.TMP_PATH .. "/acl/" .. id
|
||||
|
||||
local function alert(msg)
|
||||
http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate(msg)))
|
||||
end
|
||||
|
||||
if name == "default" then
|
||||
if proto == "UDP" and (uci_get("@global[0]", "udp_node") or "nil") == "tcp" and not fs.access(path .. "/" .. proto .. ".log") then
|
||||
proto = "TCP"
|
||||
end
|
||||
else
|
||||
local global_tcp = uci_get("@global[0]", "tcp_node") or "nil"
|
||||
local global_udp = uci_get("@global[0]", "udp_node") or "nil"
|
||||
local acl_tcp = uci_get(name, "tcp_node") or "nil"
|
||||
local acl_udp = uci_get(name, "udp_node") or "nil"
|
||||
local name = "global"
|
||||
if id and id ~= "default" then
|
||||
local global_node = uci_get("@global[0]", "node") or "nil"
|
||||
local acl_node = uci_get(id, "node") or "nil"
|
||||
local global_enabled = uci_get("@global[0]", "enabled") == "1"
|
||||
if proto == "TCP" and acl_tcp == global_tcp and global_enabled then
|
||||
if acl_node == global_node and global_enabled then
|
||||
path = api.TMP_PATH .. "/acl/default"
|
||||
if uci_get("@global[0]", "log_tcp") ~= "1" then
|
||||
if uci_get("@global[0]", "log_node") ~= "1" then
|
||||
alert("The access control node is the same as the global node. Please enable global logging.")
|
||||
return
|
||||
end
|
||||
end
|
||||
if proto == "UDP" and acl_udp == global_udp and global_enabled then
|
||||
path = api.TMP_PATH .. "/acl/default"
|
||||
if uci_get("@global[0]", "log_udp") ~= "1" then
|
||||
alert("The access control node is the same as the global node. Please enable global logging.")
|
||||
return
|
||||
end
|
||||
end
|
||||
if proto == "UDP" and acl_udp == "tcp" and not fs.access(path .. "/" .. proto .. ".log") then
|
||||
proto = "TCP"
|
||||
else
|
||||
name = "node"
|
||||
end
|
||||
end
|
||||
|
||||
if fs.access(path .. "/" .. proto .. ".log") then
|
||||
local content = luci.sys.exec("tail -n 19999 ".. path .. "/" .. proto .. ".log")
|
||||
if fs.access(path .. "/" .. name .. ".log") then
|
||||
local content = luci.sys.exec("tail -n 5000 ".. path .. "/" .. name .. ".log")
|
||||
content = content:gsub("\n", "<br />")
|
||||
http.write(content)
|
||||
else
|
||||
@@ -310,7 +292,7 @@ function get_socks_log()
|
||||
local name = http.formvalue("name")
|
||||
local path = api.TMP_PATH .. "/" .. name .. ".log"
|
||||
if fs.access(path) then
|
||||
local content = luci.sys.exec("cat ".. path)
|
||||
local content = luci.sys.exec("tail -n 5000 ".. path)
|
||||
content = content:gsub("\n", "<br />")
|
||||
http.write(content)
|
||||
else
|
||||
@@ -322,9 +304,9 @@ function get_chinadns_log()
|
||||
local flag = http.formvalue("flag")
|
||||
local path = api.TMP_PATH .. "/acl/" .. flag .. "/chinadns_ng.log"
|
||||
if flag ~= "default" then
|
||||
local global_tcp = uci_get("@global[0]", "tcp_node") or "nil"
|
||||
local acl_tcp = uci_get(flag, "tcp_node") or "nil"
|
||||
if acl_tcp == global_tcp and uci_get("@global[0]", "enabled") == "1" then
|
||||
local global_node = uci_get("@global[0]", "node") or "nil"
|
||||
local acl_node = uci_get(flag, "node") or "nil"
|
||||
if acl_node == global_node and uci_get("@global[0]", "enabled") == "1" then
|
||||
path = api.TMP_PATH .. "/acl/default/chinadns_ng.log"
|
||||
if uci_get("@global[0]", "log_chinadns_ng") ~= "1" then
|
||||
http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate("The access control node is the same as the global node. Please enable global logging.")))
|
||||
@@ -332,7 +314,6 @@ function get_chinadns_log()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if fs.access(path) then
|
||||
local content = luci.sys.exec("tail -n 5000 ".. path)
|
||||
content = content:gsub("\n", "<br />")
|
||||
@@ -365,22 +346,29 @@ function index_status()
|
||||
|
||||
e.haproxy_status = "-1"
|
||||
if api.is_finded("haproxy") then
|
||||
e.haproxy_status = (luci.sys.call("/bin/busybox top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null" % appname) == 0) and "0" or "1"
|
||||
e.haproxy_status = (luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep haproxy >/dev/null" % appname) == 0) and "0" or "1"
|
||||
end
|
||||
|
||||
e["tcp_node_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep 'default' | grep 'TCP' >/dev/null" % api.TMP_PATH) == 0
|
||||
|
||||
if (uci_get("@global[0]", "udp_node") or "nil") == "tcp" then
|
||||
e["udp_node_status"] = e["tcp_node_status"]
|
||||
else
|
||||
e["udp_node_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep 'default' | grep 'UDP' >/dev/null" % api.TMP_PATH) == 0
|
||||
if api.get_cache_var("ENABLED_DEFAULT_ACL") == "1" then
|
||||
local has_tproxy = api.get_cache_var("HAS_TPROXY")
|
||||
if not has_tproxy then
|
||||
local handle = io.popen("lsmod")
|
||||
local mods = handle and handle:read("*a") or ""
|
||||
if handle then handle:close() end
|
||||
has_tproxy = (mods:find("TPROXY") or mods:find("nft_tproxy")) and "1" or "0"
|
||||
api.set_cache_var("HAS_TPROXY", has_tproxy)
|
||||
end
|
||||
e["tcp_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep 'default' | grep 'global' >/dev/null" % api.TMP_PATH) == 0
|
||||
if has_tproxy == "1" then
|
||||
e["udp_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v -E 'grep|naive' | grep '%s/bin/' | grep 'default' | grep 'global' >/dev/null" % api.TMP_PATH) == 0
|
||||
end
|
||||
end
|
||||
http_write_json(e)
|
||||
end
|
||||
|
||||
function haproxy_status()
|
||||
local e = {}
|
||||
e["status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null" % appname) == 0
|
||||
e["status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep haproxy >/dev/null" % appname) == 0
|
||||
http_write_json(e)
|
||||
end
|
||||
|
||||
@@ -408,7 +396,7 @@ function connect_status()
|
||||
local gfw_list = uci_get("@global[0]", "use_gfw_list") or "1"
|
||||
local proxy_mode = uci_get("@global[0]", "tcp_proxy_mode") or "proxy"
|
||||
local localhost_proxy = uci_get("@global[0]", "localhost_proxy") or "1"
|
||||
local socks_server = (localhost_proxy == "0") and api.get_cache_var("GLOBAL_TCP_SOCKS_server") or ""
|
||||
local socks_server = (localhost_proxy == "0") and api.get_cache_var("GLOBAL_SOCKS_server") or ""
|
||||
url = "-w %{http_code}:%{time_pretransfer} " .. url
|
||||
if socks_server and socks_server ~= "" then
|
||||
if (chn_list == "proxy" and gfw_list == "0" and proxy_mode ~= "proxy" and aliyun ~= nil) or (chn_list == "0" and gfw_list == "0" and proxy_mode == "proxy") then
|
||||
@@ -515,23 +503,24 @@ function add_node()
|
||||
end
|
||||
|
||||
function set_node()
|
||||
local protocol = http.formvalue("protocol")
|
||||
local type = http.formvalue("type")
|
||||
local config = http.formvalue("config")
|
||||
local section = http.formvalue("section")
|
||||
uci_set("@global[0]", protocol .. "_node", section)
|
||||
if protocol == "tcp" then
|
||||
if type == "@global[0]" then
|
||||
local node_protocol = uci_get(section, "protocol")
|
||||
if node_protocol == "_shunt" then
|
||||
local type = uci_get(section, "type")
|
||||
local dns_shunt = uci_get("@global[0]", "dns_shunt")
|
||||
local node_type = uci_get(section, "type")
|
||||
local dns_shunt = uci_get(type, "dns_shunt")
|
||||
local dns_key = (dns_shunt == "smartdns") and "smartdns_dns_mode" or "dns_mode"
|
||||
local dns_mode = uci_get("@global[0]", dns_key)
|
||||
local new_dns_mode = (type == "Xray") and "xray" or "sing-box"
|
||||
local dns_mode = uci_get(type, dns_key)
|
||||
local new_dns_mode = (node_type == "Xray") and "xray" or "sing-box"
|
||||
if dns_mode ~= new_dns_mode then
|
||||
uci_set("@global[0]", dns_key, new_dns_mode)
|
||||
uci_set("@global[0]", "v2ray_dns_mode", "tcp")
|
||||
uci_set(type, dns_key, new_dns_mode)
|
||||
uci_set(type, "v2ray_dns_mode", "tcp")
|
||||
end
|
||||
end
|
||||
end
|
||||
uci_set(type, config, section)
|
||||
uci_save(true, true)
|
||||
http.redirect(api.url("log"))
|
||||
end
|
||||
@@ -555,8 +544,7 @@ function clear_all_nodes()
|
||||
uci_set('@global[0]', "enabled", "0")
|
||||
uci_set('@global[0]', "socks_enabled", "0")
|
||||
uci_set('@global_haproxy[0]', "balancing_enable", "0")
|
||||
uci_del('@global[0]', "tcp_node")
|
||||
uci_del('@global[0]', "udp_node")
|
||||
uci_del('@global[0]', "node")
|
||||
uci_foreach("socks", function(t)
|
||||
uci_del(t[".name"])
|
||||
uci_set(t[".name"], "autoswitch_backup_node", {})
|
||||
@@ -565,8 +553,7 @@ function clear_all_nodes()
|
||||
uci_del(t[".name"])
|
||||
end)
|
||||
uci_foreach("acl_rule", function(t)
|
||||
uci_del(t[".name"], "tcp_node")
|
||||
uci_del(t[".name"], "udp_node")
|
||||
uci_del(t[".name"], "node")
|
||||
end)
|
||||
uci_foreach("nodes", function(node)
|
||||
uci_del(node['.name'])
|
||||
@@ -587,11 +574,8 @@ function delete_select_nodes()
|
||||
local ids_t = {}
|
||||
string.gsub(ids, '[^' .. "," .. ']+', function(w)
|
||||
ids_t[#ids_t + 1] = w
|
||||
if (uci_get("@global[0]", "tcp_node") or "") == w then
|
||||
uci_del('@global[0]', "tcp_node")
|
||||
end
|
||||
if (uci_get("@global[0]", "udp_node") or "") == w then
|
||||
uci_del('@global[0]', "udp_node")
|
||||
if (uci_get("@global[0]", "node") or "") == w then
|
||||
uci_del('@global[0]', "node")
|
||||
end
|
||||
uci_foreach("socks", function(t)
|
||||
local changed = false
|
||||
@@ -620,11 +604,8 @@ function delete_select_nodes()
|
||||
end
|
||||
end)
|
||||
uci_foreach("acl_rule", function(t)
|
||||
if t["tcp_node"] == w then
|
||||
uci_del(t[".name"], "tcp_node")
|
||||
end
|
||||
if t["udp_node"] == w then
|
||||
uci_del(t[".name"], "udp_node")
|
||||
if t["node"] == w then
|
||||
uci_del(t[".name"], "node")
|
||||
end
|
||||
end)
|
||||
uci_foreach("nodes", function(t)
|
||||
|
||||
@@ -128,31 +128,25 @@ sources.validate = function(self, value, t)
|
||||
flag = true
|
||||
end
|
||||
end
|
||||
|
||||
if flag == false and datatypes.macaddr(v) then
|
||||
flag = true
|
||||
end
|
||||
|
||||
if flag == false and datatypes.ip4addr(v) then
|
||||
flag = true
|
||||
end
|
||||
|
||||
if flag == false and api.iprange(v) then
|
||||
flag = true
|
||||
end
|
||||
|
||||
if flag == false then
|
||||
err[#err + 1] = v
|
||||
end
|
||||
end
|
||||
|
||||
if #err > 0 then
|
||||
self:add_error(t, "invalid", translate("Not true format, please re-enter!"))
|
||||
for _, v in ipairs(err) do
|
||||
self:add_error(t, "invalid", v)
|
||||
end
|
||||
end
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
@@ -195,57 +189,16 @@ o.default = "0"
|
||||
o.rmempty = false
|
||||
o:depends({ _hide_node_option = "1", ['!reverse'] = true })
|
||||
|
||||
o = s:option(ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>")
|
||||
o = s:option(ListValue, "node", "<a style='color: red'>" .. translate("Proxy Node") .. "</a>")
|
||||
o.default = ""
|
||||
o:depends({ _hide_node_option = false, use_global_config = false })
|
||||
o.template = m:template_path("/cbi/nodes_listvalue")
|
||||
o.group = {}
|
||||
o.remove = function(self, section)
|
||||
m:del(section, self.option)
|
||||
m:del(section, "udp_node")
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "_tcp_node_bool", "")
|
||||
o = s:option(DummyValue, "_acl_node_bool", "")
|
||||
o.template = m:template_path("/cbi/hidevalue")
|
||||
o.value = "1"
|
||||
o:depends({ tcp_node = "", ['!reverse'] = true })
|
||||
|
||||
o = s:option(ListValue, "udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
|
||||
o.default = ""
|
||||
o:value("", translate("Close"))
|
||||
o:value("tcp", translate("Same as the tcp node"))
|
||||
o:depends({ _tcp_node_bool = "1", _node_sel_other = "1" })
|
||||
o.template = m:template_path("/cbi/nodes_listvalue")
|
||||
o.group = {"",""}
|
||||
o.remove = function(self, section)
|
||||
local v = s.fields["shunt_udp_node"]:formvalue(section)
|
||||
if not v or v == "close" then
|
||||
return m:del(section, self.option)
|
||||
else
|
||||
return m:set(section, self.option, "tcp")
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(ListValue, "shunt_udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
|
||||
o:value("close", translate("Close"))
|
||||
o:value("tcp", translate("Same as the tcp node"))
|
||||
o:depends({ _tcp_node_bool = "1", _node_sel_shunt = "1" })
|
||||
o.cfgvalue = function(self, section)
|
||||
local v = m:get(section, "udp_node") or ""
|
||||
if v == "" then v = "close" end
|
||||
if v ~= "close" and v ~= "tcp" then v = "tcp" end
|
||||
return v
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
if value == "close" then value = "" end
|
||||
return m:set(section, "udp_node", value)
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "_udp_node_bool", "")
|
||||
o.template = m:template_path("/cbi/hidevalue")
|
||||
o.value = "1"
|
||||
o:depends({ udp_node = "", ['!reverse'] = true })
|
||||
o:depends({ shunt_udp_node = "tcp" })
|
||||
o:depends({ node = "", ['!reverse'] = true })
|
||||
|
||||
---- Log
|
||||
o = s:option(Flag, "log", translate("Enable Node Log"))
|
||||
@@ -268,7 +221,7 @@ o:value("", translate("Use global config") .. "(" .. TCP_PROXY_DROP_PORTS .. ")"
|
||||
o:value("disable", translate("No patterns are used"))
|
||||
o.validate = port_validate
|
||||
o:depends({ use_global_config = true })
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
---- UDP Proxy Drop Ports
|
||||
local UDP_PROXY_DROP_PORTS = m:get("@global_forwarding[0]", "udp_proxy_drop_ports")
|
||||
@@ -278,7 +231,7 @@ o:value("disable", translate("No patterns are used"))
|
||||
o:value("443", translate("QUIC"))
|
||||
o.validate = port_validate
|
||||
o:depends({ use_global_config = true })
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
---- TCP Redir Ports
|
||||
local TCP_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_redir_ports")
|
||||
@@ -290,7 +243,7 @@ o:value("80:65535", "80 " .. translate("or more"))
|
||||
o:value("1:443", "443 " .. translate("or less"))
|
||||
o.validate = port_validate
|
||||
o:depends({ use_global_config = true })
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
---- UDP Redir Ports
|
||||
local UDP_REDIR_PORTS = m:get("@global_forwarding[0]", "udp_redir_ports")
|
||||
@@ -300,7 +253,7 @@ o:value("1:65535", translate("All"))
|
||||
o:value("53", "53")
|
||||
o.validate = port_validate
|
||||
o:depends({ use_global_config = true })
|
||||
o:depends({ _udp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
o = s:option(DummyValue, "tips", " ")
|
||||
o.rawhtml = true
|
||||
@@ -309,24 +262,24 @@ o.cfgvalue = function(t, n)
|
||||
translate("The port settings support single ports and ranges.<br>Separate multiple ports with commas (,).<br>Example: 21,80,443,1000:2000."))
|
||||
end
|
||||
o:depends({ use_global_config = true })
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
o = s:option(Flag, "use_direct_list", translatef("Use %s", translate("Direct List")))
|
||||
o.default = "1"
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
o = s:option(Flag, "use_proxy_list", translatef("Use %s", translate("Proxy List")))
|
||||
o.default = "1"
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
o = s:option(Flag, "use_block_list", translatef("Use %s", translate("Block List")))
|
||||
o.default = "1"
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
if has_gfwlist then
|
||||
o = s:option(Flag, "use_gfw_list", translatef("Use %s", translate("GFW List")))
|
||||
o.default = "1"
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
end
|
||||
|
||||
if has_chnlist or has_chnroute then
|
||||
@@ -335,28 +288,28 @@ 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_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
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_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
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_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
o = s:option(DummyValue, "switch_mode", " ")
|
||||
o.template = m:template_path("/global/proxy")
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
-- Node → DNS Depends Settings
|
||||
o = s:option(DummyValue, "_node_sel_shunt", "")
|
||||
o.template = m:template_path("/cbi/hidevalue")
|
||||
o.value = "1"
|
||||
o:depends({ tcp_node = "__always__" })
|
||||
o:depends({ node = "__always__" })
|
||||
|
||||
o = s:option(DummyValue, "_node_sel_other", "")
|
||||
o.template = m:template_path("/cbi/hidevalue")
|
||||
@@ -368,11 +321,11 @@ o = s:option(ListValue, "dns_shunt", "DNS " .. translate("Shunt"))
|
||||
o.default = "chinadns-ng"
|
||||
o:value("dnsmasq", "Dnsmasq")
|
||||
o:value("chinadns-ng", translate("ChinaDNS-NG (recommended)"))
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
o = s:option(Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"), translate("Experimental feature."))
|
||||
o.default = "0"
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o:depends({ _acl_node_bool = "1" })
|
||||
|
||||
---- DNS Forward Mode
|
||||
o = s:option(ListValue, "dns_mode", translate("Filter Mode"))
|
||||
@@ -385,7 +338,7 @@ end
|
||||
if has_xray then
|
||||
o:value("xray", "Xray")
|
||||
end
|
||||
o:depends({ _tcp_node_bool = "1", _node_sel_other = "1" })
|
||||
o:depends({ _acl_node_bool = "1", _node_sel_other = "1" })
|
||||
o.write = function(self, section, value)
|
||||
if value == "dns2socks" then
|
||||
m:del(section, "v2ray_dns_mode")
|
||||
@@ -393,7 +346,7 @@ o.write = function(self, section, value)
|
||||
return ListValue.write(self, section, value)
|
||||
end
|
||||
o.remove = function(self, section)
|
||||
local f = s.fields["tcp_node"]
|
||||
local f = s.fields["node"]
|
||||
local id_val = f and f:formvalue(section) or ""
|
||||
if id_val == "" then
|
||||
return m:del(section, self.option)
|
||||
@@ -517,10 +470,10 @@ o:depends({dns_mode = "xray"})
|
||||
o.validate = function(self, value, t)
|
||||
if value and value == "1" then
|
||||
local _dns_mode = s.fields["dns_mode"]:formvalue(t)
|
||||
local _tcp_node = s.fields["tcp_node"]:formvalue(t)
|
||||
if _dns_mode and _tcp_node then
|
||||
if (m:get(_tcp_node, "type") or ""):lower() ~= _dns_mode and not _tcp_node:find("socks_") then
|
||||
return nil, translatef("TCP node must be '%s' type to use FakeDNS.", _dns_mode)
|
||||
local _node = s.fields["node"]:formvalue(t)
|
||||
if _dns_mode and _node then
|
||||
if (m:get(_node, "type") or ""):lower() ~= _dns_mode and not _node:find("socks_") then
|
||||
return nil, translatef("Node must be '%s' type to use FakeDNS.", _dns_mode)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -562,44 +515,35 @@ o:value("direct", translate("Direct DNS"))
|
||||
o.description = desc .. "</ul>"
|
||||
o:depends({dns_shunt = "dnsmasq", tcp_proxy_mode = "proxy", chn_list = "direct"})
|
||||
|
||||
local tcp = s.fields["tcp_node"]
|
||||
local udp = s.fields["udp_node"]
|
||||
local o_node = s.fields["node"]
|
||||
for k, v in pairs(socks_list) do
|
||||
tcp:value(v.id, v["remark"])
|
||||
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
udp:value(v.id, v["remark"])
|
||||
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_node:value(v.id, v["remark"])
|
||||
o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
for k, v in pairs(nodes_table) do
|
||||
if #normal_list == 0 then
|
||||
s.fields["dns_mode"]:depends({ _tcp_node_bool = "1" })
|
||||
s.fields["dns_mode"]:depends({ _acl_node_bool = "1" })
|
||||
break
|
||||
end
|
||||
if v.protocol == "_shunt" then
|
||||
if v.type == "Xray" and has_xray then
|
||||
tcp:value(v.id, v["remark"])
|
||||
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
udp:value(v.id, v["remark"])
|
||||
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_node:value(v.id, v["remark"])
|
||||
o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
|
||||
s.fields["xray_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
|
||||
s.fields["_node_sel_shunt"]:depends({ tcp_node = v.id })
|
||||
s.fields["xray_dns_mode"]:depends({ _acl_node_bool = "1", node = v.id })
|
||||
s.fields["_node_sel_shunt"]:depends({ node = v.id })
|
||||
end
|
||||
if v.type == "sing-box" and has_singbox then
|
||||
tcp:value(v.id, v["remark"])
|
||||
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
udp:value(v.id, v["remark"])
|
||||
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_node:value(v.id, v["remark"])
|
||||
o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
|
||||
s.fields["singbox_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
|
||||
s.fields["_node_sel_shunt"]:depends({ tcp_node = v.id })
|
||||
s.fields["remote_rewrite_ttl"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
|
||||
s.fields["singbox_dns_mode"]:depends({ _acl_node_bool = "1", node = v.id })
|
||||
s.fields["_node_sel_shunt"]:depends({ node = v.id })
|
||||
s.fields["remote_rewrite_ttl"]:depends({ _acl_node_bool = "1", node = v.id })
|
||||
end
|
||||
else
|
||||
tcp:value(v.id, v["remark"])
|
||||
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
udp:value(v.id, v["remark"])
|
||||
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_node:value(v.id, v["remark"])
|
||||
o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ end
|
||||
|
||||
local socks_list = {}
|
||||
|
||||
local tcp_socks_server = "127.0.0.1" .. ":" .. (m:get("@global[0]", "tcp_node_socks_port") or "1070")
|
||||
local socks_server = "127.0.0.1" .. ":" .. (m:get("@global[0]", "node_socks_port") or "1070")
|
||||
local socks_table = {}
|
||||
socks_table[#socks_table + 1] = {
|
||||
id = tcp_socks_server,
|
||||
remark = tcp_socks_server .. " - " .. translate("TCP Node")
|
||||
id = socks_server,
|
||||
remark = socks_server .. " - " .. translate("Proxy Node")
|
||||
}
|
||||
m:foreach("socks", function(s)
|
||||
if s.enabled == "1" and s.node then
|
||||
@@ -103,44 +103,13 @@ s:tab("Main", translate("Main"))
|
||||
o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
|
||||
o.rmempty = false
|
||||
|
||||
---- TCP Node
|
||||
o = s:taboption("Main", ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>")
|
||||
---- Node
|
||||
o = s:taboption("Main", ListValue, "node", "<a style='color: red'>" .. translate("Proxy Node") .. "</a>")
|
||||
o.template = m:template_path("/cbi/nodes_listvalue")
|
||||
o:value("", translate("Close"))
|
||||
o.group = {""}
|
||||
|
||||
---- UDP Node
|
||||
o = s:taboption("Main", ListValue, "udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
|
||||
o.template = m:template_path("/cbi/nodes_listvalue")
|
||||
o:value("", translate("Close"))
|
||||
o:value("tcp", translate("Same as the tcp node"))
|
||||
o.group = {"",""}
|
||||
o:depends("_node_sel_other", "1")
|
||||
o.remove = function(self, section)
|
||||
local v = s.fields["shunt_udp_node"]:formvalue(section)
|
||||
if not v or v == "close" then
|
||||
return m:del(section, self.option)
|
||||
else
|
||||
return m:set(section, self.option, "tcp")
|
||||
end
|
||||
end
|
||||
|
||||
o = s:taboption("Main", ListValue, "shunt_udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
|
||||
o:value("close", translate("Close"))
|
||||
o:value("tcp", translate("Same as the tcp node"))
|
||||
o:depends("_node_sel_shunt", "1")
|
||||
o.cfgvalue = function(self, section)
|
||||
local v = m:get(section, "udp_node") or ""
|
||||
if v == "" then v = "close" end
|
||||
if v ~= "close" and v ~= "tcp" then v = "tcp" end
|
||||
return v
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
if value == "close" then value = "" end
|
||||
return m:set(section, "udp_node", value)
|
||||
end
|
||||
|
||||
current_node_id = m:get(s.section, "tcp_node")
|
||||
current_node_id = m:get(s.section, "node")
|
||||
current_node = current_node_id and m:get(current_node_id) or {}
|
||||
|
||||
-- Shunt Start
|
||||
@@ -157,7 +126,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
|
||||
balancing_list = balancing_list,
|
||||
iface_list = iface_list,
|
||||
normal_list = normal_list,
|
||||
verify_option = s.fields["tcp_node"],
|
||||
verify_option = s.fields["node"],
|
||||
tab = "Shunt",
|
||||
tab_desc = translate("Shunt Rule")
|
||||
})
|
||||
@@ -168,36 +137,36 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
|
||||
tips.cfgvalue = function(t, n)
|
||||
return string.format('<a style="color: red">%s</a>', translate("There are no available nodes, please add or subscribe nodes first."))
|
||||
end
|
||||
tips:depends({ tcp_node = "", ["!reverse"] = true })
|
||||
tips:depends({ node = "", ["!reverse"] = true })
|
||||
for k, v in pairs(shunt_list) do
|
||||
tips:depends("tcp_node", v.id)
|
||||
tips:depends("node", v.id)
|
||||
end
|
||||
for k, v in pairs(balancing_list) do
|
||||
tips:depends("tcp_node", v.id)
|
||||
tips:depends("node", v.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
o = s:taboption("Main", Value, "tcp_node_socks_port", translate("TCP Node") .. " Socks " .. translate("Listen Port"))
|
||||
o = s:taboption("Main", Value, "node_socks_port", translate("Node") .. " Socks " .. translate("Listen Port"))
|
||||
o.default = 1070
|
||||
o.datatype = "port"
|
||||
o:depends({ tcp_node = "", ["!reverse"] = true })
|
||||
o:depends({ node = "", ["!reverse"] = true })
|
||||
--[[
|
||||
if has_singbox or has_xray then
|
||||
o = s:taboption("Main", Value, "tcp_node_http_port", translate("TCP Node") .. " HTTP " .. translate("Listen Port") .. " " .. translate("0 is not use"))
|
||||
o = s:taboption("Main", Value, "node_http_port", translate("Node") .. " HTTP " .. translate("Listen Port") .. " " .. translate("0 is not use"))
|
||||
o.default = 0
|
||||
o.datatype = "port"
|
||||
end
|
||||
]]--
|
||||
o = s:taboption("Main", Flag, "tcp_node_socks_bind_local", translate("TCP Node") .. " Socks " .. translate("Bind Local"), translate("When selected, it can only be accessed localhost."))
|
||||
o = s:taboption("Main", Flag, "node_socks_bind_local", translate("Node") .. " Socks " .. translate("Bind Local"), translate("When selected, it can only be accessed localhost."))
|
||||
o.default = "1"
|
||||
o:depends({ tcp_node = "", ["!reverse"] = true })
|
||||
o:depends({ node = "", ["!reverse"] = true })
|
||||
|
||||
-- Node → DNS Depends Settings
|
||||
o = s:taboption("Main", DummyValue, "_node_sel_shunt", "")
|
||||
o.template = m:template_path("/cbi/hidevalue")
|
||||
o.value = "1"
|
||||
o:depends({ tcp_node = "__always__" })
|
||||
o:depends({ node = "__always__" })
|
||||
|
||||
o = s:taboption("Main", DummyValue, "_node_sel_other", "")
|
||||
o.template = m:template_path("/cbi/hidevalue")
|
||||
@@ -256,9 +225,9 @@ o:depends("direct_dns_mode", "tcp")
|
||||
o = s:taboption("DNS", Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"))
|
||||
o.default = "0"
|
||||
|
||||
-- TCP分流时dns过滤模式保存逻辑
|
||||
-- 分流时dns过滤模式保存逻辑
|
||||
function dns_mode_save(section)
|
||||
local f = s.fields["tcp_node"]
|
||||
local f = s.fields["node"]
|
||||
local id_val = f and f:formvalue(section) or ""
|
||||
if id_val == "" then
|
||||
return
|
||||
@@ -478,10 +447,10 @@ o.validate = function(self, value, t)
|
||||
if not _dns_mode and s.fields["smartdns_dns_mode"] then
|
||||
_dns_mode = s.fields["smartdns_dns_mode"]:formvalue(t)
|
||||
end
|
||||
local _tcp_node = s.fields["tcp_node"]:formvalue(t)
|
||||
if _dns_mode and _tcp_node then
|
||||
if (m:get(_tcp_node, "type") or ""):lower() ~= _dns_mode and not _tcp_node:find("socks_") then
|
||||
return nil, translatef("TCP node must be '%s' type to use FakeDNS.", _dns_mode)
|
||||
local _node = s.fields["node"]:formvalue(t)
|
||||
if _dns_mode and _node then
|
||||
if (m:get(_node, "type") or ""):lower() ~= _dns_mode and not _node:find("socks_") then
|
||||
return nil, translatef("Node must be '%s' type to use FakeDNS.", _dns_mode)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -625,11 +594,7 @@ o.cfgvalue = function(t, n)
|
||||
end
|
||||
|
||||
s:tab("log", translate("Log"))
|
||||
o = s:taboption("log", Flag, "log_tcp", translate("Enable") .. " " .. translatef("%s Node Log", "TCP"))
|
||||
o.default = "0"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("log", Flag, "log_udp", translate("Enable") .. " " .. translatef("%s Node Log", "UDP"))
|
||||
o = s:taboption("log", Flag, "log_node", translate("Enable Node Log"))
|
||||
o.default = "0"
|
||||
o.rmempty = false
|
||||
|
||||
@@ -691,18 +656,12 @@ function s2.remove(e, t)
|
||||
if node0 then
|
||||
new_node = node0[".name"]
|
||||
end
|
||||
if (m:get("@global[0]", "tcp_node") or "") == t then
|
||||
m:set('@global[0]', "tcp_node", new_node)
|
||||
end
|
||||
if (m:get("@global[0]", "udp_node") or "") == t then
|
||||
m:set('@global[0]', "udp_node", new_node)
|
||||
if (m:get("@global[0]", "node") or "") == t then
|
||||
m:set('@global[0]', "node", new_node)
|
||||
end
|
||||
m:foreach("acl_rule", function(s)
|
||||
if s["tcp_node"] and s["tcp_node"] == t then
|
||||
m:set(s[".name"], "tcp_node", "default")
|
||||
end
|
||||
if s["udp_node"] and s["udp_node"] == t then
|
||||
m:set(s[".name"], "udp_node", "default")
|
||||
if s["node"] and s["node"] == t then
|
||||
m:set(s[".name"], "node", "default")
|
||||
end
|
||||
end)
|
||||
m:foreach("nodes", function(s)
|
||||
@@ -779,14 +738,11 @@ if has_singbox or has_xray then
|
||||
end
|
||||
]]--
|
||||
|
||||
local tcp = s.fields["tcp_node"]
|
||||
local udp = s.fields["udp_node"]
|
||||
local socks = s2.fields["node"]
|
||||
local o_node = s.fields["node"]
|
||||
local o_socks = s2.fields["node"]
|
||||
for k, v in pairs(socks_list) do
|
||||
tcp:value(v.id, v["remark"])
|
||||
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
udp:value(v.id, v["remark"])
|
||||
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_node:value(v.id, v["remark"])
|
||||
o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
for k, v in pairs(nodes_table) do
|
||||
if #normal_list == 0 and #iface_list == 0 then
|
||||
@@ -794,33 +750,29 @@ for k, v in pairs(nodes_table) do
|
||||
end
|
||||
if v.protocol == "_shunt" then
|
||||
if has_singbox or has_xray then
|
||||
tcp:value(v.id, v["remark"])
|
||||
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
udp:value(v.id, v["remark"])
|
||||
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_node:value(v.id, v["remark"])
|
||||
o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
|
||||
s.fields["_node_sel_shunt"]:depends({ tcp_node = v.id })
|
||||
s.fields["_node_sel_shunt"]:depends({ node = v.id })
|
||||
if m:get(v.id, "type") == "Xray" then
|
||||
s.fields["xray_dns_mode"]:depends({ tcp_node = v.id })
|
||||
s.fields["xray_dns_mode"]:depends({ node = v.id })
|
||||
else
|
||||
s.fields["singbox_dns_mode"]:depends({ tcp_node = v.id })
|
||||
s.fields["remote_rewrite_ttl"]:depends({ tcp_node = v.id })
|
||||
s.fields["singbox_dns_mode"]:depends({ node = v.id })
|
||||
s.fields["remote_rewrite_ttl"]:depends({ node = v.id })
|
||||
end
|
||||
end
|
||||
else
|
||||
tcp:value(v.id, v["remark"])
|
||||
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
udp:value(v.id, v["remark"])
|
||||
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_node:value(v.id, v["remark"])
|
||||
o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
if v.type == "Socks" then
|
||||
if has_singbox or has_xray then
|
||||
socks:value(v.id, v["remark"])
|
||||
socks.group[#socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_socks:value(v.id, v["remark"])
|
||||
o_socks.group[#o_socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
else
|
||||
socks:value(v.id, v["remark"])
|
||||
socks.group[#socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
o_socks:value(v.id, v["remark"])
|
||||
o_socks.group[#o_socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -119,11 +119,8 @@ o:value("1", "Nftables")
|
||||
|
||||
---- Check the transparent proxy component
|
||||
local handle = io.popen("lsmod")
|
||||
local mods = ""
|
||||
if handle then
|
||||
mods = handle:read("*a") or ""
|
||||
handle:close()
|
||||
end
|
||||
local mods = handle and handle:read("*a") or ""
|
||||
if handle then handle:close() end
|
||||
|
||||
if (mods:find("REDIRECT") and mods:find("TPROXY")) or (mods:find("nft_redir") and mods:find("nft_tproxy")) then
|
||||
o = s:option(ListValue, "tcp_proxy_way", translate("TCP Proxy Way"))
|
||||
|
||||
@@ -258,7 +258,7 @@ end
|
||||
|
||||
function curl_proxy(url, file, args)
|
||||
--使用代理
|
||||
local socks_server = get_cache_var("GLOBAL_TCP_SOCKS_server")
|
||||
local socks_server = get_cache_var("GLOBAL_SOCKS_server")
|
||||
if socks_server and socks_server ~= "" then
|
||||
if not args then args = {} end
|
||||
local tmp_args = clone(args)
|
||||
|
||||
@@ -73,8 +73,7 @@ function gen_config(var)
|
||||
return
|
||||
end
|
||||
local node = api.uci_get_c(node_id)
|
||||
local local_tcp_redir_port = var["local_tcp_redir_port"]
|
||||
local local_udp_redir_port = var["local_udp_redir_port"]
|
||||
local local_redir_port = var["local_redir_port"]
|
||||
local local_socks_address = var["local_socks_address"] or "0.0.0.0"
|
||||
local local_socks_port = var["local_socks_port"]
|
||||
local local_socks_username = var["local_socks_username"]
|
||||
@@ -170,14 +169,14 @@ function gen_config(var)
|
||||
username = (local_http_username and local_http_password) and local_http_username or nil,
|
||||
password = (local_http_username and local_http_password) and local_http_password or nil,
|
||||
} or nil,
|
||||
tcpRedirect = ("redirect" == tcp_proxy_way and local_tcp_redir_port) and {
|
||||
listen = "0.0.0.0:" .. local_tcp_redir_port
|
||||
tcpRedirect = ("redirect" == tcp_proxy_way and local_redir_port) and {
|
||||
listen = "0.0.0.0:" .. local_redir_port
|
||||
} or nil,
|
||||
tcpTProxy = ("tproxy" == tcp_proxy_way and local_tcp_redir_port) and {
|
||||
listen = "0.0.0.0:" .. local_tcp_redir_port
|
||||
tcpTProxy = ("tproxy" == tcp_proxy_way and local_redir_port) and {
|
||||
listen = "0.0.0.0:" .. local_redir_port
|
||||
} or nil,
|
||||
udpTProxy = (local_udp_redir_port) and {
|
||||
listen = "0.0.0.0:" .. local_udp_redir_port
|
||||
udpTProxy = (local_redir_port) and {
|
||||
listen = "0.0.0.0:" .. local_redir_port
|
||||
} or nil
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,8 @@ function gen_config(var)
|
||||
local local_http_port = var["local_http_port"]
|
||||
local local_http_username = var["local_http_username"]
|
||||
local local_http_password = var["local_http_password"]
|
||||
local local_tcp_redir_port = var["local_tcp_redir_port"]
|
||||
local local_tcp_redir_address = var["local_tcp_redir_address"] or "0.0.0.0"
|
||||
local local_udp_redir_port = var["local_udp_redir_port"]
|
||||
local local_udp_redir_address = var["local_udp_redir_address"] or "0.0.0.0"
|
||||
local local_redir_port = var["local_redir_port"]
|
||||
local local_redir_address = var["local_redir_address"] or "0.0.0.0"
|
||||
|
||||
if api.is_ipv6(server_host) then
|
||||
server_host = api.get_ipv6_only(server_host)
|
||||
@@ -118,21 +116,13 @@ function gen_config(var)
|
||||
local_port = tonumber(local_http_port)
|
||||
})
|
||||
end
|
||||
if local_tcp_redir_address and local_tcp_redir_port then
|
||||
if local_redir_address and local_redir_port then
|
||||
table.insert(config.locals, {
|
||||
protocol = "redir",
|
||||
mode = "tcp_only",
|
||||
mode = "tcp_and_udp",
|
||||
tcp_redir = var["tcp_tproxy"] and "tproxy" or nil,
|
||||
local_address = local_tcp_redir_address,
|
||||
local_port = tonumber(local_tcp_redir_port)
|
||||
})
|
||||
end
|
||||
if local_udp_redir_address and local_udp_redir_port then
|
||||
table.insert(config.locals, {
|
||||
protocol = "redir",
|
||||
mode = "udp_only",
|
||||
local_address = local_udp_redir_address,
|
||||
local_port = tonumber(local_udp_redir_port)
|
||||
local_address = local_redir_address,
|
||||
local_port = tonumber(local_redir_port)
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1087,8 +1087,7 @@ function gen_config(var)
|
||||
local server_host = var["server_host"]
|
||||
local server_port = var["server_port"]
|
||||
local tcp_proxy_way = var["tcp_proxy_way"]
|
||||
local tcp_redir_port = var["tcp_redir_port"]
|
||||
local udp_redir_port = var["udp_redir_port"]
|
||||
local redir_port = var["redir_port"]
|
||||
local local_socks_address = var["local_socks_address"] or "0.0.0.0"
|
||||
local local_socks_port = var["local_socks_port"]
|
||||
local local_socks_username = var["local_socks_username"]
|
||||
@@ -1237,43 +1236,34 @@ function gen_config(var)
|
||||
table.insert(inbounds, inbound)
|
||||
end
|
||||
|
||||
if tcp_redir_port then
|
||||
local inbound
|
||||
if redir_port then
|
||||
local inbound_tproxy = {
|
||||
type = "tproxy",
|
||||
tag = "tproxy",
|
||||
listen = "::",
|
||||
listen_port = tonumber(redir_port),
|
||||
}
|
||||
if tcp_proxy_way ~= "tproxy" then
|
||||
inbound = {
|
||||
local inbound = {
|
||||
type = "redirect",
|
||||
tag = "redirect_tcp",
|
||||
listen = "::",
|
||||
listen_port = tonumber(tcp_redir_port)
|
||||
listen_port = tonumber(redir_port),
|
||||
}
|
||||
else
|
||||
inbound = {
|
||||
type = "tproxy",
|
||||
tag = "tproxy_tcp",
|
||||
network = "tcp",
|
||||
listen = "::",
|
||||
listen_port = tonumber(tcp_redir_port)
|
||||
}
|
||||
end
|
||||
table.insert(inbounds, inbound)
|
||||
table.insert(route.rules, {
|
||||
action = "sniff",
|
||||
inbound = inbound.tag
|
||||
})
|
||||
end
|
||||
table.insert(inbounds, inbound)
|
||||
table.insert(route.rules, {
|
||||
action = "sniff",
|
||||
inbound = inbound.tag
|
||||
})
|
||||
|
||||
if udp_redir_port then
|
||||
local inbound = {
|
||||
type = "tproxy",
|
||||
tag = "tproxy_udp",
|
||||
network = "udp",
|
||||
listen = "::",
|
||||
listen_port = tonumber(udp_redir_port)
|
||||
}
|
||||
table.insert(inbounds, inbound)
|
||||
inbound_tproxy.tag = "tproxy_udp"
|
||||
inbound_tproxy.network = "udp"
|
||||
end
|
||||
|
||||
table.insert(inbounds, inbound_tproxy)
|
||||
table.insert(route.rules, {
|
||||
action = "sniff",
|
||||
inbound = inbound.tag
|
||||
inbound = inbound_tproxy.tag
|
||||
})
|
||||
end
|
||||
|
||||
@@ -1315,7 +1305,7 @@ function gen_config(var)
|
||||
ut_nodes = _node.urltest_node
|
||||
end
|
||||
|
||||
api.log(" - 加载 Sing-Box URLTest 节点【" .. (_node.remarks or "") .. "】,子节点数量:" .. #(ut_nodes or {}))
|
||||
-- api.log(" - 加载 Sing-Box URLTest 节点【" .. (_node.remarks or "") .. "】,子节点数量:" .. #(ut_nodes or {}))
|
||||
|
||||
local valid_nodes = {}
|
||||
for i = 1, #(ut_nodes or {}) do
|
||||
@@ -1620,16 +1610,14 @@ function gen_config(var)
|
||||
if e["inbound"] and e["inbound"] ~= "" then
|
||||
inboundTag = {}
|
||||
if e["inbound"]:find("tproxy") then
|
||||
if tcp_redir_port then
|
||||
if redir_port then
|
||||
if tcp_proxy_way == "tproxy" then
|
||||
table.insert(inboundTag, "tproxy_tcp")
|
||||
table.insert(inboundTag, "tproxy")
|
||||
else
|
||||
table.insert(inboundTag, "redirect_tcp")
|
||||
table.insert(inboundTag, "tproxy_udp")
|
||||
end
|
||||
end
|
||||
if udp_redir_port then
|
||||
table.insert(inboundTag, "tproxy_udp")
|
||||
end
|
||||
end
|
||||
if e["inbound"]:find("socks") then
|
||||
if local_socks_port then
|
||||
@@ -1987,7 +1975,7 @@ function gen_config(var)
|
||||
local default_dns_flag = "remote"
|
||||
if dns_socks_address and dns_socks_port then
|
||||
else
|
||||
if node_id and (tcp_redir_port or udp_redir_port) then
|
||||
if node_id and redir_port then
|
||||
local node = get_node_by_id(node_id)
|
||||
if node.protocol == "_shunt" then
|
||||
if node.default_node == "_direct" then
|
||||
|
||||
@@ -869,8 +869,7 @@ function gen_config(var)
|
||||
local server_host = var["server_host"]
|
||||
local server_port = var["server_port"]
|
||||
local tcp_proxy_way = var["tcp_proxy_way"] or "redirect"
|
||||
local tcp_redir_port = var["tcp_redir_port"]
|
||||
local udp_redir_port = var["udp_redir_port"]
|
||||
local redir_port = var["redir_port"]
|
||||
local local_socks_address = var["local_socks_address"] or "0.0.0.0"
|
||||
local local_socks_port = var["local_socks_port"]
|
||||
local local_socks_username = var["local_socks_username"]
|
||||
@@ -1068,7 +1067,7 @@ function gen_config(var)
|
||||
blc_nodes = _node.balancing_node
|
||||
end
|
||||
|
||||
api.log(" - 加载 Xray 负载均衡 节点【" .. (_node.remarks or "") .. "】,子节点数量:" .. #(blc_nodes or {}))
|
||||
-- api.log(" - 加载 Xray 负载均衡 节点【" .. (_node.remarks or "") .. "】,子节点数量:" .. #(blc_nodes or {}))
|
||||
|
||||
local valid_nodes = {}
|
||||
for i = 1, #(blc_nodes or {}) do
|
||||
@@ -1448,11 +1447,9 @@ function gen_config(var)
|
||||
if e["inbound"] and e["inbound"] ~= "" then
|
||||
inbound_tag = {}
|
||||
if e["inbound"]:find("tproxy") then
|
||||
if tcp_redir_port then
|
||||
table.insert(inbound_tag, "tcp_redir")
|
||||
end
|
||||
if udp_redir_port then
|
||||
table.insert(inbound_tag, "udp_redir")
|
||||
if redir_port then
|
||||
table.insert(inboundTag, "tcp_redir")
|
||||
table.insert(inboundTag, "udp_redir")
|
||||
end
|
||||
end
|
||||
if e["inbound"]:find("socks") then
|
||||
@@ -1585,13 +1582,14 @@ function gen_config(var)
|
||||
end
|
||||
end
|
||||
|
||||
if tcp_redir_port or udp_redir_port then
|
||||
if redir_port then
|
||||
local inbound = {
|
||||
port = tonumber(redir_port),
|
||||
protocol = "tunnel",
|
||||
settings = {allowedNetwork = "tcp,udp", followRedirect = true},
|
||||
streamSettings = {sockopt = {tproxy = "tproxy"}},
|
||||
sniffing = {
|
||||
enabled = (xray_settings.sniffing_override_dest == "1") or (node and node.protocol == "_shunt") or false
|
||||
enabled = xray_settings.sniffing_override_dest == "1" or node.protocol == "_shunt"
|
||||
}
|
||||
}
|
||||
if inbound.sniffing.enabled == true then
|
||||
@@ -1611,22 +1609,16 @@ function gen_config(var)
|
||||
end
|
||||
end
|
||||
|
||||
if tcp_redir_port then
|
||||
local tcp_inbound = api.clone(inbound)
|
||||
tcp_inbound.tag = "tcp_redir"
|
||||
tcp_inbound.settings.allowedNetwork = "tcp"
|
||||
tcp_inbound.port = tonumber(tcp_redir_port)
|
||||
tcp_inbound.streamSettings.sockopt.tproxy = tcp_proxy_way
|
||||
table.insert(inbounds, tcp_inbound)
|
||||
end
|
||||
local tcp_inbound = api.clone(inbound)
|
||||
tcp_inbound.tag = "tcp_redir"
|
||||
tcp_inbound.settings.allowedNetwork = "tcp"
|
||||
tcp_inbound.streamSettings.sockopt.tproxy = tcp_proxy_way
|
||||
table.insert(inbounds, tcp_inbound)
|
||||
|
||||
if udp_redir_port then
|
||||
local udp_inbound = api.clone(inbound)
|
||||
udp_inbound.tag = "udp_redir"
|
||||
udp_inbound.settings.allowedNetwork = "udp"
|
||||
udp_inbound.port = tonumber(udp_redir_port)
|
||||
table.insert(inbounds, udp_inbound)
|
||||
end
|
||||
local udp_inbound = api.clone(inbound)
|
||||
udp_inbound.tag = "udp_redir"
|
||||
udp_inbound.settings.allowedNetwork = "udp"
|
||||
table.insert(inbounds, udp_inbound)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ local sid = self.section
|
||||
if (!node) return false;
|
||||
let changed = false;
|
||||
const all_node = node.querySelectorAll("[id]");
|
||||
const reg1 = /^cbid\..*\.(tcp_node|udp_node)\.main$/;
|
||||
const reg1 = /^cbid\..*node\.main$/;
|
||||
|
||||
for (const el of all_node) {
|
||||
if (!reg1.test(el.id)) continue;
|
||||
@@ -43,15 +43,15 @@ local sid = self.section
|
||||
const cbid = el.id.replace(/\.main$/, "");
|
||||
const hidden_select = document.getElementById(cbid);
|
||||
const node_select_value = hidden_select?.options[0]?.value;
|
||||
if (!node_select_value || node_select_value.indexOf("tcp") === 0) {
|
||||
if (!node_select_value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let html = '<a href="#" onclick="return to_edit_node(this);"><%:Edit%></a>';
|
||||
|
||||
const m = cbid.match(/\.(tcp|udp)_node$/);
|
||||
if (m && (m[1] === "tcp" || m[1] === "udp")) {
|
||||
html += '<a href="#" onclick="window.open(\'' + '<%=api.url("get_redir_log") .. "?name=" .. sid%>&proto=' + m[1] + '\', \'_blank\')"><%:Log%></a>';
|
||||
const m = cbid.match(/\.node$/);
|
||||
if (m) {
|
||||
html += '<a href="#" onclick="window.open(\'' + '<%=api.url("get_redir_log") .. "?id=" .. sid%>' + '\', \'_blank\')"><%:Log%></a>';
|
||||
}
|
||||
|
||||
html = '<div class="node-actions" style="display:inline-flex; align-items:center; gap:4px; flex-wrap:wrap; margin-left:4px;">' + html + '</div>'
|
||||
|
||||
@@ -131,9 +131,9 @@ local sid = "@global[0]"
|
||||
|
||||
let html = '<a href="#" onclick="return to_edit_node(this, global_id);"><%:Edit%></a>';
|
||||
|
||||
const m = cbid.match(/\.(tcp|udp)_node$/);
|
||||
if (m && (m[1] === "tcp" || m[1] === "udp")) {
|
||||
html += '<a href="#" onclick="window.open(\'' + '<%=api.url("get_redir_log")%>?name=default&proto=' + m[1] + '\', \'_blank\')"><%:Log%></a>';
|
||||
const m = cbid.match(/\.node$/);
|
||||
if (m) {
|
||||
html += '<a href="#" onclick="window.open(\'' + '<%=api.url("get_redir_log")%>?id=default' + '\', \'_blank\')"><%:Log%></a>';
|
||||
}
|
||||
|
||||
html = '<div class="node-actions" style="display:inline-flex; align-items:center; gap:4px; flex-wrap:wrap; margin-left:4px;">' + html + '</div>'
|
||||
@@ -249,7 +249,7 @@ local sid = "@global[0]"
|
||||
})();
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => setTimeout(() => {
|
||||
const hiddenSelect = document.getElementById("cbid.<%=appname%>.<%=sid%>.tcp_node");
|
||||
const hiddenSelect = document.getElementById("cbid.<%=appname%>.<%=sid%>.node");
|
||||
let o_val = hiddenSelect.value
|
||||
const o_hasItem = shunt_list.find(element => element.id == o_val);
|
||||
hiddenSelect.addEventListener("change", function(el){
|
||||
@@ -259,7 +259,7 @@ local sid = "@global[0]"
|
||||
XHR.get('<%=api.url("update_config")%>', {
|
||||
id: "<%=sid%>",
|
||||
data: JSON.stringify({
|
||||
tcp_node: new_val
|
||||
node: new_val
|
||||
})
|
||||
},
|
||||
function(x, data) {
|
||||
|
||||
@@ -99,7 +99,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
</div>
|
||||
</div>
|
||||
<div class="pure-u-2-3">
|
||||
<h4 id="status_tcp_node">TCP<br /><span class="red"><%:NOT RUNNING%></span></h4>
|
||||
<h4 id="status_tcp">TCP<br /><span class="red"><%:NOT RUNNING%></span></h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -111,7 +111,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
</div>
|
||||
</div>
|
||||
<div class="pure-u-2-3">
|
||||
<h4 id="status_udp_node">UDP<br /><span class="red"><%:NOT RUNNING%></span></h4>
|
||||
<h4 id="status_udp">UDP<br /><span class="red"><%:NOT RUNNING%></span></h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -201,26 +201,26 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
var status_haproxy = document.getElementById('status_haproxy');
|
||||
if (data) {
|
||||
if (true) {
|
||||
var status_tcp_node = document.getElementById('status_tcp_node');
|
||||
if (status_tcp_node) {
|
||||
var status_tcp = document.getElementById('status_tcp');
|
||||
if (status_tcp) {
|
||||
var text = 'TCP<br />';
|
||||
if (data["tcp_node_status"])
|
||||
if (data["tcp_status"])
|
||||
text += '<span class="green"><%:RUNNING%></span>';
|
||||
else
|
||||
text += '<span class="red"><%:NOT RUNNING%></span>';
|
||||
status_tcp_node.innerHTML = text;
|
||||
status_tcp.innerHTML = text;
|
||||
}
|
||||
}
|
||||
|
||||
if (true) {
|
||||
var status_udp_node = document.getElementById('status_udp_node');
|
||||
if (status_udp_node) {
|
||||
var status_udp = document.getElementById('status_udp');
|
||||
if (status_udp) {
|
||||
var text = 'UDP<br />';
|
||||
if (data["udp_node_status"])
|
||||
if (data["udp_status"])
|
||||
text += '<span class="green"><%:RUNNING%></span>';
|
||||
else
|
||||
text += '<span class="red"><%:NOT RUNNING%></span>';
|
||||
status_udp_node.innerHTML = text;
|
||||
status_udp.innerHTML = text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,23 @@ local api = map.api
|
||||
local appname = map.config
|
||||
local is_js_luci = api.is_js_luci()
|
||||
local section_tag = is_js_luci and "div" or "fieldset"
|
||||
|
||||
local default_node_type = ""
|
||||
local shunt_rule_list = {}
|
||||
local node = map:get("@global[0]", "node")
|
||||
if node then
|
||||
local node_type = map:get(node, "type")
|
||||
local node_protocol = map:get(node, "protocol")
|
||||
if (node_type == "Xray" or node_type == "sing-box") and node_protocol == "_shunt" then
|
||||
default_node_type = node_protocol
|
||||
local node_shunt_group = map:get(node, "shunt_group")
|
||||
map:foreach("shunt_rules", function(e)
|
||||
if e[".name"] and e.remarks and e.group == node_shunt_group then
|
||||
shunt_rule_list[#shunt_rule_list + 1] = e
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
-%>
|
||||
<script src="<%=resource%>/view/<%=appname%>/Sortable.min.js?v=1.15.7"></script>
|
||||
|
||||
@@ -22,12 +39,13 @@ table td, .table .td {
|
||||
display: none;
|
||||
width: 30rem;
|
||||
position: fixed;
|
||||
top:50%;
|
||||
padding-top: 30px;
|
||||
top:45%;
|
||||
z-index: 99;
|
||||
text-align: center;
|
||||
background: white;
|
||||
box-shadow: darkgrey 10px 10px 30px 5px;
|
||||
box-shadow: darkgrey 10px 10px 30px 5px;
|
||||
text-align: center;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
._now_use_bg {
|
||||
@@ -669,13 +687,13 @@ table td, .table .td {
|
||||
function get_now_use_node() {
|
||||
XHR.get('<%=api.url("get_now_use_node")%>', null,
|
||||
function(x, result) {
|
||||
var id = result["TCP"];
|
||||
var id = result["global"];
|
||||
if (id) {
|
||||
var dom = document.getElementById("cbi-<%=appname%>-" + id);
|
||||
if (dom) {
|
||||
dom.title = '<%=api.i18n.translatef("Currently using %s node", "TCP")%>';
|
||||
dom.title = "<%:Currently using node%>";
|
||||
dom.classList.add("_now_use_bg");
|
||||
//var v = "<a style='color: red'>当前TCP节点:</a>" + document.getElementById("cbid.<%=appname%>." + id + ".remarks").value;
|
||||
//var v = "<a style='color: red'><%:Using...%>:</a>" + document.getElementById("cbid.<%=appname%>." + id + ".remarks").value;
|
||||
//document.getElementById("cbi-<%=appname%>-" + id + "-remarks").innerHTML = v;
|
||||
var dom_remarks = dom.querySelector("td.pw-remark");
|
||||
if (dom_remarks) {
|
||||
@@ -683,22 +701,6 @@ table td, .table .td {
|
||||
}
|
||||
}
|
||||
}
|
||||
id = result["UDP"];
|
||||
if (id) {
|
||||
var dom = document.getElementById("cbi-<%=appname%>-" + id);
|
||||
if (dom) {
|
||||
if (result["TCP"] == result["UDP"]) {
|
||||
dom.title = '<%=api.i18n.translatef("Currently using %s node", "TCP/UDP")%>';
|
||||
} else {
|
||||
dom.title = '<%=api.i18n.translatef("Currently using %s node", "UDP")%>';
|
||||
}
|
||||
dom.classList.add("_now_use_bg");
|
||||
var dom_remarks = dom.querySelector("td.pw-remark");
|
||||
if (dom_remarks) {
|
||||
dom_remarks.style.color = 'red';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1223,10 +1225,10 @@ table td, .table .td {
|
||||
document.getElementById("set_node_div").style.display="none";
|
||||
document.getElementById("set_node_name").textContent = "";
|
||||
},
|
||||
set(protocol) {
|
||||
if (confirm('<%:Are you sure set to%> ' + protocol.toUpperCase() + ' <%:the server?%>') == true){
|
||||
set(type, config) {
|
||||
if (confirm('<%:Are you sure set this node?%>') == true){
|
||||
ajax.abortAll();
|
||||
window.location.href = '<%=api.url("set_node")%>?protocol=' + protocol + '§ion=' + this.section;
|
||||
window.location.href = '<%=api.url("set_node")%>?type=' + type + '&config=' + config + '§ion=' + this.section;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1617,14 +1619,22 @@ table td, .table .td {
|
||||
</div>
|
||||
|
||||
<div style="display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;">
|
||||
<div id="set_node_div" style="text-align: center;">
|
||||
<div class="cbi-value" style="display: flex; justify-content: center; align-items: center; margin: 8px 0;">
|
||||
<div id="set_node_div">
|
||||
<div class="cbi-value" style="display: flex; justify-content: center; align-items: center; margin: 1em 0; height: 2em;">
|
||||
<font color=#666><%:You choose node is:%></font><a style="color: red" id="set_node_name"></a>
|
||||
<div style="position:absolute; right:0.5em; top: 0.5em;"><input class="btn cbi-button" type="button" onclick="set_node_div.close()" value="X" /></div>
|
||||
</div>
|
||||
<div class="cbi-value" style="display: flex; justify-content: center; gap: 8px; margin: 8px 0;">
|
||||
<input class="btn cbi-button cbi-button-edit" type="button" onclick="set_node_div.set('tcp')" value="TCP" />
|
||||
<input class="btn cbi-button cbi-button-edit" type="button" onclick="set_node_div.set('udp')" value="UDP" />
|
||||
<input class="btn cbi-button cbi-button-remove" type="button" onclick="set_node_div.close()" value="<%:Close%>" />
|
||||
<div class="cbi-value" style="justify-content: center; gap: 8px; margin: 1em 0;">
|
||||
<%- if default_node_type == "_shunt" then
|
||||
for i, v in ipairs(shunt_rule_list) do
|
||||
-%>
|
||||
<input class="btn cbi-button" type="button" onclick="set_node_div.set('<%=node%>', '<%=v[".name"]%>')" value="<%=v.remarks%>" />
|
||||
<%-
|
||||
end
|
||||
-%>
|
||||
<% else %>
|
||||
<input class="btn cbi-button" type="button" onclick="set_node_div.set('@global[0]', 'node')" value="<%:Node%>" />
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -94,11 +94,8 @@ msgstr "清除"
|
||||
msgid "Main switch"
|
||||
msgstr "主开关"
|
||||
|
||||
msgid "TCP Node"
|
||||
msgstr "TCP 节点"
|
||||
|
||||
msgid "UDP Node"
|
||||
msgstr "UDP 节点"
|
||||
msgid "Proxy Node"
|
||||
msgstr "代理节点"
|
||||
|
||||
msgid "Edit Current Node"
|
||||
msgstr "编辑当前节点"
|
||||
@@ -139,8 +136,8 @@ msgstr "%s 不能为空。"
|
||||
msgid "Filter Mode"
|
||||
msgstr "过滤模式"
|
||||
|
||||
msgid "TCP node must be '%s' type to use FakeDNS."
|
||||
msgstr "TCP 节点必须是 '%s' 类型才能使用 FakeDNS。"
|
||||
msgid "Node must be '%s' type to use FakeDNS."
|
||||
msgstr "节点必须是 '%s' 类型才能使用 FakeDNS。"
|
||||
|
||||
msgid "Direct DNS"
|
||||
msgstr "直连 DNS"
|
||||
@@ -430,8 +427,8 @@ msgstr "你确定要删除选择的节点吗?"
|
||||
msgid "You no select nodes !"
|
||||
msgstr "你没有选择任何节点!"
|
||||
|
||||
msgid "Are you sure set to"
|
||||
msgstr "你确定要设为"
|
||||
msgid "Are you sure set this node?"
|
||||
msgstr "你确定要设置这个节点吗?"
|
||||
|
||||
msgid "the server?"
|
||||
msgstr "服务器吗?"
|
||||
@@ -1625,9 +1622,6 @@ msgstr "日志"
|
||||
msgid "Enable Node Log"
|
||||
msgstr "启用节点日志"
|
||||
|
||||
msgid "%s Node Log"
|
||||
msgstr "%s 节点日志"
|
||||
|
||||
msgid "Log Level"
|
||||
msgstr "日志等级"
|
||||
|
||||
@@ -2133,8 +2127,8 @@ msgstr "调整分组"
|
||||
msgid "Reassign Node Group"
|
||||
msgstr "调整节点分组"
|
||||
|
||||
msgid "Currently using %s node"
|
||||
msgstr "当前使用的 %s 节点"
|
||||
msgid "Currently using node"
|
||||
msgstr "当前使用的节点"
|
||||
|
||||
msgid "Search nodes..."
|
||||
msgstr "搜索节点…"
|
||||
|
||||
@@ -61,6 +61,31 @@ for sid in $(uci show passwall | grep "@subscribe_list" | cut -d '.' -sf 2 | cut
|
||||
unset sid new_id
|
||||
done
|
||||
|
||||
migrate_option() {
|
||||
local section="$1"
|
||||
local old="$2"
|
||||
local new="$3"
|
||||
local prefix="passwall.${section}"
|
||||
if uci -q show "${prefix}.${new}" >/dev/null; then
|
||||
uci -q delete "${prefix}.${old}"
|
||||
elif uci -q show "${prefix}.${old}" >/dev/null; then
|
||||
uci -q set "${prefix}.${new}=$(uci -q get "${prefix}.${old}")"
|
||||
uci -q delete "${prefix}.${old}"
|
||||
fi
|
||||
}
|
||||
|
||||
migrate_option "@global[0]" tcp_node node
|
||||
uci -q delete "passwall.@global[0].udp_node"
|
||||
migrate_option "@global[0]" tcp_node_socks_port node_socks_port
|
||||
migrate_option "@global[0]" tcp_node_socks_bind_local node_socks_bind_local
|
||||
migrate_option "@global[0]" log_tcp log_node
|
||||
uci -q delete "passwall.@global[0].log_udp"
|
||||
|
||||
for sid in $(uci show passwall | grep "=acl_rule" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
|
||||
migrate_option "${sid}" tcp_node node
|
||||
uci -q delete "passwall.${sid}.udp_node"
|
||||
done
|
||||
|
||||
uci -q commit passwall
|
||||
|
||||
sed -i "s#add_from#group#g" /etc/config/passwall 2>/dev/null
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
config global
|
||||
option enabled '0'
|
||||
option socks_enabled '0'
|
||||
option tcp_node_socks_port '1070'
|
||||
option node_socks_port '1070'
|
||||
option filter_proxy_ipv6 '1'
|
||||
option dns_shunt 'chinadns-ng'
|
||||
option dns_mode 'tcp'
|
||||
@@ -21,8 +21,7 @@ config global
|
||||
option localhost_proxy '1'
|
||||
option client_proxy '1'
|
||||
option acl_enable '0'
|
||||
option log_tcp '0'
|
||||
option log_udp '0'
|
||||
option log_node '0'
|
||||
option loglevel 'error'
|
||||
option log_chinadns_ng '0'
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -14,7 +14,7 @@ local NO_IPV6_TRUST = var["-NO_IPV6_TRUST"]
|
||||
local DEFAULT_MODE = var["-DEFAULT_MODE"]
|
||||
local DEFAULT_TAG = var["-DEFAULT_TAG"]
|
||||
local NO_LOGIC_LOG = var["-NO_LOGIC_LOG"]
|
||||
local TCP_NODE = var["-TCP_NODE"]
|
||||
local NODE = var["-NODE"]
|
||||
local NFTFLAG = var["-NFTFLAG"]
|
||||
local FILTER_HTTPS = var["-FILTER_HTTPS"]
|
||||
local LOG_FILE = var["-LOG_FILE"]
|
||||
@@ -30,7 +30,7 @@ local FLAG_PATH = TMP_ACL_PATH .. "/" .. FLAG
|
||||
local config_lines = {}
|
||||
local tmp_lines = {}
|
||||
local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview")
|
||||
local IS_SHUNT_NODE = api.uci_get_c(TCP_NODE, "protocol") == "_shunt"
|
||||
local IS_SHUNT_NODE = api.uci_get_c(NODE, "protocol") == "_shunt"
|
||||
|
||||
if not api.is_finded("geoview") then
|
||||
USE_GEOVIEW = "0"
|
||||
@@ -385,7 +385,7 @@ if IS_SHUNT_NODE then
|
||||
local file_shunt_host = FLAG_PATH .. "/shunt_proxy_host"
|
||||
local geosite_white_arg, geosite_shunt_arg = "", ""
|
||||
|
||||
local t = api.uci_get_c(TCP_NODE)
|
||||
local t = api.uci_get_c(NODE)
|
||||
local default_node_id = t["default_node"] or "_direct"
|
||||
api.uci_foreach_c("shunt_rules", function(s)
|
||||
local _node_id = t[s[".name"]]
|
||||
|
||||
@@ -163,7 +163,7 @@ function add_rule(var)
|
||||
local TUN_DNS = var["-TUN_DNS"]
|
||||
local USE_DEFAULT_DNS = var["-USE_DEFAULT_DNS"]
|
||||
local CHINADNS_DNS = var["-CHINADNS_DNS"]
|
||||
local TCP_NODE = var["-TCP_NODE"]
|
||||
local NODE = var["-NODE"]
|
||||
local USE_DIRECT_LIST = var["-USE_DIRECT_LIST"]
|
||||
local USE_PROXY_LIST = var["-USE_PROXY_LIST"]
|
||||
local USE_BLOCK_LIST = var["-USE_BLOCK_LIST"]
|
||||
@@ -178,7 +178,7 @@ function add_rule(var)
|
||||
local CACHE_DNS_PATH = CACHE_PATH .. "/" .. CACHE_FLAG
|
||||
local CACHE_TEXT_FILE = CACHE_DNS_PATH .. ".txt"
|
||||
local USE_CHINADNS_NG = "0"
|
||||
local IS_SHUNT_NODE = api.uci_get_c(TCP_NODE, "protocol") == "_shunt"
|
||||
local IS_SHUNT_NODE = api.uci_get_c(NODE, "protocol") == "_shunt"
|
||||
local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview")
|
||||
|
||||
local list1 = {}
|
||||
@@ -613,7 +613,7 @@ function add_rule(var)
|
||||
|
||||
--分流规则
|
||||
if IS_SHUNT_NODE and USE_CHINADNS_NG == "0" then
|
||||
local t = api.uci_get_c(TCP_NODE)
|
||||
local t = api.uci_get_c(NODE)
|
||||
local default_node_id = t["default_node"] or "_direct"
|
||||
api.uci_foreach_c("shunt_rules", function(s)
|
||||
local _node_id = t[s[".name"]]
|
||||
|
||||
@@ -10,7 +10,7 @@ local USE_DEFAULT_DNS = var["-USE_DEFAULT_DNS"]
|
||||
local REMOTE_DNS = var["-REMOTE_DNS"]
|
||||
local TUN_DNS = var["-TUN_DNS"]
|
||||
local DNS_MODE = var["-DNS_MODE"]
|
||||
local TCP_NODE = var["-TCP_NODE"]
|
||||
local NODE = var["-NODE"]
|
||||
local USE_DIRECT_LIST = var["-USE_DIRECT_LIST"]
|
||||
local USE_PROXY_LIST = var["-USE_PROXY_LIST"]
|
||||
local USE_BLOCK_LIST = var["-USE_BLOCK_LIST"]
|
||||
@@ -36,7 +36,7 @@ local TMP_CONF_FILE = FLAG_PATH .. "/smartdns.conf"
|
||||
local config_lines = {}
|
||||
local tmp_lines = {}
|
||||
local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview")
|
||||
local IS_SHUNT_NODE = api.uci_get_c(TCP_NODE, "protocol") == "_shunt"
|
||||
local IS_SHUNT_NODE = api.uci_get_c(NODE, "protocol") == "_shunt"
|
||||
|
||||
if not api.is_finded("geoview") then
|
||||
USE_GEOVIEW = "0"
|
||||
@@ -553,7 +553,7 @@ if IS_SHUNT_NODE then
|
||||
local file_shunt_host = FLAG_PATH .. "/shunt_proxy_host"
|
||||
local geosite_white_arg, geosite_shunt_arg = "", ""
|
||||
|
||||
local t = api.uci_get_c(TCP_NODE)
|
||||
local t = api.uci_get_c(NODE)
|
||||
local default_node_id = t["default_node"] or "_direct"
|
||||
api.uci_foreach_c("shunt_rules", function(s)
|
||||
local _node_id = t[s[".name"]]
|
||||
|
||||
@@ -25,9 +25,6 @@ IPSET_BLACK6="psw_black6"
|
||||
IPSET_WHITE6="psw_white6"
|
||||
IPSET_BLOCK6="psw_block6"
|
||||
|
||||
USE_SHUNT_TCP=0
|
||||
USE_SHUNT_UDP=0
|
||||
|
||||
# ASCII code for PSW1.Use whatever,just not the same.
|
||||
FWMARK="0x50535731"
|
||||
|
||||
@@ -231,42 +228,29 @@ load_acl() {
|
||||
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
|
||||
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
|
||||
|
||||
[ -n "$(get_cache_var "ACL_${sid}_tcp_node")" ] && tcp_node=$(get_cache_var "ACL_${sid}_tcp_node")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_tcp_redir_port")" ] && tcp_port=$(get_cache_var "ACL_${sid}_tcp_redir_port")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_udp_node")" ] && udp_node=$(get_cache_var "ACL_${sid}_udp_node")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_udp_redir_port")" ] && udp_port=$(get_cache_var "ACL_${sid}_udp_redir_port")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_node")" ] && node=$(get_cache_var "ACL_${sid}_node")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_redir_port")" ] && {
|
||||
tcp_port=$(get_cache_var "ACL_${sid}_redir_port")
|
||||
udp_port=$tcp_port
|
||||
}
|
||||
[ -n "$(get_cache_var "ACL_${sid}_dns_port")" ] && dns_redirect_port=$(get_cache_var "ACL_${sid}_dns_port")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_fakedns")" ] && use_fakedns=$(get_cache_var "ACL_${sid}_fakedns")
|
||||
[ -n "$tcp_node" ] && {
|
||||
if [ "$(config_get_type $tcp_node)" = "socks" ]; then
|
||||
tcp_node_remark="Socks 配置($(config_n_get $tcp_node port) 端口)"
|
||||
[ -n "$node" ] && {
|
||||
if [ "$(config_get_type $node)" = "socks" ]; then
|
||||
node_remark="Socks 配置($(config_n_get $node port) 端口)"
|
||||
else
|
||||
tcp_node_remark=$(config_n_get $tcp_node remarks)
|
||||
fi
|
||||
}
|
||||
[ -n "$udp_node" ] && {
|
||||
if [ "$(config_get_type $udp_node)" = "socks" ]; then
|
||||
udp_node_remark="Socks 配置($(config_n_get $udp_node port) 端口)"
|
||||
else
|
||||
udp_node_remark=$(config_n_get $udp_node remarks)
|
||||
node_remark=$(config_n_get $node remarks)
|
||||
fi
|
||||
}
|
||||
|
||||
use_shunt_tcp=0
|
||||
use_shunt_udp=0
|
||||
[ -n "$tcp_node" ] && [ "$(config_n_get $tcp_node protocol)" = "_shunt" ] && use_shunt_tcp=1
|
||||
[ -n "$udp_node" ] && [ "$(config_n_get $udp_node protocol)" = "_shunt" ] && use_shunt_udp=1
|
||||
use_shunt_node=0
|
||||
[ -n "$node" ] && [ "$(config_n_get $node protocol)" = "_shunt" ] && use_shunt_node=1
|
||||
|
||||
[ "${use_global_config}" = "1" ] && {
|
||||
if [ "$(config_get_type $TCP_NODE)" = "socks" ]; then
|
||||
tcp_node_remark="Socks 配置($(config_n_get $TCP_NODE} port) 端口)"
|
||||
if [ "$(config_get_type $NODE)" = "socks" ]; then
|
||||
node_remark="Socks 配置($(config_n_get $NODE} port) 端口)"
|
||||
else
|
||||
tcp_node_remark=$(config_n_get $TCP_NODE remarks)
|
||||
fi
|
||||
if [ "$(config_get_type $UDP_NODE)" = "socks" ]; then
|
||||
udp_node_remark="Socks 配置($(config_n_get $UDP_NODE port) 端口)"
|
||||
else
|
||||
udp_node_remark=$(config_n_get $UDP_NODE remarks)
|
||||
node_remark=$(config_n_get $NODE remarks)
|
||||
fi
|
||||
use_direct_list=${USE_DIRECT_LIST}
|
||||
use_proxy_list=${USE_PROXY_LIST}
|
||||
@@ -275,8 +259,7 @@ load_acl() {
|
||||
chn_list=${CHN_LIST}
|
||||
tcp_proxy_mode=${TCP_PROXY_MODE}
|
||||
udp_proxy_mode=${UDP_PROXY_MODE}
|
||||
use_shunt_tcp=${USE_SHUNT_TCP}
|
||||
use_shunt_udp=${USE_SHUNT_UDP}
|
||||
use_shunt_node=${USE_SHUNT_NODE}
|
||||
dns_redirect_port=${DNS_REDIRECT_PORT}
|
||||
black_set_name=${IPSET_BLACK}
|
||||
black6_set_name=${IPSET_BLACK6}
|
||||
@@ -388,7 +371,7 @@ load_acl() {
|
||||
ipset -! create $gfw6_set_name nethash family inet6 maxelem 1048576 timeout 172800
|
||||
}
|
||||
}
|
||||
[ "${use_shunt_tcp}" = "1" ] || [ "${use_shunt_udp}" = "1" ] && {
|
||||
[ "${use_shunt_node}" = "1" ] && {
|
||||
[ "${use_global_config}" = "0" ] && {
|
||||
shunt_set_name="psw_${sid}_shunt"
|
||||
shunt6_set_name="psw_${sid}_shunt6"
|
||||
@@ -397,12 +380,8 @@ load_acl() {
|
||||
# 预加载分流规则 ip 到 ipset
|
||||
local GEOIP_CODE=""
|
||||
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
|
||||
local shunt_group shunt_id
|
||||
if [ "${use_shunt_tcp}" = "1" ]; then
|
||||
shunt_group=$(config_n_get $tcp_node shunt_group)
|
||||
elif [ "${use_shunt_udp}" = "1" ]; then
|
||||
shunt_group=$(config_n_get $udp_node shunt_group)
|
||||
fi
|
||||
local shunt_group=$(config_n_get $node shunt_group)
|
||||
local shunt_id
|
||||
for shunt_id in $shunt_ids; do
|
||||
[ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue
|
||||
config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | grep -v "^#" | sed -e "/^$/d" | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | sed -e "s/^/add $shunt_set_name &/g" -e "s/$/ timeout 0/g" | ipset -! -R
|
||||
@@ -431,7 +410,7 @@ load_acl() {
|
||||
[ "$_ipv4" != "1" ] && $ip6t_n -A PSW_DNS $(comment "$remarks") -p udp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect} 2>/dev/null
|
||||
$ipt_n -A PSW_DNS $(comment "$remarks") -p tcp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect}
|
||||
[ "$_ipv4" != "1" ] && $ip6t_n -A PSW_DNS $(comment "$remarks") -p tcp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect} 2>/dev/null
|
||||
[ -z "$(get_cache_var "ACL_${sid}_tcp_default")" ] && echolog " - ${msg}使用与全局配置不相同节点,已将DNS强制重定向到专用 DNS 服务器。"
|
||||
[ -z "$(get_cache_var "ACL_${sid}_default")" ] && echolog " - ${msg}使用与全局配置不相同节点,已将DNS强制重定向到专用 DNS 服务器。"
|
||||
fi
|
||||
|
||||
[ -n "$tcp_port" ] || [ -n "$udp_port" ] && {
|
||||
@@ -448,14 +427,14 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $black6_set_name) -j MARK --set-mark 88" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $gfw6_set_name) -j MARK --set-mark 88" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")" 2>/dev/null
|
||||
[ "${use_shunt_tcp}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $shunt6_set_name) -j MARK --set-mark 88" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $shunt6_set_name) -j MARK --set-mark 88" 2>/dev/null
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-j MARK --set-mark 88" 2>/dev/null
|
||||
}
|
||||
[ "${use_fakedns}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-d $FAKE_IP -j MARK --set-mark 88"
|
||||
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $black_set_name) -j MARK --set-mark 88"
|
||||
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $gfw_set_name) -j MARK --set-mark 88"
|
||||
[ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")"
|
||||
[ "${use_shunt_tcp}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $shunt_set_name) -j MARK --set-mark 88"
|
||||
[ "${use_shunt_node}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $shunt_set_name) -j MARK --set-mark 88"
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-j MARK --set-mark 88"
|
||||
echolog " - ${msg}屏蔽代理 TCP 端口[${tcp_proxy_drop_ports}]"
|
||||
}
|
||||
@@ -466,14 +445,14 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $black6_set_name) -j MARK --set-mark 88" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $gfw6_set_name) -j MARK --set-mark 88" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")" 2>/dev/null
|
||||
[ "${use_shunt_udp}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $shunt6_set_name) -j MARK --set-mark 88" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $shunt6_set_name) -j MARK --set-mark 88" 2>/dev/null
|
||||
[ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-j MARK --set-mark 88" 2>/dev/null
|
||||
}
|
||||
[ "${use_fakedns}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-d $FAKE_IP -j MARK --set-mark 88"
|
||||
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $black_set_name) -j MARK --set-mark 88"
|
||||
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $gfw_set_name) -j MARK --set-mark 88"
|
||||
[ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")"
|
||||
[ "${use_shunt_udp}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $shunt_set_name) -j MARK --set-mark 88"
|
||||
[ "${use_shunt_node}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $shunt_set_name) -j MARK --set-mark 88"
|
||||
[ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-j MARK --set-mark 88"
|
||||
echolog " - ${msg}屏蔽代理 UDP 端口[${udp_proxy_drop_ports}]"
|
||||
}
|
||||
@@ -486,7 +465,7 @@ load_acl() {
|
||||
|
||||
[ -n "$tcp_port" ] && {
|
||||
if [ -n "${tcp_proxy_mode}" ]; then
|
||||
msg2="${msg}使用 TCP 节点[$tcp_node_remark]"
|
||||
msg2="${msg}代理 TCP 使用节点[$node_remark]"
|
||||
if [ -n "${is_tproxy}" ]; then
|
||||
msg2="${msg2}(TPROXY:${tcp_port})"
|
||||
ipt_tmp=$ipt_m
|
||||
@@ -501,7 +480,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $black_set_name) $(REDIRECT)
|
||||
[ "${use_gfw_list}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $gfw_set_name) $(REDIRECT)
|
||||
[ "${chn_list}" != "0" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $IPSET_CHN) $(get_jump_ipt ${chn_list})
|
||||
[ "${use_shunt_tcp}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $shunt_set_name) $(REDIRECT)
|
||||
[ "${use_shunt_node}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $shunt_set_name) $(REDIRECT)
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(REDIRECT)
|
||||
}
|
||||
|
||||
@@ -510,7 +489,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $black6_set_name) $(REDIRECT) 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $gfw6_set_name) $(REDIRECT) 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list}) 2>/dev/null
|
||||
[ "${use_shunt_tcp}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $shunt6_set_name) $(REDIRECT) 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $shunt6_set_name) $(REDIRECT) 2>/dev/null
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(REDIRECT) 2>/dev/null
|
||||
}
|
||||
|
||||
@@ -518,7 +497,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $black_set_name) ${ipt_j}"
|
||||
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $gfw_set_name) ${ipt_j}"
|
||||
[ "${chn_list}" != "0" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "${ipt_j}")"
|
||||
[ "${use_shunt_tcp}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $shunt_set_name) ${ipt_j}"
|
||||
[ "${use_shunt_node}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $shunt_set_name) ${ipt_j}"
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "${ipt_j}"
|
||||
[ -n "${is_tproxy}" ] && $ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY)
|
||||
|
||||
@@ -527,7 +506,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $black6_set_name) -j PSW_RULE" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $gfw6_set_name) -j PSW_RULE" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j PSW_RULE")" 2>/dev/null
|
||||
[ "${use_shunt_tcp}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $shunt6_set_name) -j PSW_RULE" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $shunt6_set_name) -j PSW_RULE" 2>/dev/null
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "-j PSW_RULE" 2>/dev/null
|
||||
$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY) 2>/dev/null
|
||||
}
|
||||
@@ -542,14 +521,14 @@ load_acl() {
|
||||
|
||||
[ -n "$udp_port" ] && {
|
||||
if [ -n "${udp_proxy_mode}" ]; then
|
||||
msg2="${msg}使用 UDP 节点[$udp_node_remark]"
|
||||
msg2="${msg}代理 UDP 使用节点[$node_remark]"
|
||||
msg2="${msg2}(TPROXY:${udp_port})"
|
||||
|
||||
[ "${use_fakedns}" = "1" ] && $ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} -d $FAKE_IP -j PSW_RULE
|
||||
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $black_set_name) -j PSW_RULE"
|
||||
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $gfw_set_name) -j PSW_RULE"
|
||||
[ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j PSW_RULE")"
|
||||
[ "${use_shunt_udp}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $shunt_set_name) -j PSW_RULE"
|
||||
[ "${use_shunt_node}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $shunt_set_name) -j PSW_RULE"
|
||||
[ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "-j PSW_RULE"
|
||||
$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} $(REDIRECT $udp_port TPROXY)
|
||||
|
||||
@@ -558,7 +537,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $black6_set_name) -j PSW_RULE" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $gfw6_set_name) -j PSW_RULE" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j PSW_RULE")" 2>/dev/null
|
||||
[ "${use_shunt_udp}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $shunt6_set_name) -j PSW_RULE" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $shunt6_set_name) -j PSW_RULE" 2>/dev/null
|
||||
[ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "-j PSW_RULE" 2>/dev/null
|
||||
$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} $(REDIRECT $udp_port TPROXY) 2>/dev/null
|
||||
}
|
||||
@@ -571,8 +550,8 @@ load_acl() {
|
||||
$ipt_m -A PSW $(comment "$remarks") ${_ipt_source} -p udp -j RETURN
|
||||
unset ipt_tmp ipt_j _ipt_source msg msg2 _ipv4
|
||||
done
|
||||
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 dns_redirect_port 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 interface
|
||||
unset tcp_port udp_port tcp_node_remark udp_node_remark _acl_list use_shunt_tcp use_shunt_udp dns_redirect use_fakedns
|
||||
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 dns_redirect_port tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports node interface
|
||||
unset tcp_port udp_port node_remark _acl_list use_shunt_node dns_redirect use_fakedns
|
||||
done
|
||||
}
|
||||
|
||||
@@ -605,7 +584,7 @@ load_acl() {
|
||||
|
||||
local DNS_REDIRECT
|
||||
[ $(config_t_get global dns_redirect "1") = "1" ] && DNS_REDIRECT=53
|
||||
if ([ -n "$TCP_NODE" ] && [ -n "${TCP_PROXY_MODE}" ]) || ([ -n "$UDP_NODE" ] && [ -n "${UDP_PROXY_MODE}" ]); then
|
||||
if [ -n "$NODE" ] && ([ -n "${TCP_PROXY_MODE}" ] || [ -n "${UDP_PROXY_MODE}" ]); then
|
||||
[ -n "${DNS_REDIRECT_PORT}" ] && DNS_REDIRECT=${DNS_REDIRECT_PORT}
|
||||
else
|
||||
[ -n "${DIRECT_DNSMASQ_PORT}" ] && DNS_REDIRECT=${DIRECT_DNSMASQ_PORT}
|
||||
@@ -636,14 +615,14 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK6) -j MARK --set-mark 88"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW6) -j MARK --set-mark 88"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT6) -j MARK --set-mark 88"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT6) -j MARK --set-mark 88"
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
|
||||
}
|
||||
[ "${USE_FAKEDNS}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-d $FAKE_IP -j MARK --set-mark 88"
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS $(dst $IPSET_SHUNT) "-j MARK --set-mark 88"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS $(dst $IPSET_SHUNT) "-j MARK --set-mark 88"
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
|
||||
echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]"
|
||||
}
|
||||
@@ -654,14 +633,14 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK6) -j MARK --set-mark 88"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW6) -j MARK --set-mark 88"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT6) -j MARK --set-mark 88"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT6) -j MARK --set-mark 88"
|
||||
[ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
|
||||
}
|
||||
[ "${USE_FAKEDNS}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-d $FAKE_IP -j MARK --set-mark 88"
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
|
||||
[ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
|
||||
echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]"
|
||||
}
|
||||
@@ -674,18 +653,18 @@ load_acl() {
|
||||
|
||||
# 加载TCP默认代理模式
|
||||
if [ -n "${TCP_PROXY_MODE}" ]; then
|
||||
[ -n "$TCP_NODE" ] && {
|
||||
if [ "$(config_get_type $TCP_NODE)" = "socks" ]; then
|
||||
msg2="${msg}使用 TCP 节点[Socks 配置($(config_n_get $TCP_NODE port) 端口)]"
|
||||
[ -n "$NODE" ] && {
|
||||
if [ "$(config_get_type $NODE)" = "socks" ]; then
|
||||
msg2="${msg}代理 TCP 使用节点[Socks 配置($(config_n_get $NODE port) 端口)]"
|
||||
else
|
||||
msg2="${msg}使用 TCP 节点[$(config_n_get $TCP_NODE remarks)]"
|
||||
msg2="${msg}代理 TCP 使用节点[$(config_n_get $NODE remarks)]"
|
||||
fi
|
||||
if [ -n "${is_tproxy}" ]; then
|
||||
msg2="${msg2}(TPROXY:${TCP_REDIR_PORT})"
|
||||
msg2="${msg2}(TPROXY:${REDIR_PORT})"
|
||||
ipt_j="-j PSW_RULE"
|
||||
else
|
||||
msg2="${msg2}(REDIRECT:${TCP_REDIR_PORT})"
|
||||
ipt_j="$(REDIRECT $TCP_REDIR_PORT)"
|
||||
msg2="${msg2}(REDIRECT:${REDIR_PORT})"
|
||||
ipt_j="$(REDIRECT $REDIR_PORT)"
|
||||
fi
|
||||
|
||||
[ "$accept_icmp" = "1" ] && {
|
||||
@@ -693,7 +672,7 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_BLACK) $(REDIRECT)
|
||||
[ "${USE_GFW_LIST}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_GFW) $(REDIRECT)
|
||||
[ "${CHN_LIST}" != "0" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST})
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_SHUNT) $(REDIRECT)
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_SHUNT) $(REDIRECT)
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(REDIRECT)
|
||||
}
|
||||
|
||||
@@ -702,7 +681,7 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_BLACK6) $(REDIRECT)
|
||||
[ "${USE_GFW_LIST}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_GFW6) $(REDIRECT)
|
||||
[ "${CHN_LIST}" != "0" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST})
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_SHUNT6) $(REDIRECT)
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_SHUNT6) $(REDIRECT)
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(REDIRECT)
|
||||
}
|
||||
|
||||
@@ -710,18 +689,18 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK) ${ipt_j}"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW) ${ipt_j}"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "${ipt_j}")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT) ${ipt_j}"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT) ${ipt_j}"
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "${ipt_j}"
|
||||
[ -n "${is_tproxy}" ]&& $ipt_tmp -A PSW $(comment "默认") -p tcp $(REDIRECT $TCP_REDIR_PORT TPROXY)
|
||||
[ -n "${is_tproxy}" ]&& $ipt_tmp -A PSW $(comment "默认") -p tcp $(REDIRECT $REDIR_PORT TPROXY)
|
||||
|
||||
[ "$PROXY_IPV6" = "1" ] && {
|
||||
[ "${USE_FAKEDNS}" = "1" ] && $ip6t_m -A PSW $(comment "默认") -p tcp -d $FAKE_IP_6 -j PSW_RULE
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "-j PSW_RULE"
|
||||
$ip6t_m -A PSW $(comment "默认") -p tcp $(REDIRECT $TCP_REDIR_PORT TPROXY)
|
||||
$ip6t_m -A PSW $(comment "默认") -p tcp $(REDIRECT $REDIR_PORT TPROXY)
|
||||
}
|
||||
|
||||
echolog " - ${msg2}"
|
||||
@@ -733,29 +712,29 @@ load_acl() {
|
||||
|
||||
# 加载UDP默认代理模式
|
||||
if [ -n "${UDP_PROXY_MODE}" ]; then
|
||||
[ -n "$UDP_NODE" ] || [ "$TCP_UDP" = "1" ] && {
|
||||
if [ "$(config_get_type $UDP_NODE)" = "socks" ]; then
|
||||
msg2="${msg}使用 UDP 节点[Socks 配置($(config_n_get $UDP_NODE port) 端口)](TPROXY:${UDP_REDIR_PORT})"
|
||||
[ -n "$NODE" ] && {
|
||||
if [ "$(config_get_type $NODE)" = "socks" ]; then
|
||||
msg2="${msg}代理 UDP 使用节点[Socks 配置($(config_n_get $NODE port) 端口)](TPROXY:${REDIR_PORT})"
|
||||
else
|
||||
msg2="${msg}使用 UDP 节点[$(config_n_get $UDP_NODE remarks)](TPROXY:${UDP_REDIR_PORT})"
|
||||
msg2="${msg}代理 UDP 使用节点[$(config_n_get $NODE remarks)](TPROXY:${REDIR_PORT})"
|
||||
fi
|
||||
|
||||
[ "${USE_FAKEDNS}" = "1" ] && $ipt_m -A PSW $(comment "默认") -p udp -d $FAKE_IP -j PSW_RULE
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK) -j PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW) -j PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT) -j PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT) -j PSW_RULE"
|
||||
[ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "-j PSW_RULE"
|
||||
$ipt_m -A PSW $(comment "默认") -p udp $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ipt_m -A PSW $(comment "默认") -p udp $(REDIRECT $REDIR_PORT TPROXY)
|
||||
|
||||
[ "$PROXY_IPV6" = "1" ] && {
|
||||
[ "${USE_FAKEDNS}" = "1" ] && $ip6t_m -A PSW $(comment "默认") -p udp -d $FAKE_IP_6 -j PSW_RULE
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
|
||||
[ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "-j PSW_RULE"
|
||||
$ip6t_m -A PSW $(comment "默认") -p udp $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ip6t_m -A PSW $(comment "默认") -p udp $(REDIRECT $REDIR_PORT TPROXY)
|
||||
}
|
||||
|
||||
echolog " - ${msg2}"
|
||||
@@ -909,18 +888,14 @@ add_firewall_rule() {
|
||||
cat $RULES_PATH/chnroute6 | tr -s '\n' | grep -v "^#" | sed -e "/^$/d" | sed -e "s/^/add $IPSET_CHN6 &/g" -e "s/$/ timeout 0/g" | ipset -! -R
|
||||
|
||||
#导入规则列表、分流规则中的IP列表
|
||||
local USE_SHUNT_NODE=0
|
||||
local USE_PROXY_LIST_ALL=${USE_PROXY_LIST}
|
||||
local USE_DIRECT_LIST_ALL=${USE_DIRECT_LIST}
|
||||
local USE_BLOCK_LIST_ALL=${USE_BLOCK_LIST}
|
||||
local _TCP_NODE=$(config_t_get global tcp_node)
|
||||
local _UDP_NODE=$(config_t_get global udp_node)
|
||||
USE_SHUNT_NODE=0
|
||||
USE_GEOVIEW=$(config_t_get global_rules enable_geoview)
|
||||
[ -z "$(first_type $(config_t_get global_app geoview_file) geoview)" ] && USE_GEOVIEW=0
|
||||
|
||||
[ -n "$_TCP_NODE" ] && [ "$(config_n_get $_TCP_NODE protocol)" = "_shunt" ] && USE_SHUNT_TCP=1 && USE_SHUNT_NODE=1
|
||||
[ -n "$_UDP_NODE" ] && [ "$(config_n_get $_UDP_NODE protocol)" = "_shunt" ] && USE_SHUNT_UDP=1 && USE_SHUNT_NODE=1
|
||||
[ "$_UDP_NODE" = "tcp" ] && USE_SHUNT_UDP=$USE_SHUNT_TCP
|
||||
[ -n "$NODE" ] && [ "$(config_n_get $NODE protocol)" = "_shunt" ] && USE_SHUNT_NODE=1
|
||||
|
||||
for acl_section in $(uci show ${CONFIG} | grep "=acl_rule" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
|
||||
[ "$(config_n_get $acl_section enabled)" != "1" ] && continue
|
||||
@@ -929,10 +904,6 @@ add_firewall_rule() {
|
||||
[ "$(config_n_get $acl_section use_proxy_list 1)" = "1" ] && USE_DIRECT_LIST_ALL=1
|
||||
[ "$(config_n_get $acl_section use_block_list 1)" = "1" ] && USE_BLOCK_LIST_ALL=1
|
||||
}
|
||||
for _node in $(config_n_get $acl_section tcp_node) $(config_n_get $acl_section udp_node); do
|
||||
local node_protocol=$(config_n_get $_node protocol)
|
||||
[ "$node_protocol" = "_shunt" ] && { USE_SHUNT_NODE=1; break; }
|
||||
done
|
||||
done
|
||||
|
||||
#直连列表
|
||||
@@ -981,12 +952,8 @@ add_firewall_rule() {
|
||||
[ "$USE_SHUNT_NODE" = "1" ] && {
|
||||
local GEOIP_CODE=""
|
||||
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
|
||||
local shunt_group shunt_id
|
||||
if [ "${USE_SHUNT_TCP}" = "1" ]; then
|
||||
shunt_group=$(config_n_get $_TCP_NODE shunt_group)
|
||||
elif [ "${USE_SHUNT_UDP}" = "1" ]; then
|
||||
shunt_group=$(config_n_get $_UDP_NODE shunt_group)
|
||||
fi
|
||||
local shunt_group=$(config_n_get $NODE shunt_group)
|
||||
local shunt_id
|
||||
for shunt_id in $shunt_ids; do
|
||||
[ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue
|
||||
config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | grep -v "^#" | sed -e "/^$/d" | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | sed -e "s/^/add $IPSET_SHUNT &/g" -e "s/$/ timeout 0/g" | ipset -! -R
|
||||
@@ -1197,15 +1164,13 @@ add_firewall_rule() {
|
||||
ip -6 rule add fwmark ${FWMARK} table 999 priority 999
|
||||
ip -6 route add local ::/0 dev lo table 999
|
||||
|
||||
[ "$TCP_UDP" = "1" ] && [ -z "$UDP_NODE" ] && UDP_NODE=$TCP_NODE
|
||||
|
||||
[ "$ENABLED_DEFAULT_ACL" = 1 ] && {
|
||||
local ipt_tmp=$ipt_n
|
||||
if [ -n "${is_tproxy}" ]; then
|
||||
ipt_tmp=$ipt_m
|
||||
ipt_j="-j PSW_RULE"
|
||||
else
|
||||
ipt_j="$(REDIRECT $TCP_REDIR_PORT)"
|
||||
ipt_j="$(REDIRECT $REDIR_PORT)"
|
||||
fi
|
||||
|
||||
msg="【路由器本机】,"
|
||||
@@ -1231,7 +1196,7 @@ add_firewall_rule() {
|
||||
fi
|
||||
}
|
||||
|
||||
if ([ -n "$TCP_NODE" ] && [ -n "${LOCALHOST_TCP_PROXY_MODE}" ]) || ([ -n "$UDP_NODE" ] && [ -n "${LOCALHOST_UDP_PROXY_MODE}" ]); then
|
||||
if [ -n "$NODE" ] && ([ -n "${LOCALHOST_TCP_PROXY_MODE}" ] || [ -n "${LOCALHOST_UDP_PROXY_MODE}" ]); then
|
||||
[ -n "$DNS_REDIRECT_PORT" ] && {
|
||||
$ipt_n -A OUTPUT $(comment "PSW_DNS") -p udp -o lo --dport 53 -j REDIRECT --to-ports $DNS_REDIRECT_PORT
|
||||
$ip6t_n -A OUTPUT $(comment "PSW_DNS") -p udp -o lo --dport 53 -j REDIRECT --to-ports $DNS_REDIRECT_PORT 2>/dev/null
|
||||
@@ -1246,7 +1211,7 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
|
||||
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
|
||||
echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]"
|
||||
}
|
||||
@@ -1256,14 +1221,14 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
|
||||
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
|
||||
echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]"
|
||||
}
|
||||
}
|
||||
|
||||
# 加载路由器自身代理 TCP
|
||||
if [ -n "$TCP_NODE" ]; then
|
||||
if [ -n "$NODE" ]; then
|
||||
_proxy_tcp_access() {
|
||||
[ -n "${2}" ] || return 0
|
||||
if echo "${2}" | grep -q -v ':'; then
|
||||
@@ -1273,10 +1238,10 @@ add_firewall_rule() {
|
||||
return 0
|
||||
}
|
||||
if [ -z "${is_tproxy}" ]; then
|
||||
$ipt_n -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} $(REDIRECT $TCP_REDIR_PORT)
|
||||
$ipt_n -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT)
|
||||
else
|
||||
$ipt_m -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} -j PSW_RULE
|
||||
$ipt_m -I PSW $(comment "本机") -p tcp -i lo -d ${2} --dport ${3} $(REDIRECT $TCP_REDIR_PORT TPROXY)
|
||||
$ipt_m -I PSW $(comment "本机") -p tcp -i lo -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT TPROXY)
|
||||
fi
|
||||
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 TCP 转发链"
|
||||
else
|
||||
@@ -1286,7 +1251,7 @@ add_firewall_rule() {
|
||||
return 0
|
||||
}
|
||||
$ip6t_m -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} -j PSW_RULE
|
||||
$ip6t_m -I PSW $(comment "本机") -p tcp -i lo -d ${2} --dport ${3} $(REDIRECT $TCP_REDIR_PORT TPROXY)
|
||||
$ip6t_m -I PSW $(comment "本机") -p tcp -i lo -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT TPROXY)
|
||||
echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 TCP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!"
|
||||
fi
|
||||
}
|
||||
@@ -1298,7 +1263,7 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_BLACK) $(REDIRECT)
|
||||
[ "${USE_GFW_LIST}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_GFW) $(REDIRECT)
|
||||
[ "${CHN_LIST}" != "0" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST})
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_SHUNT) $(REDIRECT)
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_SHUNT) $(REDIRECT)
|
||||
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && $ipt_n -A PSW_OUTPUT -p icmp $(REDIRECT)
|
||||
}
|
||||
|
||||
@@ -1308,7 +1273,7 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_BLACK6) $(REDIRECT)
|
||||
[ "${USE_GFW_LIST}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_GFW6) $(REDIRECT)
|
||||
[ "${CHN_LIST}" != "0" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST})
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_SHUNT6) $(REDIRECT)
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_SHUNT6) $(REDIRECT)
|
||||
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(REDIRECT)
|
||||
}
|
||||
|
||||
@@ -1317,9 +1282,9 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK) ${ipt_j}"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW) ${ipt_j}"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "${ipt_j}")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT) ${ipt_j}"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT) ${ipt_j}"
|
||||
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "${ipt_j}"
|
||||
[ -n "${is_tproxy}" ] && $ipt_m -A PSW $(comment "本机") -p tcp -i lo $(REDIRECT $TCP_REDIR_PORT TPROXY)
|
||||
[ -n "${is_tproxy}" ] && $ipt_m -A PSW $(comment "本机") -p tcp -i lo $(REDIRECT $REDIR_PORT TPROXY)
|
||||
}
|
||||
[ -z "${is_tproxy}" ] && $ipt_n -A OUTPUT -p tcp -j PSW_OUTPUT
|
||||
[ -n "${is_tproxy}" ] && {
|
||||
@@ -1333,9 +1298,9 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
|
||||
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "-j PSW_RULE"
|
||||
$ip6t_m -A PSW $(comment "本机") -p tcp -i lo $(REDIRECT $TCP_REDIR_PORT TPROXY)
|
||||
$ip6t_m -A PSW $(comment "本机") -p tcp -i lo $(REDIRECT $REDIR_PORT TPROXY)
|
||||
}
|
||||
$ip6t_m -A PSW $(comment "本机") -p tcp -i lo -j RETURN
|
||||
insert_rule_before "$ip6t_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p tcp -j PSW_OUTPUT"
|
||||
@@ -1343,7 +1308,7 @@ add_firewall_rule() {
|
||||
fi
|
||||
|
||||
# 加载路由器自身代理 UDP
|
||||
if [ -n "$UDP_NODE" ] || [ "$TCP_UDP" = "1" ]; then
|
||||
if [ -n "$NODE" ]; then
|
||||
_proxy_udp_access() {
|
||||
[ -n "${2}" ] || return 0
|
||||
if echo "${2}" | grep -q -v ':'; then
|
||||
@@ -1353,7 +1318,7 @@ add_firewall_rule() {
|
||||
return 0
|
||||
}
|
||||
$ipt_m -I PSW_OUTPUT -p udp -d ${2} --dport ${3} -j PSW_RULE
|
||||
$ipt_m -I PSW $(comment "本机") -p udp -i lo -d ${2} --dport ${3} $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ipt_m -I PSW $(comment "本机") -p udp -i lo -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT TPROXY)
|
||||
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 UDP 转发链"
|
||||
else
|
||||
ipset -q test $IPSET_LAN6 ${2}
|
||||
@@ -1362,7 +1327,7 @@ add_firewall_rule() {
|
||||
return 0
|
||||
}
|
||||
$ip6t_m -I PSW_OUTPUT -p udp -d ${2} --dport ${3} -j PSW_RULE
|
||||
$ip6t_m -I PSW $(comment "本机") -p udp -i lo -d ${2} --dport ${3} $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ip6t_m -I PSW $(comment "本机") -p udp -i lo -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT TPROXY)
|
||||
echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 UDP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!"
|
||||
fi
|
||||
}
|
||||
@@ -1372,9 +1337,9 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK) -j PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW) -j PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT) -j PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT) -j PSW_RULE"
|
||||
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "-j PSW_RULE"
|
||||
$ipt_m -A PSW $(comment "本机") -p udp -i lo $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ipt_m -A PSW $(comment "本机") -p udp -i lo $(REDIRECT $REDIR_PORT TPROXY)
|
||||
}
|
||||
$ipt_m -A PSW $(comment "本机") -p udp -i lo -j RETURN
|
||||
insert_rule_before "$ipt_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p udp -j PSW_OUTPUT"
|
||||
@@ -1385,9 +1350,9 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
|
||||
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "-j PSW_RULE"
|
||||
$ip6t_m -A PSW $(comment "本机") -p udp -i lo $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ip6t_m -A PSW $(comment "本机") -p udp -i lo $(REDIRECT $REDIR_PORT TPROXY)
|
||||
}
|
||||
$ip6t_m -A PSW $(comment "本机") -p udp -i lo -j RETURN
|
||||
insert_rule_before "$ip6t_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p udp -j PSW_OUTPUT"
|
||||
|
||||
@@ -42,9 +42,6 @@ NFTSET_WHITE6_STATIC="${NFTSET_WHITE6}_static"
|
||||
NFTSET_BLOCK6_STATIC="${NFTSET_BLOCK6}_static"
|
||||
NFTSET_SHUNT6_STATIC="${NFTSET_SHUNT6}_static"
|
||||
|
||||
USE_SHUNT_TCP=0
|
||||
USE_SHUNT_UDP=0
|
||||
|
||||
# ASCII code for PSW1.Use whatever,just not the same.
|
||||
FWMARK="0x50535731"
|
||||
|
||||
@@ -291,41 +288,28 @@ load_acl() {
|
||||
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
|
||||
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
|
||||
|
||||
[ -n "$(get_cache_var "ACL_${sid}_tcp_node")" ] && tcp_node=$(get_cache_var "ACL_${sid}_tcp_node")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_tcp_redir_port")" ] && tcp_port=$(get_cache_var "ACL_${sid}_tcp_redir_port")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_udp_node")" ] && udp_node=$(get_cache_var "ACL_${sid}_udp_node")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_udp_redir_port")" ] && udp_port=$(get_cache_var "ACL_${sid}_udp_redir_port")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_node")" ] && node=$(get_cache_var "ACL_${sid}_node")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_redir_port")" ] && {
|
||||
tcp_port=$(get_cache_var "ACL_${sid}_redir_port")
|
||||
udp_port=$tcp_port
|
||||
}
|
||||
[ -n "$(get_cache_var "ACL_${sid}_dns_port")" ] && dns_redirect_port=$(get_cache_var "ACL_${sid}_dns_port")
|
||||
[ -n "$(get_cache_var "ACL_${sid}_fakedns")" ] && use_fakedns=$(get_cache_var "ACL_${sid}_fakedns")
|
||||
[ -n "$tcp_node" ] && {
|
||||
if [ "$(config_get_type $tcp_node)" = "socks" ]; then
|
||||
tcp_node_remark="Socks 配置($(config_n_get $tcp_node port) 端口)"
|
||||
[ -n "$node" ] && {
|
||||
if [ "$(config_get_type $node)" = "socks" ]; then
|
||||
node_remark="Socks 配置($(config_n_get $node port) 端口)"
|
||||
else
|
||||
tcp_node_remark=$(config_n_get $tcp_node remarks)
|
||||
node_remark=$(config_n_get $node remarks)
|
||||
fi
|
||||
}
|
||||
[ -n "$udp_node" ] && {
|
||||
if [ "$(config_get_type $udp_node)" = "socks" ]; then
|
||||
udp_node_remark="Socks 配置($(config_n_get $udp_node port) 端口)"
|
||||
else
|
||||
udp_node_remark=$(config_n_get $udp_node remarks)
|
||||
fi
|
||||
}
|
||||
use_shunt_tcp=0
|
||||
use_shunt_udp=0
|
||||
[ -n "$tcp_node" ] && [ "$(config_n_get $tcp_node protocol)" = "_shunt" ] && use_shunt_tcp=1
|
||||
[ -n "$udp_node" ] && [ "$(config_n_get $udp_node protocol)" = "_shunt" ] && use_shunt_udp=1
|
||||
use_shunt_node=0
|
||||
[ -n "$node" ] && [ "$(config_n_get $node protocol)" = "_shunt" ] && use_shunt_node=1
|
||||
|
||||
[ "${use_global_config}" = "1" ] && {
|
||||
if [ "$(config_get_type $TCP_NODE)" = "socks" ]; then
|
||||
tcp_node_remark="Socks 配置($(config_n_get $TCP_NODE port) 端口)"
|
||||
if [ "$(config_get_type $NODE)" = "socks" ]; then
|
||||
node_remark="Socks 配置($(config_n_get $NODE port) 端口)"
|
||||
else
|
||||
tcp_node_remark=$(config_n_get $TCP_NODE remarks)
|
||||
fi
|
||||
if [ "$(config_get_type $UDP_NODE)" = "socks" ]; then
|
||||
udp_node_remark="Socks 配置($(config_n_get $UDP_NODE port) 端口)"
|
||||
else
|
||||
udp_node_remark=$(config_n_get $UDP_NODE remarks)
|
||||
node_remark=$(config_n_get $NODE remarks)
|
||||
fi
|
||||
use_direct_list=${USE_DIRECT_LIST}
|
||||
use_proxy_list=${USE_PROXY_LIST}
|
||||
@@ -334,8 +318,7 @@ load_acl() {
|
||||
chn_list=${CHN_LIST}
|
||||
tcp_proxy_mode=${TCP_PROXY_MODE}
|
||||
udp_proxy_mode=${UDP_PROXY_MODE}
|
||||
use_shunt_tcp=${USE_SHUNT_TCP}
|
||||
use_shunt_udp=${USE_SHUNT_UDP}
|
||||
use_shunt_node=${USE_SHUNT_NODE}
|
||||
dns_redirect_port=${DNS_REDIRECT_PORT}
|
||||
black_set_name=${NFTSET_BLACK}
|
||||
black_set_name_static=${NFTSET_BLACK_STATIC}
|
||||
@@ -445,7 +428,7 @@ load_acl() {
|
||||
gen_nftset $gfw6_set_name ipv6_addr "2d"
|
||||
}
|
||||
}
|
||||
[ "${use_shunt_tcp}" = "1" ] || [ "${use_shunt_udp}" = "1" ] && {
|
||||
[ "${use_shunt_node}" = "1" ] && {
|
||||
[ "${use_global_config}" = "0" ] && {
|
||||
shunt_set_name="psw_${sid}_shunt"
|
||||
shunt_set_name_static="psw_${sid}_shunt_static"
|
||||
@@ -458,12 +441,8 @@ load_acl() {
|
||||
# 预加载分流规则 ip 到 nftset
|
||||
local GEOIP_CODE=""
|
||||
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
|
||||
local shunt_group shunt_id
|
||||
if [ "${use_shunt_tcp}" = "1" ]; then
|
||||
shunt_group=$(config_n_get $tcp_node shunt_group)
|
||||
elif [ "${use_shunt_udp}" = "1" ]; then
|
||||
shunt_group=$(config_n_get $udp_node shunt_group)
|
||||
fi
|
||||
local shunt_group=$(config_n_get $node shunt_group)
|
||||
local shunt_id
|
||||
for shunt_id in $shunt_ids; do
|
||||
[ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue
|
||||
config_n_get $shunt_id ip_list | sed 's/#.*//' | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | insert_nftset $shunt_set_name_static
|
||||
@@ -492,7 +471,7 @@ load_acl() {
|
||||
#nft "add rule $NFTABLE_NAME PSW_DNS ip protocol tcp ${_ipt_source} tcp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\""
|
||||
nft "add rule $NFTABLE_NAME PSW_DNS meta l4proto udp ${_ipt_source} udp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\""
|
||||
nft "add rule $NFTABLE_NAME PSW_DNS meta l4proto tcp ${_ipt_source} tcp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\""
|
||||
[ -z "$(get_cache_var "ACL_${sid}_tcp_default")" ] && echolog " - ${msg}使用与全局配置不相同节点,已将DNS强制重定向到专用 DNS 服务器。"
|
||||
[ -z "$(get_cache_var "ACL_${sid}_default")" ] && echolog " - ${msg}使用与全局配置不相同节点,已将DNS强制重定向到专用 DNS 服务器。"
|
||||
fi
|
||||
|
||||
[ -n "$tcp_port" ] || [ -n "$udp_port" ] && {
|
||||
@@ -511,14 +490,14 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$black6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr @$gfw6_set_name counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$shunt6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$shunt6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") counter reject comment \"$remarks\"" 2>/dev/null
|
||||
}
|
||||
[ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr $FAKE_IP counter reject comment \"$remarks\""
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$black_set_name" "counter reject comment \"$remarks\""
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr @$gfw_set_name counter reject comment \"$remarks\""
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\""
|
||||
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$shunt_set_name" "counter reject comment \"$remarks\""
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$shunt_set_name" "counter reject comment \"$remarks\""
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") counter reject comment \"$remarks\""
|
||||
echolog " - ${msg}屏蔽代理 TCP 端口[${tcp_proxy_drop_ports}]"
|
||||
}
|
||||
@@ -529,14 +508,14 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$black6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr @$gfw6_set_name counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_udp}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$shunt6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$shunt6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") counter reject comment \"$remarks\"" 2>/dev/null
|
||||
}
|
||||
[ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr $FAKE_IP counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$black_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr @$gfw_set_name counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_udp}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$shunt_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$shunt_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
|
||||
[ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") counter reject comment \"$remarks\"" 2>/dev/null
|
||||
echolog " - ${msg}屏蔽代理 UDP 端口[${udp_proxy_drop_ports}]"
|
||||
}
|
||||
@@ -544,7 +523,7 @@ load_acl() {
|
||||
|
||||
[ -n "$tcp_port" ] && {
|
||||
if [ -n "${tcp_proxy_mode}" ]; then
|
||||
msg2="${msg}使用 TCP 节点[$tcp_node_remark]"
|
||||
msg2="${msg}代理 TCP 使用节点[$node_remark]"
|
||||
if [ -n "${is_tproxy}" ]; then
|
||||
msg2="${msg2}(TPROXY:${tcp_port})"
|
||||
nft_chain="PSW_MANGLE"
|
||||
@@ -561,7 +540,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$black_set_name" "$(REDIRECT) comment \"$remarks\""
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} ip daddr @$gfw_set_name $(REDIRECT) comment \"$remarks\""
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list}) comment \"$remarks\""
|
||||
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$shunt_set_name" "$(REDIRECT) comment \"$remarks\""
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$shunt_set_name" "$(REDIRECT) comment \"$remarks\""
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} $(REDIRECT) comment \"$remarks\""
|
||||
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} return comment \"$remarks\""
|
||||
}
|
||||
@@ -572,7 +551,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$black6_set_name" "$(REDIRECT) comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} ip6 daddr @$gfw6_set_name $(REDIRECT) comment \"$remarks\"" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list}) comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$shunt6_set_name" "$(REDIRECT) comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$shunt6_set_name" "$(REDIRECT) comment \"$remarks\"" 2>/dev/null
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} $(REDIRECT) comment \"$remarks\"" 2>/dev/null
|
||||
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} return comment \"$remarks\"" 2>/dev/null
|
||||
}
|
||||
@@ -581,7 +560,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$black_set_name" "${nft_j} comment \"$remarks\""
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr @$gfw_set_name ${nft_j} comment \"$remarks\""
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "${nft_j}") comment \"$remarks\""
|
||||
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$shunt_set_name" "${nft_j} comment \"$remarks\""
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$shunt_set_name" "${nft_j} comment \"$remarks\""
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ${nft_j} comment \"$remarks\""
|
||||
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY4) comment \"$remarks\""
|
||||
|
||||
@@ -590,7 +569,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$black6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr @$gfw6_set_name counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$shunt6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$shunt6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY) comment \"$remarks\"" 2>/dev/null
|
||||
}
|
||||
@@ -605,14 +584,14 @@ load_acl() {
|
||||
|
||||
[ -n "$udp_port" ] && {
|
||||
if [ -n "${udp_proxy_mode}" ]; then
|
||||
msg2="${msg}使用 UDP 节点[$udp_node_remark]"
|
||||
msg2="${msg}代理 UDP 使用节点[$node_remark]"
|
||||
msg2="${msg2}(TPROXY:${udp_port})"
|
||||
|
||||
[ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} ip daddr $FAKE_IP counter jump PSW_RULE comment \"$remarks\""
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$black_set_name" "counter jump PSW_RULE comment \"$remarks\""
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr @$gfw_set_name counter jump PSW_RULE comment \"$remarks\""
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\""
|
||||
[ "${use_shunt_udp}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$shunt_set_name" "counter jump PSW_RULE comment \"$remarks\""
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$shunt_set_name" "counter jump PSW_RULE comment \"$remarks\""
|
||||
[ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") counter jump PSW_RULE comment \"$remarks\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(REDIRECT $udp_port TPROXY4) comment \"$remarks\""
|
||||
|
||||
@@ -621,7 +600,7 @@ load_acl() {
|
||||
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$black6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr @$gfw6_set_name counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_udp}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$shunt6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
[ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$shunt6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
[ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(REDIRECT $udp_port TPROXY) comment \"$remarks\"" 2>/dev/null
|
||||
}
|
||||
@@ -634,8 +613,8 @@ load_acl() {
|
||||
[ "$_ipv4" != "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} counter return comment \"$remarks\"" 2>/dev/null
|
||||
unset nft_chain nft_j _ipt_source msg msg2 _ipv4
|
||||
done
|
||||
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 dns_redirect_port 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 interface
|
||||
unset tcp_port udp_port tcp_node_remark udp_node_remark _acl_list use_shunt_tcp use_shunt_udp dns_redirect use_fakedns
|
||||
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 dns_redirect_port tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports node interface
|
||||
unset tcp_port udp_port node_remark _acl_list use_shunt_node dns_redirect use_fakedns
|
||||
done
|
||||
}
|
||||
|
||||
@@ -665,7 +644,7 @@ load_acl() {
|
||||
|
||||
local DNS_REDIRECT
|
||||
[ $(config_t_get global dns_redirect "1") = "1" ] && DNS_REDIRECT=53
|
||||
if ([ -n "$TCP_NODE" ] && [ -n "${TCP_PROXY_MODE}" ]) || ([ -n "$UDP_NODE" ] && [ -n "${UDP_PROXY_MODE}" ]); then
|
||||
if [ -n "$NODE" ] && ([ -n "${TCP_PROXY_MODE}" ] || [ -n "${UDP_PROXY_MODE}" ]); then
|
||||
[ -n "${DNS_REDIRECT_PORT}" ] && DNS_REDIRECT=${DNS_REDIRECT_PORT}
|
||||
else
|
||||
[ -n "${DIRECT_DNSMASQ_PORT}" ] && DNS_REDIRECT=${DIRECT_DNSMASQ_PORT}
|
||||
@@ -698,7 +677,7 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_BLACK6" "counter reject comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr @$NFTSET_GFW6 counter reject comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\""
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter reject comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter reject comment \"默认\""
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject comment \"默认\""
|
||||
}
|
||||
|
||||
@@ -706,7 +685,7 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_BLACK" "counter reject comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr @$NFTSET_GFW counter reject comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\""
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_SHUNT" "counter reject comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_SHUNT" "counter reject comment \"默认\""
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject comment \"默认\""
|
||||
echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]"
|
||||
}
|
||||
@@ -717,14 +696,14 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_BLACK6" "counter reject comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr @$NFTSET_GFW6 counter reject comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\""
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter reject comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter reject comment \"默认\""
|
||||
[ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject comment \"默认\""
|
||||
}
|
||||
[ "${USE_FAKEDNS}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr $FAKE_IP counter reject comment \"默认\""
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_BLACK" "counter reject comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr @$NFTSET_GFW counter reject comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\""
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_SHUNT" "counter reject comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_SHUNT" "counter reject comment \"默认\""
|
||||
[ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject comment \"默认\""
|
||||
echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]"
|
||||
}
|
||||
@@ -732,20 +711,20 @@ load_acl() {
|
||||
|
||||
# 加载TCP默认代理模式
|
||||
if [ -n "${TCP_PROXY_MODE}" ]; then
|
||||
[ -n "$TCP_NODE" ] && {
|
||||
if [ "$(config_get_type $TCP_NODE)" = "socks" ]; then
|
||||
msg2="${msg}使用 TCP 节点[Socks 配置($(config_n_get $TCP_NODE port) 端口)]"
|
||||
[ -n "$NODE" ] && {
|
||||
if [ "$(config_get_type $NODE)" = "socks" ]; then
|
||||
msg2="${msg}代理 TCP 使用节点[Socks 配置($(config_n_get $NODE port) 端口)]"
|
||||
else
|
||||
msg2="${msg}使用 TCP 节点[$(config_n_get $TCP_NODE remarks)]"
|
||||
msg2="${msg}代理 TCP 使用节点[$(config_n_get $NODE remarks)]"
|
||||
fi
|
||||
if [ -n "${is_tproxy}" ]; then
|
||||
msg2="${msg2}(TPROXY:${TCP_REDIR_PORT})"
|
||||
msg2="${msg2}(TPROXY:${REDIR_PORT})"
|
||||
nft_chain="PSW_MANGLE"
|
||||
nft_j="counter jump PSW_RULE"
|
||||
else
|
||||
msg2="${msg2}(REDIRECT:${TCP_REDIR_PORT})"
|
||||
msg2="${msg2}(REDIRECT:${REDIR_PORT})"
|
||||
nft_chain="PSW_NAT"
|
||||
nft_j="$(REDIRECT $TCP_REDIR_PORT)"
|
||||
nft_j="$(REDIRECT $REDIR_PORT)"
|
||||
fi
|
||||
|
||||
[ "$accept_icmp" = "1" ] && {
|
||||
@@ -754,7 +733,7 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_BLACK" "$(REDIRECT) comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ip daddr @$NFTSET_GFW $(REDIRECT) comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST}) comment \"默认\""
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_SHUNT" "$(REDIRECT) comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_SHUNT" "$(REDIRECT) comment \"默认\""
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp $(REDIRECT) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp return comment \"默认\""
|
||||
}
|
||||
@@ -765,7 +744,7 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_BLACK6" "$(REDIRECT) comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ip6 daddr @$NFTSET_GFW6 $(REDIRECT) comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST}) comment \"默认\""
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_SHUNT6" "$(REDIRECT) comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_SHUNT6" "$(REDIRECT) comment \"默认\""
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 $(REDIRECT) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 return comment \"默认\""
|
||||
}
|
||||
@@ -774,9 +753,9 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_BLACK" "${nft_j} comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr @$NFTSET_GFW ${nft_j} comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "${nft_j}") comment \"默认\""
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_SHUNT" "${nft_j} comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_SHUNT" "${nft_j} comment \"默认\""
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j} comment \"默认\""
|
||||
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(REDIRECT $TCP_REDIR_PORT TPROXY4) comment \"默认\""
|
||||
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(REDIRECT $REDIR_PORT TPROXY4) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp counter return comment \"默认\""
|
||||
|
||||
[ "$PROXY_IPV6" = "1" ] && {
|
||||
@@ -784,9 +763,9 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_BLACK6" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr @$NFTSET_GFW6 counter jump PSW_RULE comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\""
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(REDIRECT $TCP_REDIR_PORT TPROXY) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(REDIRECT $REDIR_PORT TPROXY) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp counter return comment \"默认\""
|
||||
}
|
||||
|
||||
@@ -796,20 +775,20 @@ load_acl() {
|
||||
|
||||
# 加载UDP默认代理模式
|
||||
if [ -n "${UDP_PROXY_MODE}" ]; then
|
||||
[ -n "$UDP_NODE" ] || [ "$TCP_UDP" = "1" ] && {
|
||||
if [ "$(config_get_type $UDP_NODE)" = "socks" ]; then
|
||||
msg2="${msg}使用 UDP 节点[Socks 配置($(config_n_get $UDP_NODE port) 端口)](TPROXY:${UDP_REDIR_PORT})"
|
||||
[ -n "$NODE" ] && {
|
||||
if [ "$(config_get_type $NODE)" = "socks" ]; then
|
||||
msg2="${msg}代理 UDP 使用节点[Socks 配置($(config_n_get $NODE port) 端口)](TPROXY:${REDIR_PORT})"
|
||||
else
|
||||
msg2="${msg}使用 UDP 节点[$(config_n_get $UDP_NODE remarks)](TPROXY:${UDP_REDIR_PORT})"
|
||||
msg2="${msg}代理 UDP 使用节点[$(config_n_get $NODE remarks)](TPROXY:${REDIR_PORT})"
|
||||
fi
|
||||
|
||||
[ "${USE_FAKEDNS}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ip daddr $FAKE_IP counter jump PSW_RULE comment \"默认\""
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_BLACK" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr @$NFTSET_GFW counter jump PSW_RULE comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\""
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_SHUNT" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_SHUNT" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(REDIRECT $UDP_REDIR_PORT TPROXY4) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(REDIRECT $REDIR_PORT TPROXY4) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp counter return comment \"默认\""
|
||||
|
||||
[ "$PROXY_IPV6" = "1" ] && {
|
||||
@@ -817,9 +796,9 @@ load_acl() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_BLACK6" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr @$NFTSET_GFW6 counter jump PSW_RULE comment \"默认\""
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\""
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter jump PSW_RULE comment \"默认\""
|
||||
[ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(REDIRECT $UDP_REDIR_PORT TPROXY) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(REDIRECT $REDIR_PORT TPROXY) comment \"默认\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp counter return comment \"默认\""
|
||||
}
|
||||
|
||||
@@ -1013,18 +992,14 @@ add_firewall_rule() {
|
||||
gen_nftset $NFTSET_SHUNT6_STATIC ipv6_addr 0
|
||||
|
||||
#导入规则列表、分流规则中的IP列表
|
||||
local USE_SHUNT_NODE=0
|
||||
local USE_PROXY_LIST_ALL=${USE_PROXY_LIST}
|
||||
local USE_DIRECT_LIST_ALL=${USE_DIRECT_LIST}
|
||||
local USE_BLOCK_LIST_ALL=${USE_BLOCK_LIST}
|
||||
local _TCP_NODE=$(config_t_get global tcp_node)
|
||||
local _UDP_NODE=$(config_t_get global udp_node)
|
||||
USE_SHUNT_NODE=0
|
||||
USE_GEOVIEW=$(config_t_get global_rules enable_geoview)
|
||||
[ -z "$(first_type $(config_t_get global_app geoview_file) geoview)" ] && USE_GEOVIEW=0
|
||||
|
||||
[ -n "$_TCP_NODE" ] && [ "$(config_n_get $_TCP_NODE protocol)" = "_shunt" ] && USE_SHUNT_TCP=1 && USE_SHUNT_NODE=1
|
||||
[ -n "$_UDP_NODE" ] && [ "$(config_n_get $_UDP_NODE protocol)" = "_shunt" ] && USE_SHUNT_UDP=1 && USE_SHUNT_NODE=1
|
||||
[ "$_UDP_NODE" = "tcp" ] && USE_SHUNT_UDP=$USE_SHUNT_TCP
|
||||
[ -n "$NODE" ] && [ "$(config_n_get $NODE protocol)" = "_shunt" ] && USE_SHUNT_NODE=1
|
||||
|
||||
for acl_section in $(uci show ${CONFIG} | grep "=acl_rule" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
|
||||
[ "$(config_n_get $acl_section enabled)" != "1" ] && continue
|
||||
@@ -1033,10 +1008,6 @@ add_firewall_rule() {
|
||||
[ "$(config_n_get $acl_section use_proxy_list 1)" = "1" ] && USE_DIRECT_LIST_ALL=1
|
||||
[ "$(config_n_get $acl_section use_block_list 1)" = "1" ] && USE_BLOCK_LIST_ALL=1
|
||||
}
|
||||
for _node in $(config_n_get $acl_section tcp_node) $(config_n_get $acl_section udp_node); do
|
||||
local node_protocol=$(config_n_get $_node protocol)
|
||||
[ "$node_protocol" = "_shunt" ] && { USE_SHUNT_NODE=1; break; }
|
||||
done
|
||||
done
|
||||
|
||||
#直连列表
|
||||
@@ -1085,12 +1056,8 @@ add_firewall_rule() {
|
||||
[ "$USE_SHUNT_NODE" = "1" ] && {
|
||||
local GEOIP_CODE=""
|
||||
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
|
||||
local shunt_group shunt_id
|
||||
if [ "${USE_SHUNT_TCP}" = "1" ]; then
|
||||
shunt_group=$(config_n_get $_TCP_NODE shunt_group)
|
||||
elif [ "${USE_SHUNT_UDP}" = "1" ]; then
|
||||
shunt_group=$(config_n_get $_UDP_NODE shunt_group)
|
||||
fi
|
||||
local shunt_group=$(config_n_get $NODE shunt_group)
|
||||
local shunt_id
|
||||
for shunt_id in $shunt_ids; do
|
||||
[ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue
|
||||
config_n_get $shunt_id ip_list | sed 's/#.*//' | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | insert_nftset $NFTSET_SHUNT_STATIC
|
||||
@@ -1145,8 +1112,7 @@ add_firewall_rule() {
|
||||
filter_vpsip > /dev/null 2>&1 &
|
||||
# filter_haproxy > /dev/null 2>&1 &
|
||||
# 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 download_address) $(config_n_get $UDP_NODE download_address) > /dev/null 2>&1 &
|
||||
filter_vps_addr $(config_n_get $NODE address) $(config_n_get $NODE download_address) > /dev/null 2>&1 &
|
||||
|
||||
accept_icmp=$(config_t_get global_forwarding accept_icmp 0)
|
||||
accept_icmpv6=$(config_t_get global_forwarding accept_icmpv6 0)
|
||||
@@ -1291,8 +1257,6 @@ add_firewall_rule() {
|
||||
ip -6 route add local ::/0 dev lo table 999
|
||||
}
|
||||
|
||||
[ "$TCP_UDP" = "1" ] && [ -z "$UDP_NODE" ] && UDP_NODE=$TCP_NODE
|
||||
|
||||
[ "$ENABLED_DEFAULT_ACL" = 1 ] && {
|
||||
msg="【路由器本机】,"
|
||||
|
||||
@@ -1318,7 +1282,7 @@ add_firewall_rule() {
|
||||
fi
|
||||
}
|
||||
|
||||
if ([ -n "$TCP_NODE" ] && [ -n "${LOCALHOST_TCP_PROXY_MODE}" ]) || ([ -n "$UDP_NODE" ] && [ -n "${LOCALHOST_UDP_PROXY_MODE}" ]); then
|
||||
if [ -n "$NODE" ] && ([ -n "${LOCALHOST_TCP_PROXY_MODE}" ] || [ -n "${LOCALHOST_UDP_PROXY_MODE}" ]); then
|
||||
[ -n "$DNS_REDIRECT_PORT" ] && {
|
||||
nft "add rule $NFTABLE_NAME nat_output ip protocol udp oif lo udp dport 53 counter redirect to :$DNS_REDIRECT_PORT comment \"PSW_DNS\""
|
||||
nft "add rule $NFTABLE_NAME nat_output ip protocol tcp oif lo tcp dport 53 counter redirect to :$DNS_REDIRECT_PORT comment \"PSW_DNS\""
|
||||
@@ -1333,7 +1297,7 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_BLACK" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft add rule $NFTABLE_NAME $nft_output_chain ip protocol tcp ip daddr @$NFTSET_GFW $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_CHN" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "counter reject")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_SHUNT" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_SHUNT" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject"
|
||||
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft add rule $NFTABLE_NAME $nft_output_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject
|
||||
echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]"
|
||||
}
|
||||
@@ -1343,14 +1307,14 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_BLACK" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr @$NFTSET_GFW $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_CHN" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter reject")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_SHUNT" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_SHUNT" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject"
|
||||
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject
|
||||
echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]"
|
||||
}
|
||||
}
|
||||
|
||||
# 加载路由器自身代理 TCP
|
||||
if [ -n "$TCP_NODE" ]; then
|
||||
if [ -n "$NODE" ]; then
|
||||
_proxy_tcp_access() {
|
||||
[ -n "${2}" ] || return 0
|
||||
if echo "${2}" | grep -q -v ':'; then
|
||||
@@ -1360,10 +1324,10 @@ add_firewall_rule() {
|
||||
return 0
|
||||
}
|
||||
if [ -z "${is_tproxy}" ]; then
|
||||
nft insert rule $NFTABLE_NAME PSW_OUTPUT_NAT ip protocol tcp ip daddr ${2} tcp dport ${3} $(REDIRECT $TCP_REDIR_PORT)
|
||||
nft insert rule $NFTABLE_NAME PSW_OUTPUT_NAT ip protocol tcp ip daddr ${2} tcp dport ${3} $(REDIRECT $REDIR_PORT)
|
||||
else
|
||||
nft insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol tcp ip daddr ${2} tcp dport ${3} counter jump PSW_RULE
|
||||
nft insert rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo tcp dport ${3} ip daddr ${2} $(REDIRECT $TCP_REDIR_PORT TPROXY4) comment \"本机\"
|
||||
nft insert rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo tcp dport ${3} ip daddr ${2} $(REDIRECT $REDIR_PORT TPROXY4) comment \"本机\"
|
||||
fi
|
||||
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 TCP 转发链"
|
||||
else
|
||||
@@ -1373,7 +1337,7 @@ add_firewall_rule() {
|
||||
return 0
|
||||
}
|
||||
nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp ip6 daddr ${2} tcp dport ${3} counter jump PSW_RULE"
|
||||
nft "insert rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo tcp dport ${3} ip6 daddr ${2} $(REDIRECT $TCP_REDIR_PORT TPROXY6) comment \"本机\""
|
||||
nft "insert rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo tcp dport ${3} ip6 daddr ${2} $(REDIRECT $REDIR_PORT TPROXY6) comment \"本机\""
|
||||
echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 TCP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!"
|
||||
fi
|
||||
}
|
||||
@@ -1384,7 +1348,7 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_BLACK" "counter redirect"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp ip daddr @$NFTSET_GFW counter redirect"
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST})"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_SHUNT" "counter redirect"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_SHUNT" "counter redirect"
|
||||
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp counter redirect"
|
||||
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp counter return"
|
||||
}
|
||||
@@ -1394,7 +1358,7 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_BLACK6" "counter redirect"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 ip6 daddr @$NFTSET_GFW6 counter redirect"
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST})"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_SHUNT6" "counter redirect"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_SHUNT6" "counter redirect"
|
||||
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 counter redirect"
|
||||
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 counter return"
|
||||
}
|
||||
@@ -1404,7 +1368,7 @@ add_firewall_rule() {
|
||||
nft_j="counter jump PSW_RULE"
|
||||
else
|
||||
nft_chain="PSW_OUTPUT_NAT"
|
||||
nft_j="$(REDIRECT $TCP_REDIR_PORT)"
|
||||
nft_j="$(REDIRECT $REDIR_PORT)"
|
||||
fi
|
||||
|
||||
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && {
|
||||
@@ -1412,9 +1376,9 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_BLACK" "$(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ip daddr @$NFTSET_GFW $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_CHN" "$(factor $TCP_REDIR_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "${nft_j}")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_SHUNT" "$(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_SHUNT" "$(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
|
||||
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
|
||||
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo $(REDIRECT $TCP_REDIR_PORT TPROXY4) comment \"本机\""
|
||||
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo $(REDIRECT $REDIR_PORT TPROXY4) comment \"本机\""
|
||||
}
|
||||
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo counter return comment \"本机\""
|
||||
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME mangle_output ip protocol tcp counter jump PSW_OUTPUT_MANGLE comment \"PSW_OUTPUT_MANGLE\""
|
||||
@@ -1426,16 +1390,16 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_BLACK6" "$(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp ip6 daddr @$NFTSET_GFW6 $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_CHN6" "$(factor $TCP_REDIR_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")"
|
||||
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_SHUNT6" "$(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_SHUNT6" "$(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
|
||||
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo $(REDIRECT $TCP_REDIR_PORT TPROXY) comment \"本机\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo $(REDIRECT $REDIR_PORT TPROXY) comment \"本机\""
|
||||
}
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo counter return comment \"本机\""
|
||||
}
|
||||
fi
|
||||
|
||||
# 加载路由器自身代理 UDP
|
||||
if [ -n "$UDP_NODE" ] || [ "$TCP_UDP" = "1" ]; then
|
||||
if [ -n "$NODE" ]; then
|
||||
_proxy_udp_access() {
|
||||
[ -n "${2}" ] || return 0
|
||||
if echo "${2}" | grep -q -v ':'; then
|
||||
@@ -1445,7 +1409,7 @@ add_firewall_rule() {
|
||||
return 0
|
||||
}
|
||||
nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr ${2} udp dport ${3} counter jump PSW_RULE"
|
||||
nft "insert rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo ip daddr ${2} $(REDIRECT $UDP_REDIR_PORT TPROXY4) comment \"本机\""
|
||||
nft "insert rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo ip daddr ${2} $(REDIRECT $REDIR_PORT TPROXY4) comment \"本机\""
|
||||
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 UDP 转发链"
|
||||
else
|
||||
nft "get element $NFTABLE_NAME $NFTSET_LAN6 {${2}}" &>/dev/null
|
||||
@@ -1454,7 +1418,7 @@ add_firewall_rule() {
|
||||
return 0
|
||||
}
|
||||
nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp ip6 daddr ${2} udp dport ${3} counter jump PSW_RULE"
|
||||
nft "insert rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo ip6 daddr ${2} $(REDIRECT $UDP_REDIR_PORT TPROXY6) comment \"本机\""
|
||||
nft "insert rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo ip6 daddr ${2} $(REDIRECT $REDIR_PORT TPROXY6) comment \"本机\""
|
||||
echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 UDP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!"
|
||||
fi
|
||||
}
|
||||
@@ -1464,9 +1428,9 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_BLACK" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr @$NFTSET_GFW $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_CHN" "$(factor $UDP_REDIR_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_SHUNT" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_SHUNT" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo $(REDIRECT $UDP_REDIR_PORT TPROXY4) comment \"本机\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo $(REDIRECT $REDIR_PORT TPROXY4) comment \"本机\""
|
||||
}
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo counter return comment \"本机\""
|
||||
nft "add rule $NFTABLE_NAME mangle_output ip protocol udp counter jump PSW_OUTPUT_MANGLE comment \"PSW_OUTPUT_MANGLE\""
|
||||
@@ -1477,9 +1441,9 @@ add_firewall_rule() {
|
||||
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_BLACK6" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp ip6 daddr @$NFTSET_GFW6 $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_CHN6" "$(factor $UDP_REDIR_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")"
|
||||
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_SHUNT6" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
[ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_SHUNT6" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo $(REDIRECT $UDP_REDIR_PORT TPROXY) comment \"本机\""
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo $(REDIRECT $REDIR_PORT TPROXY) comment \"本机\""
|
||||
}
|
||||
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo counter return comment \"本机\""
|
||||
}
|
||||
|
||||
@@ -136,15 +136,13 @@ end
|
||||
-- 获取各项动态配置的当前服务器,可以用 get 和 set, get必须要获取到节点表
|
||||
local CONFIG = {}
|
||||
do
|
||||
local function import_config(protocol)
|
||||
local name = string.upper(protocol)
|
||||
if true then
|
||||
local szType = "@global[0]"
|
||||
local option = protocol .. "_node"
|
||||
|
||||
local option = "node"
|
||||
local node_id = uci_get(szType, option)
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = true,
|
||||
remarks = name .. "节点",
|
||||
remarks = "全局节点",
|
||||
currentNode = (function(id)
|
||||
local section = id and uci_get(id) or nil
|
||||
if not section then return nil end
|
||||
@@ -159,8 +157,6 @@ do
|
||||
end
|
||||
}
|
||||
end
|
||||
import_config("tcp")
|
||||
import_config("udp")
|
||||
|
||||
if true then
|
||||
local i = 0
|
||||
@@ -255,30 +251,27 @@ do
|
||||
|
||||
if true then
|
||||
local i = 0
|
||||
local options = {"tcp", "udp"}
|
||||
uci_foreach("acl_rule", function(t)
|
||||
i = i + 1
|
||||
for index, value in ipairs(options) do
|
||||
local option = value .. "_node"
|
||||
local node_id = t[option]
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = true,
|
||||
id = t[".name"],
|
||||
remarks = "访问控制列表[" .. i .. "]",
|
||||
currentNode = (function(id)
|
||||
local section = id and uci_get(id) or nil
|
||||
if not section then return nil end
|
||||
if section[".type"] == "socks" then
|
||||
return { Socks = id }
|
||||
end
|
||||
return section
|
||||
end)(node_id),
|
||||
set = function(o, server)
|
||||
uci_set(t[".name"], option, server)
|
||||
o.newNodeId = server
|
||||
local option = "node"
|
||||
local node_id = t[option]
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = true,
|
||||
id = t[".name"],
|
||||
remarks = "访问控制列表[" .. i .. "]",
|
||||
currentNode = (function(id)
|
||||
local section = id and uci_get(id) or nil
|
||||
if not section then return nil end
|
||||
if section[".type"] == "socks" then
|
||||
return { Socks = id }
|
||||
end
|
||||
}
|
||||
end
|
||||
return section
|
||||
end)(node_id),
|
||||
set = function(o, server)
|
||||
uci_set(t[".name"], option, server)
|
||||
o.newNodeId = server
|
||||
end
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -486,20 +486,16 @@ ln_run() {
|
||||
if [ -z "$persist_log_path" ] && [ "$sys_log" != "1" ]; then
|
||||
${file_func:-echolog " - ${ln_name}"} "$@" >${output} 2>&1 &
|
||||
else
|
||||
case "$output" in
|
||||
*TCP.log) local protocol="TCP" ;;
|
||||
*UDP.log) local protocol="UDP" ;;
|
||||
esac
|
||||
if [ -n "${persist_log_path}" ]; then
|
||||
mkdir -p ${persist_log_path}
|
||||
local log_file=${persist_log_path}/passwall_${protocol}_${ln_name}_$(date '+%F').log
|
||||
local log_file=${persist_log_path}/passwall_global_${ln_name}_$(date '+%F').log
|
||||
echolog "记录到持久性日志文件:${log_file}"
|
||||
${file_func:-echolog " - ${ln_name}"} "$@" >> ${log_file} 2>&1 &
|
||||
sys_log=0
|
||||
fi
|
||||
if [ "${sys_log}" = "1" ]; then
|
||||
echolog "记录 ${ln_name}_${protocol} 到系统日志"
|
||||
${file_func:-echolog " - ${ln_name}"} "$@" 2>&1 | logger -t PASSWALL_${protocol}_${ln_name} &
|
||||
echolog "记录 ${ln_name}_global 到系统日志"
|
||||
${file_func:-echolog " - ${ln_name}"} "$@" 2>&1 | logger -t PASSWALL_global_${ln_name} &
|
||||
fi
|
||||
fi
|
||||
[ "$NO_REC_PROCESS" = "1" ] && return
|
||||
|
||||
@@ -49,7 +49,7 @@ fi
|
||||
|
||||
if [ -z "$version" ] || [ "$version" -lt 1 ]; then
|
||||
uci -q set luci.main.lang='auto'
|
||||
uci -q set luci.main.mediaurlbase=/luci-static/argon
|
||||
uci -q set luci.main.mediaurlbase=/luci-static/footstrap
|
||||
uci commit luci
|
||||
|
||||
if uci -q get system.@system[0] >/dev/null; then
|
||||
|
||||
Reference in new issue
Block a user