OpenClash: bump to v0.42.01-beta

Signed-off-by: CN_SZTL <cnsztl@project-openwrt.eu.org>
This commit is contained in:
vernesong 2021-02-20 19:59:29 +08:00 committed by CN_SZTL
parent 5193617b8a
commit 71b8df962b
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
28 changed files with 203 additions and 9959 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-openclash PKG_NAME:=luci-app-openclash
PKG_VERSION:=0.41.14 PKG_VERSION:=0.42.01
PKG_RELEASE:=beta PKG_RELEASE:=beta
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash> PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>

View File

@ -144,10 +144,21 @@ o:value("debug", translate("Debug Mode"))
o:value("silent", translate("Silent Mode")) o:value("silent", translate("Silent Mode"))
o.default = "silent" o.default = "silent"
o = s:taboption("settings", Value, "log_size", translate("Log Size (KB)"))
o.description = translate("Set Log File Size (KB)")
o.default=1024
o = s:taboption("settings", Flag, "intranet_allowed", translate("Only intranet allowed")) o = s:taboption("settings", Flag, "intranet_allowed", translate("Only intranet allowed"))
o.description = translate("When Enabled, The Control Panel And The Connection Broker Port Will Not Be Accessible From The Public Network") o.description = translate("When Enabled, The Control Panel And The Connection Broker Port Will Not Be Accessible From The Public Network")
o.default=0 o.default=0
o = s:taboption("settings", Value, "dns_port")
o.title = translate("DNS Port")
o.default = 7874
o.datatype = "port"
o.rmempty = false
o.description = translate("Please Make Sure Ports Available")
o = s:taboption("settings", Value, "proxy_port") o = s:taboption("settings", Value, "proxy_port")
o.title = translate("Redir Port") o.title = translate("Redir Port")
o.default = 7892 o.default = 7892

View File

