parent
f189752312
commit
77c90fe209
@ -27,6 +27,7 @@ local CACHE_PATH = api.CACHE_PATH
|
|||||||
local CACHE_FLAG = "dnsmasq_" .. FLAG
|
local CACHE_FLAG = "dnsmasq_" .. FLAG
|
||||||
local CACHE_DNS_PATH = CACHE_PATH .. "/" .. CACHE_FLAG
|
local CACHE_DNS_PATH = CACHE_PATH .. "/" .. CACHE_FLAG
|
||||||
local CACHE_TEXT_FILE = CACHE_DNS_PATH .. ".txt"
|
local CACHE_TEXT_FILE = CACHE_DNS_PATH .. ".txt"
|
||||||
|
local USE_CHINADNS_NG = "0"
|
||||||
|
|
||||||
local uci = api.uci
|
local uci = api.uci
|
||||||
local sys = api.sys
|
local sys = api.sys
|
||||||
@ -184,6 +185,7 @@ if DEFAULT_PROXY_MODE == "proxy" and CHN_LIST == "0" and USE_GFW_LIST == "0" the
|
|||||||
end
|
end
|
||||||
if USE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then
|
if USE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then
|
||||||
dnsmasq_default_dns = CHINADNS_DNS
|
dnsmasq_default_dns = CHINADNS_DNS
|
||||||
|
USE_CHINADNS_NG = "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
local setflag_4= (NFTFLAG == "1") and "4#inet#passwall#" or ""
|
local setflag_4= (NFTFLAG == "1") and "4#inet#passwall#" or ""
|
||||||
@ -194,7 +196,7 @@ if not fs.access(CACHE_DNS_PATH) then
|
|||||||
fs.mkdir(CACHE_DNS_PATH)
|
fs.mkdir(CACHE_DNS_PATH)
|
||||||
|
|
||||||
--屏蔽列表
|
--屏蔽列表
|
||||||
if USE_DEFAULT_DNS ~= "chinadns_ng" or CHINADNS_DNS == "0" then
|
if USE_CHINADNS_NG == "0" then
|
||||||
if USE_BLOCK_LIST == "1" then
|
if USE_BLOCK_LIST == "1" then
|
||||||
for line in io.lines("/usr/share/passwall/rules/block_host") do
|
for line in io.lines("/usr/share/passwall/rules/block_host") do
|
||||||
line = api.get_std_domain(line)
|
line = api.get_std_domain(line)
|
||||||
@ -212,7 +214,7 @@ if not fs.access(CACHE_DNS_PATH) then
|
|||||||
--始终用国内DNS解析节点域名
|
--始终用国内DNS解析节点域名
|
||||||
if true then
|
if true then
|
||||||
fwd_dns = LOCAL_DNS
|
fwd_dns = LOCAL_DNS
|
||||||
if USE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then
|
if USE_CHINADNS_NG == "1" then
|
||||||
fwd_dns = nil
|
fwd_dns = nil
|
||||||
else
|
else
|
||||||
uci:foreach(appname, "nodes", function(t)
|
uci:foreach(appname, "nodes", function(t)
|
||||||
@ -231,7 +233,7 @@ if not fs.access(CACHE_DNS_PATH) then
|
|||||||
if USE_DIRECT_LIST == "1" then
|
if USE_DIRECT_LIST == "1" then
|
||||||
if fs.access("/usr/share/passwall/rules/direct_host") then
|
if fs.access("/usr/share/passwall/rules/direct_host") then
|
||||||
fwd_dns = LOCAL_DNS
|
fwd_dns = LOCAL_DNS
|
||||||
if USE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then
|
if USE_CHINADNS_NG == "1" then
|
||||||
fwd_dns = nil
|
fwd_dns = nil
|
||||||
end
|
end
|
||||||
if fwd_dns then
|
if fwd_dns then
|
||||||
@ -253,7 +255,7 @@ if not fs.access(CACHE_DNS_PATH) then
|
|||||||
if USE_PROXY_LIST == "1" then
|
if USE_PROXY_LIST == "1" then
|
||||||
if fs.access("/usr/share/passwall/rules/proxy_host") then
|
if fs.access("/usr/share/passwall/rules/proxy_host") then
|
||||||
fwd_dns = TUN_DNS
|
fwd_dns = TUN_DNS
|
||||||
if USE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then
|
if USE_CHINADNS_NG == "1" then
|
||||||
fwd_dns = nil
|
fwd_dns = nil
|
||||||
end
|
end
|
||||||
if fwd_dns then
|
if fwd_dns then
|
||||||
@ -283,7 +285,7 @@ if not fs.access(CACHE_DNS_PATH) then
|
|||||||
if USE_GFW_LIST == "1" then
|
if USE_GFW_LIST == "1" then
|
||||||
if fs.access("/usr/share/passwall/rules/gfwlist") then
|
if fs.access("/usr/share/passwall/rules/gfwlist") then
|
||||||
fwd_dns = TUN_DNS
|
fwd_dns = TUN_DNS
|
||||||
if USE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then
|
if USE_CHINADNS_NG == "1" then
|
||||||
fwd_dns = nil
|
fwd_dns = nil
|
||||||
end
|
end
|
||||||
if fwd_dns then
|
if fwd_dns then
|
||||||
@ -323,7 +325,7 @@ if not fs.access(CACHE_DNS_PATH) then
|
|||||||
if CHN_LIST == "proxy" then
|
if CHN_LIST == "proxy" then
|
||||||
fwd_dns = TUN_DNS
|
fwd_dns = TUN_DNS
|
||||||
end
|
end
|
||||||
if USE_DEFAULT_DNS == "chinadns_ng" and CHINADNS_DNS ~= "0" then
|
if USE_CHINADNS_NG == "1" then
|
||||||
fwd_dns = nil
|
fwd_dns = nil
|
||||||
end
|
end
|
||||||
if fwd_dns then
|
if fwd_dns then
|
||||||
@ -356,7 +358,7 @@ if not fs.access(CACHE_DNS_PATH) then
|
|||||||
end
|
end
|
||||||
|
|
||||||
--分流规则
|
--分流规则
|
||||||
if uci:get(appname, TCP_NODE, "protocol") == "_shunt" and (USE_DEFAULT_DNS ~= "chinadns_ng" or CHINADNS_DNS == "0") then
|
if uci:get(appname, TCP_NODE, "protocol") == "_shunt" and USE_CHINADNS_NG == "0" then
|
||||||
local t = uci:get_all(appname, TCP_NODE)
|
local t = uci:get_all(appname, TCP_NODE)
|
||||||
local default_node_id = t["default_node"] or "_direct"
|
local default_node_id = t["default_node"] or "_direct"
|
||||||
uci:foreach(appname, "shunt_rules", function(s)
|
uci:foreach(appname, "shunt_rules", function(s)
|
||||||
@ -460,16 +462,20 @@ if not fs.access(CACHE_DNS_PATH) then
|
|||||||
f_out:close()
|
f_out:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if USE_CHINADNS_NG == "0" then
|
||||||
if api.is_install("procd\\-ujail") then
|
if api.is_install("procd\\-ujail") then
|
||||||
fs.copyr(CACHE_DNS_PATH, TMP_DNSMASQ_PATH)
|
fs.copyr(CACHE_DNS_PATH, TMP_DNSMASQ_PATH)
|
||||||
else
|
else
|
||||||
api.remove(TMP_DNSMASQ_PATH)
|
api.remove(TMP_DNSMASQ_PATH)
|
||||||
fs.symlink(CACHE_DNS_PATH, TMP_DNSMASQ_PATH)
|
fs.symlink(CACHE_DNS_PATH, TMP_DNSMASQ_PATH)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if DNSMASQ_CONF_FILE ~= "nil" then
|
if DNSMASQ_CONF_FILE ~= "nil" then
|
||||||
local conf_out = io.open(DNSMASQ_CONF_FILE, "a")
|
local conf_out = io.open(DNSMASQ_CONF_FILE, "a")
|
||||||
|
if USE_CHINADNS_NG == "0" then
|
||||||
conf_out:write(string.format("conf-dir=%s\n", TMP_DNSMASQ_PATH))
|
conf_out:write(string.format("conf-dir=%s\n", TMP_DNSMASQ_PATH))
|
||||||
|
end
|
||||||
if dnsmasq_default_dns then
|
if dnsmasq_default_dns then
|
||||||
for s in string.gmatch(dnsmasq_default_dns, '[^' .. "," .. ']+') do
|
for s in string.gmatch(dnsmasq_default_dns, '[^' .. "," .. ']+') do
|
||||||
conf_out:write(string.format("server=%s\n", s))
|
conf_out:write(string.format("server=%s\n", s))
|
||||||
@ -478,7 +484,7 @@ if DNSMASQ_CONF_FILE ~= "nil" then
|
|||||||
conf_out:write("no-poll\n")
|
conf_out:write("no-poll\n")
|
||||||
conf_out:write("no-resolv\n")
|
conf_out:write("no-resolv\n")
|
||||||
conf_out:close()
|
conf_out:close()
|
||||||
if USE_DEFAULT_DNS ~= "chinadns_ng" or CHINADNS_DNS == "0" then
|
if USE_CHINADNS_NG == "0" then
|
||||||
log(string.format(" - 默认:%s", dnsmasq_default_dns))
|
log(string.format(" - 默认:%s", dnsmasq_default_dns))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -490,6 +496,6 @@ if DNSMASQ_CONF_FILE ~= "nil" then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if USE_DEFAULT_DNS ~= "chinadns_ng" or CHINADNS_DNS == "0" then
|
if USE_CHINADNS_NG == "0" then
|
||||||
log(" - PassWall必须依赖于Dnsmasq,如果你自行配置了错误的DNS流程,将会导致域名(直连/代理域名)分流失效!!!")
|
log(" - PassWall必须依赖于Dnsmasq,如果你自行配置了错误的DNS流程,将会导致域名(直连/代理域名)分流失效!!!")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user