diff --git a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash b/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash index eb14769323..71eecf5da5 100755 --- a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash +++ b/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash @@ -111,25 +111,17 @@ yml_check() #检查关键字避免后续操作出错 #proxies [ -z "$(grep "^Proxy:" "$3")" ] && { - sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$3" 2>/dev/null - sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$3" 2>/dev/null sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$3" 2>/dev/null } [ -z "$(grep "^Proxy:" "$3")" ] && { - sed -i "s/^\'proxies\':/Proxy:/" "$3" 2>/dev/null - sed -i 's/^\"proxies\":/Proxy:/' "$3" 2>/dev/null sed -i "s/^proxies:/Proxy:/" "$3" 2>/dev/null } #proxy-providers [ -z "$(grep "^proxy-provider:" "$3")" ] && { - sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$3" 2>/dev/null - sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$3" 2>/dev/null sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$3" 2>/dev/null } [ -z "$(grep "^proxy-provider:" "$3")" ] && { - sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$3" 2>/dev/null - sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$3" 2>/dev/null sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$3" 2>/dev/null } #proxy-groups @@ -139,27 +131,19 @@ yml_check() sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$3" 2>/dev/null } [ -z "$(grep "^Proxy Group:" "$3")" ] && { - sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$3" 2>/dev/null - sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$3" 2>/dev/null sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$3" 2>/dev/null } #rules [ -z "$(grep "^Rule:" "$3")" ] && { - sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$3" 2>/dev/null - sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$3" 2>/dev/null sed -i "/^ \{1,\}Rule:/c\Rule:" "$3" 2>/dev/null } [ -z "$(grep "^Rule:" "$3")" ] && { - sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$3" 2>/dev/null - sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$3" 2>/dev/null sed -i "/^ \{0,\}rules:/c\Rule:" "$3" 2>/dev/null } #dns [ -z "$(grep "^dns:" "$3")" ] && { - sed -i "/^ \{0,\}\'dns\':/c\dns:" "$3" 2>/dev/null - sed -i '/^ \{0,\}\"dns\":/c\dns:' "$3" 2>/dev/null sed -i "/^ \{1,\}dns:/c\dns:" "$3" 2>/dev/null } diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/default.yaml b/package/ctcgfw/luci-app-openclash/files/etc/openclash/default.yaml index 132ebfc3e3..6173de4aa4 100644 --- a/package/ctcgfw/luci-app-openclash/files/etc/openclash/default.yaml +++ b/package/ctcgfw/luci-app-openclash/files/etc/openclash/default.yaml @@ -97,9 +97,15 @@ Proxy: # 节点设置,此部分与proxy-provider两者不能同时删除 # aes-128-gcm aes-192-gcm aes-256-gcm # aes-128-cfb aes-192-cfb aes-256-cfb # aes-128-ctr aes-192-ctr aes-256-ctr -# rc4-md5 chacha20 chacha20-ietf xchacha20 +# rc4-md5 chacha20-ietf xchacha20 # chacha20-ietf-poly1305 xchacha20-ietf-poly1305 -- { name: "ss1", type: ss, server: server, port: 443, cipher: chacha20-ietf-poly1305, password: "password", udp: true } +- name: "ss1" + type: ss + server: server + port: 443 + cipher: chacha20-ietf-poly1305 + password: "password" + # udp: true # old obfs configuration remove after prerelease - name: "ss2" @@ -111,7 +117,7 @@ Proxy: # 节点设置,此部分与proxy-provider两者不能同时删除 plugin: obfs plugin-opts: mode: tls # or http - # host: bing.com + # host: bing.com - name: "ss3" type: ss @@ -122,42 +128,49 @@ Proxy: # 节点设置,此部分与proxy-provider两者不能同时删除 plugin: v2ray-plugin plugin-opts: mode: websocket # no QUIC now - # tls: true # wss - # skip-cert-verify: true - # host: bing.com - # path: "/" - # headers: - # custom: value + # tls: true # wss + # skip-cert-verify: true + # host: bing.com + # path: "/" + # headers: + # custom: value # vmess # cipher support auto/aes-128-gcm/chacha20-poly1305/none -- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto } -# with tls -- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, tls: true } -# with tls and skip-cert-verify -- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, tls: true, skip-cert-verify: true } -# with ws-path and ws-headers -- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, network: ws, ws-path: /path, ws-headers: { Host: v2ray.com } } -# with ws + tls -- { name: "vmess", type: vmess, server: server, port: 443, uuid: uuid, alterId: 32, cipher: auto, network: ws, ws-path: /path, tls: true } +- name: "vmess" + type: vmess + server: server + port: 443 + uuid: uuid + alterId: 32 + cipher: auto + # udp: true + # tls: true + # skip-cert-verify: true + # network: ws + # ws-path: /path + # ws-headers: + # Host: v2ray.com # socks5 -- { name: "socks", type: socks5, server: server, port: 443 } -# socks5 with authentication -- { name: "socks", type: socks5, server: server, port: 443, username: "username", password: "password" } -# with tls -- { name: "socks", type: socks5, server: server, port: 443, tls: true } -# with tls and skip-cert-verify -- { name: "socks", type: socks5, server: server, port: 443, tls: true, skip-cert-verify: true } - +- name: "socks" + type: socks5 + server: server + port: 443 + # username: username + # password: password + # tls: true + # skip-cert-verify: true + # udp: true # http -- { name: "http", type: http, server: server, port: 443 } -# http with authentication -- { name: "http", type: http, server: server, port: 443, username: "username", password: "password" } -# with tls (https) -- { name: "http", type: http, server: server, port: 443, tls: true } -# with tls (https) and skip-cert-verify -- { name: "http", type: http, server: server, port: 443, tls: true, skip-cert-verify: true } +- name: "http" + type: http + server: server + port: 443 + # username: username + # password: password + # tls: true # https + # skip-cert-verify: true # snell - name: "snell" @@ -165,9 +178,9 @@ Proxy: # 节点设置,此部分与proxy-provider两者不能同时删除 server: server port: 44046 psk: yourpsk - # obfs-opts: - # mode: http # or tls - # host: bing.com + # obfs-opts: + # mode: http # or tls + # host: bing.com # trojan - name: "trojan" @@ -175,12 +188,12 @@ Proxy: # 节点设置,此部分与proxy-provider两者不能同时删除 server: server port: 443 password: yourpsk - # udp: true - # sni: example.com # aka server name - # alpn: - # - h2 - # - http/1.1 - # skip-cert-verify: true + # udp: true + # sni: example.com # aka server name + # alpn: + # - h2 + # - http/1.1 + # skip-cert-verify: true # Openclash 不会对下方策略组设置进行任何更改,请确保设置正确 diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua index 48c9298f09..bbb7f13747 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua +++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/controller/openclash.lua @@ -82,7 +82,8 @@ local function dase() end local function check_lastversion() - return luci.sys.exec("sh /usr/share/openclash/openclash_version.sh && sed -n '/^https:/,$p' /tmp/openclash_last_version 2>/dev/null") + luci.sys.exec("sh /usr/share/openclash/openclash_version.sh 2>/dev/null") + return luci.sys.exec("sed -n '/^https:/,$p' /tmp/openclash_last_version 2>/dev/null") end local function check_currentversion() @@ -128,11 +129,13 @@ local function oplv() end local function opup() - return luci.sys.exec("rm -rf /tmp/*_last_version 2>/dev/null && sh /usr/share/openclash/openclash_version.sh && sh /usr/share/openclash/openclash_update.sh >/dev/null 2>&1 &") + luci.sys.call("rm -rf /tmp/*_last_version 2>/dev/null && sh /usr/share/openclash/openclash_version.sh >/dev/null 2>&1") + return luci.sys.call("sh /usr/share/openclash/openclash_update.sh >/dev/null 2>&1 &") end local function coreup() - return luci.sys.exec("uci set openclash.config.enable=1 && uci commit openclash && rm -rf /tmp/*_last_version 2>/dev/null && sh /usr/share/openclash/clash_version.sh && sh /usr/share/openclash/openclash_core.sh >/dev/null 2>&1 &") + luci.sys.call("uci set openclash.config.enable=1 && uci commit openclash && rm -rf /tmp/*_last_version 2>/dev/null && sh /usr/share/openclash/clash_version.sh >/dev/null 2>&1") + return luci.sys.call("sh /usr/share/openclash/openclash_core.sh >/dev/null 2>&1 &") end local function corever() diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/client.lua b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/client.lua index 91b6a073ca..465e9b8209 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/client.lua +++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/client.lua @@ -38,7 +38,7 @@ function config_check(CONFIG_FILE) if (proxy ~= 0) then proxy = luci.sys.call(string.format('egrep "^proxies:" "%s" >/dev/null 2>&1',CONFIG_FILE)) end - group = luci.sys.call(string.format('egrep "^ {0,}Proxy Group:" "%s" >/dev/null 2>&1',CONFIG_FILE)) + group = luci.sys.call(string.format('egrep " {0,}Proxy Group" "%s" >/dev/null 2>&1',CONFIG_FILE)) if (group ~= 0) then group = luci.sys.call(string.format('egrep "^ {0,}proxy-groups:" "%s" >/dev/null 2>&1',CONFIG_FILE)) end diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua index 91a36f5e7f..4ebd2c180d 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua +++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/model/cbi/openclash/config.lua @@ -36,7 +36,7 @@ function config_check(CONFIG_FILE) if (proxy ~= 0) then proxy = luci.sys.call(string.format('egrep "^proxies:" "%s" >/dev/null 2>&1',CONFIG_FILE)) end - group = luci.sys.call(string.format('egrep "^ {0,}Proxy Group:" "%s" >/dev/null 2>&1',CONFIG_FILE)) + group = luci.sys.call(string.format('egrep " {0,}Proxy Group" "%s" >/dev/null 2>&1',CONFIG_FILE)) if (group ~= 0) then group = luci.sys.call(string.format('egrep "^ {0,}proxy-groups:" "%s" >/dev/null 2>&1',CONFIG_FILE)) end @@ -245,8 +245,9 @@ e.inputstyle="reset" Button.render(e,t,a) end btnrm.write=function(a,t) -local a=fs.unlink("/etc/openclash/config/"..luci.openclash.basename(e[t].name)) -local db=fs.unlink("/etc/openclash/backup/"..luci.openclash.basename(e[t].name)) + fs.unlink("/tmp/Proxy_Group") + fs.unlink("/etc/openclash/backup/"..luci.openclash.basename(e[t].name)) + local a=fs.unlink("/etc/openclash/config/"..luci.openclash.basename(e[t].name)) if a then table.remove(e,t)end return a end diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh index aff1c305d1..8bcc3f5a95 100755 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh +++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash.sh @@ -88,25 +88,17 @@ config_encode() { #proxies [ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && { - sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$CFG_FILE" 2>/dev/null - sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$CFG_FILE" 2>/dev/null sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$CFG_FILE" 2>/dev/null } [ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && { - sed -i "s/^\'proxies\':/Proxy:/" "$CFG_FILE" 2>/dev/null - sed -i 's/^\"proxies\":/Proxy:/' "$CFG_FILE" 2>/dev/null sed -i "s/^proxies:/Proxy:/" "$CFG_FILE" 2>/dev/null } #proxy-providers [ -z "$(grep "^proxy-provider:" "$CFG_FILE")" ] && { - sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null - sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null } [ -z "$(grep "^proxy-provider:" "$CFG_FILE")" ] && { - sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null - sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null } #proxy-groups @@ -116,20 +108,14 @@ config_encode() sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null } [ -z "$(grep "^Proxy Group:" "$CFG_FILE")" ] && { - sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null - sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null } #rules [ -z "$(grep "^Rule:" "$CFG_FILE")" ] && { - sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$CFG_FILE" 2>/dev/null - sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$CFG_FILE" 2>/dev/null sed -i "/^ \{1,\}Rule:/c\Rule:" "$CFG_FILE" 2>/dev/null } [ -z "$(grep "^Rule:" "$CFG_FILE")" ] && { - sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$CFG_FILE" 2>/dev/null - sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$CFG_FILE" 2>/dev/null sed -i "/^ \{0,\}rules:/c\Rule:" "$CFG_FILE" 2>/dev/null } } diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_version.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_version.sh index 7dc5b710c9..5dedb48498 100755 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_version.sh +++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/openclash_version.sh @@ -34,4 +34,4 @@ elif [ "$(expr "$OP_CV" \>= "$OP_LV")" -eq 1 ]; then echo "CheckTime:$CKTIME" >> $LAST_OPVER elif [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 ]; then return 2 -fi +fi 2>/dev/null diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_get.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_get.sh index dd12474954..abe3a37070 100755 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_get.sh +++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_groups_name_get.sh @@ -15,25 +15,17 @@ if [ -f "$CFG_FILE" ]; then #检查关键字避免后续操作出错 #proxies [ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && { - sed -i "s/^ \{0,\}\'Proxy\':/Proxy:/" "$CFG_FILE" 2>/dev/null - sed -i 's/^ \{0,\}\"Proxy\":/Proxy:/' "$CFG_FILE" 2>/dev/null sed -i "s/^ \{1,\}Proxy:/c\Proxy:/" "$CFG_FILE" 2>/dev/null } [ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && { - sed -i "s/^\'proxies\':/Proxy:/" "$CFG_FILE" 2>/dev/null - sed -i 's/^\"proxies\":/Proxy:/' "$CFG_FILE" 2>/dev/null sed -i "s/^proxies:/Proxy:/" "$CFG_FILE" 2>/dev/null } #proxy-providers [ -z "$(grep "^proxy-provider:" "$CFG_FILE")" ] && { - sed -i "s/^ \{0,\}\'proxy-provider\':/proxy-provider:/" "$CFG_FILE" 2>/dev/null - sed -i 's/^ \{0,\}\"proxy-provider\":/proxy-provider:/' "$CFG_FILE" 2>/dev/null sed -i "s/^ \{1,\}proxy-provider:/proxy-provider:/" "$CFG_FILE" 2>/dev/null } [ -z "$(grep "^proxy-provider:" "$CFG_FILE")" ] && { - sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null - sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null } #proxy-groups @@ -43,27 +35,19 @@ if [ -f "$CFG_FILE" ]; then sed -i "s/^ \{1,\}Proxy Group:/Proxy Group:/" "$CFG_FILE" 2>/dev/null } [ -z "$(grep "^Proxy Group:" "$CFG_FILE")" ] && { - sed -i "s/^ \{0,\}\'proxy-groups\':/Proxy Group:/" "$CFG_FILE" 2>/dev/null - sed -i 's/^ \{0,\}\"proxy-groups\":/Proxy Group:/' "$CFG_FILE" 2>/dev/null sed -i "s/^ \{0,\}proxy-groups:/Proxy Group:/" "$CFG_FILE" 2>/dev/null } #rules [ -z "$(grep "^Rule:" "$CFG_FILE")" ] && { - sed -i "s/^ \{0,\}\'Rule\':/Rule:/" "$CFG_FILE" 2>/dev/null - sed -i 's/^ \{0,\}\"Rule\":/Rule:/' "$CFG_FILE" 2>/dev/null sed -i "s/^ \{1,\}Rule:/Rule:/" "$CFG_FILE" 2>/dev/null } [ -z "$(grep "^Rule:" "$CFG_FILE")" ] && { - sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$CFG_FILE" 2>/dev/null - sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$CFG_FILE" 2>/dev/null sed -i "/^ \{0,\}rules:/c\Rule:" "$CFG_FILE" 2>/dev/null } #dns [ -z "$(grep "^dns:" "$CFG_FILE")" ] && { - sed -i "s/^ \{0,\}\'dns\':/dns:/" "$CFG_FILE" 2>/dev/null - sed -i 's/^ \{0,\}\"dns\":/dns:/' "$CFG_FILE" 2>/dev/null sed -i "s/^ \{1,\}dns:/dns:/" "$CFG_FILE" 2>/dev/null } diff --git a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh index aad61e59b8..58438256a8 100755 --- a/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh +++ b/package/ctcgfw/luci-app-openclash/files/usr/share/openclash/yml_proxys_get.sh @@ -67,8 +67,8 @@ servers_if_update=$(uci get openclash.config.servers_if_update 2>/dev/null) new_servers_group=$(uci get openclash.config.new_servers_group 2>/dev/null) #proxy -line=$(sed -n '/^ \{0,\}- name:/=' $server_file 2>/dev/null) -num=$(grep -c "^ \{0,\}- name:" $server_file 2>/dev/null) +line=$(sed -n '/name:/=' $server_file 2>/dev/null) +num=$(grep -c "name:" $server_file 2>/dev/null) count=1 #provider