@ -3,14 +3,17 @@
<fieldset class="cbi-section"> <fieldset class="cbi-section">
<table width="100%"> <table width="100%">
<tr> <tr>
<td width="33%" align="center"> <td width="25%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="stop_refresh_button" value="<%:Stop Refresh Log%>" onclick=" return stop_refresh() "/> <input type="button" class="cbi-button cbi-button-apply" id="stop_refresh_button" value="<%:Stop Refresh Log%>" onclick=" return stop_refresh() "/>
</td> </td>
<td width="33%" align="center"> <td width="25%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="start_refresh_button" value="<%:Start Refresh Log%>" onclick=" return start_refresh() "/> <input type="button" class="cbi-button cbi-button-apply" id="start_refresh_button" value="<%:Start Refresh Log%>" onclick=" return start_refresh() "/>
</td> </td>
<td width="33%" align="center"> <td width="25%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="del_log_button" value="<%:Clean Log%>" style=" display:inline;" onclick=" return del_log()" /> <input type="button" class="cbi-button cbi-button-apply" id="del_log_button" value="<%:Clean Log%>" style=" display:inline;" onclick=" return del_log() " />
</td>
<td width="25%" align="center">
<input type="button" class="cbi-button cbi-button-apply" id="down_log_button" value="<%:Download Log%>" style=" display:inline;" onclick=" return download_log() " />
</td> </td>
</tr> </tr>
</table> </table>
@ -30,6 +33,22 @@ function start_refresh() {
return return
} }
function createAndDownloadFile(fileName, content) {
var aTag = document.createElement('a');
var blob = new Blob([content]);
aTag.download = fileName;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(blob);
}
function download_log(){
var lv = document.getElementById('cbid.openclash.config.clog');
var dt = new Date();
var timestamp = dt.getFullYear()+"-"+(dt.getMonth()+1)+"-"+dt.getDate()+"-"+dt.getHours()+"-"+dt.getMinutes()+"-"+dt.getSeconds();
createAndDownloadFile("OpenClash-"+timestamp+".log",lv.innerHTML)
return
}
function del_log() { function del_log() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "del_log")%>',null,function(x, data){ XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "del_log")%>',null,function(x, data){
var lv = document.getElementById('cbid.openclash.config.clog'); var lv = document.getElementById('cbid.openclash.config.clog');

View File

@ -1438,4 +1438,16 @@ msgid "Restart Time (Every Week)"
msgstr "重启时间(每周)" msgstr "重启时间(每周)"
msgid "Restart time (every day)" msgid "Restart time (every day)"
msgstr "重启时间(每天)" msgstr "重启时间(每天)"
msgid "DNS Port"
msgstr "DNS监听端口"
msgid "Log Size (KB)"
msgstr "日志大小KB"
msgid "Set Log File Size (KB)"
msgstr "设置日志文件大小KB"
msgid "Download Log"
msgstr "下载日志"

View File

@ -4,6 +4,7 @@ config openclash 'config'
option mixed_port '7893' option mixed_port '7893'
option socks_port '7891' option socks_port '7891'
option http_port '7890' option http_port '7890'
option dns_port '7874'
option enable '0' option enable '0'
option update '0' option update '0'
option en_mode '0' option en_mode '0'
@ -34,6 +35,7 @@ config openclash 'config'
option small_flash_memory '0' option small_flash_memory '0'
option interface_name '0' option interface_name '0'
option common_ports '0' option common_ports '0'
option log_size '1024'
option geo_custom_url 'http://www.ideame.top/mmdb/Country.mmdb' option geo_custom_url 'http://www.ideame.top/mmdb/Country.mmdb'
option chnr_custom_url 'https://ispip.clang.cn/all_cn.txt' option chnr_custom_url 'https://ispip.clang.cn/all_cn.txt'

View File

@ -24,13 +24,13 @@ PROXY_FWMARK="0x162"
PROXY_ROUTE_TABLE="0x162" PROXY_ROUTE_TABLE="0x162"
set_lock() { set_lock() {
exec 888>"$LOCK_FILE" 2>/dev/null exec 888>"$LOCK_FILE" 2>/dev/null
flock -x 888 2>/dev/null flock -x 888 2>/dev/null
} }
del_lock() { del_lock() {
flock -u 888 2>/dev/null flock -u 888 2>/dev/null
rm -rf "$LOCK_FILE" 2>/dev/null rm -rf "$LOCK_FILE" 2>/dev/null
} }
add_cron() add_cron()
@ -139,27 +139,9 @@ start_fail()
exit 0 exit 0
} }
yml_check()
{
#创建原始备份
if [ ! -f "$2" ]; then
cp "$1" "$2"
fi
dns_port="$(ruby_read "$1" "['dns']['listen'].split(':')[1]")"
if [ -z "$dns_port" ] || [ "$dns_port" -eq 53 ]; then
dns_port=7874
fi
#保存DNS端口方便后续调用
uci set openclash.config.dns_port="$dns_port" && uci commit openclash
}
yml_dns_check() yml_dns_check()
{ {
#检查DNS服务 #检查DNS服务
if [ -z "$(ruby_read "$1" "['dns']['nameserver']")" ]; then if [ -z "$(ruby_read "$1" "['dns']['nameserver']")" ]; then
echo "检测到DNS选项下的Nameserver未设置服务器开始补全..." >$START_LOG echo "检测到DNS选项下的Nameserver未设置服务器开始补全..." >$START_LOG
echo " nameserver:" > "$DNS_FILE" 2>/dev/null echo " nameserver:" > "$DNS_FILE" 2>/dev/null
@ -946,17 +928,22 @@ do_run_file()
sleep 5 sleep 5
start_fail start_fail
fi fi
#创建原始备份
if [ ! -f "$2" ]; then
cp "$1" "$2"
fi
} }
#绑定interface防止回环 #绑定interface防止回环
check_interface_name() check_interface_name()
{ {
if [ -n "$interface_name" ] && [ "$interface_name" != "0" ]; then if [ -n "$interface_name" ] && [ "$interface_name" != "0" ]; then
ruby_edit "$CONFIG_FILE" "['interface-name']='$interface_name'" ruby_edit "$CONFIG_FILE" "['interface-name']='$interface_name'"
else else
sed -i "/^interface-name:/d" "$CONFIG_FILE" 2>/dev/null sed -i "/^interface-name:/d" "$CONFIG_FILE" 2>/dev/null
fi fi
} }
start_run_core() start_run_core()
@ -1341,7 +1328,7 @@ if [ -z "$en_mode_tun" ] || [ "$en_mode_tun" -eq 3 ]; then
iptables -t mangle -A openclash -m set --match-set china_ip_route dst -j RETURN >/dev/null 2>&1 iptables -t mangle -A openclash -m set --match-set china_ip_route dst -j RETURN >/dev/null 2>&1
fi fi
iptables -t mangle -A openclash -p udp --dport 53 -j RETURN >/dev/null 2>&1 iptables -t mangle -A openclash -p udp --dport 53 -j RETURN >/dev/null 2>&1
iptables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --on-ip 0.0.0.0 --tproxy-mark "$PROXY_FWMARK" iptables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark "$PROXY_FWMARK"
iptables -t mangle -A PREROUTING -p udp -j openclash iptables -t mangle -A PREROUTING -p udp -j openclash
fi fi
fi fi
@ -1605,6 +1592,8 @@ get_config()
mixed_port=$(uci get openclash.config.mixed_port 2>/dev/null) mixed_port=$(uci get openclash.config.mixed_port 2>/dev/null)
interface_name=$(uci get openclash.config.interface_name 2>/dev/null) interface_name=$(uci get openclash.config.interface_name 2>/dev/null)
common_ports=$(uci get openclash.config.common_ports 2>/dev/null) common_ports=$(uci get openclash.config.common_ports 2>/dev/null)
dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
[ -z "$dns_port" ] && dns_port=7874 && uci set openclash.config.dns_port=7874 2>/dev/null
uci set openclash.config.restricted_mode=0 && uci commit openclash uci set openclash.config.restricted_mode=0 && uci commit openclash
} }
@ -1622,11 +1611,9 @@ start()
echo "第一步: 获取配置..." >$START_LOG echo "第一步: 获取配置..." >$START_LOG
get_config get_config
echo "第二步: 组件运行前检查..." >$START_LOG
#检查文件是否存在 #检查文件是否存在
do_run_file do_run_file "$CONFIG_FILE" "$BACKUP_FILE"
echo "第二步: 配置文件检查..." >$START_LOG
yml_check "$CONFIG_FILE" "$BACKUP_FILE"
echo "第三步: 修改配置文件..." >$START_LOG echo "第三步: 修改配置文件..." >$START_LOG
config_load "openclash" config_load "openclash"
@ -1746,7 +1733,7 @@ restart()
[ -f "$LOCK_FILE" ] && echo "${LOGTIME} Warning: Multiple Restart Scripts Running, Exit..." >> $LOG_FILE && exit 0 [ -f "$LOCK_FILE" ] && echo "${LOGTIME} Warning: Multiple Restart Scripts Running, Exit..." >> $LOG_FILE && exit 0
mkdir -p /tmp/lock mkdir -p /tmp/lock
touch $LOCK_FILE touch $LOCK_FILE
set_lock set_lock
stop stop
start start
del_lock del_lock

