OpenClash: sync with upstream source

This commit is contained in:
CN_SZTL 2020-04-04 21:39:48 +08:00
parent 3e2dd5d750
commit 56dd34ec60
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
15 changed files with 177 additions and 87 deletions

View File

@ -928,9 +928,9 @@ EOF
iptables -t mangle -I PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK"
iptables -t nat -I PREROUTING -p tcp --dport 53 -j ACCEPT
#ipv6
#if [ "$ipv6_enable" -eq 1 ]; then
#ip6tables -t mangle -I PREROUTING -j MARK --set-mark "$PROXY_FWMARK"
#fi
# if [ "$ipv6_enable" -eq 1 ]; then
# ip6tables -t mangle -I PREROUTING -j MARK --set-mark "$PROXY_FWMARK"
# fi
fi
echo "第九步: 重启 Dnsmasq 程序..." >$START_LOG
@ -956,7 +956,7 @@ EOF
if [ "$rule_source" != 0 ] || [ "$enable_custom_clash_rules" != 0 ]; then
echo "错误: OpenClash 启动失败,尝试还原规则并重新启动 Clash 主程序..." >$START_LOG
echo "${LOGTIME} OpenClash Can Not Start, Try Use Backup Rules Start Again" >> $LOG_FILE
mv "$BACKUP_FILE" /etc/openclash/configrules.bak
mv "$START_BACKUP" /etc/openclash/configrules.bak
sed -i -n '/^Rule:/,$p' /etc/openclash/configrules.bak
sed -i '/^Rule:/,$d' "$CONFIG_FILE"
cat /etc/openclash/configrules.bak >> "$CONFIG_FILE"

View File

@ -88,4 +88,11 @@ migu.cn
msftconnecttest.com
msftncsi.com
#QQ快捷登录
ptlogin2.qq.com
ptlogin2.qq.com
#Nintendo Switch
srv.nintendo.net
#Sony PlayStation
stun.playstation.net
#Microsoft Xbox
microsoft.com
xboxlive.com

View File

@ -152,6 +152,24 @@ Proxy: # 节点设置此部分与proxy-provider两者不能同时删除
# ws-headers:
# Host: v2ray.com
- name: "vmess-http"
type: vmess
server: server
port: 443
uuid: uuid
alterId: 32
cipher: auto
# udp: true
# network: http
# http-opts:
# # method: "GET"
# # path:
# # - '/'
# # - '/video'
# # headers:
# # Connection:
# # - keep-alive
# socks5
- name: "socks"
type: socks5

View File

@ -86,7 +86,11 @@ e[t].num=string.format(t)
e[t].name=fs.basename(o)
BACKUP_FILE="/etc/openclash/backup/".. e[t].name
CONFIG_FILE="/etc/openclash/config/".. e[t].name
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE)) or os.date("%Y-%m-%d %H:%M:%S",a.mtime)
if fs.mtime(BACKUP_FILE) then
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE))
else
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
end
if string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 23, -2) == e[t].name then
e[t].state=translate("Enable")
else

View File

@ -163,7 +163,11 @@ e[t]={}
e[t].name=fs.basename(o)
BACKUP_FILE="/etc/openclash/backup/".. e[t].name
CONFIG_FILE="/etc/openclash/config/".. e[t].name
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE)) or os.date("%Y-%m-%d %H:%M:%S",a.mtime)
if fs.mtime(BACKUP_FILE) then
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE))
else
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
end
if string.sub(luci.sys.exec("uci get openclash.config.config_path 2>/dev/null"), 23, -2) == e[t].name then
e[t].state=translate("Enable")
else

View File

