@@ -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
230232end
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+
232242local function corecv ()
233243 if not nixio .fs .access (dev_core_path ) then
234244 return " 0"
@@ -334,6 +344,24 @@ local function historychecktime()
334344 end
335345end
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+
337365function 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' ))
379406end
380407
381408function action_remove_all_core ()
@@ -1114,6 +1141,13 @@ function action_opupdate()
11141141 })
11151142end
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+
11171151function action_coreupdate ()
11181152 luci .http .prepare_content (" application/json" )
11191153 luci .http .write_json ({
0 commit comments