View File

@ -1,17 +0,0 @@
{
"files": {
"main.css": "./static/css/main.a3812757.chunk.css",
"main.js": "./static/js/main.8e23a89d.chunk.js",
"runtime-main.js": "./static/js/runtime-main.b905e4f3.js",
"static/js/2.d14c2fca.chunk.js": "./static/js/2.d14c2fca.chunk.js",
"index.html": "./index.html",
"static/js/2.d14c2fca.chunk.js.LICENSE.txt": "./static/js/2.d14c2fca.chunk.js.LICENSE.txt",
"static/media/logo.45983944.png": "./static/media/logo.45983944.png"
},
"entrypoints": [
"static/js/runtime-main.b905e4f3.js",
"static/js/2.d14c2fca.chunk.js",
"static/css/main.a3812757.chunk.css",
"static/js/main.8e23a89d.chunk.js"
]
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1,22 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"/><meta name="description" content="Clash web port"/><title>Clash</title><link href="./static/css/main.a3812757.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,a,l=r[0],f=r[1],i=r[2],p=0,s=[];p<l.length;p++)a=l[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(c&&c(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var f=t[l];0!==o[f]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="./";var l=this["webpackJsonpclash-dashboard"]=this["webpackJsonpclash-dashboard"]||[],f=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var c=f;t()}([])</script><script src="./static/js/2.d14c2fca.chunk.js"></script><script src="./static/js/main.8e23a89d.chunk.js"></script></body></html> <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Clash web port"
/>
<title>Clash</title>
<script type="module" crossorigin src="./assets/index.236bee55.js"></script>
<link rel="modulepreload" href="./assets/vendor.b176d855.js">
<link rel="stylesheet" href="./assets/index.5dfcf857.css">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View File

@ -1,56 +0,0 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** @license React v0.20.1
* scheduler.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-is.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 v17.0.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 v17.0.1
* 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.
*/

View File

@ -1 +0,0 @@
!function(e){function r(r){for(var n,a,l=r[0],f=r[1],i=r[2],p=0,s=[];p<l.length;p++)a=l[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(c&&c(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var f=t[l];0!==o[f]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="./";var l=this["webpackJsonpclash-dashboard"]=this["webpackJsonpclash-dashboard"]||[],f=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var c=f;t()}([]);

View File

@ -22,7 +22,7 @@ urlencode() {
} }
GROUP_STATE() { GROUP_STATE() {
echo "$(curl -m 5 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies/"$1" 2>/dev/null |sed -n '$p' 2>/dev/null)" echo "$(curl -m 2 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies/"$1" 2>/dev/null |sed -n '$p' 2>/dev/null)"
} }
restore_history() { restore_history() {
@ -36,11 +36,11 @@ restore_history() {
GROUP_STATE_NUM=$(expr "$GROUP_STATE_NUM" + 1) GROUP_STATE_NUM=$(expr "$GROUP_STATE_NUM" + 1)
GROUP_STATE=$(GROUP_STATE "$GROUP_NAME") GROUP_STATE=$(GROUP_STATE "$GROUP_NAME")
done done
curl -m 5 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GROUP_NAME" >> "$LOG_FILE" curl -m 2 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GROUP_NAME" >> "$LOG_FILE"
} }
close_all_conection() { close_all_conection() {
curl -m 5 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X DELETE http://"$LAN_IP":"$PORT"/connections >/dev/null 2>&1 curl -m 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X DELETE http://"$LAN_IP":"$PORT"/connections >/dev/null 2>&1
} }
if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then

View File

@ -10,6 +10,7 @@ dns_port=$(uci get openclash.config.dns_port 2>/dev/null)
disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null) disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null)
en_mode=$(uci get openclash.config.en_mode 2>/dev/null) en_mode=$(uci get openclash.config.en_mode 2>/dev/null)
cfg_update_interval=$(uci get openclash.config.config_update_interval 2>/dev/null) cfg_update_interval=$(uci get openclash.config.config_update_interval 2>/dev/null)
log_size=$(uci get openclash.config.log_size 2>/dev/null || 1024)
CRASH_NUM=0 CRASH_NUM=0
CFG_UPDATE_INT=0 CFG_UPDATE_INT=0
@ -77,8 +78,8 @@ fi
## Log File Size Manage: ## Log File Size Manage:
LOGSIZE=`ls -l /tmp/openclash.log |awk '{print int($5/1024)}'` LOGSIZE=`ls -l /tmp/openclash.log |awk '{print int($5/1024)}'`
if [ "$LOGSIZE" -gt 90 ]; then if [ "$LOGSIZE" -gt "$log_size" ]; then
echo "$LOGTIME Watchdog: Size Limit, Clean Up All Log Records." > $LOG_FILE echo "$LOGTIME Watchdog: Log Size Limit, Clean Up All Log Records." > $LOG_FILE
fi fi
## 端口转发重启 ## 端口转发重启

View File

@ -89,6 +89,14 @@ hosts:
# '*.clash.dev': 127.0.0.1 # '*.clash.dev': 127.0.0.1
# '.dev': 127.0.0.1 # '.dev': 127.0.0.1
# 'alpha.clash.dev': '::1' # 'alpha.clash.dev': '::1'
profile:
# store the `select` results in $HOME/.config/clash/.cache
# when two different configurations have groups with the same name, the selected values are shared
# set false if you don't want this behavior
store-selected: true
# open tracing exporter API
tracing: true
# DNS server settings # DNS server settings
# This section is optional. When not present, the DNS server will be disabled. # This section is optional. When not present, the DNS server will be disabled.

File diff suppressed because one or more lines are too long

View File

@ -5,38 +5,38 @@ LOG_FILE="/tmp/openclash.log"
START_LOG="/tmp/openclash_start.log" START_LOG="/tmp/openclash_start.log"
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S") LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
if [ "$14" != "1" ]; then if [ "${14}" != "1" ]; then
controller_address="0.0.0.0" controller_address="0.0.0.0"
bind_address="*" bind_address="*"
else else
controller_address=$11 controller_address=${11}
bind_address=$11 bind_address=${11}
fi fi
if [ -n "$(ruby_read "$7" "['tun']")" ]; then if [ -n "$(ruby_read "$7" "['tun']")" ]; then
if [ -n "$(ruby_read "$7" "['tun']['device-url']")" ]; then if [ -n "$(ruby_read "$7" "['tun']['device-url']")" ]; then
if [ "$15" -eq 1 ] || [ "$15" -eq 3 ]; then if [ "${15}" -eq 1 ] || [ "${15}" -eq 3 ]; then
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
fi fi
else else
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
fi fi
else else
if [ -n "$15" ]; then if [ -n "${15}" ]; then
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
fi fi
fi fi
if [ -z "$15" ]; then if [ -z "${15}" ]; then
en_mode_tun=0 en_mode_tun=0
else else
en_mode_tun=$15 en_mode_tun=${15}
fi fi
if [ -z "$16" ]; then if [ -z "${16}" ]; then
stack_type=system stack_type=system
else else
stack_type=$16 stack_type=${16}
fi fi
if [ "$(ruby_read "$7" "['external-controller']")" != "$controller_address:$5" ]; then if [ "$(ruby_read "$7" "['external-controller']")" != "$controller_address:$5" ]; then
@ -62,20 +62,20 @@ ruby -ryaml -E UTF-8 -e "
begin begin
Value = YAML.load_file('$7'); Value = YAML.load_file('$7');
rescue Exception => e rescue Exception => e
puts '${LOGTIME} Load File Error: ' + e.message puts '${LOGTIME} Load File Error: ' + e.message
end end
begin begin
Value['redir-port']=$6; Value['redir-port']=$6;
Value['port']=$9; Value['port']=$9;
Value['socks-port']=$10; Value['socks-port']=${10};
Value['mixed-port']=$19; Value['mixed-port']=${19};
Value['mode']='$13'; Value['mode']='${13}';
Value['log-level']='$12'; Value['log-level']='${12}';
Value['allow-lan']=true; Value['allow-lan']=true;
Value['external-controller']='$controller_address:$5'; Value['external-controller']='$controller_address:$5';
Value['secret']='$4'; Value['secret']='$4';
Value['bind-address']='$bind_address'; Value['bind-address']='$bind_address';
Value['external-ui']='/usr/share/openclash/dashboard'; Value['external-ui']='/usr/share/openclash/dashboard';
if not Value.key?('dns') then if not Value.key?('dns') then
Value_1={'dns'=>{'enable'=>true}} Value_1={'dns'=>{'enable'=>true}}
Value['dns']=Value_1['dns'] Value['dns']=Value_1['dns']
@ -96,9 +96,9 @@ else
Value['dns'].delete('fake-ip-range') Value['dns'].delete('fake-ip-range')
end; end;
if $8 != 1 then if $8 != 1 then
Value['dns']['listen']='127.0.0.1:$17' Value['dns']['listen']='127.0.0.1:${17}'
else else
Value['dns']['listen']='0.0.0.0:$17' Value['dns']['listen']='0.0.0.0:${17}'
end; end;
Value_2={'tun'=>{'enable'=>true}}; Value_2={'tun'=>{'enable'=>true}};
if $en_mode_tun == 1 or $en_mode_tun == 3 then if $en_mode_tun == 1 or $en_mode_tun == 3 then
@ -115,6 +115,12 @@ elsif $en_mode_tun == 0
Value['tun'].clear Value['tun'].clear
end end
end; end;
if not Value.key?('profile') then
Value_3={'profile'=>{'store-selected'=>true}}
Value['profile']=Value_3['profile']
else
Value['profile']['store-selected']=true
end;
rescue Exception => e rescue Exception => e
puts '${LOGTIME} Set General Error: ' + e.message puts '${LOGTIME} Set General Error: ' + e.message
end end

View File

@ -38,7 +38,7 @@
if (config && config.strict && (dir > 0) != (pos == where.ch)) return null; if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style, config);
if (found == null) return null; if (found == null) return null;
return {from: Pos(where.line, pos), to: found && found.pos, return {from: Pos(where.line, pos), to: found && found.pos,
match: found && found.ch == match.charAt(0), forward: dir > 0}; match: found && found.ch == match.charAt(0), forward: dir > 0};
@ -67,7 +67,8 @@
if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
for (; pos != end; pos += dir) { for (; pos != end; pos += dir) {
var ch = line.charAt(pos); var ch = line.charAt(pos);
if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { if (re.test(ch) && (style === undefined ||
(cm.getTokenTypeAt(Pos(lineNo, pos + 1)) || "") == (style || ""))) {
var match = matching[ch]; var match = matching[ch];
if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch); if (match && (match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
@ -80,11 +81,12 @@
function matchBrackets(cm, autoclear, config) { function matchBrackets(cm, autoclear, config) {
// Disable brace matching in long lines, since it'll cause hugely slow updates // Disable brace matching in long lines, since it'll cause hugely slow updates
var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000; var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000,
highlightNonMatching = config && config.highlightNonMatching;
var marks = [], ranges = cm.listSelections(); var marks = [], ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++) { for (var i = 0; i < ranges.length; i++) {
var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config); var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { if (match && (match.match || highlightNonMatching !== false) && cm.getLine(match.from.line).length <= maxHighlightLen) {
var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
@ -94,7 +96,7 @@
if (marks.length) { if (marks.length) {
// Kludge to work around the IE bug from issue #1193, where text // Kludge to work around the IE bug from issue #1193, where text
// input stops going to the textare whever this fires. // input stops going to the textarea whenever this fires.
if (ie_lt8 && cm.state.focused) cm.focus(); if (ie_lt8 && cm.state.focused) cm.focus();
var clear = function() { var clear = function() {
@ -117,25 +119,25 @@
}); });
} }
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { function clearHighlighted(cm) {
function clear(cm) { if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) { cm.state.matchBrackets.currentlyHighlighted();
cm.state.matchBrackets.currentlyHighlighted(); cm.state.matchBrackets.currentlyHighlighted = null;
cm.state.matchBrackets.currentlyHighlighted = null;
}
} }
}
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) { if (old && old != CodeMirror.Init) {
cm.off("cursorActivity", doMatchBrackets); cm.off("cursorActivity", doMatchBrackets);
cm.off("focus", doMatchBrackets) cm.off("focus", doMatchBrackets)
cm.off("blur", clear) cm.off("blur", clearHighlighted)
clear(cm); clearHighlighted(cm);
} }
if (val) { if (val) {
cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.state.matchBrackets = typeof val == "object" ? val : {};
cm.on("cursorActivity", doMatchBrackets); cm.on("cursorActivity", doMatchBrackets);
cm.on("focus", doMatchBrackets) cm.on("focus", doMatchBrackets)
cm.on("blur", clear) cm.on("blur", clearHighlighted)
} }
}); });

File diff suppressed because one or more lines are too long

View File

@ -170,6 +170,10 @@
var anns = annotations[line]; var anns = annotations[line];
if (!anns) continue; if (!anns) continue;
// filter out duplicate messages
var message = [];
anns = anns.filter(function(item) { return message.indexOf(item.message) > -1 ? false : message.push(item.message) });
var maxSeverity = null; var maxSeverity = null;
var tipLabel = state.hasGutter && document.createDocumentFragment(); var tipLabel = state.hasGutter && document.createDocumentFragment();
@ -187,9 +191,9 @@
__annotation: ann __annotation: ann
})); }));
} }
// use original annotations[line] to show multiple messages
if (state.hasGutter) if (state.hasGutter)
cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, anns.length > 1, cm.setGutterMarker(line, GUTTER_ID, makeMarker(cm, tipLabel, maxSeverity, annotations[line].length > 1,
state.options.tooltips)); state.options.tooltips));
} }
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm); if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);