@ -96,6 +96,7 @@ o.rmempty = false
o = s:option(Value, "port", translate("Server Port"))
o.datatype = "port"
o.rmempty = false
o.default = 443
o = s:option(Value, "password", translate("Password"))
o.password = true
@ -117,6 +118,19 @@ for _, v in ipairs(securitys) do o:value(v) end
o.rmempty = true
o:depends("type", "vmess")
-- AlterId
o = s:option(Value, "alterId", translate("AlterId"))
o.datatype = "port"
o.default = 32
o.rmempty = true
o:depends("type", "vmess")
-- VmessId
o = s:option(Value, "uuid", translate("VmessId (UUID)"))
o.rmempty = true
o.default = uuid
o:depends("type", "vmess")
o = s:option(ListValue, "udp", translate("UDP Enable"))
o.rmempty = true
o.default = "false"
@ -149,8 +163,35 @@ o.rmempty = true
o.default = "none"
o:value("none")
o:value("websocket", translate("websocket (ws)"))
o:value("http", translate("http"))
o:depends("type", "vmess")
-- [[ skip-cert-verify ]]--
o = s:option(ListValue, "skip_cert_verify", translate("skip-cert-verify"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "none")
o:depends("obfs_vmess", "websocket")
o:depends("type", "socks5")
o:depends("type", "http")
o:depends("type", "trojan")
-- [[ TLS ]]--
o = s:option(ListValue, "tls", translate("TLS"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "none")
o:depends("obfs_vmess", "websocket")
o:depends("obfs_vmess", "http")
o:depends("type", "socks5")
o:depends("type", "http")
o = s:option(Value, "host", translate("obfs-hosts"))
o.datatype = "host"
o.rmempty = true
@ -160,31 +201,29 @@ o:depends("obfs", "websocket")
o:depends("obfs_snell", "tls")
o:depends("obfs_snell", "http")
o = s:option(Value, "custom", translate("ws-headers"))
-- vmess路径
o = s:option(Value, "path", translate("path"))
o.rmempty = true
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "websocket")
-- [[ WS部分 ]]--
o = s:option(DynamicList, "http_path", translate("path"))
o.rmempty = true
o:value("/")
o:value("/video")
o:depends("obfs_vmess", "http")
-- WS路径
o = s:option(Value, "path", translate("ws-path"))
o = s:option(Value, "custom", translate("headers"))
o.rmempty = true
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "websocket")
-- AlterId
o = s:option(Value, "alterId", translate("AlterId"))
o.datatype = "port"
o.default = 16
o = s:option(Value, "keep_alive", translate("keep-alive"))
o.rmempty = true
o:depends("type", "vmess")
-- VmessId
o = s:option(Value, "uuid", translate("VmessId (UUID)"))
o.rmempty = true
o.default = uuid
o:depends("type", "vmess")
o.default = "true"
o:value("true")
o:value("false")
o:depends("obfs_vmess", "http")
-- 验证用户名
o = s:option(Value, "auth_name", translate("Auth Username"))
@ -220,31 +259,6 @@ o:value("h2")
o:value("http/1.1")
o:depends("type", "trojan")
-- [[ skip-cert-verify ]]--
o = s:option(ListValue, "skip_cert_verify", translate("skip-cert-verify"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "none")
o:depends("obfs_vmess", "websocket")
o:depends("type", "socks5")
o:depends("type", "http")
o:depends("type", "trojan")
-- [[ TLS ]]--
o = s:option(ListValue, "tls", translate("TLS"))
o.rmempty = true
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "none")
o:depends("obfs_vmess", "websocket")
o:depends("type", "socks5")
o:depends("type", "http")
o = s:option(DynamicList, "groups", translate("Proxy Group"))
o.description = font_red..bold_on..translate("No Need Set when Config Create, The added Proxy Groups Must Exist")..bold_off..font_off
o.rmempty = true

View File

