luci-app-passwall: bump to 4-9

Signed-off-by: CN_SZTL <cnsztl@project-openwrt.eu.org>
This commit is contained in:
xiaorouji 2021-01-17 01:41:40 +08:00 committed by CN_SZTL
parent 599e9680fe
commit 849594d74f
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
11 changed files with 320 additions and 768 deletions

View File

@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=4
PKG_RELEASE:=7
PKG_DATE:=20210111
PKG_RELEASE:=9
PKG_DATE:=20210119
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
@ -69,10 +69,6 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG
bool "Include ChinaDNS-NG"
default n
config PACKAGE_$(PKG_NAME)_INCLUDE_https_dns_proxy
bool "Include Https DNS Proxy(DoH)"
default y
config PACKAGE_$(PKG_NAME)_INCLUDE_dns2socks
bool "Include dns2socks"
default n
@ -114,7 +110,6 @@ define Package/$(PKG_NAME)
+PACKAGE_$(PKG_NAME)_INCLUDE_kcptun:kcptun-client \
+PACKAGE_$(PKG_NAME)_INCLUDE_haproxy:haproxy \
+PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG:chinadns-ng \
+PACKAGE_$(PKG_NAME)_INCLUDE_https_dns_proxy:https-dns-proxy \
+PACKAGE_$(PKG_NAME)_INCLUDE_dns2socks:dns2socks \
+PACKAGE_$(PKG_NAME)_INCLUDE_v2ray-plugin:v2ray-plugin \
+PACKAGE_$(PKG_NAME)_INCLUDE_simple-obfs:simple-obfs

View File

@ -191,12 +191,12 @@ function socks_status()
local index = luci.http.formvalue("index")
local id = luci.http.formvalue("id")
e.index = index
e.socks_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep 'SOCKS_%s' > /dev/null", appname, id)) == 0
e.socks_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep '%s' | grep 'SOCKS_' > /dev/null", appname, id)) == 0
local use_http = ucic:get(appname, id, "http_port") or 0
e.use_http = 0
if tonumber(use_http) > 0 then
e.use_http = 1
e.http_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep 'SOCKS2HTTP_%s' > /dev/null", appname, id)) == 0
e.http_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep '%s' | grep -E 'HTTP_|HTTP2SOCKS' > /dev/null", appname, id)) == 0
end
luci.http.prepare_content("application/json")
luci.http.write_json(e)

View File

