diff --git a/package/ctcgfw/luci-app-openclash/Makefile b/package/ctcgfw/luci-app-openclash/Makefile index 5ef6e85b77..10a39262ed 100644 --- a/package/ctcgfw/luci-app-openclash/Makefile +++ b/package/ctcgfw/luci-app-openclash/Makefile @@ -34,6 +34,7 @@ define Build/Prepare mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/config >/dev/null 2>&1 mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/proxy_provider >/dev/null 2>&1 mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/backup >/dev/null 2>&1 + mkdir -p $(PKG_BUILD_DIR)/files/etc/openclash/core >/dev/null 2>&1 endef define Build/Configure @@ -47,12 +48,14 @@ define Package/$(PKG_NAME)/preinst if [ -f "/etc/config/openclash" ]; then cp "/etc/config/openclash" "/tmp/openclash.bak" >/dev/null 2>&1 cp "/etc/config/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1 + cp "/etc/config/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1 cp "/etc/config/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1 cp "/etc/config/openclash_custom_fake_black.conf" "/tmp/openclash_custom_fake_black.conf.bak" >/dev/null 2>&1 cp "/etc/openclash/history" "/tmp/openclash_history.bak" >/dev/null 2>&1 fi if [ -f "/etc/openclash/custom/openclash_custom_rules.list" ]; then cp "/etc/openclash/custom/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1 + cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1 cp "/etc/openclash/custom/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1 cp "/etc/openclash/custom/openclash_custom_fake_black.conf" "/tmp/openclash_custom_fake_black.conf.bak" >/dev/null 2>&1 fi @@ -74,9 +77,18 @@ mkdir -p /etc/openclash/config >/dev/null 2>&1 mkdir -p /etc/openclash/proxy_provider >/dev/null 2>&1 mkdir -p /etc/openclash/backup >/dev/null 2>&1 mkdir -p /etc/openclash/core >/dev/null 2>&1 +mkdir -p /usr/share/openclash/backup >/dev/null 2>&1 + +cp "/etc/config/openclash" "/usr/share/openclash/backup/openclash" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_rules.list" "/usr/share/openclash/backup/openclash_custom_rules.list" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/usr/share/openclash/backup/openclash_custom_rules_2.list" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_hosts.list" "/usr/share/openclash/backup/openclash_custom_hosts.list" >/dev/null 2>&1 +cp "/etc/openclash/custom/openclash_custom_fake_black.conf" "/usr/share/openclash/backup/openclash_custom_fake_black.conf" >/dev/null 2>&1 + if [ -f "/tmp/openclash.bak" ]; then mv "/tmp/openclash.bak" "/etc/config/openclash" >/dev/null 2>&1 mv "/tmp/openclash_custom_rules.list.bak" "/etc/openclash/custom/openclash_custom_rules.list" >/dev/null 2>&1 + mv "/tmp/openclash_custom_rules_2.list.bak" "/etc/openclash/custom/openclash_custom_rules_2.list" >/dev/null 2>&1 mv "/tmp/openclash_custom_hosts.list.bak" "/etc/openclash/custom/openclash_custom_hosts.list" >/dev/null 2>&1 mv "/tmp/openclash_custom_fake_black.conf.bak" "/etc/openclash/custom/openclash_custom_fake_black.conf" >/dev/null 2>&1 mv "/tmp/openclash_history.bak" "/etc/openclash/history" >/dev/null 2>&1 @@ -135,6 +147,7 @@ define Package/$(PKG_NAME)/prerm cp "/etc/config/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1 cp "/etc/config/openclash_custom_fake_black.conf" "/tmp/openclash_custom_fake_black.conf.bak" >/dev/null 2>&1 cp "/etc/openclash/custom/openclash_custom_rules.list" "/tmp/openclash_custom_rules.list.bak" >/dev/null 2>&1 + cp "/etc/openclash/custom/openclash_custom_rules_2.list" "/tmp/openclash_custom_rules_2.list.bak" >/dev/null 2>&1 cp "/etc/openclash/custom/openclash_custom_hosts.list" "/tmp/openclash_custom_hosts.list.bak" >/dev/null 2>&1 cp "/etc/openclash/custom/openclash_custom_fake_black.conf" "/tmp/openclash_custom_fake_black.conf.bak" >/dev/null 2>&1 endef 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 1dbca0fc21..70fdedd6ff 100755 --- a/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash +++ b/package/ctcgfw/luci-app-openclash/files/etc/init.d/openclash @@ -110,14 +110,6 @@ yml_check() sed -i "s/- \{2,\}/- /g" "$3" 2>/dev/null #检查关键字避免后续操作出错 - #proxies - [ -z "$(grep "^Proxy:" "$3")" ] && { - sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$3" 2>/dev/null - } - [ -z "$(grep "^Proxy:" "$3")" ] && { - sed -i "s/^proxies:/Proxy:/" "$3" 2>/dev/null - } - #proxy-providers [ -z "$(grep "^proxy-provider:" "$3")" ] && { sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$3" 2>/dev/null @@ -135,6 +127,21 @@ yml_check() sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$3" 2>/dev/null } + #proxies + [ -z "$(grep "^Proxy:" "$3")" ] && { + sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$3" 2>/dev/null + } + [ -z "$(grep "^Proxy:" "$3")" ] && { + sed -i "/^proxies:/c\Proxy:" "$3" 2>/dev/null + } + [ -z "$(grep "^Proxy:" "$3")" ] && { + group_len=$(sed -n '/^Proxy Group:/=' "$3" 2>/dev/null) + proxies_len=$(sed -n '/proxies:/=' "$3" 2>/dev/null |sed -n 1p) + if [ "$proxies_len" -lt "$group_len" ]; then + sed -i "${proxies_len}c\Proxy:" "$3" 2>/dev/null + fi 2>/dev/null + } + #rules [ -z "$(grep "^Rule:" "$3")" ] && { sed -i "/^ \{1,\}Rule:/c\Rule:" "$3" 2>/dev/null @@ -158,9 +165,8 @@ yml_check() #位置检查 proxy_len=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null) - group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$3" 2>/dev/null) provider_len=$(sed -n '/^proxy-provider:/=' "$3" 2>/dev/null) - dns_len=$(sed -n '/^ \{0,\}dns:/=' "$3" 2>/dev/null) + dns_len=$(sed -n '/^dns:/=' "$3" 2>/dev/null) rule_len=$(sed -n '/^Rule:/=' "$3" 2>/dev/null) if [ "$dns_len" -ge "$proxy_len" ] || [ "$dns_len" -ge "$rule_len" ] || [ "$dns_len" -ge "$group_len" ]; then diff --git a/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules.list b/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules.list index 7a1834929f..7822a00a10 100644 --- a/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules.list +++ b/package/ctcgfw/luci-app-openclash/files/etc/openclash/game_rules.list @@ -75,6 +75,7 @@ Kurtzpel,Kurtzpel.rules 失落的方舟俄服,Lostark-RU.rules 冒险岛,Maplestory-us.rules 怪兽世界猎人steam版,Monster-Hunter-World.rules +万智牌:竞技场-国际服,MTG-Arena.rules 奇迹传奇MU2,MU2.rules NBA-2K19,NBA-2K19.rules NBA2K20,NBA2K20.rules 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 e1549e206f..142ea1ed6b 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 @@ -21,6 +21,7 @@ function index() entry({"admin", "services", "openclash", "coregameupdate"},call("action_core_game_update")) entry({"admin", "services", "openclash", "ping"}, call("act_ping")) entry({"admin", "services", "openclash", "download_game_rule"}, call("action_download_rule")) + entry({"admin", "services", "openclash", "restore"}, call("action_restore_config")) entry({"admin", "services", "openclash", "settings"},cbi("openclash/settings"),_("Global Settings"), 30).leaf = true entry({"admin", "services", "openclash", "servers"},cbi("openclash/servers"),_("Severs and Groups"), 40).leaf = true entry({"admin", "services", "openclash", "game-settings"},cbi("openclash/game-settings"),_("Game Rules and Groups"), 50).leaf = true @@ -194,6 +195,15 @@ function download_rule() return state end +function action_restore_config() + luci.sys.call("/etc/init.d/openclash stop >/dev/null 2>&1") + luci.sys.call("cp '/usr/share/openclash/backup/openclash' '/etc/config/openclash' >/dev/null 2>&1 &") + luci.sys.call("cp '/usr/share/openclash/backup/openclash_custom_rules.list' '/etc/openclash/custom/openclash_custom_rules.list' >/dev/null 2>&1 &") + luci.sys.call("cp '/usr/share/openclash/backup/openclash_custom_rules_2.list' '/etc/openclash/custom/openclash_custom_rules_2.list' >/dev/null 2>&1 &") + luci.sys.call("cp '/usr/share/openclash/backup/openclash_custom_fake_black.conf' '/etc/openclash/custom/openclash_custom_fake_black.conf' >/dev/null 2>&1 &") + luci.sys.call("cp '/usr/share/openclash/backup/openclash_custom_hosts.list' '/etc/openclash/custom/openclash_custom_hosts.list' >/dev/null 2>&1 &") +end + function action_status() luci.http.prepare_content("application/json") luci.http.write_json({ @@ -206,6 +216,7 @@ function action_status() mode = mode(); }) end + function action_state() luci.http.prepare_content("application/json") luci.http.write_json({ @@ -302,4 +313,4 @@ function action_download_rule() luci.http.write_json({ game_rule_download_status = download_rule(); }) -end +end \ No newline at end of file diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/myip.htm b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/myip.htm index d4b8b20d72..bffa5a7a0b 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/myip.htm +++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/myip.htm @@ -202,13 +202,9 @@ throw error; }), parseIPIpip: (ip, elID) => { - IP.get(`https://api.skk.moe/network/parseIp/ipip/v3/${ip}`, 'json') + IP.get(`https://qqwry.api.skk.moe/${ip}`, 'json') .then(resp => { - let x = ''; - for (let i of resp.data) { - x += (i !== '') ? `${i} ` : ''; - } - $$.getElementById(elID).innerHTML = x; + $$.getElementById(elID).innerHTML = resp.data.geo; //$$.getElementById(elID).innerHTML = `${resp.data.country} ${resp.data.regionName} ${resp.data.city} ${resp.data.isp}`; }) }, diff --git a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/update.htm b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/update.htm index 61c04e9faa..4ffb03f6bd 100644 --- a/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/update.htm +++ b/package/ctcgfw/luci-app-openclash/files/usr/lib/lua/luci/view/openclash/update.htm @@ -1,6 +1,5 @@
-

@@ -43,6 +42,11 @@

更新客户端 <%:Collecting data...%> 下载最新版本客户端 <%:Collecting data...%>
+
+ + +
<%:Collecting data...%>
+