luci-app-passwall2: sync upstream
This commit is contained in:
parent
0c4f30f84a
commit
f7a88bb759
@ -5,7 +5,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-passwall2
|
PKG_NAME:=luci-app-passwall2
|
||||||
PKG_VERSION:=1.21-1
|
PKG_VERSION:=1.21-2
|
||||||
PKG_RELEASE:=
|
PKG_RELEASE:=
|
||||||
|
|
||||||
PKG_CONFIG_DEPENDS:= \
|
PKG_CONFIG_DEPENDS:= \
|
||||||
|
@ -16,6 +16,7 @@ OPENWRT_ARCH = nil
|
|||||||
DISTRIB_ARCH = nil
|
DISTRIB_ARCH = nil
|
||||||
|
|
||||||
LOG_FILE = "/tmp/log/passwall2.log"
|
LOG_FILE = "/tmp/log/passwall2.log"
|
||||||
|
CACHE_PATH = "/tmp/etc/passwall2_tmp"
|
||||||
|
|
||||||
function log(...)
|
function log(...)
|
||||||
local result = os.date("%Y-%m-%d %H:%M:%S: ") .. table.concat({...}, " ")
|
local result = os.date("%Y-%m-%d %H:%M:%S: ") .. table.concat({...}, " ")
|
||||||
@ -921,6 +922,30 @@ function to_move(app_name,file)
|
|||||||
return {code = 0}
|
return {code = 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function cacheFileCompareToLogic(file, str)
|
||||||
|
local result = nil
|
||||||
|
if file and str then
|
||||||
|
local file_str = ""
|
||||||
|
if fs.access(file) then
|
||||||
|
file_str = sys.exec("cat " .. file)
|
||||||
|
end
|
||||||
|
|
||||||
|
if file_str ~= str then
|
||||||
|
sys.call("rm -f " .. file)
|
||||||
|
result = false
|
||||||
|
else
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
|
||||||
|
local f_out = io.open(file, "w")
|
||||||
|
if f_out then
|
||||||
|
f_out:write(str)
|
||||||
|
f_out:close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
function is_js_luci()
|
function is_js_luci()
|
||||||
return sys.call('[ -f "/www/luci-static/resources/uci.js" ]') == 0
|
return sys.call('[ -f "/www/luci-static/resources/uci.js" ]') == 0
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,7 @@ local sys = api.sys
|
|||||||
local jsonc = api.jsonc
|
local jsonc = api.jsonc
|
||||||
local appname = api.appname
|
local appname = api.appname
|
||||||
local fs = api.fs
|
local fs = api.fs
|
||||||
|
local CACHE_PATH = api.CACHE_PATH
|
||||||
|
|
||||||
local new_port
|
local new_port
|
||||||
|
|
||||||
@ -712,6 +713,8 @@ function gen_config(var)
|
|||||||
local direct_dns_udp_server = var["-direct_dns_udp_server"]
|
local direct_dns_udp_server = var["-direct_dns_udp_server"]
|
||||||
local direct_dns_udp_port = var["-direct_dns_udp_port"]
|
local direct_dns_udp_port = var["-direct_dns_udp_port"]
|
||||||
local direct_dns_query_strategy = var["-direct_dns_query_strategy"]
|
local direct_dns_query_strategy = var["-direct_dns_query_strategy"]
|
||||||
|
local direct_ipset = var["-direct_ipset"]
|
||||||
|
local direct_nftset = var["-direct_nftset"]
|
||||||
local remote_dns_udp_server = var["-remote_dns_udp_server"]
|
local remote_dns_udp_server = var["-remote_dns_udp_server"]
|
||||||
local remote_dns_udp_port = var["-remote_dns_udp_port"]
|
local remote_dns_udp_port = var["-remote_dns_udp_port"]
|
||||||
local remote_dns_tcp_server = var["-remote_dns_tcp_server"]
|
local remote_dns_tcp_server = var["-remote_dns_tcp_server"]
|
||||||
@ -731,6 +734,8 @@ function gen_config(var)
|
|||||||
local inbounds = {}
|
local inbounds = {}
|
||||||
local outbounds = {}
|
local outbounds = {}
|
||||||
|
|
||||||
|
local CACHE_TEXT_FILE = CACHE_PATH .. "/cache_" .. flag .. ".txt"
|
||||||
|
|
||||||
local singbox_settings = uci:get_all(appname, "@global_singbox[0]") or {}
|
local singbox_settings = uci:get_all(appname, "@global_singbox[0]") or {}
|
||||||
|
|
||||||
local route = {
|
local route = {
|
||||||
@ -1349,6 +1354,25 @@ function gen_config(var)
|
|||||||
},
|
},
|
||||||
outbound = "dns-out"
|
outbound = "dns-out"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local content = flag .. node_id .. jsonc.stringify(dns)
|
||||||
|
if api.cacheFileCompareToLogic(CACHE_TEXT_FILE, content) == false then
|
||||||
|
--clear ipset/nftset
|
||||||
|
if direct_ipset then
|
||||||
|
string.gsub(direct_ipset, '[^' .. "," .. ']+', function(w)
|
||||||
|
sys.call("ipset -q -F " .. w)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if direct_nftset then
|
||||||
|
string.gsub(direct_nftset, '[^' .. "," .. ']+', function(w)
|
||||||
|
local s = string.reverse(w)
|
||||||
|
local _, i = string.find(s, "#")
|
||||||
|
local m = string.len(s) - i + 1
|
||||||
|
local n = w:sub(m + 1)
|
||||||
|
sys.call("nft flush set inet fw4 " .. n .. "2>/dev/null")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if inbounds or outbounds then
|
if inbounds or outbounds then
|
||||||
|
@ -5,6 +5,7 @@ local sys = api.sys
|
|||||||
local jsonc = api.jsonc
|
local jsonc = api.jsonc
|
||||||
local appname = api.appname
|
local appname = api.appname
|
||||||
local fs = api.fs
|
local fs = api.fs
|
||||||
|
local CACHE_PATH = api.CACHE_PATH
|
||||||
|
|
||||||
local new_port
|
local new_port
|
||||||
|
|
||||||
@ -520,6 +521,8 @@ function gen_config(var)
|
|||||||
local dns_query_strategy = var["-dns_query_strategy"]
|
local dns_query_strategy = var["-dns_query_strategy"]
|
||||||
local direct_dns_udp_server = var["-direct_dns_udp_server"]
|
local direct_dns_udp_server = var["-direct_dns_udp_server"]
|
||||||
local direct_dns_udp_port = var["-direct_dns_udp_port"]
|
local direct_dns_udp_port = var["-direct_dns_udp_port"]
|
||||||
|
local direct_ipset = var["-direct_ipset"]
|
||||||
|
local direct_nftset = var["-direct_nftset"]
|
||||||
local remote_dns_udp_server = var["-remote_dns_udp_server"]
|
local remote_dns_udp_server = var["-remote_dns_udp_server"]
|
||||||
local remote_dns_udp_port = var["-remote_dns_udp_port"]
|
local remote_dns_udp_port = var["-remote_dns_udp_port"]
|
||||||
local remote_dns_fake = var["-remote_dns_fake"]
|
local remote_dns_fake = var["-remote_dns_fake"]
|
||||||
@ -537,6 +540,8 @@ function gen_config(var)
|
|||||||
local routing = nil
|
local routing = nil
|
||||||
local observatory = nil
|
local observatory = nil
|
||||||
|
|
||||||
|
local CACHE_TEXT_FILE = CACHE_PATH .. "/cache_" .. flag .. ".txt"
|
||||||
|
|
||||||
local xray_settings = uci:get_all(appname, "@global_xray[0]") or {}
|
local xray_settings = uci:get_all(appname, "@global_xray[0]") or {}
|
||||||
|
|
||||||
local nodes = {}
|
local nodes = {}
|
||||||
@ -1228,6 +1233,25 @@ function gen_config(var)
|
|||||||
if dns_hosts_len == 0 then
|
if dns_hosts_len == 0 then
|
||||||
dns.hosts = nil
|
dns.hosts = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local content = flag .. node_id .. jsonc.stringify(dns)
|
||||||
|
if api.cacheFileCompareToLogic(CACHE_TEXT_FILE, content) == false then
|
||||||
|
--clear ipset/nftset
|
||||||
|
if direct_ipset then
|
||||||
|
string.gsub(direct_ipset, '[^' .. "," .. ']+', function(w)
|
||||||
|
sys.call("ipset -q -F " .. w)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if direct_nftset then
|
||||||
|
string.gsub(direct_nftset, '[^' .. "," .. ']+', function(w)
|
||||||
|
local s = string.reverse(w)
|
||||||
|
local _, i = string.find(s, "#")
|
||||||
|
local m = string.len(s) - i + 1
|
||||||
|
local n = w:sub(m + 1)
|
||||||
|
sys.call("nft flush set inet fw4 " .. n .. "2>/dev/null")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if inbounds or outbounds then
|
if inbounds or outbounds then
|
||||||
|
@ -74,11 +74,9 @@ config nodes 'myshunt'
|
|||||||
option DirectGame '_direct'
|
option DirectGame '_direct'
|
||||||
option ProxyGame '_default'
|
option ProxyGame '_default'
|
||||||
option Direct '_direct'
|
option Direct '_direct'
|
||||||
option AD 'nil'
|
option GooglePlay '_default'
|
||||||
option BT '_direct'
|
|
||||||
option Netflix 'nil'
|
option Netflix 'nil'
|
||||||
option OpenAI 'nil'
|
option OpenAI 'nil'
|
||||||
option TVB 'nil'
|
|
||||||
option Proxy '_default'
|
option Proxy '_default'
|
||||||
option China '_direct'
|
option China '_direct'
|
||||||
option QUIC '_blackhole'
|
option QUIC '_blackhole'
|
||||||
@ -175,15 +173,12 @@ cdn-qc.content.steamchina.com
|
|||||||
cdn-ali.content.steamchina.com
|
cdn-ali.content.steamchina.com
|
||||||
epicgames-download1-1251447533.file.myqcloud.com'
|
epicgames-download1-1251447533.file.myqcloud.com'
|
||||||
|
|
||||||
config shunt_rules 'AD'
|
config shunt_rules 'GooglePlay'
|
||||||
option remarks 'AD'
|
option remarks 'GooglePlay'
|
||||||
option domain_list 'geosite:category-ads-all'
|
|
||||||
option network 'tcp,udp'
|
|
||||||
|
|
||||||
config shunt_rules 'BT'
|
|
||||||
option remarks 'BT'
|
|
||||||
option protocol 'bittorrent'
|
|
||||||
option network 'tcp,udp'
|
option network 'tcp,udp'
|
||||||
|
option domain_list 'domain:googleapis.cn
|
||||||
|
domain:googleapis.com
|
||||||
|
domain:xn--ngstr-lra8j.com'
|
||||||
|
|
||||||
config shunt_rules 'Netflix'
|
config shunt_rules 'Netflix'
|
||||||
option remarks 'Netflix'
|
option remarks 'Netflix'
|
||||||
@ -192,14 +187,8 @@ config shunt_rules 'Netflix'
|
|||||||
|
|
||||||
config shunt_rules 'OpenAI'
|
config shunt_rules 'OpenAI'
|
||||||
option remarks 'OpenAI'
|
option remarks 'OpenAI'
|
||||||
option domain_list 'geosite:openai'
|
|
||||||
|
|
||||||
config shunt_rules 'TVB'
|
|
||||||
option remarks 'TVB'
|
|
||||||
option network 'tcp,udp'
|
option network 'tcp,udp'
|
||||||
option domain_list 'geosite:tvb
|
option domain_list 'geosite:openai'
|
||||||
geosite:mytvsuper
|
|
||||||
'
|
|
||||||
|
|
||||||
config shunt_rules 'Proxy'
|
config shunt_rules 'Proxy'
|
||||||
option network 'tcp,udp'
|
option network 'tcp,udp'
|
||||||
|
@ -393,6 +393,8 @@ run_xray() {
|
|||||||
[ -n "$dns_cache" ] && _extra_param="${_extra_param} -dns_cache ${dns_cache}"
|
[ -n "$dns_cache" ] && _extra_param="${_extra_param} -dns_cache ${dns_cache}"
|
||||||
_extra_param="${_extra_param} -dns_query_strategy UseIP"
|
_extra_param="${_extra_param} -dns_query_strategy UseIP"
|
||||||
_extra_param="${_extra_param} -direct_dns_udp_port ${direct_dnsmasq_listen_port} -direct_dns_udp_server 127.0.0.1"
|
_extra_param="${_extra_param} -direct_dns_udp_port ${direct_dnsmasq_listen_port} -direct_dns_udp_server 127.0.0.1"
|
||||||
|
[ -n "${direct_ipset}" ] && _extra_param="${_extra_param} -direct_ipset ${direct_ipset}"
|
||||||
|
[ -n "${direct_nftset}" ] && _extra_param="${_extra_param} -direct_nftset ${direct_nftset}"
|
||||||
_extra_param="${_extra_param} -remote_dns_udp_port ${dns_remote_listen_port} -remote_dns_udp_server 127.0.0.1"
|
_extra_param="${_extra_param} -remote_dns_udp_port ${dns_remote_listen_port} -remote_dns_udp_server 127.0.0.1"
|
||||||
[ "$remote_fakedns" = "1" ] && _extra_param="${_extra_param} -remote_dns_fake 1 -remote_dns_fake_strategy ${remote_dns_query_strategy}"
|
[ "$remote_fakedns" = "1" ] && _extra_param="${_extra_param} -remote_dns_fake 1 -remote_dns_fake_strategy ${remote_dns_query_strategy}"
|
||||||
}
|
}
|
||||||
@ -472,6 +474,8 @@ run_singbox() {
|
|||||||
run_ipset_dnsmasq listen_port=${direct_dnsmasq_listen_port} server_dns=127.0.0.1#${dns_direct_listen_port} ipset="${direct_ipset}" nftset="${direct_nftset}" config_file=${direct_ipset_conf}
|
run_ipset_dnsmasq listen_port=${direct_dnsmasq_listen_port} server_dns=127.0.0.1#${dns_direct_listen_port} ipset="${direct_ipset}" nftset="${direct_nftset}" config_file=${direct_ipset_conf}
|
||||||
|
|
||||||
_extra_param="${_extra_param} -direct_dns_udp_port ${direct_dnsmasq_listen_port} -direct_dns_udp_server 127.0.0.1 -direct_dns_query_strategy ${direct_dns_query_strategy}"
|
_extra_param="${_extra_param} -direct_dns_udp_port ${direct_dnsmasq_listen_port} -direct_dns_udp_server 127.0.0.1 -direct_dns_query_strategy ${direct_dns_query_strategy}"
|
||||||
|
[ -n "${direct_ipset}" ] && _extra_param="${_extra_param} -direct_ipset ${direct_ipset}"
|
||||||
|
[ -n "${direct_nftset}" ] && _extra_param="${_extra_param} -direct_nftset ${direct_nftset}"
|
||||||
|
|
||||||
case "$remote_dns_protocol" in
|
case "$remote_dns_protocol" in
|
||||||
udp)
|
udp)
|
||||||
|
Loading…
Reference in New Issue
Block a user