luci-app-ssr-plus: sync upstream

last commit: 9d61093d71
This commit is contained in:
gitea-action 2024-11-30 15:00:33 +08:00
parent 505d841e5e
commit d12bc028d2
8 changed files with 125 additions and 22 deletions

View File

@ -74,6 +74,17 @@ o = s:option(Flag, "apple_optimization", translate("Apple domains optimization")
o.rmempty = false
o.default = "1"
o = s:option(Value, "apple_url", translate("Apple Domains Update url"))
o:value("https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/apple.china.conf", translate("felixonmars/dnsmasq-china-list"))
o.default = "https://fastly.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/apple.china.conf"
o:depends("apple_optimization", "1")
o = s:option(Value, "apple_dns", translate("Apple Domains DNS"), translate("If empty, Not change Apple domains parsing DNS (Default is empty)"))
o.rmempty = true
o.default = ""
o.datatype = "ip4addr"
o:depends("apple_optimization", "1")
o = s:option(Flag, "adblock", translate("Enable adblock"))
o.rmempty = false

View File

@ -944,7 +944,7 @@ if is_finded("xray") then
o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw", reality = true})
-- [[ uTLS ]]--
o = s:option(Value, "fingerprint", translate("Finger Print"))
o = s:option(ListValue, "fingerprint", translate("Finger Print"))
o.default = "chrome"
o:value("chrome", translate("chrome"))
o:value("firefox", translate("firefox"))

View File

@ -48,6 +48,10 @@ if nixio.fs.access("/etc/ssrplus/china_ssr.txt") then
ip_count = tonumber(luci.sys.exec("cat /etc/ssrplus/china_ssr.txt | wc -l"))
end
if nixio.fs.access("/etc/ssrplus/applechina.conf") then
apple_count = tonumber(luci.sys.exec("cat /etc/ssrplus/applechina.conf | wc -l"))
end
if nixio.fs.access("/etc/ssrplus/netflixip.list") then
nfip_count = tonumber(luci.sys.exec("cat /etc/ssrplus/netflixip.list | wc -l"))
end
@ -169,6 +173,13 @@ s.rawhtml = true
s.template = "shadowsocksr/refresh"
s.value = ip_count .. " " .. translate("Records")
if uci:get_first("shadowsocksr", 'global', 'apple_optimization', '0') ~= '0' then
s = m:field(DummyValue, "apple_data", translate("Apple Domains Data"))
s.rawhtml = true
s.template = "shadowsocksr/refresh"
s.value = apple_count .. " " .. translate("Records")
end
if uci:get_first("shadowsocksr", 'global', 'netflix_enable', '0') ~= '0' then
s = m:field(DummyValue, "nfip_data", translate("Netflix IP Data"))
s.rawhtml = true

View File

@ -410,6 +410,9 @@ msgstr "【中国大陆 IP 段】数据库"
msgid "Netflix IP Data"
msgstr "【Netflix IP 段】数据库"
msgid "Apple Domains Data"
msgstr "【Apple 域名】数据库"
msgid "Advertising Data"
msgstr "【广告屏蔽】数据库"
@ -470,6 +473,15 @@ msgstr "启用广告屏蔽"
msgid "adblock_url"
msgstr "广告屏蔽更新 URL"
msgid "Apple Domains Update url"
msgstr "Apple 域名更新 URL"
msgid "Apple Domains DNS"
msgstr "Apple 域名 DNS"
msgid "If empty, Not change Apple domains parsing DNS (Default is empty)"
msgstr "如果为空,则不更改 Apple 域名解析 DNS默认为空"
msgid "gfwlist Update url"
msgstr "GFW 列表更新 URL"

View File

@ -232,6 +232,14 @@ start_dns() {
fi
if [ "$(uci_get_by_type global apple_optimization 1)" == "1" ]; then
local new_appledns="$(uci_get_by_type global apple_dns)"
if [ -n "$new_appledns" ]; then
sed -i 's/[[:space:]]//g' /etc/ssrplus/applechina.conf #去除所有空白字符
local old_appledns=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' /etc/ssrplus/applechina.conf | sort -u)
if [ -n "$old_appledns" ] && [ "$old_appledns" != "$new_appledns" ]; then
sed -i "s,$(printf '%s' "$old_appledns"),$(printf '%s' "$new_appledns"),g" /etc/ssrplus/applechina.conf
fi
fi
echolog "Apple 域名中国大陆 CDN 的 优化规则正在加载。"
cp -f /etc/ssrplus/applechina.conf $TMP_DNSMASQ_PATH/
echolog "Apple 域名中国大陆 CDN 的 优化规则加载完毕。"

View File

@ -28,6 +28,16 @@ touch /etc/ssrplus/gfw_list.conf
touch /etc/ssrplus/oversea_list.conf
touch /etc/ssrplus/ad.conf
touch /etc/config/shadowsocksr
if [ -s "/etc/config/shadowsocksr" ]; then
if ! uci -q get shadowsocksr.@global_xray_fragment[0] > /dev/null; then
uci -q add shadowsocksr global_xray_fragment
uci -q set shadowsocksr.@global_xray_fragment[0].fragment='0'
uci -q set shadowsocksr.@global_xray_fragment[0].noise='0'
uci -q commit shadowsocksr
fi
fi
[ -s "/etc/config/shadowsocksr" ] || /etc/init.d/shadowsocksr reset
sed -i "s/option type 'vmess'/option type 'v2ray'\n\toption v2ray_protocol 'vmess'/g" /etc/config/shadowsocksr

View File

@ -59,6 +59,7 @@ local excluded_domain = {
local mydnsip = '127.0.0.1'
local mydnsport = '5335'
local ipsetname = 'gfwlist'
local new_appledns = uci:get_first("shadowsocksr", "global", "apple_dns")
local bc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
-- base64decoding
local function base64_dec(data)
@ -112,6 +113,29 @@ local function generate_gfwlist(type)
os.remove("/tmp/ssr-update.tmp")
end
-- 更换 Apple dns
local function generate_apple(type)
local domains, domains_map = {}, {}
local out = io.open("/tmp/ssr-update." .. type, "w")
for line in io.lines("/tmp/ssr-update.tmp") do
if not (string.find(line, comment_pattern)) then
local start, finish, match = string.find(line, domain_pattern)
if start and not domains_map[match] then
domains_map[match] = true
match = string.gsub(match, "%s", "") --从域名中去除所有空白字符
table.insert(domains, match)
end
end
end
for _, domain in ipairs(domains) do
if new_appledns and new_appledns ~= "" then
out:write(string.format("server=/%s/%s\n", domain, new_appledns))
end
end
out:close()
os.remove("/tmp/ssr-update.tmp")
end
-- adblock转码至dnsmasq格式
local function generate_adblock(type)
local domains, domains_map = {}, {}
@ -159,6 +183,21 @@ local function update(url, file, type, file2)
generate_gfwlist(type)
Num = 2
end
if type == "apple_data" then
local apple = io.open("/tmp/ssr-update." .. type, "r")
local decode = apple:read("*a")
if not decode:find("apple") then
decode = base64_dec(decode)
end
apple:close()
-- 写回applechina
apple = io.open("/tmp/ssr-update.tmp", "w")
apple:write(decode)
apple:close()
if new_appledns and new_appledns ~= "" then
generate_apple(type)
end
end
if type == "ad_data" then
local adblock = io.open("/tmp/ssr-update." .. type, "r")
local decode = adblock:read("*a")
@ -217,12 +256,16 @@ if args then
update(uci:get_first("shadowsocksr", "global", "chnroute_url"), "/etc/ssrplus/china_ssr.txt", args, TMP_PATH .. "/china_ssr.txt")
os.exit(0)
end
if args == "apple_data" then
update(uci:get_first("shadowsocksr", "global", "apple_url"), "/etc/ssrplus/applechina.conf", args, TMP_DNSMASQ_PATH .. "/applechina.conf")
os.exit(0)
end
if args == "ad_data" then
update(uci:get_first("shadowsocksr", "global", "adblock_url"), "/etc/ssrplus/ad.conf", args, TMP_DNSMASQ_PATH .. "/ad.conf")
os.exit(0)
end
if args == "nfip_data" then
update(uci:get_first("shadowsocksr", "global", "nfip_url"), "/etc/ssrplus/netflixip.list", args)
update(uci:get_first("shadowsocksr", "global", "nfip_url"), "/etc/ssrplus/netflixip.list", args, TMP_DNSMASQ_PATH .. "/netflixip.list")
os.exit(0)
end
else
@ -230,10 +273,18 @@ else
update(uci:get_first("shadowsocksr", "global", "gfwlist_url"), "/etc/ssrplus/gfw_list.conf", "gfw_data", TMP_DNSMASQ_PATH .. "/gfw_list.conf")
log("正在更新【国内IP段】数据库")
update(uci:get_first("shadowsocksr", "global", "chnroute_url"), "/etc/ssrplus/china_ssr.txt", "ip_data", TMP_PATH .. "/china_ssr.txt")
if uci:get_first("shadowsocksr", "global", "apple_optimization", "0") == "1" then
log("正在更新【Apple域名】数据库")
update(uci:get_first("shadowsocksr", "global", "apple_url"), "/etc/ssrplus/applechina.conf", "apple_data", TMP_DNSMASQ_PATH .. "/applechina.conf")
end
if uci:get_first("shadowsocksr", "global", "adblock", "0") == "1" then
log("正在更新【广告屏蔽】数据库")
update(uci:get_first("shadowsocksr", "global", "adblock_url"), "/etc/ssrplus/ad.conf", "ad_data", TMP_DNSMASQ_PATH .. "/ad.conf")
end
if uci:get_first("shadowsocksr", "global", "netflix_enable", "0") == "1" then
log("正在更新【Netflix IP段】数据库")
update(uci:get_first("shadowsocksr", "global", "nfip_url"), "/etc/ssrplus/netflixip.list", "nfip_data", TMP_DNSMASQ_PATH .. "/netflixip.list")
end
-- log("正在更新【Netflix IP段】数据库")
-- update(uci:get_first("shadowsocksr", "global", "nfip_url"), "/etc/ssrplus/netflixip.list", "nfip_data")
end

View File

@ -134,7 +134,7 @@ index 8ceaba7..f381a54 100644
page.acl_depends = { "luci-app-ssr-plus" }
entry({"admin", "services", "shadowsocksr", "client"}, cbi("shadowsocksr/client"), _("SSR Client"), 10).leaf = true
diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua
index 5fc774f..bca8c17 100644
index 9853997..de97787 100644
--- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua
+++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua
@@ -70,45 +70,6 @@ o.default = "https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt"
@ -238,10 +238,10 @@ index 26de9ba..b24183e 100644
o = s:option(Value, "chinadns_forward", translate("Domestic DNS Server"))
o:value("", translate("Disable ChinaDNS-NG"))
diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua
index a095d44..1400c91 100644
index 2a5c5e2..65b916e 100644
--- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua
+++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua
@@ -88,7 +88,7 @@ if Process_list:find("ssr.server") then
@@ -92,7 +92,7 @@ if Process_list:find("ssr.server") then
server_run = 1
end
@ -430,10 +430,10 @@ index 0e19670..a7485ac 100644
}
}
diff --git a/luci-app-ssr-plus/po/zh_Hans/ssr-plus.po b/luci-app-ssr-plus/po/zh_Hans/ssr-plus.po
index 18f19a7..307725e 100644
index 6bc5944..e1f75e5 100644
--- a/luci-app-ssr-plus/po/zh_Hans/ssr-plus.po
+++ b/luci-app-ssr-plus/po/zh_Hans/ssr-plus.po
@@ -557,27 +557,6 @@ msgstr "使用 DNS2TCP 查询"
@@ -569,27 +569,6 @@ msgstr "使用 DNS2TCP 查询"
msgid "Use DNS2SOCKS query and cache"
msgstr "使用 DNS2SOCKS 查询并缓存"
@ -462,7 +462,7 @@ index 18f19a7..307725e 100644
msgstr "DNS 服务器 IP:Port"
diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr
index 740bdce..66d0cc9 100755
index 8edf65b..9d8e5e6 100755
--- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr
+++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr
@@ -188,23 +188,17 @@ ln_start_bin() {
@ -521,7 +521,7 @@ index 740bdce..66d0cc9 100755
esac
if [ "$run_mode" = "router" ]; then
@@ -495,33 +469,6 @@ start_udp() {
@@ -503,33 +477,6 @@ start_udp() {
esac
}
@ -555,7 +555,7 @@ index 740bdce..66d0cc9 100755
start_shunt() {
local type=$(uci_get_by_name $SHUNT_SERVER type)
case "$type" in
@@ -535,14 +482,14 @@ start_shunt() {
@@ -543,14 +490,14 @@ start_shunt() {
local tmp_port=$tmp_shunt_local_port
ln_start_bin $(first_type ${type}local ${type}-local) ${type}-local -c $shunt_dns_config_file
fi
@ -572,7 +572,7 @@ index 740bdce..66d0cc9 100755
echolog "shunt:$($(first_type xray v2ray) version | head -1) Started!"
;;
trojan)
@@ -554,7 +501,7 @@ start_shunt() {
@@ -562,7 +509,7 @@ start_shunt() {
local tmp_port=$tmp_shunt_local_port
ln_start_bin $(first_type trojan) $type --config $shunt_dns_config_file
fi
@ -581,7 +581,7 @@ index 740bdce..66d0cc9 100755
echolog "shunt:$($(first_type trojan) --version 2>&1 | head -1) Started!"
;;
naiveproxy)
@@ -566,7 +513,7 @@ start_shunt() {
@@ -574,7 +521,7 @@ start_shunt() {
local tmp_port=$tmp_shunt_local_port
ln_start_bin $(first_type naive) naive --config $shunt_dns_config_file
fi
@ -590,7 +590,7 @@ index 740bdce..66d0cc9 100755
echolog "shunt:$($(first_type "naive") --version 2>&1 | head -1) Started!"
redir_udp=0
;;
@@ -579,7 +526,7 @@ start_shunt() {
@@ -587,7 +534,7 @@ start_shunt() {
gen_config_file $SHUNT_SERVER $type 3 $tmp_shunt_port $tmp_port
fi
ln_start_bin $(first_type hysteria) hysteria client --config $shunt_config_file
@ -599,7 +599,7 @@ index 740bdce..66d0cc9 100755
echolog "shunt:$($(first_type hysteria) version | grep Version | awk '{print "Hysteria2: " $2}') Started!"
;;
tuic)
@@ -591,7 +538,7 @@ start_shunt() {
@@ -599,7 +546,7 @@ start_shunt() {
[ -n "$tmp_local_port" ] && tmp_port=$tmp_local_port || tmp_port=$tmp_shunt_local_port
gen_config_file $SHUNT_SERVER $type 3 $tmp_port # make a tuic socks :304
ln_start_bin $(first_type tuic-client) tuic-client --config $shunt_dns_config_file
@ -608,7 +608,7 @@ index 740bdce..66d0cc9 100755
echolog "Netflix Separated Shunt Server:tuic-client $($(first_type tuic-client) --version) Started!"
# FIXME: ipt2socks cannot handle udp reply from tuic
#redir_udp=0
@@ -601,7 +548,7 @@ start_shunt() {
@@ -609,7 +556,7 @@ start_shunt() {
gen_config_file $SHUNT_SERVER $type 3 "10${tmp_shunt_port}" $tmp_port chain/$tmp_shunt_port #make a redir:303 and a socks:304
#echo "debug \$tmp_port=$tmp_port, \$tmp_shunt_port=${tmp_shunt_port}, \$tmp_shunt_local_port=$tmp_shunt_local_port"
ln_start_bin $(first_type shadow-tls) shadow-tls config --config $chain_config_file
@ -617,7 +617,7 @@ index 740bdce..66d0cc9 100755
local chain_type=$(uci_get_by_name $SHUNT_SERVER chain_type)
case ${chain_type} in
vmess)
@@ -627,7 +574,7 @@ start_shunt() {
@@ -635,7 +582,7 @@ start_shunt() {
# local tmp_port=$tmp_shunt_local_port
# ln_start_bin $(first_type microsocks) microsocks -i 127.0.0.1 -p $tmp_port shunt-dns-ssr-plus
# fi
@ -626,7 +626,7 @@ index 740bdce..66d0cc9 100755
# echolog "shunt:$type REDIRECT/TPROXY Started!"
# ;;
*)
@@ -639,7 +586,7 @@ start_shunt() {
@@ -647,7 +594,7 @@ start_shunt() {
local tmp_port=$tmp_shunt_local_port
ln_start_bin $(first_type microsocks) microsocks -i 127.0.0.1 -p $tmp_port shunt-dns-ssr-plus
fi
@ -635,7 +635,7 @@ index 740bdce..66d0cc9 100755
echolog "shunt:$type REDIRECT/TPROXY Started!"
;;
esac
@@ -938,11 +885,6 @@ start_server() {
@@ -946,11 +893,6 @@ start_server() {
server_service() {
[ "$(uci_get_by_name $1 enable 0)" == "0" ] && return 1
let server_count=server_count+1
@ -647,7 +647,7 @@ index 740bdce..66d0cc9 100755
local type=$(uci_get_by_name $1 type)
case "$type" in
ss | ssr)
@@ -956,32 +898,23 @@ start_server() {
@@ -964,32 +906,23 @@ start_server() {
echolog "Server:Socks5 Server$server_count Started!"
;;
esac
@ -692,7 +692,7 @@ index 740bdce..66d0cc9 100755
return 0
}
@@ -1114,12 +1047,6 @@ stop() {
@@ -1122,12 +1055,6 @@ stop() {
unlock
set_lock
/usr/bin/ssr-rules -f
@ -705,7 +705,7 @@ index 740bdce..66d0cc9 100755
if [ -z "$switch_server" ]; then
$PS -w | grep -v "grep" | grep ssr-switch | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
rm -f /var/lock/ssr-switch.lock
@@ -1130,7 +1057,7 @@ stop() {
@@ -1138,7 +1065,7 @@ stop() {
( \
# Graceful kill first, so programs have the chance to stop its subprocesses
$PS -w | grep -v "grep" | grep "$TMP_PATH" | awk '{print $1}' | xargs kill >/dev/null 2>&1 ; \
@ -714,7 +714,7 @@ index 740bdce..66d0cc9 100755
# Force kill hanged programs
$PS -w | grep -v "grep" | grep "$TMP_PATH" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 ; \
)
@@ -1148,6 +1075,9 @@ stop() {
@@ -1156,6 +1083,9 @@ stop() {
rm -rf $DNSMASQ_CONF_DIR/dnsmasq-ssrplus.conf $TMP_DNSMASQ_PATH $TMP_PATH/*-ssr-*.json $TMP_PATH/ssr-server*.json
/etc/init.d/dnsmasq restart >/dev/null 2>&1
fi