@ -1,15 +1,8 @@
module("luci.model.cbi.passwall.api.gen_xray", package.seeall)
local api = require "luci.model.cbi.passwall.api.api"
local ucursor = require"luci.model.uci".cursor()
local sys = require "luci.sys"
local json = require "luci.jsonc"
local appname = "passwall"
local inbounds = {}
local outbounds = {}
local routing = nil
local myarg = {
"-node", "-proto", "-redir_port", "-socks_proxy_port", "-loglevel"
"-node", "-proto", "-redir_port", "-socks_proxy_port", "-http_proxy_port", "-dns_listen_port", "-dns_server", "-doh_url", "-doh_host", "-doh_socks_address", "-doh_socks_port", "-loglevel"
}
local var = api.get_args(arg, myarg)
@ -18,10 +11,26 @@ local node_section = var["-node"]
local proto = var["-proto"]
local redir_port = var["-redir_port"]
local socks_proxy_port = var["-socks_proxy_port"]
local http_proxy_port = var["-http_proxy_port"]
local dns_listen_port = var["-dns_listen_port"]
local dns_server = var["-dns_server"]
local doh_url = var["-doh_url"]
local doh_host = var["-doh_host"]
local doh_socks_address = var["-doh_socks_address"]
local doh_socks_port = var["-doh_socks_port"]
local loglevel = var["-loglevel"] or "warning"
local network = proto
local new_port
local ucursor = require"luci.model.uci".cursor()
local sys = require "luci.sys"
local json = require "luci.jsonc"
local appname = "passwall"
local dns = nil
local inbounds = {}
local outbounds = {}
local routing = nil
local function get_new_port()
if new_port then
new_port = tonumber(sys.exec(string.format("echo -n $(/usr/share/%s/app.sh get_new_port %s tcp)", appname, new_port + 1)))
@ -142,7 +151,7 @@ function gen_outbound(node, tag, relay_port)
{
id = node.uuid,
alterId = tonumber(node.alter_id),
level = node.level and tonumber(node.level) or 0,
level = 0,
security = (node.protocol == "vmess") and node.security or nil,
encryption = node.encryption or "none",
flow = node.flow or nil
@ -178,6 +187,14 @@ if node_section then
})
network = "tcp,udp"
end
if http_proxy_port then
table.insert(inbounds, {
listen = "0.0.0.0",
port = tonumber(http_proxy_port),
protocol = "http",
settings = {allowTransparent = false}
})
end
if redir_port then
table.insert(inbounds, {
@ -307,21 +324,132 @@ if node_section then
local outbound = gen_outbound(node)
if outbound then table.insert(outbounds, outbound) end
end
end
-- 额外传出连接
table.insert(outbounds, {protocol = "freedom", tag = "direct", settings = {keep = ""}})
if dns_server then
local rules = {}
dns = {
tag = "dns-in1",
servers = {
dns_server
}
}
if doh_url and doh_host then
dns.hosts = {
[doh_host] = dns_server
}
dns.servers = {
doh_url
}
end
if dns_listen_port then
table.insert(inbounds, {
listen = "127.0.0.1",
port = tonumber(dns_listen_port),
protocol = "dokodemo-door",
tag = "dns-in",
settings = {
address = dns_server,
port = 53,
network = "udp"
}
})
table.insert(outbounds, {
protocol = "dns",
tag = "dns-out"
})
end
table.insert(rules, {
type = "field",
inboundTag = {
"dns-in"
},
outboundTag = "dns-out"
})
if doh_socks_address and doh_socks_port then
table.insert(outbounds, {
tag = "out",
protocol = "socks",
streamSettings = {
network = "tcp",
security = "none"
},
settings = {
servers = {
{
address = doh_socks_address,
port = tonumber(doh_socks_port)
}
}
}
})
table.insert(rules, {
type = "field",
inboundTag = {
"dns-in1"
},
outboundTag = "out"
})
else
table.insert(rules, {
type = "field",
inboundTag = {
"dns-in1"
},
outboundTag = "direct"
})
end
routing = {
domainStrategy = "IPOnDemand",
rules = rules
}
end
if inbounds or outbounds then
table.insert(outbounds, {
protocol = "freedom",
tag = "direct",
settings = {domainStrategy = "UseIPv4"}
})
local xray = {
log = {
-- error = string.format("/var/etc/passwall/%s.log", node[".name"]),
loglevel = loglevel
},
-- DNS
dns = dns,
-- 传入连接
inbounds = inbounds,
-- 传出连接
outbounds = outbounds,
-- 路由
routing = routing
routing = routing,
-- 本地策略
--[[
policy = {
levels = {
[0] = {
handshake = 4,
connIdle = 300,
uplinkOnly = 2,
downlinkOnly = 5,
bufferSize = 10240,
statsUserUplink = false,
statsUserDownlink = false
}
},
system = {
statsInboundUplink = false,
statsInboundDownlink = false
}
}
]]--
}
print(json.stringify(xray, 1))
end

View File

@ -131,12 +131,12 @@ if api.is_finded("chinadns-ng") then
o:depends("chinadns_ng", "1")
end
o = s:taboption("DNS", Value, "up_china_dns", translate("Resolver For Local/WhiteList Domains") .. "(UDP)")
o = s:taboption("DNS", Value, "up_china_dns", translate("Local DNS") .. "(UDP)")
o.description = translate("IP:Port mode acceptable, multi value split with english comma.") .. "<br />" .. translate("When the selection is not the default, this DNS is forced to be set to dnsmasq upstream DNS.")
o.default = "default"
o:value("default", translate("Default"))
if api.is_finded("https-dns-proxy") then
o:value("https-dns-proxy", "https-dns-proxy(DoH)")
if api.is_finded("xray") then
o:value("xray_doh", "Xray DNS(DoH)")
end
o:value("223.5.5.5", "223.5.5.5 (" .. translate("Ali") .. "DNS)")
o:value("223.6.6.6", "223.6.6.6 (" .. translate("Ali") .. "DNS)")
@ -150,24 +150,24 @@ o:value("180.76.76.76", "180.76.76.76 (" .. translate("Baidu") .. "DNS)")
---- DoH
o = s:taboption("DNS", Value, "up_china_dns_doh", translate("DoH request address"))
o:value("https://dns.alidns.com/dns-query,223.5.5.5,223.6.6.6", "AliDNS")
o:value("https://doh.pub/dns-query,119.29.29.29,119.28.28.28", "DNSPod")
o.default = "https://dns.alidns.com/dns-query,223.5.5.5,223.6.6.6"
o:value("https://dns.alidns.com/dns-query,223.5.5.5", "AliDNS")
o:value("https://doh.pub/dns-query,119.29.29.29", "DNSPod")
o.default = "https://dns.alidns.com/dns-query,223.5.5.5"
o.validate = doh_validate
o:depends("up_china_dns", "https-dns-proxy")
o:depends("up_china_dns", "xray_doh")
---- DNS Forward Mode
o = s:taboption("DNS", ListValue, "dns_mode", translate("Filter Mode"))
o.rmempty = false
o:reset_values()
if api.is_finded("pdnsd") then
o:value("pdnsd", "pdnsd")
o:value("pdnsd", "pdnsd " .. translatef("Requery DNS By %s", translate("TCP Node")))
end
if api.is_finded("dns2socks") then
o:value("dns2socks", "dns2socks")
end
if api.is_finded("https-dns-proxy") then
o:value("https-dns-proxy", "https-dns-proxy(DoH)")
if api.is_finded("xray") then
o:value("xray_doh", "Xray DNS(DoH)")
end
o:value("udp", translatef("Requery DNS By %s", translate("UDP Node")))
o:value("nonuse", translate("No Filter"))
@ -185,17 +185,10 @@ o.validate = function(self, value, t)
end
o:depends({dns_mode = "custom"})
o = s:taboption("DNS", ListValue, "up_trust_pdnsd_dns", translate("Resolver For The List Proxied"))
-- o.description = translate("You can use other resolving DNS services as trusted DNS, Example: dns2socks, dns-forwarder... 127.0.0.1#5353<br />Only use two at most, english comma separation, If you do not fill in the # and the following port, you are using port 53.")
o.default = "tcp"
o:value("tcp", translatef("Requery DNS By %s", translate("TCP Node")))
o:value("udp", translatef("Requery DNS By %s", translate("UDP Node")))
o:depends("dns_mode", "pdnsd")
o = s:taboption("DNS", ListValue, "up_trust_doh_dns", translate("Resolver For The List Proxied"))
o:value("tcp", translatef("Requery DNS By %s", translate("TCP Node")))
o:value("socks", translatef("Requery DNS By %s", translate("Socks Node")))
o:depends("dns_mode", "https-dns-proxy")
o:depends("dns_mode", "xray_doh")
o = s:taboption("DNS", Value, "socks_server", translate("Socks Server"), translate("Make sure socks service is available on this address."))
for k, v in pairs(socks_table) do o:value(v.id, v.remarks) end
@ -206,27 +199,28 @@ o.validate = function(self, value, t)
return value
end
o:depends({dns_mode = "dns2socks"})
o:depends({dns_mode = "https-dns-proxy", up_trust_doh_dns = "socks"})
o:depends({dns_mode = "xray_doh", up_trust_doh_dns = "socks"})
---- DoH
o = s:taboption("DNS", Value, "up_trust_doh", translate("DoH request address"))
o:value("https://dns.adguard.com/dns-query,176.103.130.130,176.103.130.131", "AdGuard")
o:value("https://cloudflare-dns.com/dns-query,1.1.1.1,1.0.0.1", "Cloudflare")
o:value("https://security.cloudflare-dns.com/dns-query,1.1.1.2,1.0.0.2", "Cloudflare-Security")
o:value("https://doh.opendns.com/dns-query,208.67.222.222,208.67.220.220", "OpenDNS")
o:value("https://dns.google/dns-query,8.8.8.8,8.8.4.4", "Google")
o:value("https://dns.adguard.com/dns-query,176.103.130.130", "AdGuard")
o:value("https://cloudflare-dns.com/dns-query,1.1.1.1", "Cloudflare")
o:value("https://security.cloudflare-dns.com/dns-query,1.1.1.2", "Cloudflare-Security")
o:value("https://doh.opendns.com/dns-query,208.67.222.222", "OpenDNS")
o:value("https://dns.google/dns-query,8.8.8.8", "Google")
o:value("https://doh.libredns.gr/dns-query,116.202.176.26", "LibreDNS")
o:value("https://doh.libredns.gr/ads,116.202.176.26", "LibreDNS (No Ads)")
o:value("https://dns.quad9.net/dns-query,9.9.9.9,149.112.112.112", "Quad9-Recommended")
o.default = "https://dns.google/dns-query,8.8.8.8,8.8.4.4"
o:value("https://dns.quad9.net/dns-query,9.9.9.9", "Quad9-Recommended")
o.default = "https://dns.google/dns-query,8.8.8.8"
o.validate = doh_validate
o:depends({dns_mode = "https-dns-proxy"})
o:depends({dns_mode = "xray_doh"})
---- DNS Forward
o = s:taboption("DNS", Value, "dns_forward", translate("Filtered DNS(For Proxied Domains)"), translate("IP:Port mode acceptable, the 1st for 'dns2socks' if split with english comma."))
o.default = "8.8.4.4"
o:value("8.8.4.4", "8.8.4.4 (Google DNS)")
o = s:taboption("DNS", Value, "dns_forward", translate("Remote DNS"))
--o.description = translate("IP:Port mode acceptable, multi value split with english comma.") .. " " .. translate("If you use dns2socks, only the first one is valid.")
o.default = "8.8.8.8"
o:value("8.8.8.8", "8.8.8.8 (Google DNS)")
o:value("8.8.4.4", "8.8.4.4 (Google DNS)")
o:value("208.67.222.222", "208.67.222.222 (Open DNS)")
o:value("208.67.220.220", "208.67.220.220 (Open DNS)")
o:depends({dns_mode = "dns2socks"})
@ -240,9 +234,6 @@ o:depends({dns_mode = "dns2socks"})
o:depends({dns_mode = "pdnsd"})
]]--
o = s:taboption("DNS", Flag, "use_chnlist", translate("Use ChinaList"), translate("Only useful in non-gfwlist mode.") .. "<br />" .. translate("When used, the domestic DNS will be used only when the chnlist rule is hit, and the domain name that misses the rule will be resolved by remote DNS."))
o.default = "0"
o = s:taboption("DNS", Button, "clear_ipset", translate("Clear IPSET"), translate("Try this feature if the rule modification does not take effect."))
o.inputstyle = "remove"
function o.write(e, e)