View File

@ -19,7 +19,7 @@
} }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */ background-color: transparent; /* The little square between H and V scrollbars */
} }
/* GUTTER */ /* GUTTER */

View File

@ -38,9 +38,9 @@ CodeMirror.defineMode("yaml", function() {
state.pair = false; state.pair = false;
state.pairStart = false; state.pairStart = false;
/* document start */ /* document start */
if(stream.match(/---/)) { return "def"; } if(stream.match('---')) { return "def"; }
/* document end */ /* document end */
if (stream.match(/\.\.\./)) { return "def"; } if (stream.match('...')) { return "def"; }
/* array list item */ /* array list item */
if (stream.match(/\s*-\s+/)) { return 'meta'; } if (stream.match(/\s*-\s+/)) { return 'meta'; }
} }
@ -57,12 +57,12 @@ CodeMirror.defineMode("yaml", function() {
return 'meta'; return 'meta';
} }
/* list seperator */ /* list separator */
if (state.inlineList > 0 && !esc && ch == ',') { if (state.inlineList > 0 && !esc && ch == ',') {
stream.next(); stream.next();
return 'meta'; return 'meta';
} }
/* pairs seperator */ /* pairs separator */
if (state.inlinePairs > 0 && !esc && ch == ',') { if (state.inlinePairs > 0 && !esc && ch == ',') {
state.keyCol = 0; state.keyCol = 0;
state.pair = false; state.pair = false;