mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-02 09:13:56 +08:00
update 2026-10-12 01:13:21
This commit is contained in:
1 parent
6f8f22eee4
commit
5ece75ecfd
7 files changed
+46635
-283280
No files matched your search
@@ -1278,12 +1278,16 @@ start_dns() {
|
||||
|
||||
echolog " - 域名解析:使用SmartDNS,请确保配置正常。"
|
||||
china_ng_listen="127.0.0.1#${SMARTDNS_LISTEN_PORT}"
|
||||
echolog " - SmartDNS(127.0.0.1#${SMARTDNS_LOCAL_PORT}) -> 国内分组(${group_domestic:-null}),SmartDNS(${china_ng_listen}) -> Dnsmasq"
|
||||
if [ "${DNS_REDIRECT}" = "1" ]; then
|
||||
echolog " - DNS 重定向 -> SmartDNS(${china_ng_listen}),直连 DNS -> 国内分组(${group_domestic:-null})"
|
||||
else
|
||||
echolog " - SmartDNS(127.0.0.1#${SMARTDNS_LOCAL_PORT}) -> 国内分组(${group_domestic:-null}),SmartDNS(${china_ng_listen}) -> Dnsmasq"
|
||||
fi
|
||||
china_ng_listen="${china_ng_listen},::1#${SMARTDNS_LISTEN_PORT}"
|
||||
|
||||
local subnet_ip=$(config_n_get @global[0] remote_dns_client_ip)
|
||||
lua $APP_PATH/helper_smartdns_add.lua -FLAG "default" -SMARTDNS_CONF "/tmp/etc/smartdns/$CONFIG.conf" \
|
||||
-LISTEN_PORT ${SMARTDNS_LISTEN_PORT} -LOCAL_PORT ${SMARTDNS_LOCAL_PORT} \
|
||||
-LISTEN_PORT ${SMARTDNS_LISTEN_PORT} -LOCAL_PORT ${SMARTDNS_LOCAL_PORT} -DNS_REDIRECT ${DNS_REDIRECT} \
|
||||
-LOCAL_GROUP ${group_domestic:-null} -REMOTE_GROUP "passwall_proxy" -REMOTE_PROXY_SERVER ${GLOBAL_SOCKS_server} -USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" \
|
||||
-REMOTE_DNS ${smartdns_remote_dns} -DNS_MODE ${DNS_MODE:-socks} -TUN_DNS ${TUN_DNS} \
|
||||
-USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \
|
||||
@@ -1370,6 +1374,10 @@ start_dns() {
|
||||
uci -q add_list dhcp.@dnsmasq[0].addnmount=${GLOBAL_DNSMASQ_CONF_PATH}
|
||||
uci -q commit dhcp
|
||||
lua $APP_PATH/helper_dnsmasq.lua logic_restart -LOG 1
|
||||
elif [ "${DNS_SHUNT}" = "smartdns" ]; then
|
||||
# SmartDNS reads DHCP leases itself; no forwarding dnsmasq instance is needed.
|
||||
DNS_REDIRECT_PORT=${SMARTDNS_LISTEN_PORT}
|
||||
set_cache_var "ACL_default_dns_port" "${DNS_REDIRECT_PORT}"
|
||||
else
|
||||
#Run a copy dnsmasq instance, DNS hijack for that need proxy devices.
|
||||
GLOBAL_DNSMASQ_PORT=$(get_new_port 11400)
|
||||
@@ -1489,7 +1497,7 @@ acl_app() {
|
||||
if [ -n "${GLOBAL_NODE}" ]; then
|
||||
set_cache_var "ACL_${sid}_node" "${GLOBAL_NODE}"
|
||||
set_cache_var "ACL_${sid}_redir_port" "${GLOBAL_redir_port}"
|
||||
set_cache_var "ACL_${sid}_dns_port" "${GLOBAL_DNSMASQ_PORT}"
|
||||
set_cache_var "ACL_${sid}_dns_port" "${DNS_REDIRECT_PORT:-${GLOBAL_DNSMASQ_PORT}}"
|
||||
set_cache_var "ACL_${sid}_default" "1"
|
||||
[ "$GLOBAL_SHUNT_NODE_FAKEDNS" = "1" ] && use_fakedns=1
|
||||
else
|
||||
|
||||
@@ -465,7 +465,9 @@ if IS_SHUNT_NODE and not only_global then
|
||||
|
||||
SHUNT_LIST = SHUNT_LIST .. domain_list .. (_node_id:sub(1, 1) == "_" and "not-node" or "node")
|
||||
|
||||
log(string.format(" - Sing-Box/Xray分流规则(%s):%s", s.remarks, DNS_TRUST or "默认"))
|
||||
if _node_id ~= "_direct" and _node_id ~= "_blackhole" then
|
||||
log(string.format(" - Sing-Box/Xray分流规则(%s):%s", s.remarks, DNS_TRUST or "默认"))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@@ -721,7 +721,9 @@ function add_rule(var)
|
||||
end
|
||||
end
|
||||
|
||||
log(string.format(" - Sing-Box/Xray分流规则(%s):%s", s.remarks, fwd_dns or "默认"))
|
||||
if _node_id ~= "_direct" and _node_id ~= "_blackhole" then
|
||||
log(string.format(" - Sing-Box/Xray分流规则(%s):%s", s.remarks, fwd_dns or "默认"))
|
||||
end
|
||||
end
|
||||
end)
|
||||
elseif only_global == 1 and NO_PROXY_IPV6 == "1" then
|
||||
|
||||
@@ -23,6 +23,7 @@ local NFTFLAG = var["-NFTFLAG"]
|
||||
local SUBNET = var["-SUBNET"]
|
||||
local LISTEN_PORT = var["-LISTEN_PORT"]
|
||||
local LOCAL_PORT = var["-LOCAL_PORT"]
|
||||
local DNS_REDIRECT = var["-DNS_REDIRECT"] == "1"
|
||||
|
||||
local sys = api.sys
|
||||
local fs = api.fs
|
||||
@@ -185,14 +186,26 @@ end
|
||||
|
||||
local force_https_soa = api.uci_get_c("@global[0]", "force_https_soa") or 0
|
||||
local proxy_server_name = "psw-proxy-server"
|
||||
local listen_address = "[::]:" .. LISTEN_PORT .. (DNS_REDIRECT and "" or "@lo")
|
||||
local local_domain = DNS_REDIRECT and api.uci_get("dhcp", "@dnsmasq[0]", "domain")
|
||||
config_lines = {
|
||||
tonumber(LISTEN_PORT) ~= 0 and "bind [::]:" .. LISTEN_PORT .. "@lo" or "",
|
||||
tonumber(LISTEN_PORT) ~= 0 and "bind " .. listen_address or "",
|
||||
tonumber(LISTEN_PORT) ~= 0 and "bind-tcp " .. listen_address or "",
|
||||
(tonumber(LOCAL_PORT) ~= 0 and LOCAL_GROUP) and "bind [::]:" .. LOCAL_PORT .. "@lo -group " .. LOCAL_GROUP or "",
|
||||
(tonumber(LOCAL_PORT) ~= 0 and LOCAL_GROUP) and "bind-tcp [::]:" .. LOCAL_PORT .. "@lo -group " .. LOCAL_GROUP or "",
|
||||
tonumber(force_https_soa) == 1 and "force-qtype-SOA 65" or "force-qtype-SOA -,65",
|
||||
"server 223.5.5.5 -bootstrap-dns",
|
||||
-- Set the suffix before loading hosts/leases so initial records are expanded too.
|
||||
(local_domain and local_domain ~= "") and "local-domain " .. local_domain or "",
|
||||
is_file_nonzero("/etc/hosts") and "hosts-file /etc/hosts" or "",
|
||||
DNS_MODE == "socks" and string.format("proxy-server socks5://%s -name %s", REMOTE_PROXY_SERVER, proxy_server_name) or ""
|
||||
}
|
||||
if DNS_REDIRECT then
|
||||
-- SmartDNS monitors the lease file and updates local records without a restart.
|
||||
local lease_file = api.uci_get("dhcp", "@dnsmasq[0]", "leasefile")
|
||||
if not lease_file or lease_file == "" then lease_file = "/tmp/dhcp.leases" end
|
||||
table.insert(config_lines, string.format("dnsmasq-lease-file %q", lease_file))
|
||||
end
|
||||
if DNS_MODE == "socks" then
|
||||
for w in string.gmatch(REMOTE_DNS, '[^|]+') do
|
||||
local server_dns = api.trim(w)
|
||||
@@ -632,7 +645,9 @@ if IS_SHUNT_NODE and not only_global then
|
||||
|
||||
SHUNT_LIST = SHUNT_LIST .. domain_list .. (_node_id:sub(1, 1) == "_" and "not-node" or "node")
|
||||
|
||||
log(string.format(" - Sing-Box/Xray分流规则(%s)使用分组:%s", s.remarks, REMOTE_GROUP or "默认"))
|
||||
if _node_id ~= "_direct" and _node_id ~= "_blackhole" then
|
||||
log(string.format(" - Sing-Box/Xray分流规则(%s)使用分组:%s", s.remarks, REMOTE_GROUP or "默认"))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -770,4 +785,8 @@ end
|
||||
|
||||
fs.symlink(TMP_CONF_FILE, SMARTDNS_CONF)
|
||||
sys.call(string.format('echo "conf-file %s" >> /etc/smartdns/custom.conf', string.gsub(SMARTDNS_CONF, "passwall", "passwall*")))
|
||||
log(" - SmartDNS已作为Dnsmasq上游,如果你自行配置了错误的DNS流程,将会导致域名(直连/代理)分流失效!!!")
|
||||
if DNS_REDIRECT then
|
||||
log(" - DNS 重定向直接使用 SmartDNS,DHCP 租约由 SmartDNS 自动加载。")
|
||||
else
|
||||
log(" - SmartDNS已作为Dnsmasq上游,如果你自行配置了错误的DNS流程,将会导致域名(直连/代理)分流失效!!!")
|
||||
end
|
||||
Reference in new issue
Block a user