Skip to content

Commit 8d4cfe5

Browse files
committed
chore: refine
1 parent 2bc3f16 commit 8d4cfe5

117 files changed

Lines changed: 1145 additions & 1023 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

luci-app-openclash/luasrc/controller/openclash.lua

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ function index()
7474
entry({"admin", "services", "openclash", "manual_stream_unlock_test"}, call("manual_stream_unlock_test"))
7575
entry({"admin", "services", "openclash", "all_proxies_stream_test"}, call("all_proxies_stream_test"))
7676
entry({"admin", "services", "openclash", "set_subinfo_url"}, call("set_subinfo_url"))
77+
entry({"admin", "services", "openclash", "check_core"}, call("action_check_core"))
78+
entry({"admin", "services", "openclash", "core_download"}, call("core_download"))
7779
entry({"admin", "services", "openclash", "settings"},cbi("openclash/settings"),_("Plugin Settings"), 30).leaf = true
7880
entry({"admin", "services", "openclash", "config-overwrite"},cbi("openclash/config-overwrite"),_("Overwrite Settings"), 40).leaf = true
7981
entry({"admin", "services", "openclash", "servers"},cbi("openclash/servers"),_("Onekey Create"), 50).leaf = true
@@ -229,6 +231,14 @@ local function coremodel()
229231
end
230232
end
231233

234+
local function check_core()
235+
if not nixio.fs.access(dev_core_path) and not nixio.fs.access(tun_core_path) and not nixio.fs.access(meta_core_path) then
236+
return "0"
237+
else
238+
return "1"
239+
end
240+
end
241+
232242
local function corecv()
233243
if not nixio.fs.access(dev_core_path) then
234244
return "0"
@@ -334,6 +344,24 @@ local function historychecktime()
334344
end
335345
end
336346

347+
function core_download()
348+
if uci:get("openclash", "config", "github_address_mod") == "0" or not uci:get("openclash", "config", "github_address_mod") then
349+
uci:set("openclash", "config", "github_address_mod", "https://testingcf.jsdelivr.net/")
350+
uci:commit("openclash")
351+
luci.sys.call("rm -rf /tmp/clash_last_version 2>/dev/null && bash /usr/share/openclash/clash_version.sh >/dev/null 2>&1")
352+
luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'Dev' >/dev/null 2>&1 &")
353+
luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'TUN' >/dev/null 2>&1 &")
354+
luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'Meta' >/dev/null 2>&1 &")
355+
uci:set("openclash", "config", "github_address_mod", "0")
356+
uci:commit("openclash")
357+
else
358+
luci.sys.call("rm -rf /tmp/clash_last_version 2>/dev/null && bash /usr/share/openclash/clash_version.sh >/dev/null 2>&1")
359+
luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'Dev' >/dev/null 2>&1 &")
360+
luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'TUN' >/dev/null 2>&1 &")
361+
luci.sys.call("bash /usr/share/openclash/openclash_core.sh 'Meta' >/dev/null 2>&1 &")
362+
end
363+
end
364+
337365
function download_rule()
338366
local filename = luci.http.formvalue("filename")
339367
local state = luci.sys.call(string.format('/usr/share/openclash/openclash_download_rule_list.sh "%s" >/dev/null 2>&1',filename))
@@ -375,7 +403,6 @@ function action_restore_config()
375403
luci.sys.call("cp /usr/share/openclash/backup/openclash_sniffing* /etc/openclash/custom/ >/dev/null 2>&1 &")
376404
luci.sys.call("cp /usr/share/openclash/backup/yml_change.sh /usr/share/openclash/yml_change.sh >/dev/null 2>&1 &")
377405
luci.sys.call("rm -rf /etc/openclash/history/* >/dev/null 2>&1 &")
378-
luci.http.redirect(luci.dispatcher.build_url('admin/services/openclash/settings'))
379406
end
380407

381408
function action_remove_all_core()
@@ -1114,6 +1141,13 @@ function action_opupdate()
11141141
})
11151142
end
11161143

