mirror of
https://github.com/kenzok8/small-package.git
synced 2026-02-08 07:37:13 +08:00
update 2023-04-27 00:22:40
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall2
|
||||
PKG_VERSION:=1.13-1
|
||||
PKG_VERSION:=1.13-3
|
||||
PKG_RELEASE:=
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
||||
@@ -230,7 +230,6 @@ o = s:option(ListValue, "remote_dns_protocol", translate("Remote DNS Protocol"))
|
||||
o:value("tcp", "TCP")
|
||||
o:value("doh", "DoH")
|
||||
o:value("udp", "UDP")
|
||||
o:value("fakedns", "FakeDNS")
|
||||
o:depends({ node = "default", ['!reverse'] = true })
|
||||
|
||||
---- DNS Forward
|
||||
@@ -269,16 +268,27 @@ o.datatype = "ipaddr"
|
||||
o:depends("remote_dns_protocol", "tcp")
|
||||
o:depends("remote_dns_protocol", "doh")
|
||||
|
||||
o = s:option(Flag, "remote_fakedns", "FakeDNS", translate("Use FakeDNS work in the shunt domain that proxy."))
|
||||
o.default = "0"
|
||||
o.rmempty = false
|
||||
o:depends("remote_dns_protocol", "tcp")
|
||||
o:depends("remote_dns_protocol", "doh")
|
||||
o:depends("remote_dns_protocol", "udp")
|
||||
|
||||
o = s:option(ListValue, "remote_dns_query_strategy", translate("Remote Query Strategy"))
|
||||
o.default = "UseIPv4"
|
||||
o:value("UseIP")
|
||||
o:value("UseIPv4")
|
||||
o:value("UseIPv6")
|
||||
o:depends({ node = "default", ['!reverse'] = true })
|
||||
o:depends("remote_dns_protocol", "tcp")
|
||||
o:depends("remote_dns_protocol", "doh")
|
||||
o:depends("remote_dns_protocol", "udp")
|
||||
|
||||
hosts = s:option(TextValue, "dns_hosts", translate("Domain Override"))
|
||||
hosts.rows = 5
|
||||
hosts.wrap = "off"
|
||||
hosts:depends({ node = "default", ['!reverse'] = true })
|
||||
hosts:depends("remote_dns_protocol", "tcp")
|
||||
hosts:depends("remote_dns_protocol", "doh")
|
||||
hosts:depends("remote_dns_protocol", "udp")
|
||||
|
||||
return m
|
||||
|
||||
@@ -215,7 +215,6 @@ o = s:taboption("DNS", ListValue, "remote_dns_protocol", translate("Remote DNS P
|
||||
o:value("tcp", "TCP")
|
||||
o:value("doh", "DoH")
|
||||
o:value("udp", "UDP")
|
||||
o:value("fakedns", "FakeDNS")
|
||||
|
||||
---- DNS Forward
|
||||
o = s:taboption("DNS", Value, "remote_dns", translate("Remote DNS"))
|
||||
@@ -253,6 +252,10 @@ o.datatype = "ipaddr"
|
||||
o:depends("remote_dns_protocol", "tcp")
|
||||
o:depends("remote_dns_protocol", "doh")
|
||||
|
||||
o = s:taboption("DNS", Flag, "remote_fakedns", "FakeDNS", translate("Use FakeDNS work in the shunt domain that proxy."))
|
||||
o.default = "0"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("DNS", ListValue, "remote_dns_query_strategy", translate("Remote Query Strategy"))
|
||||
o.default = "UseIPv4"
|
||||
o:value("UseIP")
|
||||
|
||||
@@ -885,7 +885,7 @@ function gen_config(var)
|
||||
|
||||
end
|
||||
|
||||
if remote_dns_udp_server or remote_dns_fake then
|
||||
if remote_dns_udp_server then
|
||||
local rules = {}
|
||||
local _remote_dns_proto
|
||||
|
||||
@@ -931,16 +931,18 @@ function gen_config(var)
|
||||
end
|
||||
|
||||
if true then
|
||||
local _remote_dns = {
|
||||
_flag = "remote",
|
||||
domains = #dns_remote_domains > 0 and dns_remote_domains or nil
|
||||
--expectIPs = #dns_remote_expectIPs > 0 and dns_remote_expectIPs or nil
|
||||
}
|
||||
|
||||
if remote_dns_udp_server then
|
||||
_remote_dns.address = remote_dns_udp_server
|
||||
_remote_dns.port = tonumber(remote_dns_port) or 53
|
||||
local _remote_dns = {
|
||||
_flag = "remote",
|
||||
address = remote_dns_udp_server,
|
||||
port = tonumber(remote_dns_port) or 53
|
||||
}
|
||||
if not remote_dns_fake then
|
||||
_remote_dns.domains = #dns_remote_domains > 0 and dns_remote_domains or nil
|
||||
_remote_dns.expectIPs = #dns_remote_expectIPs > 0 and dns_remote_expectIPs or nil
|
||||
end
|
||||
_remote_dns_proto = "udp"
|
||||
table.insert(dns.servers, _remote_dns)
|
||||
|
||||
table.insert(routing.rules, 1, {
|
||||
type = "field",
|
||||
@@ -952,7 +954,6 @@ function gen_config(var)
|
||||
outboundTag = "direct"
|
||||
})
|
||||
end
|
||||
|
||||
if remote_dns_fake then
|
||||
fakedns = {}
|
||||
fakedns[#fakedns + 1] = {
|
||||
@@ -965,10 +966,14 @@ function gen_config(var)
|
||||
poolSize = 65535
|
||||
}
|
||||
end
|
||||
_remote_dns.address = "fakedns"
|
||||
local _remote_dns = {
|
||||
_flag = "remote_fakedns",
|
||||
address = "fakedns",
|
||||
domains = #dns_remote_domains > 0 and dns_remote_domains or nil
|
||||
--expectIPs = #dns_remote_expectIPs > 0 and dns_remote_expectIPs or nil
|
||||
}
|
||||
table.insert(dns.servers, _remote_dns)
|
||||
end
|
||||
|
||||
table.insert(dns.servers, _remote_dns)
|
||||
end
|
||||
|
||||
if true then
|
||||
@@ -1069,6 +1074,10 @@ function gen_config(var)
|
||||
local dns_servers = nil
|
||||
for index, value in ipairs(dns.servers) do
|
||||
if not dns_servers and value["_flag"] == default_dns_flag then
|
||||
if value["_flag"] == default_dns_flag and remote_dns_fake then
|
||||
value["_flag"] = "default"
|
||||
break
|
||||
end
|
||||
dns_servers = {
|
||||
_flag = "default",
|
||||
address = value.address,
|
||||
|
||||
@@ -139,6 +139,9 @@ msgstr "直连查询策略"
|
||||
msgid "Remote Query Strategy"
|
||||
msgstr "远程查询策略"
|
||||
|
||||
msgid "Use FakeDNS work in the shunt domain that proxy."
|
||||
msgstr "需要代理的分流规则域名使用 FakeDNS。"
|
||||
|
||||
msgid "Domain Override"
|
||||
msgstr "域名重写"
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ lua_api() {
|
||||
|
||||
run_v2ray() {
|
||||
local flag node redir_port socks_address socks_port socks_username socks_password http_address http_port http_username http_password
|
||||
local dns_listen_port direct_dns_protocol direct_dns_udp_server direct_dns_tcp_server direct_dns_doh direct_dns_client_ip direct_dns_query_strategy remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_dns_query_strategy dns_cache
|
||||
local dns_listen_port direct_dns_protocol direct_dns_udp_server direct_dns_tcp_server direct_dns_doh direct_dns_client_ip direct_dns_query_strategy remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_fakedns remote_dns_query_strategy dns_cache
|
||||
local loglevel log_file config_file
|
||||
local _extra_param=""
|
||||
eval_set_val $@
|
||||
@@ -352,61 +352,53 @@ run_v2ray() {
|
||||
direct_dnsmasq_listen_port=$(get_new_port $(expr $dns_direct_listen_port + 1) udp)
|
||||
run_direct_ipset_dnsmasq listen_port=${direct_dnsmasq_listen_port} server_dns=127.0.0.1#${dns_direct_listen_port} ipset=whitelist,whitelist6 config_file=$TMP_PATH/dnsmasq_global_direct.conf
|
||||
|
||||
[ "$remote_dns_protocol" != "fakedns" ] && {
|
||||
V2RAY_DNS_REMOTE_CONFIG="${TMP_PATH}/${flag}_dns_remote.json"
|
||||
V2RAY_DNS_REMOTE_LOG="${TMP_PATH}/${flag}_dns_remote.log"
|
||||
V2RAY_DNS_REMOTE_LOG="/dev/null"
|
||||
V2RAY_DNS_REMOTE_ARGS="-dns_out_tag remote"
|
||||
dns_remote_listen_port=$(get_new_port $(expr $direct_dnsmasq_listen_port + 1) udp)
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -dns_listen_port ${dns_remote_listen_port}"
|
||||
case "$remote_dns_protocol" in
|
||||
udp)
|
||||
local _dns=$(get_first_dns remote_dns_udp_server 53 | sed 's/#/:/g')
|
||||
local _dns_address=$(echo ${_dns} | awk -F ':' '{print $1}')
|
||||
local _dns_port=$(echo ${_dns} | awk -F ':' '{print $2}')
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_server ${_dns_address} -remote_dns_port ${_dns_port} -remote_dns_udp_server ${_dns_address}"
|
||||
;;
|
||||
tcp)
|
||||
local _dns=$(get_first_dns remote_dns_tcp_server 53 | sed 's/#/:/g')
|
||||
local _dns_address=$(echo ${_dns} | awk -F ':' '{print $1}')
|
||||
local _dns_port=$(echo ${_dns} | awk -F ':' '{print $2}')
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_server ${_dns_address} -remote_dns_port ${_dns_port} -remote_dns_tcp_server tcp://${_dns}"
|
||||
;;
|
||||
doh)
|
||||
local _doh_url=$(echo $remote_dns_doh | awk -F ',' '{print $1}')
|
||||
local _doh_host_port=$(lua_api "get_domain_from_url(\"${_doh_url}\")")
|
||||
#local _doh_host_port=$(echo $_doh_url | sed "s/https:\/\///g" | awk -F '/' '{print $1}')
|
||||
local _doh_host=$(echo $_doh_host_port | awk -F ':' '{print $1}')
|
||||
local is_ip=$(lua_api "is_ip(\"${_doh_host}\")")
|
||||
local _doh_port=$(echo $_doh_host_port | awk -F ':' '{print $2}')
|
||||
[ -z "${_doh_port}" ] && _doh_port=443
|
||||
local _doh_bootstrap=$(echo $remote_dns_doh | cut -d ',' -sf 2-)
|
||||
[ "${is_ip}" = "true" ] && _doh_bootstrap=${_doh_host}
|
||||
[ -n "$_doh_bootstrap" ] && V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_server ${_doh_bootstrap}"
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_port ${_doh_port} -remote_dns_doh_url ${_doh_url} -remote_dns_doh_host ${_doh_host}"
|
||||
;;
|
||||
fakedns)
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_fake 1"
|
||||
;;
|
||||
esac
|
||||
V2RAY_DNS_REMOTE_CONFIG="${TMP_PATH}/${flag}_dns_remote.json"
|
||||
V2RAY_DNS_REMOTE_LOG="${TMP_PATH}/${flag}_dns_remote.log"
|
||||
V2RAY_DNS_REMOTE_LOG="/dev/null"
|
||||
V2RAY_DNS_REMOTE_ARGS="-dns_out_tag remote"
|
||||
dns_remote_listen_port=$(get_new_port $(expr $direct_dnsmasq_listen_port + 1) udp)
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -dns_listen_port ${dns_remote_listen_port}"
|
||||
case "$remote_dns_protocol" in
|
||||
udp)
|
||||
local _dns=$(get_first_dns remote_dns_udp_server 53 | sed 's/#/:/g')
|
||||
local _dns_address=$(echo ${_dns} | awk -F ':' '{print $1}')
|
||||
local _dns_port=$(echo ${_dns} | awk -F ':' '{print $2}')
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_server ${_dns_address} -remote_dns_port ${_dns_port} -remote_dns_udp_server ${_dns_address}"
|
||||
;;
|
||||
tcp)
|
||||
local _dns=$(get_first_dns remote_dns_tcp_server 53 | sed 's/#/:/g')
|
||||
local _dns_address=$(echo ${_dns} | awk -F ':' '{print $1}')
|
||||
local _dns_port=$(echo ${_dns} | awk -F ':' '{print $2}')
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_server ${_dns_address} -remote_dns_port ${_dns_port} -remote_dns_tcp_server tcp://${_dns}"
|
||||
;;
|
||||
doh)
|
||||
local _doh_url=$(echo $remote_dns_doh | awk -F ',' '{print $1}')
|
||||
local _doh_host_port=$(lua_api "get_domain_from_url(\"${_doh_url}\")")
|
||||
#local _doh_host_port=$(echo $_doh_url | sed "s/https:\/\///g" | awk -F '/' '{print $1}')
|
||||
local _doh_host=$(echo $_doh_host_port | awk -F ':' '{print $1}')
|
||||
local is_ip=$(lua_api "is_ip(\"${_doh_host}\")")
|
||||
local _doh_port=$(echo $_doh_host_port | awk -F ':' '{print $2}')
|
||||
[ -z "${_doh_port}" ] && _doh_port=443
|
||||
local _doh_bootstrap=$(echo $remote_dns_doh | cut -d ',' -sf 2-)
|
||||
[ "${is_ip}" = "true" ] && _doh_bootstrap=${_doh_host}
|
||||
[ -n "$_doh_bootstrap" ] && V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_server ${_doh_bootstrap}"
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_port ${_doh_port} -remote_dns_doh_url ${_doh_url} -remote_dns_doh_host ${_doh_host}"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -n "$remote_dns_query_strategy" ] && V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -dns_query_strategy ${remote_dns_query_strategy}"
|
||||
[ -n "$remote_dns_client_ip" ] && V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -dns_client_ip ${remote_dns_client_ip}"
|
||||
[ -n "$remote_dns_query_strategy" ] && V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -dns_query_strategy ${remote_dns_query_strategy}"
|
||||
[ -n "$remote_dns_client_ip" ] && V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -dns_client_ip ${remote_dns_client_ip}"
|
||||
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_outbound_socks_address 127.0.0.1 -remote_dns_outbound_socks_port ${socks_port}"
|
||||
lua $UTIL_XRAY gen_dns_config ${V2RAY_DNS_REMOTE_ARGS} > $V2RAY_DNS_REMOTE_CONFIG
|
||||
ln_run "$(first_type $(config_t_get global_app ${type}_file) ${type})" ${type} $V2RAY_DNS_REMOTE_LOG run -c "$V2RAY_DNS_REMOTE_CONFIG"
|
||||
}
|
||||
V2RAY_DNS_REMOTE_ARGS="${V2RAY_DNS_REMOTE_ARGS} -remote_dns_outbound_socks_address 127.0.0.1 -remote_dns_outbound_socks_port ${socks_port}"
|
||||
lua $UTIL_XRAY gen_dns_config ${V2RAY_DNS_REMOTE_ARGS} > $V2RAY_DNS_REMOTE_CONFIG
|
||||
ln_run "$(first_type $(config_t_get global_app ${type}_file) ${type})" ${type} $V2RAY_DNS_REMOTE_LOG run -c "$V2RAY_DNS_REMOTE_CONFIG"
|
||||
|
||||
[ -n "$dns_listen_port" ] && _extra_param="${_extra_param} -dns_listen_port ${dns_listen_port}"
|
||||
[ -n "$dns_cache" ] && _extra_param="${_extra_param} -dns_cache ${dns_cache}"
|
||||
_extra_param="${_extra_param} -dns_query_strategy UseIP"
|
||||
_extra_param="${_extra_param} -direct_dns_port ${direct_dnsmasq_listen_port} -direct_dns_udp_server 127.0.0.1"
|
||||
if [ "$remote_dns_protocol" == "fakedns" ]; then
|
||||
_extra_param="${_extra_param} -remote_dns_fake 1"
|
||||
else
|
||||
_extra_param="${_extra_param} -remote_dns_port ${dns_remote_listen_port} -remote_dns_udp_server 127.0.0.1"
|
||||
fi
|
||||
_extra_param="${_extra_param} -remote_dns_port ${dns_remote_listen_port} -remote_dns_udp_server 127.0.0.1"
|
||||
[ -n "$remote_fakedns" ] && _extra_param="${_extra_param} -remote_dns_fake 1"
|
||||
}
|
||||
|
||||
lua $UTIL_XRAY gen_config -node $node -redir_port $redir_port -tcp_proxy_way $tcp_proxy_way -loglevel $loglevel ${_extra_param} > $config_file
|
||||
@@ -636,10 +628,12 @@ run_global() {
|
||||
V2RAY_ARGS="${V2RAY_ARGS} remote_dns_doh=${REMOTE_DNS_DOH}"
|
||||
msg="${msg} 远程DNS:${REMOTE_DNS_DOH}"
|
||||
;;
|
||||
fakedns)
|
||||
msg="${msg} 远程DNS:FakeDNS"
|
||||
;;
|
||||
esac
|
||||
[ "$REMOTE_FAKEDNS" = "1" ] && {
|
||||
V2RAY_ARGS="${V2RAY_ARGS} remote_fakedns=1"
|
||||
msg="${msg} + FakeDNS "
|
||||
}
|
||||
|
||||
local _remote_dns_client_ip=$(config_t_get global remote_dns_client_ip)
|
||||
[ -n "${_remote_dns_client_ip}" ] && V2RAY_ARGS="${V2RAY_ARGS} remote_dns_client_ip=${_remote_dns_client_ip}"
|
||||
}
|
||||
@@ -977,6 +971,7 @@ DIRECT_DNS=$(config_t_get global direct_dns 119.29.29.29:53 | sed 's/#/:/g' | se
|
||||
DIRECT_DNS_QUERY_STRATEGY=$(config_t_get global direct_dns_query_strategy UseIP)
|
||||
REMOTE_DNS_PROTOCOL=$(config_t_get global remote_dns_protocol tcp)
|
||||
REMOTE_DNS=$(config_t_get global remote_dns 1.1.1.1:53 | sed 's/#/:/g' | sed -E 's/\:([^:]+)$/#\1/g')
|
||||
REMOTE_FAKEDNS=$(config_t_get global remote_fakedns '0')
|
||||
REMOTE_DNS_QUERY_STRATEGY=$(config_t_get global remote_dns_query_strategy UseIPv4)
|
||||
DNS_CACHE=$(config_t_get global dns_cache 1)
|
||||
|
||||
|
||||
@@ -620,13 +620,13 @@ add_firewall_rule() {
|
||||
$ip6t_n -N PSW2
|
||||
$ip6t_n -A PSW2 $(dst $IPSET_LANIPLIST6) -j RETURN
|
||||
$ip6t_n -A PSW2 $(dst $IPSET_VPSIPLIST6) -j RETURN
|
||||
$ip6t_n -A PSW2 $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP6 -j RETURN
|
||||
$ip6t_n -A PSW2 $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP_6 -j RETURN
|
||||
$ip6t_n -A PREROUTING -p ipv6-icmp -j PSW2
|
||||
|
||||
$ip6t_n -N PSW2_OUTPUT
|
||||
$ip6t_n -A PSW2_OUTPUT $(dst $IPSET_LANIPLIST6) -j RETURN
|
||||
$ip6t_n -A PSW2_OUTPUT $(dst $IPSET_VPSIPLIST6) -j RETURN
|
||||
$ip6t_n -A PSW2_OUTPUT $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP6 -j RETURN
|
||||
$ip6t_n -A PSW2_OUTPUT $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP_6 -j RETURN
|
||||
$ip6t_n -A PSW2_OUTPUT -m mark --mark 0xff -j RETURN
|
||||
}
|
||||
|
||||
@@ -644,7 +644,7 @@ add_firewall_rule() {
|
||||
$ip6t_m -N PSW2
|
||||
$ip6t_m -A PSW2 $(dst $IPSET_LANIPLIST6) -j RETURN
|
||||
$ip6t_m -A PSW2 $(dst $IPSET_VPSIPLIST6) -j RETURN
|
||||
$ip6t_m -A PSW2 $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP6 -j RETURN
|
||||
$ip6t_m -A PSW2 $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP_6 -j RETURN
|
||||
|
||||
WAN6_IP=$(get_wan6_ip)
|
||||
[ ! -z "${WAN6_IP}" ] && $ip6t_m -A PSW2 $(comment "WAN6_IP_RETURN") -d ${WAN6_IP} -j RETURN
|
||||
@@ -657,7 +657,7 @@ add_firewall_rule() {
|
||||
$ip6t_m -A PSW2_OUTPUT -m mark --mark 0xff -j RETURN
|
||||
$ip6t_m -A PSW2_OUTPUT $(dst $IPSET_LANIPLIST6) -j RETURN
|
||||
$ip6t_m -A PSW2_OUTPUT $(dst $IPSET_VPSIPLIST6) -j RETURN
|
||||
$ip6t_m -A PSW2_OUTPUT $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP6 -j RETURN
|
||||
$ip6t_m -A PSW2_OUTPUT $(dst $IPSET_WHITELIST6) ! -d $FAKE_IP_6 -j RETURN
|
||||
|
||||
ip -6 rule add fwmark 1 table 100
|
||||
ip -6 route add local ::/0 dev lo table 100
|
||||
|
||||
Reference in New Issue
Block a user