OpenClash: bump to 0.40.14-beta

This commit is contained in:
CN_SZTL 2020-10-29 22:38:27 +08:00
parent 76a502660c
commit 7eec1799a6
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
13 changed files with 124 additions and 103 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.40.13 PKG_VERSION:=0.40.14
PKG_RELEASE:=beta PKG_RELEASE:=beta
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash> PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>

View File

@ -1085,6 +1085,19 @@ do_run_file()
} }
#绑定interface防止回环
check_interface_name()
{
interface_name=$(ip route |grep "default" |awk '{print $5}' 2>/dev/null)
if [ -z "$(grep "^interface-name: $interface_name" "$CONFIG_FILE" 2>/dev/null)" ] && [ -n "$interface_name" ]; then
if [ ! -z "$(grep "^ \{0,\}interface-name:" "$CONFIG_FILE" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}interface-name:/c\interface-name: ${interface_name}" "$CONFIG_FILE" 2>/dev/null
else
sed -i "/^redir-port:/a\interface-name: ${interface_name}" "$CONFIG_FILE" 2>/dev/null
fi
fi
}
start_run_core() start_run_core()
{ {
echo "$core_start_log" >$START_LOG echo "$core_start_log" >$START_LOG
@ -1092,6 +1105,7 @@ start_run_core()
ulimit -SHn 65535 2>/dev/null ulimit -SHn 65535 2>/dev/null
ulimit -v unlimited 2>/dev/null ulimit -v unlimited 2>/dev/null
modprobe tun >/dev/null 2>&1 modprobe tun >/dev/null 2>&1
check_interface_name
config_reload=$(uci get openclash.config.config_reload 2>/dev/null) config_reload=$(uci get openclash.config.config_reload 2>/dev/null)
if [ -n "$(pidof clash)" ] && [ "$core_type" != "Tun" ] && [ "$config_reload" != "0" ]; then if [ -n "$(pidof clash)" ] && [ "$core_type" != "Tun" ] && [ "$config_reload" != "0" ]; then
curl -s --connect-timeout 5 -m 5 -H 'Content-Type: application/json' -H "Authorization: Bearer ${da_password}" -XPUT http://"$lan_ip":"$cn_port"/configs -d "{\"path\": \"$CONFIG_FILE\"}" 2>/dev/null curl -s --connect-timeout 5 -m 5 -H 'Content-Type: application/json' -H "Authorization: Bearer ${da_password}" -XPUT http://"$lan_ip":"$cn_port"/configs -d "{\"path\": \"$CONFIG_FILE\"}" 2>/dev/null
@ -1193,6 +1207,7 @@ raw_config_start()
cn_port=$(grep "^ \{0,\}external-controller:" "$CONFIG_FILE" |awk -F ':' '{print $3}' |awk -F '#' '{print $1}' |tr -cd "[0-9]" 2>/dev/null) cn_port=$(grep "^ \{0,\}external-controller:" "$CONFIG_FILE" |awk -F ':' '{print $3}' |awk -F '#' '{print $1}' |tr -cd "[0-9]" 2>/dev/null)
uci set openclash.config.dashboard_password="$cn_port" 2>/dev/null uci set openclash.config.dashboard_password="$cn_port" 2>/dev/null
uci set openclash.config.proxy_port="$proxy_port"
uci set openclash.config.restricted_mode=1 uci set openclash.config.restricted_mode=1
uci commit openclash uci commit openclash

View File

@ -73,10 +73,16 @@ music.migu.cn
#QQ快捷登录 #QQ快捷登录
localhost.ptlogin2.qq.com localhost.ptlogin2.qq.com
#Nintendo Switch #Nintendo Switch
*.*.*.*.srv.nintendo.net +.srv.nintendo.net
#Sony PlayStation #Sony PlayStation
*.*.*.stun.playstation.net +.stun.playstation.net
#Microsoft Xbox #Microsoft Xbox
xbox.*.microsoft.com xbox.*.microsoft.com
*.*.*.xboxlive.com +.xboxlive.com
proxy.golang.org proxy.golang.org
stun.*.*
stun.*.*.*
#Linksys Router
heartbeat.belkin.com
*.linksys.com
*.linksyssmartwifi.com

View File

@ -1,19 +1,19 @@
{ {
"files": { "files": {
"main.css": "./static/css/main.83e4b341.chunk.css", "main.css": "./static/css/main.83e4b341.chunk.css",
"main.js": "./static/js/main.33688145.chunk.js", "main.js": "./static/js/main.3ba71f82.chunk.js",
"runtime-main.js": "./static/js/runtime-main.fefd5bb9.js", "runtime-main.js": "./static/js/runtime-main.fefd5bb9.js",
"static/js/2.4c19c7e9.chunk.js": "./static/js/2.4c19c7e9.chunk.js", "static/js/2.6366a4a0.chunk.js": "./static/js/2.6366a4a0.chunk.js",
"index.html": "./index.html", "index.html": "./index.html",
"service-worker.js": "./service-worker.js", "service-worker.js": "./service-worker.js",
"static/js/2.4c19c7e9.chunk.js.LICENSE.txt": "./static/js/2.4c19c7e9.chunk.js.LICENSE.txt", "static/js/2.6366a4a0.chunk.js.LICENSE.txt": "./static/js/2.6366a4a0.chunk.js.LICENSE.txt",
"static/media/logo.45983944.png": "./static/media/logo.45983944.png", "static/media/logo.45983944.png": "./static/media/logo.45983944.png",
"workbox-8a532145.js": "./workbox-8a532145.js" "workbox-8a532145.js": "./workbox-8a532145.js"
}, },
"entrypoints": [ "entrypoints": [
"static/js/runtime-main.fefd5bb9.js", "static/js/runtime-main.fefd5bb9.js",
"static/js/2.4c19c7e9.chunk.js", "static/js/2.6366a4a0.chunk.js",
"static/css/main.83e4b341.chunk.css", "static/css/main.83e4b341.chunk.css",
"static/js/main.33688145.chunk.js" "static/js/main.3ba71f82.chunk.js"
] ]
} }

View File

@ -1 +1 @@
<!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.83e4b341.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.4c19c7e9.chunk.js"></script><script src="./static/js/main.33688145.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><link href="./static/css/main.83e4b341.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.6366a4a0.chunk.js"></script><script src="./static/js/main.3ba71f82.chunk.js"></script></body></html>

View File

@ -1 +1 @@
if(!self.define){const e=e=>{"require"!==e&&(e+=".js");let s=Promise.resolve();return r[e]||(s=new Promise(async s=>{if("document"in self){const r=document.createElement("script");r.src=e,document.head.appendChild(r),r.onload=s}else importScripts(e),s()})),s.then(()=>{if(!r[e])throw new Error(`Module ${e} didnt register its module`);return r[e]})},s=(s,r)=>{Promise.all(s.map(e)).then(e=>r(1===e.length?e[0]:e))},r={require:Promise.resolve(s)};self.define=(s,i,c)=>{r[s]||(r[s]=Promise.resolve().then(()=>{let r={};const t={uri:location.origin+s.slice(1)};return Promise.all(i.map(s=>{switch(s){case"exports":return r;case"module":return t;default:return e(s)}})).then(e=>{const s=c(...e);return r.default||(r.default=s),r})}))}}define("./service-worker.js",["./workbox-8a532145"],(function(e){"use strict";self.addEventListener("message",e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}),e.clientsClaim(),e.precacheAndRoute([{url:"./index.html",revision:"b1a27ccef352baebb9667369555f9309"},{url:"./static/css/main.83e4b341.chunk.css",revision:"5a48466e5ff2a8ceec3348c3c498c260"},{url:"./static/js/2.4c19c7e9.chunk.js",revision:"d46b87667ddd715dd648d1ef8779c0b7"},{url:"./static/js/2.4c19c7e9.chunk.js.LICENSE.txt",revision:"176c1a1a28b19c611d9701905d8d60b7"},{url:"./static/js/main.33688145.chunk.js",revision:"62d6fab15c25a50205f635111e4e9e01"},{url:"./static/js/runtime-main.fefd5bb9.js",revision:"98f4f314ef9abb714a6c74c41e1e5a04"},{url:"./static/media/logo.45983944.png",revision:"198a55c9efe85ab0145d4402c07cfe65"}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("./index.html"),{denylist:[/^\/_/,/\/[^/?]+\.[^/]+$/]}))})); if(!self.define){const e=e=>{"require"!==e&&(e+=".js");let s=Promise.resolve();return r[e]||(s=new Promise(async s=>{if("document"in self){const r=document.createElement("script");r.src=e,document.head.appendChild(r),r.onload=s}else importScripts(e),s()})),s.then(()=>{if(!r[e])throw new Error(`Module ${e} didnt register its module`);return r[e]})},s=(s,r)=>{Promise.all(s.map(e)).then(e=>r(1===e.length?e[0]:e))},r={require:Promise.resolve(s)};self.define=(s,i,t)=>{r[s]||(r[s]=Promise.resolve().then(()=>{let r={};const c={uri:location.origin+s.slice(1)};return Promise.all(i.map(s=>{switch(s){case"exports":return r;case"module":return c;default:return e(s)}})).then(e=>{const s=t(...e);return r.default||(r.default=s),r})}))}}define("./service-worker.js",["./workbox-8a532145"],(function(e){"use strict";self.addEventListener("message",e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}),e.clientsClaim(),e.precacheAndRoute([{url:"./index.html",revision:"ff336a0edf18fc90c7f03fb0e43250a0"},{url:"./static/css/main.83e4b341.chunk.css",revision:"5a48466e5ff2a8ceec3348c3c498c260"},{url:"./static/js/2.6366a4a0.chunk.js",revision:"7a8970333d728cf369978e1fa658787e"},{url:"./static/js/2.6366a4a0.chunk.js.LICENSE.txt",revision:"6557abd439259b9580e2e2d5633cdacb"},{url:"./static/js/main.3ba71f82.chunk.js",revision:"2c4d6d7f7a1d7c843c445be62f92109f"},{url:"./static/js/runtime-main.fefd5bb9.js",revision:"98f4f314ef9abb714a6c74c41e1e5a04"},{url:"./static/media/logo.45983944.png",revision:"198a55c9efe85ab0145d4402c07cfe65"}],{}),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("./index.html"),{denylist:[/^\/_/,/\/[^/?]+\.[^/]+$/]}))}));

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@ object-assign
http://jedwatson.github.io/classnames http://jedwatson.github.io/classnames
*/ */
/** @license React v0.19.1 /** @license React v0.20.1
* scheduler.production.min.js * scheduler.production.min.js
* *
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
@ -28,7 +28,7 @@ object-assign
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
/** @license React v16.13.1 /** @license React v17.0.1
* react-dom.production.min.js * react-dom.production.min.js
* *
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.
@ -37,7 +37,7 @@ object-assign
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
/** @license React v16.13.1 /** @license React v17.0.1
* react.production.min.js * react.production.min.js
* *
* Copyright (c) Facebook, Inc. and its affiliates. * Copyright (c) Facebook, Inc. and its affiliates.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,20 +17,20 @@ START_LOG="/tmp/openclash_start.log"
fi fi
fi fi
if [ -z "$(grep "^ enhanced-mode: $2" "$7")" ]; then if [ -z "$(grep "^ enhanced-mode: $2" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}enhanced-mode:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}enhanced-mode:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}enhanced-mode:/c\ enhanced-mode: ${2}" "$7" sed -i "/^ \{0,\}enhanced-mode:/c\ enhanced-mode: ${2}" "$7" 2>/dev/null
else else
sed -i "/^dns:/a\ enhanced-mode: ${2}" "$7" sed -i "/^dns:/a\ enhanced-mode: ${2}" "$7" 2>/dev/null
fi fi
fi fi
if [ "$2" = "fake-ip" ]; then if [ "$2" = "fake-ip" ]; then
if [ -z "$(grep "^ \{0,\}fake-ip-range: 198.18.0.1/16" "$7")" ]; then if [ -z "$(grep "^ \{0,\}fake-ip-range: 198.18.0.1/16" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}fake-ip-range:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}fake-ip-range:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}fake-ip-range:/c\ fake-ip-range: 198.18.0.1/16" "$7" sed -i "/^ \{0,\}fake-ip-range:/c\ fake-ip-range: 198.18.0.1/16" "$7" 2>/dev/null
else else
sed -i "/^ \{0,\}enhanced-mode:/a\ fake-ip-range: 198.18.0.1/16" "$7" sed -i "/^ \{0,\}enhanced-mode:/a\ fake-ip-range: 198.18.0.1/16" "$7" 2>/dev/null
fi fi
fi fi
else else
@ -40,43 +40,43 @@ START_LOG="/tmp/openclash_start.log"
sed -i '/##Custom DNS##/d' "$7" 2>/dev/null sed -i '/##Custom DNS##/d' "$7" 2>/dev/null
if [ -z "$(grep "^redir-port: $6" "$7")" ]; then if [ -z "$(grep "^redir-port: $6" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}redir-port:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}redir-port:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}redir-port:/c\redir-port: ${6}" "$7" sed -i "/^ \{0,\}redir-port:/c\redir-port: ${6}" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\redir-port: ${6}" "$7" sed -i "/^dns:/i\redir-port: ${6}" "$7" 2>/dev/null
fi fi
fi fi
if [ -z "$(grep "^port: $9" "$7")" ]; then if [ -z "$(grep "^port: $9" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}port:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}port:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}port:/c\port: ${9}" "$7" sed -i "/^ \{0,\}port:/c\port: ${9}" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\port: ${9}" "$7" sed -i "/^dns:/i\port: ${9}" "$7" 2>/dev/null
fi fi
fi fi
if [ -z "$(grep "^socks-port: $10" "$7")" ]; then if [ -z "$(grep "^socks-port: $10" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}socks-port:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}socks-port:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}socks-port:/c\socks-port: ${10}" "$7" sed -i "/^ \{0,\}socks-port:/c\socks-port: ${10}" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\socks-port: ${10}" "$7" sed -i "/^dns:/i\socks-port: ${10}" "$7" 2>/dev/null
fi fi
fi fi
if [ -z "$(grep "^mode: $13" "$7")" ]; then if [ -z "$(grep "^mode: $13" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}mode:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}mode:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}mode:/c\mode: ${13}" "$7" sed -i "/^ \{0,\}mode:/c\mode: ${13}" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\mode: ${13}" "$7" sed -i "/^dns:/i\mode: ${13}" "$7" 2>/dev/null
fi fi
fi fi
if [ -z "$(grep "^log-level: $12" "$7")" ]; then if [ -z "$(grep "^log-level: $12" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}log-level:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}log-level:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}log-level:/c\log-level: ${12}" "$7" sed -i "/^ \{0,\}log-level:/c\log-level: ${12}" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\log-level: ${12}" "$7" sed -i "/^dns:/i\log-level: ${12}" "$7" 2>/dev/null
fi fi
fi fi
@ -94,58 +94,58 @@ START_LOG="/tmp/openclash_start.log"
sleep 3 sleep 3
fi fi
if [ -z "$(grep "^external-controller: $controller_address:$5" "$7")" ]; then if [ -z "$(grep "^external-controller: $controller_address:$5" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}external-controller:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}external-controller:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}external-controller:/c\external-controller: ${controller_address}:${5}" "$7" sed -i "/^ \{0,\}external-controller:/c\external-controller: ${controller_address}:${5}" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\external-controller: ${controller_address}:${5}" "$7" sed -i "/^dns:/i\external-controller: ${controller_address}:${5}" "$7" 2>/dev/null
fi fi
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
fi fi
if [ -z "$(grep "^secret: \"$4\"" "$7")" ]; then if [ -z "$(grep "^secret: \"$4\"" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}secret:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}secret:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}secret:/c\secret: \"${4}\"" "$7" sed -i "/^ \{0,\}secret:/c\secret: \"${4}\"" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\secret: \"${4}\"" "$7" sed -i "/^dns:/i\secret: \"${4}\"" "$7" 2>/dev/null
fi fi
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
fi fi
if [ -z "$(grep "^ \{0,\}device-url:" "$7")" ] && [ "$15" -eq 2 ]; then if [ -z "$(grep "^ \{0,\}device-url:" "$7" 2>/dev/null)" ] && [ "$15" -eq 2 ]; then
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
elif [ -z "$(grep "^ \{0,\}tun:" "$7")" ] && [ -n "$15" ]; then elif [ -z "$(grep "^ \{0,\}tun:" "$7" 2>/dev/null)" ] && [ -n "$15" ]; then
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
elif [ -n "$(grep "^ \{0,\}tun:" "$7")" ] && [ -z "$15" ]; then elif [ -n "$(grep "^ \{0,\}tun:" "$7" 2>/dev/null)" ] && [ -z "$15" ]; then
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
elif [ -n "$(grep "^ \{0,\}device-url:" "$7")" ] && [ "$15" -eq 1 ]; then elif [ -n "$(grep "^ \{0,\}device-url:" "$7" 2>/dev/null)" ] && [ "$15" -eq 1 ]; then
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
elif [ -n "$(grep "^ \{0,\}device-url:" "$7")" ] && [ "$15" -eq 3 ]; then elif [ -n "$(grep "^ \{0,\}device-url:" "$7" 2>/dev/null)" ] && [ "$15" -eq 3 ]; then
uci set openclash.config.config_reload=0 uci set openclash.config.config_reload=0
fi fi
uci commit openclash uci commit openclash
if [ -z "$(grep "^ enable: true" "$7")" ]; then if [ -z "$(grep "^ enable: true" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}enable:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}enable:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}enable:/c\ enable: true" "$7" sed -i "/^ \{0,\}enable:/c\ enable: true" "$7" 2>/dev/null
else else
sed -i "/^dns:/a\ enable: true" "$7" sed -i "/^dns:/a\ enable: true" "$7" 2>/dev/null
fi fi
fi fi
if [ -z "$(grep "^allow-lan: true" "$7")" ]; then if [ -z "$(grep "^allow-lan: true" "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}allow-lan:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}allow-lan:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}allow-lan:/c\allow-lan: true" "$7" sed -i "/^ \{0,\}allow-lan:/c\allow-lan: true" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\allow-lan: true" "$7" sed -i "/^dns:/i\allow-lan: true" "$7" 2>/dev/null
fi fi
fi fi
sed -i '/bind-address:/d' "$7" 2>/dev/null sed -i '/bind-address:/d' "$7" 2>/dev/null
sed -i "/^allow-lan:/a\bind-address: \"${bind_address}\"" "$7" sed -i "/^allow-lan:/a\bind-address: \"${bind_address}\"" "$7" 2>/dev/null
if [ -n "$(grep "^ \{0,\}listen:" "$7")" ]; then if [ -n "$(grep "^ \{0,\}listen:" "$7" 2>/dev/null)" ]; then
if [ "$8" != "1" ]; then if [ "$8" != "1" ]; then
sed -i "/^ \{0,\}listen:/c\ listen: 127.0.0.1:${17}" "$7" 2>/dev/null sed -i "/^ \{0,\}listen:/c\ listen: 127.0.0.1:${17}" "$7" 2>/dev/null
else else
@ -159,60 +159,60 @@ START_LOG="/tmp/openclash_start.log"
fi fi
fi 2>/dev/null fi 2>/dev/null
if [ -z "$(grep '^external-ui: "/usr/share/openclash/dashboard"' "$7")" ]; then if [ -z "$(grep '^external-ui: "/usr/share/openclash/dashboard"' "$7" 2>/dev/null)" ]; then
if [ ! -z "$(grep "^ \{0,\}external-ui:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}external-ui:" "$7" 2>/dev/null)" ]; then
sed -i '/^ \{0,\}external-ui:/c\external-ui: "/usr/share/openclash/dashboard"' "$7" sed -i '/^ \{0,\}external-ui:/c\external-ui: "/usr/share/openclash/dashboard"' "$7" 2>/dev/null
else else
sed -i '/^dns:/i\external-ui: "/usr/share/openclash/dashboard"' "$7" sed -i '/^dns:/i\external-ui: "/usr/share/openclash/dashboard"' "$7" 2>/dev/null
fi fi
fi fi
if [ "$8" -eq 1 ]; then if [ "$8" -eq 1 ]; then
sed -i '/^ \{0,\}ipv6:/d' "$7" 2>/dev/null sed -i '/^ \{0,\}ipv6:/d' "$7" 2>/dev/null
sed -i "/^ \{0,\}enable: true/a\ ipv6: true" "$7" sed -i "/^ \{0,\}enable: true/a\ ipv6: true" "$7" 2>/dev/null
sed -i "/^ \{0,\}mode:/i\ipv6: true" "$7" sed -i "/^ \{0,\}mode:/i\ipv6: true" "$7" 2>/dev/null
else else
sed -i '/^ \{0,\}ipv6:/d' "$7" 2>/dev/null sed -i '/^ \{0,\}ipv6:/d' "$7" 2>/dev/null 2>/dev/null
sed -i "/^ \{0,\}enable: true/a\ ipv6: false" "$7" sed -i "/^ \{0,\}enable: true/a\ ipv6: false" "$7" 2>/dev/null
sed -i "/^ \{0,\}mode:/i\ipv6: false" "$7" sed -i "/^ \{0,\}mode:/i\ipv6: false" "$7" 2>/dev/null
fi fi
#TUN #TUN
if [ "$15" -eq 1 ] || [ "$15" -eq 3 ]; then if [ "$15" -eq 1 ] || [ "$15" -eq 3 ]; then
sed -i "/^dns:/i\tun:" "$7" sed -i "/^dns:/i\tun:" "$7" 2>/dev/null
sed -i "/^dns:/i\ enable: true" "$7" sed -i "/^dns:/i\ enable: true" "$7" 2>/dev/null
if [ -n "$16" ]; then if [ -n "$16" ]; then
sed -i "/^dns:/i\ stack: ${16}" "$7" sed -i "/^dns:/i\ stack: ${16}" "$7" 2>/dev/null
else else
sed -i "/^dns:/i\ stack: system" "$7" sed -i "/^dns:/i\ stack: system" "$7" 2>/dev/null
fi fi
sed -i "/^dns:/i\ dns-hijack:" "$7" sed -i "/^dns:/i\ dns-hijack:" "$7" 2>/dev/null
# sed -i "/^dns:/i\ - 8.8.8.8:53" "$7" # sed -i "/^dns:/i\ - 8.8.8.8:53" "$7"
sed -i "/^dns:/i\ - tcp://8.8.8.8:53" "$7" sed -i "/^dns:/i\ - tcp://8.8.8.8:53" "$7" 2>/dev/null
# sed -i "/^dns:/i\ - 8.8.4.4:53" "$7" # sed -i "/^dns:/i\ - 8.8.4.4:53" "$7"
sed -i "/^dns:/i\ - tcp://8.8.4.4:53" "$7" sed -i "/^dns:/i\ - tcp://8.8.4.4:53" "$7" 2>/dev/null
elif [ "$15" -eq 2 ]; then elif [ "$15" -eq 2 ]; then
sed -i "/^dns:/i\tun:" "$7" sed -i "/^dns:/i\tun:" "$7" 2>/dev/null
sed -i "/^dns:/i\ enable: true" "$7" sed -i "/^dns:/i\ enable: true" "$7" 2>/dev/null
sed -i "/^dns:/i\ device-url: dev://clash0" "$7" sed -i "/^dns:/i\ device-url: dev://clash0" "$7" 2>/dev/null
sed -i "/^dns:/i\ dns-listen: 0.0.0.0:53" "$7" sed -i "/^dns:/i\ dns-listen: 0.0.0.0:53" "$7" 2>/dev/null
fi fi
#添加自定义Hosts设置 #添加自定义Hosts设置
if [ "$2" = "redir-host" ]; then if [ "$2" = "redir-host" ]; then
if [ -z "$(grep "^ \{0,\}hosts:" $7)" ]; then if [ -z "$(grep "^ \{0,\}hosts:" "$7" 2>/dev/null)" ]; then
sed -i '/^dns:/i\hosts:' "$7" 2>/dev/null sed -i '/^dns:/i\hosts:' "$7" 2>/dev/null
else else
if [ ! -z "$(grep "^ \{1,\}hosts:" $7)" ]; then if [ ! -z "$(grep "^ \{1,\}hosts:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}hosts:/c\hosts:" "$7" sed -i "/^ \{0,\}hosts:/c\hosts:" "$7" 2>/dev/null
fi fi
fi fi
if [ -z "$(grep "^ \{0,\}use-hosts:" $7)" ]; then if [ -z "$(grep "^ \{0,\}use-hosts:" "$7" 2>/dev/null)" ]; then
sed -i "/^dns:/a\ use-hosts: true" "$7" sed -i "/^dns:/a\ use-hosts: true" "$7" 2>/dev/null
else else
if [ ! -z "$(grep "^ \{0,\}use-hosts:" $7)" ]; then if [ ! -z "$(grep "^ \{0,\}use-hosts:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}use-hosts:/c\ use-hosts: true" "$7" sed -i "/^ \{0,\}use-hosts:/c\ use-hosts: true" "$7" 2>/dev/null
fi fi
fi fi
sed -i '/^hosts:/a\##Custom HOSTS END##' "$7" 2>/dev/null sed -i '/^hosts:/a\##Custom HOSTS END##' "$7" 2>/dev/null
@ -221,15 +221,15 @@ START_LOG="/tmp/openclash_start.log"
sed -i "/^hosts:/,/^dns:/ {s/^ \{0,\}'/ '/}" "$7" 2>/dev/null #修改参数空格 sed -i "/^hosts:/,/^dns:/ {s/^ \{0,\}'/ '/}" "$7" 2>/dev/null #修改参数空格
fi fi
if [ ! -z "$(grep "^ \{0,\}default-nameserver:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}default-nameserver:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}default-nameserver:/c\ default-nameserver:" "$7" sed -i "/^ \{0,\}default-nameserver:/c\ default-nameserver:" "$7" 2>/dev/null
sed -i "/^ \{0,\}default-nameserver:/,/,$/ {s/^ \{0,\}- / - /g}" "$7" 2>/dev/null #修改参数空格 sed -i "/^ \{0,\}default-nameserver:/,/,$/ {s/^ \{0,\}- / - /g}" "$7" 2>/dev/null #修改参数空格
fi fi
#fake-ip-filter #fake-ip-filter
sed -i '/##Custom fake-ip-filter##/,/##Custom fake-ip-filter END##/d' "$7" 2>/dev/null sed -i '/##Custom fake-ip-filter##/,/##Custom fake-ip-filter END##/d' "$7" 2>/dev/null
if [ "$2" = "fake-ip" ]; then if [ "$2" = "fake-ip" ]; then
if [ ! -f "/etc/openclash/fake_filter.list" ] || [ ! -z "$(grep "config servers" /etc/config/openclash)" ]; then if [ ! -f "/etc/openclash/fake_filter.list" ] || [ ! -z "$(grep "config servers" /etc/config/openclash 2>/dev/null)" ]; then
/usr/share/openclash/openclash_fake_filter.sh /usr/share/openclash/openclash_fake_filter.sh
fi fi
if [ -s "/etc/openclash/servers_fake_filter.conf" ]; then if [ -s "/etc/openclash/servers_fake_filter.conf" ]; then
@ -237,8 +237,8 @@ START_LOG="/tmp/openclash_start.log"
ln -s /etc/openclash/servers_fake_filter.conf /tmp/dnsmasq.d/dnsmasq_openclash.conf ln -s /etc/openclash/servers_fake_filter.conf /tmp/dnsmasq.d/dnsmasq_openclash.conf
fi fi
if [ -s "/etc/openclash/fake_filter.list" ]; then if [ -s "/etc/openclash/fake_filter.list" ]; then
if [ ! -z "$(grep "^ \{0,\}fake-ip-filter:" "$7")" ]; then if [ ! -z "$(grep "^ \{0,\}fake-ip-filter:" "$7" 2>/dev/null)" ]; then
sed -i "/^ \{0,\}fake-ip-filter:/c\ fake-ip-filter:" "$7" sed -i "/^ \{0,\}fake-ip-filter:/c\ fake-ip-filter:" "$7" 2>/dev/null
sed -i '/^ \{0,\}fake-ip-filter:/r/etc/openclash/fake_filter.list' "$7" 2>/dev/null sed -i '/^ \{0,\}fake-ip-filter:/r/etc/openclash/fake_filter.list' "$7" 2>/dev/null
sed -i "/^ \{0,\}fake-ip-filter:/,/,$/ {s/^ \{0,\}- / - /g}" "$7" 2>/dev/null #修改参数空格 sed -i "/^ \{0,\}fake-ip-filter:/,/,$/ {s/^ \{0,\}- / - /g}" "$7" 2>/dev/null #修改参数空格
else else