@ -1,12 +1 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-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.ad0717ae3407e246a9ab.css" rel="stylesheet"></head>
<body>
<div id="root"></div>
<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>
<!doctype html><html lang="en" dir="ltr"><head><meta charset="UTF-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.693efc9234a08d249710.css" rel="stylesheet"></head><body><div id="root"></div><script src="js/1.bundle.693efc9234a08d249710.min.js"></script><script src="js/bundle.693efc9234a08d249710.min.js"></script></body></html>

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@ object-assign
http://jedwatson.github.io/classnames
*/
/** @license React v0.19.0
/** @license React v0.19.1
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
@ -19,15 +19,6 @@ object-assign
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.0
* react-dom.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.13.0
* react-is.production.min.js
*
@ -37,7 +28,16 @@ object-assign
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.0
/** @license React v16.13.1
* react-dom.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.13.1
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.

View File

@ -88,9 +88,9 @@ cfg_get()
echo "$(grep "$1" "$2" 2>/dev/null |awk -v tag=$1 'BEGIN{FS=tag} {print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/\}.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null)"
}
cfg_get_alpn()
cfg_get_dynamic()
{
echo "$(grep "^ \{0,\}$1" "$2" 2>/dev/null |grep -v "^ \{0,\}- name:" |awk -v tag=$1 'BEGIN{FS=tag} {print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/\}.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null)"
echo "$(grep "^ \{0,\}$1" "$2" 2>/dev/null |grep -v "^ \{0,\}- name:" |grep -v "^ \{0,\}- keep-alive" |awk -v tag=$1 'BEGIN{FS=tag} {print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/\}.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null)"
}
echo "开始更新【$CONFIG_NAME】的代理集配置..." >$START_LOG
@ -493,7 +493,9 @@ do
#sni:
sni="$(cfg_get "sni:" "$single_server")"
#alpn:
alpns="$(cfg_get_alpn "-" "$single_server")"
alpns="$(cfg_get_dynamic "-" "$single_server")"
#http_paths:
http_paths="$(cfg_get_dynamic "-" "$single_server")"
echo "正在读取【$CONFIG_NAME】-【$server_type】-【$server_name】服务器节点配置..." >$START_LOG
@ -519,22 +521,32 @@ do
[ -z "$obfs" ] && [ "$server_type" = "ss" ] && ${uci_set}obfs="$mode"
[ -z "$obfs" ] && [ "$server_type" = "ss" ] && [ -z "$mode" ] && ${uci_set}obfs="none"
[ -z "$mode" ] && [ "$server_type" = "snell" ] && ${uci_set}obfs_snell="none"
[ -z "$mode" ] && [ ! -z "$network" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="websocket"
[ -z "$mode" ] && [ "$network" = "ws" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="websocket"
[ -z "$mode" ] && [ "$network" = "http" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="http"
[ -z "$mode" ] && [ -z "$network" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="none"
[ -z "$obfs_host" ] && ${uci_set}host="$host"
${uci_set}psk="$psk"
${uci_set}tls="$tls"
${uci_set}skip_cert_verify="$verify"
${uci_set}path="$path"
[ -z "$path" ] && ${uci_set}path="$ws_path"
[ -z "$path" ] && [ "$network" = "ws" ] && ${uci_set}path="$ws_path"
${uci_set}mux="$mux"
${uci_set}custom="$headers"
[ -z "$headers" ] && ${uci_set}custom="$Host"
[ -z "$headers" ] && [ "$network" = "ws" ] && ${uci_set}custom="$Host"
if [ "$server_type" = "vmess" ]; then
#v2ray
${uci_set}alterId="$alterId"
${uci_set}uuid="$uuid"
${uci_del}http_path >/dev/null 2>&1
for http_path in $http_paths; do
${uci_add}http_path="$http_path" >/dev/null 2>&1
done
if [ ! -z "$(grep "^ \{0,\}- keep-alive" "$single_server")" ]; then
${uci_set}keep_alive="true"
else
${uci_set}keep_alive="false"
fi
fi
if [ "$server_type" = "socks5" ] || [ "$server_type" = "http" ]; then
@ -549,7 +561,7 @@ do
${uci_set}sni="$sni"
${uci_del}alpn >/dev/null 2>&1
for alpn in $alpns; do
${uci_add}alpn="$alpn" >/dev/null 2>&1
${uci_add}alpn="$alpn" >/dev/null 2>&1
done
fi
else
@ -587,22 +599,32 @@ do
[ -z "$obfs" ] && [ "$server_type" = "ss" ] && ${uci_set}obfs="$mode"
[ -z "$obfs" ] && [ "$server_type" = "ss" ] && [ -z "$mode" ] && ${uci_set}obfs="none"
[ -z "$mode" ] && [ "$server_type" = "snell" ] && ${uci_set}obfs_snell="none"
[ -z "$mode" ] && [ ! -z "$network" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="websocket"
[ -z "$mode" ] && [ "$network" = "ws" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="websocket"
[ -z "$mode" ] && [ "$network" = "http" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="http"
[ -z "$mode" ] && [ -z "$network" ] && [ "$server_type" = "vmess" ] && ${uci_set}obfs_vmess="none"
[ -z "$obfs_host" ] && ${uci_set}host="$host"
${uci_set}psk="$psk"
${uci_set}tls="$tls"
${uci_set}skip_cert_verify="$verify"
${uci_set}path="$path"
[ -z "$path" ] && ${uci_set}path="$ws_path"
[ -z "$path" ] && [ "$network" = "ws" ] && ${uci_set}path="$ws_path"
${uci_set}mux="$mux"
${uci_set}custom="$headers"
[ -z "$headers" ] && ${uci_set}custom="$Host"
[ -z "$headers" ] && [ "$network" = "ws" ] && ${uci_set}custom="$Host"
if [ "$server_type" = "vmess" ]; then
#v2ray
${uci_set}alterId="$alterId"
${uci_set}uuid="$uuid"
${uci_del}http_path >/dev/null 2>&1
for http_path in $http_paths; do
${uci_add}http_path="$http_path" >/dev/null 2>&1
done
if [ ! -z "$(grep "^ \{0,\}- keep-alive" "$single_server")" ]; then
${uci_set}keep_alive="true"
else
${uci_set}keep_alive="false"
fi
fi
if [ "$server_type" = "socks5" ] || [ "$server_type" = "http" ]; then

View File

@ -107,6 +107,17 @@ cat >> "$SERVER_FILE" <<-EOF
EOF
}
set_http_path()
{
if [ -z "$1" ]; then
return
fi
cat >> "$SERVER_FILE" <<-EOF
- '$1'
EOF
}
#写入服务器节点到配置文件
yml_servers_set()
{
@ -138,6 +149,8 @@ yml_servers_set()
config_get "obfs_snell" "$section" "obfs_snell" ""
config_get "sni" "$section" "sni" ""
config_get "alpn" "$section" "alpn" ""
config_get "http_path" "$section" "http_path" ""
config_get "keep_alive" "$section" "keep_alive" ""
if [ ! -z "$if_game_proxy" ] && [ "$if_game_proxy" != "$name" ] && [ "$if_game_proxy_type" = "proxy" ]; then
return
@ -183,10 +196,14 @@ yml_servers_set()
fi
fi
if [ "$obfs_vmess" != "none" ]; then
if [ "$obfs_vmess" = "websocket" ]; then
obfs_vmess="network: ws"
fi
if [ "$obfs_vmess" = "http" ]; then
obfs_vmess="network: http"
fi
if [ ! -z "$custom" ] && [ "$type" = "vmess" ]; then
custom="Host: $custom"
fi
@ -194,7 +211,7 @@ yml_servers_set()
if [ ! -z "$path" ]; then
if [ "$type" != "vmess" ]; then
path="path: '$path'"
else
elif [ "$obfs_vmess" = "network: ws" ]; then
path="ws-path: $path"
fi
fi
@ -282,15 +299,30 @@ EOF
cat >> "$SERVER_FILE" <<-EOF
$obfs_vmess
EOF
if [ ! -z "$path" ]; then
if [ ! -z "$path" ] && [ "$obfs_vmess" = "network: ws" ]; then
cat >> "$SERVER_FILE" <<-EOF
$path
EOF
fi
if [ ! -z "$custom" ]; then
if [ ! -z "$custom" ] && [ "$obfs_vmess" = "network: ws" ]; then
cat >> "$SERVER_FILE" <<-EOF
ws-headers:
$custom
EOF
fi
if [ ! -z "$http_path" ] && [ "$obfs_vmess" = "network: http" ]; then
cat >> "$SERVER_FILE" <<-EOF
http-opts:
method: "GET"
path:
EOF
config_list_foreach "$section" "http_path" set_http_path
fi
if [ "$keep_alive" = "true" ] && [ "$obfs_vmess" = "network: http" ]; then
cat >> "$SERVER_FILE" <<-EOF
headers:
Connection:
- keep-alive
EOF
fi
fi