OpenClash: sync with upstream source

This commit is contained in:
CN_SZTL 2020-03-19 20:40:09 +08:00
parent 2c78f763c7
commit dda3a521da
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
11 changed files with 41 additions and 24 deletions

View File

@ -98,6 +98,7 @@ if [ -d "/tmp/openclash_game_rules/" ]; then
fi
mkdir -p /lib/upgrade/keep.d >/dev/null 2>&1
cat > "/lib/upgrade/keep.d/luci-app-openclash" <<-EOF
/etc/openclash/clash
/etc/openclash/custom/
/etc/openclash/config/
/etc/openclash/game_rules/

View File

@ -50,7 +50,6 @@ config dns_servers
config dns_servers
option ip '1.1.1.1/dns-query'
option type 'https'
option port '443'
option enabled '0'
option group 'fallback'

View File

@ -72,7 +72,12 @@ change_dns() {
revert_dns() {
uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#"$3" >/dev/null 2>&1
[ "$1" = "1" ] && {
[ -s "/tmp/resolv.conf.d/resolv.conf.auto" ] && {
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.d/resolv.conf.auto >/dev/null 2>&1
}
[ -s "/tmp/resolv.conf.auto" ] && {
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto >/dev/null 2>&1
}
uci set dhcp.@dnsmasq[0].noresolv=0 >/dev/null 2>&1
}
[ "$2" = "1" ] && {
@ -762,6 +767,16 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
ln -s /usr/share/openclash/yacd /www/luci-static/openclash 2>/dev/null
echo "第八步: 设置 OpenClash 防火墙规则..." >$START_LOG
if [ "$(iptables -t nat -nL PREROUTING --line-number |grep "udp dpt:53" |wc -l)" -gt 1 ] && [ "$enable_redirect_dns" -eq "1" ]; then
echo "发现53端口被劫持清理防火墙规则..." >$START_LOG
pre_lines=$(iptables -nvL PREROUTING -t nat |sed 1,2d |sed -n '/udp dpt:53/=' 2>/dev/null |sort -rn)
for pre_line in $pre_lines; do
iptables -t nat -D PREROUTING "$pre_line" >/dev/null 2>&1
done
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 >/dev/null 2>&1
sleep 2
fi
if [ -z "$(uci get firewall.openclash 2>/dev/null)" ] || [ -z "$(uci get ucitrack.@openclash[-1].init 2>/dev/null)" ]; then
uci delete ucitrack.@openclash[-1] >/dev/null 2>&1
uci add ucitrack openclash >/dev/null 2>&1
@ -927,11 +942,6 @@ EOF
fi
echo "第九步: 重启 Dnsmasq 程序..." >$START_LOG
if [ "$(iptables -t nat -nL PREROUTING --line-number |grep "udp dpt:53" |wc -l)" -gt 1 ]; then
echo "发现53端口被劫持如连接异常请将OpenClash设置为劫持53端口程序的上游DNS服务器" >$START_LOG
echo "${LOGTIME} Warring: OpenClash May Can Not Take Over DNS, Please Use OpenClash for Upstream DNS Resolve Server" >> $LOG_FILE
sleep 5
fi
change_dns "$enable_redirect_dns" "$disable_masq_cache"
fake_block "$en_mode" "$direct_dns"
/etc/init.d/dnsmasq restart >/dev/null 2>&1
@ -1057,9 +1067,9 @@ stop()
iptables -t nat -D OUTPUT "$out_line" >/dev/null 2>&1
done
out_lines=$(iptables -nvL PREROUTING -t nat |sed 1,2d |sed -n '/8.8./=' 2>/dev/null |sort -rn)
for out_line in $out_lines; do
iptables -t nat -D PREROUTING "$out_line" >/dev/null 2>&1
pre_lines=$(iptables -nvL PREROUTING -t nat |sed 1,2d |sed -n '/8.8./=' 2>/dev/null |sort -rn)
for pre_line in $pre_lines; do
iptables -t nat -D PREROUTING "$pre_line" >/dev/null 2>&1
done
#ipv6

View File

@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png" />
<title>Clash</title>
<link href="main.9ba3dbeae71a3cb9926b.css" rel="stylesheet"></head>
<link href="main.ad0717ae3407e246a9ab.css" rel="stylesheet"></head>
<body>
<div id="root"></div>
<script type="text/javascript" src="js/1.bundle.9ba3dbeae71a3cb9926b.min.js"></script><script type="text/javascript" src="js/bundle.9ba3dbeae71a3cb9926b.min.js"></script></body>
<script type="text/javascript" src="js/1.bundle.ad0717ae3407e246a9ab.min.js"></script><script type="text/javascript" src="js/bundle.ad0717ae3407e246a9ab.min.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -29,15 +29,6 @@ object-assign
*/
/** @license React v16.13.0
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.8.6
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
@ -45,3 +36,12 @@ object-assign
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.0
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,9 @@ if [ "$2" != 0 ]; then
if [ ! -f /etc/openclash/"$2".yaml ]; then
echo "${1} /etc/openclash/"$2".yaml Not Exist, Will Use Self Rules, Please Update and Try Again" >>/tmp/openclash.log
exit 0
elif [ "$(uci get openclash.config.Proxy)" = "读取错误,配置文件异常!" ]; then
echo "${1} Warning: Can not Get The Porxy-Group's Name, Stop Setting The Other Rules!" >>/tmp/openclash.log
exit 0
else
rulesource=$(grep '##source:' "$4" |awk -F ':' '{print $2}')
[ "$rulesource" != "$2" ] && {
@ -143,6 +146,8 @@ fi
sed -i '/^##Custom Rules 2##/d' "$4" 2>/dev/null
sed -i '/^##Custom Rules 2 End##/d' "$4" 2>/dev/null
sed -i '/- DOMAIN-KEYWORD,tracker,DIRECT/d' "$4" 2>/dev/null
sed -i '/- DOMAIN-KEYWORD,announce,DIRECT/d' "$4" 2>/dev/null
sed -i '/- DOMAIN-KEYWORD,tracker,tracker/d' "$4" 2>/dev/null
if [ "$3" = 1 ]; then
sed -i '/^Rule:/a\##Custom Rules End##' "$4" 2>/dev/null
@ -169,7 +174,9 @@ fi
fi
if [ "$7" = 1 ]; then
sed -i '1,/^ \{0,\}- GEOIP/{/^ \{0,\}- GEOIP/s/^ \{0,\}- GEOIP/- DOMAIN-KEYWORD,tracker,DIRECT\n&/}' "$4"
sed -i '1,/^ \{0,\}- GEOIP/{/^ \{0,\}- GEOIP/s/^ \{0,\}- GEOIP/- DOMAIN-KEYWORD,tracker,DIRECT\n&/}' "$4" 2>/dev/null
sed -i "/- DOMAIN-KEYWORD,tracker,DIRECT/a\- DOMAIN-KEYWORD,announce,DIRECT" "$4" 2>/dev/null
sed -i "/- DOMAIN-KEYWORD,tracker,DIRECT/a\- DOMAIN-KEYWORD,torrent,DIRECT" "$4" 2>/dev/null
if [ -z "$(grep "###- MATCH," "$4")" ] && [ -z "$(grep "###- FINAL," "$4")" ]; then
sed -i 's/- MATCH,/###&/' "$4" 2>/dev/null
sed -i 's/- FINAL,/###&/' "$4" 2>/dev/null