View File

@ -417,15 +417,6 @@ uuid:depends({ type = "V2ray", protocol = "vless" })
alter_id = s:option(Value, "alter_id", translate("Alter ID"))
alter_id:depends("protocol", "vmess")
level = s:option(Value, "level", translate("User Level"))
level.default = 1
level:depends({ type = "Xray", protocol = "vmess" })
level:depends({ type = "Xray", protocol = "vless" })
level:depends({ type = "Xray", protocol = "trojan" })
level:depends({ type = "V2ray", protocol = "vmess" })
level:depends({ type = "V2ray", protocol = "vless" })
level:depends({ type = "V2ray", protocol = "trojan" })
tls = s:option(Flag, "tls", translate("TLS"))
tls.default = 0
tls.validate = function(self, value, t)

View File

@ -160,12 +160,18 @@ msgstr "自定义DNS"
msgid "IP:Port mode ecceptable for specify other filtered name services."
msgstr "定义接受 IP:Port 形式的输入,以指定其它域名服务的过滤服务。"
msgid "Resolver For Local/WhiteList Domains"
msgstr "解析本地和白名单域名"
msgid "Local DNS"
msgstr "本地DNS"
msgid "Remote DNS"
msgstr "远程DNS"
msgid "IP:Port mode acceptable, multi value split with english comma."
msgstr "接受 IP:Port 形式的输入,多个以英文逗号分隔。"
msgid "If you use dns2socks, only the first one is valid."
msgstr "如果使用dns2socks只有第一个生效。"
msgid "When the selection is not the default, this DNS is forced to be set to dnsmasq upstream DNS."
msgstr "当选择的不是默认则将此DNS强制设置为dnsmasq上游DNS。"
@ -214,9 +220,6 @@ msgstr "请确保此Socks服务可用。"
msgid "ChinaDNS-NG Fair Mode"
msgstr "ChinaDNS-NG 公平模式"
msgid "Filtered DNS(For Proxied Domains)"
msgstr "域名过滤服务(用于被代理的域名)"
msgid "Format must be:"
msgstr "格式必须为:"
@ -229,9 +232,6 @@ msgstr "DoH Bootstrap DNS"
msgid "The Bootstrap DNS server is used to resolve the IP address of the DoH resolver you specify as the upstream."
msgstr "Bootstrap DNS 服务器用于解析您指定为上游的 DoH 解析器的 IP 地址。"
msgid "IP:Port mode acceptable, the 1st for 'dns2socks' if split with english comma."
msgstr "接受 IP:Port 形式的输入,多个以英文逗号分隔 'dns2socks' 模式下仅首个有效。"
msgid "Cache Resolved"
msgstr "缓存解析结果"