1144+
function action_check_core()
1145+
luci.http.prepare_content("application/json")
1146+
luci.http.write_json({
1147+
core_status = check_core();
1148+
})
1149+
end
1150+
11171151
function action_coreupdate()
11181152
luci.http.prepare_content("application/json")
11191153
luci.http.write_json({

luci-app-openclash/luasrc/model/cbi/openclash/settings.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ end
164164

165165
---- Access Control
166166
o = s:taboption("lan_ac", ListValue, "lan_ac_mode", translate("LAN Access Control Mode"))
167+
o.description = font_red..bold_on..translate("To Use in Fake-IP Mode, Please Switch The Dns Redirect Mode To Firewall Forwarding")..bold_off..font_off
167168
o:value("0", translate("Black List Mode"))
168169
o:value("1", translate("White List Mode"))
169170
o.default = "0"

luci-app-openclash/luasrc/view/openclash/status.htm

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@
451451
get_run_mode();
452452
state_get();
453453
clashversion_check();
454+
check_core();
454455

455456
function get_rule_mode() {
456457
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "rule_mode")%>', null, function(x, status) {
@@ -693,28 +694,26 @@
693694
{
694695
btn.value = '<%:Check All Components Update%>';
695696
btn.disabled = true;
696-
var r = confirm("<%:Check and update all Cores and plug-ins?%>")
697+
var r = confirm("<%:Check and Update all Cores and OpenClash?%>")
697698
if (r == true) {
698-
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update_check")%>', null, function(x, status) {
699-
if ( x && x.status == 200 ) {
700-
if ( status.corever != "0" ) {
701-
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update")%>', null, function(x, status) {
702-
if ( x && x.status != 200 ) {
703-
alert('<%:Check failed, Please try again later!%>')
704-
}
705-
});
706-
}
707-
else {
708-
alert('<%:No compiled version is selected. Please configure it in the General Settings tab!%>')
709-
}
710-
}
711-
else {
712-
alert('<%:Check failed, Please try again later!%>')
713-
}
714-
});
699+
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update_check")%>', null, function(x, status) {
700+
if ( x && x.status == 200 ) {
701+
if ( status.corever != "0" ) {
702+
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update")%>', null, function(x, status) {
703+
if ( x && x.status != 200 ) {
704+
alert('<%:Check failed, Please try again later!%>')
705+
}
706+
});
707+
}
708+
else {
709+
alert('<%:No compiled version is selected. Please configure it in the General Settings tab!%>')
710+
}
715711
}
716712
else {
717-
}
713+
alert('<%:Check failed, Please try again later!%>')
714+
}
715+
});
716+
}
718717
btn.disabled = false;
719718
return false;
720719
};
@@ -730,7 +729,7 @@
730729
}
731730
else {
732731
btn.disabled = false;
733-
btn.value = '<%:Check Third Party Rules Update%>';
732+
btn.value = '<%:Check Third Party Rules Update%>';
734733
}
735734
return false;
736735
});
@@ -989,5 +988,24 @@
989988
url4='https://github.com/vernesong/OpenClash/releases';
990989
winOpen(url4);
991990
};
991+
992+
function check_core()
993+
{
994+
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "check_core")%>', null, function(x, status) {
995+
if ( x && x.status == 200 ) {
996+
if ( status.core_status != "1" )
997+
{
998+
var r = confirm("<%:You have not installed the core yet, do you want to download and install it now?%>")
999+
if (r == true) {
1000+
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "core_download")%>', null, function(x, status) {
1001+
if ( x && x.status == 200 ) {
1002+
window.location.href='<%="'+window.location.protocol+'//'+window.location.hostname+'/cgi-bin/luci/admin/services/openclash/log"%>';
1003+
}
1004+
});
1005+
}
1006+
}
1007+
}
1008+
});
1009+
};
9921010
//]]></script>
9931011

luci-app-openclash/luasrc/view/openclash/update.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@
513513
if (x && x.status == 200) {
514514
btn.value = '<%:One Click Check Update%>';
515515
btn.disabled = true;
516-
var r = confirm("<%:Check and update all Cores and plug-ins?%>")
516+
var r = confirm("<%:Check and Update all Cores and OpenClash?%>")
517517
if (r == true) {
518518
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update_check")%>', null, function(x, status) {
519519
if ( x && x.status == 200 ) {

luci-app-openclash/po/zh-cn/openclash.zh-cn.po

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,9 +1260,12 @@ msgstr "GEOIP 数据库检查更新"
12601260
msgid "Check GeoSite Data Update"
12611261
msgstr "GeoSite 数据库检查更新"
12621262

1263-
msgid "Check and update all Cores and plug-ins?"
1263+
msgid "Check and Update all Cores and OpenClash?"
12641264
msgstr "确定要一键检查并更新所有内核及插件吗?"
12651265

1266+
msgid "You have not installed the core yet, do you want to download and install it now?"
1267+
msgstr "您还未安装内核,是否立即下载安装?"
1268+
12661269
msgid "Check failed, Please try again later!"
12671270
msgstr "一键检查更新失败,请稍后再试!"
12681271

@@ -3481,4 +3484,7 @@ msgid "Group Use For Proxy The Fallback DNS, Preventing DNS Lookup Failures"
34813484
msgstr "为所有 Fallback DNS 设置代理策略组,防止 DNS 查询失败"
34823485

34833486
msgid "Error: Set Fallback DNS Proxy Group Failed,"
3484-
msgstr "错误:Fallback DNS 代理策略组设置失败,"
3487+
msgstr "错误:Fallback DNS 代理策略组设置失败,"
3488+
3489+
msgid "To Use in Fake-IP Mode, Please Switch The Dns Redirect Mode To Firewall Forwarding"
3490+
msgstr "要在 Fake-IP 模式下使用,请将 Dns 重定向模式切换为防火墙转发模式"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d.metacubex.one

luci-app-openclash/root/usr/share/openclash/ui/metacubexd/assets/Config-8226e777.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)