View File

@ -6,14 +6,12 @@ config global
option udp_node 'nil'
option dns_mode 'pdnsd'
option up_china_dns 'default'
option dns_forward '8.8.4.4'
option use_chnlist '0'
option use_tcp_node_resolve_dns '1'
option dns_forward '8.8.8.8'
option tcp_proxy_mode 'chnroute'
option udp_proxy_mode 'chnroute'
option localhost_tcp_proxy_mode 'gfwlist'
option localhost_udp_proxy_mode 'gfwlist'
option socks_server '0.0.0.0:1080'
option localhost_tcp_proxy_mode 'chnroute'
option localhost_udp_proxy_mode 'chnroute'
option socks_server '127.0.0.1:9050'
option close_log_tcp '1'
option close_log_udp '1'
option loglevel 'warning'

View File

@ -298,7 +298,6 @@ load_config() {
DNS_MODE=$(config_t_get global dns_mode pdnsd)
DNS_FORWARD=$(config_t_get global dns_forward 8.8.4.4:53 | sed 's/:/#/g')
DNS_CACHE=$(config_t_get global dns_cache 1)
USE_CHNLIST=$(config_t_get global use_chnlist 0)
process=1
if [ "$(config_t_get global_forwarding process 0)" = "0" ]; then
process=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
@ -362,14 +361,14 @@ run_socks() {
[ -n "$_username" ] && [ -n "$_password" ] && local _auth="--uname $_username --passwd $_password"
ln_start_bin "$(first_type ssocks)" ssocks_SOCKS_$id $log_file --listen $socks_port --socks $server_host:$port $_auth
;;
xray)
lua $API_GEN_XRAY -node $node -socks_proxy_port $socks_port > $config_file
xray|v2ray)
[ "$http_port" != "0" ] && {
local extra_param="-http_proxy_port $http_port"
config_file=$(echo $config_file | sed "s/SOCKS/HTTP_SOCKS/g")
}
lua $API_GEN_XRAY -node $node -socks_proxy_port $socks_port $extra_param > $config_file
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $log_file -config="$config_file"
;;
v2ray)
lua $API_GEN_XRAY -node $node -socks_proxy_port $socks_port > $config_file
ln_start_bin "$(first_type $(config_t_get global_app v2ray_file) v2ray)" v2ray $log_file -config="$config_file"
;;
trojan-go)
lua $API_GEN_TROJAN -node $node -run_type client -local_addr $bind -local_port $socks_port -server_host $server_host -server_port $port > $config_file
ln_start_bin "$(first_type $(config_t_get global_app trojan_go_file) trojan-go)" trojan-go $log_file -config "$config_file"
@ -392,12 +391,12 @@ run_socks() {
;;
ss|ssr)
lua $API_GEN_SS -node $node -local_addr "0.0.0.0" -local_port $socks_port -server_host $server_host -server_port $port > $config_file
ln_start_bin "$(first_type ${type}-local)" "${type}-local" $log_file -c "$config_file" -b "$bind" -u
ln_start_bin "$(first_type ${type}-local)" "${type}-local" $log_file -c "$config_file" -b "$bind" -u -v
;;
esac
# socks to http
[ "$http_port" != "0" ] && [ "$http_config_file" != "nil" ] && {
[ "$type" != "xray" -a "$type" != "v2ray" ] && [ "$http_port" != "0" ] && [ "$http_config_file" != "nil" ] && {
lua $API_GEN_XRAY_PROTO -local_proto http -local_address "0.0.0.0" -local_port $http_port -server_proto socks -server_address "127.0.0.1" -server_port $socks_port -server_username $_username -server_password $_password > $http_config_file
echo lua $API_GEN_XRAY_PROTO -local_proto http -local_address "0.0.0.0" -local_port $http_port -server_proto socks -server_address "127.0.0.1" -server_port $socks_port -server_username $_username -server_password $_password
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $log_file -config="$http_config_file"
@ -443,18 +442,13 @@ run_redir() {
local server_username=$(config_n_get $node username)
local server_password=$(config_n_get $node password)
eval port=\$UDP_REDIR_PORT
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_udp" $log_file -U -l "$port" -b 0.0.0.0 -s "$node_address" -p "$node_port" -R
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_udp" $log_file -U -l "$port" -b 0.0.0.0 -s "$node_address" -p "$node_port" -R -v
;;
xray)
xray|v2ray)
local loglevel=$(config_t_get global loglevel "warning")
lua $API_GEN_XRAY -node $node -proto udp -redir_port $local_port -loglevel $loglevel > $config_file
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $log_file -config="$config_file"
;;
v2ray)
local loglevel=$(config_t_get global loglevel "warning")
lua $API_GEN_XRAY -node $node -proto udp -redir_port $local_port -loglevel $loglevel > $config_file
ln_start_bin "$(first_type $(config_t_get global_app v2ray_file) v2ray)" v2ray $log_file -config="$config_file"
;;
trojan-go)
local loglevel=$(config_t_get global trojan_loglevel "2")
lua $API_GEN_TROJAN -node $node -run_type nat -local_addr "0.0.0.0" -local_port $local_port -loglevel $loglevel > $config_file
@ -478,7 +472,7 @@ run_redir() {
;;
ss|ssr)
lua $API_GEN_SS -node $node -local_addr "0.0.0.0" -local_port $local_port > $config_file
ln_start_bin "$(first_type ${type}-redir)" "${type}-redir" $log_file -c "$config_file" -U
ln_start_bin "$(first_type ${type}-redir)" "${type}-redir" $log_file -c "$config_file" -U -v
;;
esac
;;
@ -571,14 +565,14 @@ run_redir() {
[ "$UDP_NODE" == "tcp" ] && extra_param="-u"
fi
for k in $(seq 1 $process); do
ln_start_bin "$(first_type ${type}-redir)" "${type}-redir" $log_file -c "$config_file" $extra_param
ln_start_bin "$(first_type ${type}-redir)" "${type}-redir" $log_file -c "$config_file" -v $extra_param
done
;;
esac
if [ -n "$_socks_flag" ]; then
local extra_param="-T"
[ "$UDP_NODE" == "tcp" ] && extra_param=""
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_tcp" $log_file -l "$local_port" -b 0.0.0.0 -s "$_socks_address" -p "$_socks_port" -R $extra_param
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_tcp" $log_file -l "$local_port" -b 0.0.0.0 -s "$_socks_address" -p "$_socks_port" -R -v $extra_param
fi
unset _socks_flag _socks_address _socks_port _socks_username _socks_password
;;
@ -634,7 +628,7 @@ start_socks() {
local config_file=$TMP_PATH/SOCKS_${id}.json
local log_file=$TMP_PATH/SOCKS_${id}.log
local http_port=$(config_n_get $id http_port 0)
local http_config_file=$TMP_PATH/SOCKS2HTTP_${id}.json
local http_config_file=$TMP_PATH/HTTP2SOCKS_${id}.json
run_socks $node "0.0.0.0" $port $config_file $http_port $http_config_file $id
done
}
@ -718,16 +712,20 @@ stop_crontab() {
}
start_dns() {
if [ "${LOCAL_DNS}" = "https-dns-proxy" ]; then
_doh=$(config_t_get global up_china_dns_doh "https://dns.alidns.com/dns-query,223.5.5.5,223.6.6.6,2400:3200::1,2400:3200:baba::1")
if [ "${LOCAL_DNS}" = "xray_doh" ]; then
_doh=$(config_t_get global up_china_dns_doh "https://dns.alidns.com/dns-query,223.5.5.5")
_doh_url=$(echo $_doh | awk -F ',' '{print $1}')
_doh_host_port=$(echo $_doh_url | sed "s/https:\/\///g" | awk -F '/' '{print $1}')
_doh_host=$(echo $_doh_host_port | awk -F ':' '{print $1}')
_doh_port=$(echo $_doh_host_port | awk -F ':' '{print $2}')
_doh_bootstrap=$(echo $_doh | cut -d ',' -sf 2-)
ln_start_bin "$(first_type https-dns-proxy)" https-dns-proxy "/dev/null" -a 127.0.0.1 -p "${LOCAL_DOH_PORT}" -b "${_doh_bootstrap}" -r "${_doh_url}" -4
lua $API_GEN_XRAY -dns_listen_port "${LOCAL_DOH_PORT}" -dns_server "${_doh_bootstrap}" -doh_url "${_doh_url}" -doh_host "${_doh_host}" > $TMP_PATH/DNS1.json
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $TMP_PATH/DNS1.log -config="$TMP_PATH/DNS1.json"
LOCAL_DNS="127.0.0.1#${LOCAL_DOH_PORT}"
unset _doh _doh_url _doh_bootstrap
fi
local pdnsd_forward other_port up_trust_pdnsd_dns msg
local pdnsd_forward other_port msg
local global chnlist returnhome china_ng_chn china_ng_gfw chnlist_param gfwlist_param extra_mode
dns_listen_port=${DNS_PORT}
pdnsd_forward=${DNS_FORWARD}
@ -741,6 +739,12 @@ start_dns() {
sed -n 's/^ipset=\/\.\?\([^/]*\).*$/\1/p' "${RULES_PATH}/gfwlist.conf" | sort -u > "${TMP_PATH}/gfwlist.txt"
echolog "过滤服务配置:准备接管域名解析[$?]..."
USE_CHNLIST=1
if [ ! -f "${RULES_PATH}/chnlist" ]; then
USE_CHNLIST=0
else
cp -a "${RULES_PATH}/chnlist" "${TMP_PATH}/chnlist"
fi
[ "$CHINADNS_NG" = "1" ] && {
echolog " | - (chinadns-ng) 只支持2~4级的域名过滤..."
[ -z "${global}${chnlist}" ] && echolog " | - (chinadns-ng) 此模式下列表外的域名查询会同时发送给本地DNS(可切换到Pdnsd + TCP节点模式解决)..."
@ -752,8 +756,8 @@ start_dns() {
elif [ "$DNS_MODE" = "dns2socks" ]; then
#[ -n "${global}${chnlist}" ] && TUN_DNS=${china_ng_gfw}
msg="dns2socks"
elif [ "$DNS_MODE" = "https-dns-proxy" ]; then
msg="https-dns-proxy(DoH)"
elif [ "$DNS_MODE" = "xray_doh" ]; then
msg="Xray DNS(DoH)"
elif [ "$DNS_MODE" = "udp" ]; then
use_udp_node_resolve_dns=1
if [ -z "${returnhome}" ]; then
@ -767,27 +771,27 @@ start_dns() {
china_ng_gfw="$(echo ${custom_dns} | sed 's/:/#/g')"
msg="自定义DNS"
fi
chnlist_param=
[ "$USE_CHNLIST" = "1" ] && {
cp -a "${RULES_PATH}/chnlist" "${TMP_PATH}/chnlist"
if [ -z "${returnhome}" ]; then
cat "${RULES_PATH}/direct_host" >> "${TMP_PATH}/chnlist"
echolog " | - [$?](chinadns-ng) 域名白名单合并到中国域名表"
cat "${RULES_PATH}/proxy_host" >> "${TMP_PATH}/gfwlist.txt"
[ -f "${RULES_PATH}/proxy_host2" ] && cat "${RULES_PATH}/proxy_host2" >> "${TMP_PATH}/gfwlist.txt"
[ -f "${RULES_PATH}/proxy_host3" ] && cat "${RULES_PATH}/proxy_host3" >> "${TMP_PATH}/gfwlist.txt"
echolog " | - [$?](chinadns-ng) 代理域名表合并到防火墙域名表"
gfwlist_param="${TMP_PATH}/gfwlist.txt"
else
echolog " | - (chinadns-ng) 白名单不与中国域名表合并"
cat "${RULES_PATH}/proxy_host" >> "${TMP_PATH}/chnlist"
[ -f "${RULES_PATH}/proxy_host2" ] && cat "${RULES_PATH}/proxy_host2" >> "${TMP_PATH}/chnlist"
[ -f "${RULES_PATH}/proxy_host3" ] && cat "${RULES_PATH}/proxy_host3" >> "${TMP_PATH}/chnlist"
chnlist_param="${TMP_PATH}/chnlist"
if [ -n "${returnhome}" ]; then
echolog " | - (chinadns-ng) 白名单不与中国域名表合并"
[ -f "${RULES_PATH}/proxy_host" ] && {
cat "${RULES_PATH}/proxy_host" >> "${chnlist_param}"
echolog " | - [$?](chinadns-ng) 忽略防火墙域名表,代理域名表合并到中国域名表"
fi
chnlist_param="${TMP_PATH}/chnlist"
chnlist_param=${chnlist_param:+-m "${chnlist_param}" -M}
}
}
else
[ -f "${RULES_PATH}/direct_host" ] && {
cat "${RULES_PATH}/direct_host" >> "${chnlist_param}"
echolog " | - [$?](chinadns-ng) 域名白名单合并到中国域名表"
}
[ -f "${RULES_PATH}/proxy_host" ] && {
gfwlist_param="${TMP_PATH}/gfwlist.txt"
cat "${RULES_PATH}/proxy_host" >> "${gfwlist_param}"
echolog " | - [$?](chinadns-ng) 代理域名表合并到防火墙域名表"
}
fi
chnlist_param=${chnlist_param:+-m "${chnlist_param}" -M}
[ "$(config_t_get global fair_mode 1)" = "1" ] && extra_mode="-f"
ln_start_bin "$(first_type chinadns-ng)" chinadns-ng "/dev/null" -l "${dns_listen_port}" ${china_ng_chn:+-c "${china_ng_chn}"} ${chnlist_param} ${china_ng_gfw:+-t "${china_ng_gfw}"} ${gfwlist_param:+-g "${gfwlist_param}"} $extra_mode
echolog " + 过滤服务ChinaDNS-NG(:${dns_listen_port}${extra_mode}) + ${msg}:中国域名列表:${china_ng_chn:-D114.114.114.114},防火墙域名列表:${china_ng_gfw:-D8.8.8.8}"
@ -803,7 +807,7 @@ start_dns() {
dns2socks)
echolog " - 域名解析dns2socks..."
;;
https-dns-proxy)
xray_doh)
up_trust_doh_dns=$(config_t_get global up_trust_doh_dns "tcp")
if [ "$up_trust_doh_dns" = "socks" ]; then
use_tcp_node_resolve_dns=0
@ -812,17 +816,10 @@ start_dns() {
use_tcp_node_resolve_dns=1
msg="TCP节点"
fi
echolog " - 域名解析 https-dns-proxy(DOH)..."
echolog " - 域名解析 Xray DNS(DOH)..."
;;
pdnsd)
up_trust_pdnsd_dns=$(config_t_get global up_trust_pdnsd_dns "nil")
if [ "$up_trust_pdnsd_dns" = "udp" ]; then
use_udp_node_resolve_dns=1
msg="UDP节点"
elif [ "${up_trust_pdnsd_dns}" = "nil" ]; then
msg="TCP节点"
fi
echolog " - 域名解析pdnsd + 使用(${msg})解析域名..."
echolog " - 域名解析pdnsd + 使用(TCP节点)解析域名..."
;;
udp)
use_udp_node_resolve_dns=1
@ -841,16 +838,21 @@ start_dns() {
gen_pdnsd_config "${dns_listen_port}" "${pdnsd_forward}"
ln_start_bin "$(first_type pdnsd)" pdnsd "/dev/null" --daemon -c "${TMP_PATH}/pdnsd/pdnsd.conf" -d
fi
if [ -n "$(echo ${DNS_MODE} | grep 'https-dns-proxy')" ]; then
up_trust_doh=$(config_t_get global up_trust_doh "https://dns.google/dns-query,8.8.8.8,8.8.4.4")
if [ -n "$(echo ${DNS_MODE} | grep 'xray_doh')" ]; then
up_trust_doh=$(config_t_get global up_trust_doh "https://dns.google/dns-query,8.8.4.4")
_doh_url=$(echo $up_trust_doh | awk -F ',' '{print $1}')
_doh_port=$(echo $_doh_url | sed "s/:\/\///g" | awk -F ':' '{print $2}'| awk -F '/' '{print $1}')
_doh_host_port=$(echo $_doh_url | sed "s/https:\/\///g" | awk -F '/' '{print $1}')
_doh_host=$(echo $_doh_host_port | awk -F ':' '{print $1}')
_doh_port=$(echo $_doh_host_port | awk -F ':' '{print $2}')
_doh_bootstrap=$(echo $up_trust_doh | cut -d ',' -sf 2-)
up_trust_doh_dns=$(config_t_get global up_trust_doh_dns "tcp")
if [ "$up_trust_doh_dns" = "socks" ]; then
socks_server=$(echo $(config_t_get global socks_server 127.0.0.1:9050) | sed "s/#/:/g")
ln_start_bin "$(first_type https-dns-proxy)" https-dns-proxy "/dev/null" -a 127.0.0.1 -p "${dns_listen_port}" -b "${_doh_bootstrap}" -r "${_doh_url}" -4 -t socks5h://${socks_server}
socks_address=$(echo $socks_server | awk -F ':' '{print $1}')
socks_port=$(echo $socks_server | awk -F ':' '{print $2}')
lua $API_GEN_XRAY -dns_listen_port "${dns_listen_port}" -dns_server "${_doh_bootstrap}" -doh_url "${_doh_url}" -doh_host "${_doh_host}" -doh_socks_address "${socks_address}" -doh_socks_port "${socks_port}" > $TMP_PATH/DNS.json
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $TMP_PATH/DNS.log -config="$TMP_PATH/DNS.json"
elif [ "${up_trust_doh_dns}" = "tcp" ]; then
DNS_FORWARD=""
_doh_bootstrap_dns=$(echo $_doh_bootstrap | sed "s/,/ /g")
@ -858,19 +860,12 @@ start_dns() {
_dns=$(echo $_dns | awk -F ':' '{print $1}'):${_doh_port:-443}
[ -n "$DNS_FORWARD" ] && DNS_FORWARD=${DNS_FORWARD},${_dns} || DNS_FORWARD=${_dns}
done
ln_start_bin "$(first_type https-dns-proxy)" https-dns-proxy "/dev/null" -a 127.0.0.1 -p "${dns_listen_port}" -b "${_doh_bootstrap}" -r "${_doh_url}" -4
lua $API_GEN_XRAY -dns_listen_port "${dns_listen_port}" -dns_server "${_doh_bootstrap}" -doh_url "${_doh_url}" -doh_host "${_doh_host}" > $TMP_PATH/DNS.json
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $TMP_PATH/DNS.log -config="$TMP_PATH/DNS.json"
unset _dns _doh_bootstrap_dns
fi
unset _doh_url _doh_port _doh_bootstrap
fi
if [ -n "$(echo ${DNS_MODE}${up_trust_pdnsd_dns} | grep dns2socks)" ]; then
local dns2socks_socks_server=$(echo $(config_t_get global socks_server 127.0.0.1:9050) | sed "s/#/:/g")
local dns2socks_forward=$(get_first_dns DNS_FORWARD 53 | sed 's/#/:/g')
[ "$DNS_CACHE" == "0" ] && local dns2sock_cache="/d"
ln_start_bin "$(first_type dns2socks)" dns2socks "/dev/null" "$dns2socks_socks_server" "$dns2socks_forward" "127.0.0.1:$dns_listen_port" $dns2sock_cache
echolog " - dns2sock(127.0.0.1:${dns_listen_port}${dns2sock_cache})${dns2socks_socks_server:-127.0.0.1:9050} -> ${dns2socks_forward-D46.182.19.48:53}"
#[ "$CHINADNS_NG" = "1" ] && [ -n "${global}${chnlist}" ] && [ -z "${returnhome}" ] && TUN_DNS=$(echo "${dns_listen_port}" | sed 's/:/#/g')
fi
[ "${use_udp_node_resolve_dns}" = "1" ] && echolog " * 要求代理 DNS 请求,如上游 DNS 非直连地址,确保 UDP 代理打开,并且已经正确转发!"
[ "${use_tcp_node_resolve_dns}" = "1" ] && echolog " * 请确认上游 DNS 支持 TCP 查询,如非直连地址,确保 TCP 代理打开,并且已经正确转发!"
}
@ -904,10 +899,6 @@ add_dnsmasq() {
#始终用国内DNS解析直连白名单列表
fwd_dns="${LOCAL_DNS}"
#如果使用ChinaDNS-NG则直接交给它处理
[ "$CHINADNS_NG" = "1" ] && unset fwd_dns
#如果没使用chnlist直接使用默认DNS
[ "${USE_CHNLIST}" = "0" ] && unset fwd_dns
sort -u "${RULES_PATH}/direct_host" | gen_dnsmasq_items "whitelist" "${fwd_dns}" "${TMP_DNSMASQ_PATH}/00-direct_host.conf"
echolog " - [$?]域名白名单(whitelist)${fwd_dns:-默认}"

View File

@ -426,6 +426,8 @@
43.228.148.0/22
43.228.152.0/22
43.228.188.0/22
43.228.204.0/22
43.228.240.0/22
43.229.40.0/22
43.229.48.0/22
43.229.56.0/22
@ -2538,6 +2540,7 @@
103.41.0.0/22
103.41.16.0/22
103.41.52.0/22
103.41.116.0/22
103.41.140.0/22
103.41.148.0/22
103.41.152.0/22
@ -2818,6 +2821,8 @@
103.56.60.0/22
103.56.72.0/22
103.56.76.0/22
103.56.100.0/22
103.56.104.0/22
103.56.140.0/22
103.56.152.0/22
103.56.184.0/22
@ -4116,6 +4121,8 @@
103.161.14.0/23
103.161.102.0/23
103.161.138.0/23
103.161.208.0/23
103.161.220.0/23
103.192.0.0/22
103.192.4.0/22
103.192.8.0/22

View File

@ -1895,6 +1895,7 @@
2409:8000::/20
240a:2000::/24
240a:4000::/21
240a:6000::/24
240a:8000::/21
240a:c000::/20
240b:8000::/21