@@ -32,10 +32,6 @@ function index()
3232 entry ({" admin" , " services" , " openclash" , " coreupdate" },call (" action_coreupdate" ))
3333 entry ({" admin" , " services" , " openclash" , " flush_fakeip_cache" }, call (" action_flush_fakeip_cache" ))
3434 entry ({" admin" , " services" , " openclash" , " download_rule" }, call (" action_download_rule" ))
35- entry ({" admin" , " services" , " openclash" , " download_netflix_domains" }, call (" action_download_netflix_domains" ))
36- entry ({" admin" , " services" , " openclash" , " download_disney_domains" }, call (" action_download_disney_domains" ))
37- entry ({" admin" , " services" , " openclash" , " catch_netflix_domains" }, call (" action_catch_netflix_domains" ))
38- entry ({" admin" , " services" , " openclash" , " write_netflix_domains" }, call (" action_write_netflix_domains" ))
3935 entry ({" admin" , " services" , " openclash" , " restore" }, call (" action_restore_config" ))
4036 entry ({" admin" , " services" , " openclash" , " backup" }, call (" action_backup" ))
4137 entry ({" admin" , " services" , " openclash" , " backup_ex_core" }, call (" action_backup_ex_core" ))
@@ -103,18 +99,17 @@ local json = require "luci.jsonc"
10399local uci = require (" luci.model.uci" ).cursor ()
104100local datatype = require " luci.cbi.datatypes"
105101local opkg
102+ local device_name = uci :get (" system" , " @system[0]" , " hostname" )
103+ local device_arh = luci .sys .exec (" uname -m |tr -d '\n '" )
104+
106105if pcall (require , " luci.model.ipkg" ) then
107106 opkg = require " luci.model.ipkg"
108107end
109108
110109local core_path_mode = uci :get (" openclash" , " config" , " small_flash_memory" )
111110if core_path_mode ~= " 1" then
112- dev_core_path = " /etc/openclash/core/clash"
113- tun_core_path = " /etc/openclash/core/clash_tun"
114111 meta_core_path = " /etc/openclash/core/clash_meta"
115112else
116- dev_core_path = " /tmp/etc/openclash/core/clash"
117- tun_core_path = " /tmp/etc/openclash/core/clash_tun"
118113 meta_core_path = " /tmp/etc/openclash/core/clash_meta"
119114end
120115
@@ -126,10 +121,6 @@ local function is_web()
126121 return luci .sys .call (" pidof clash >/dev/null" ) == 0
127122end
128123
129- local function restricted_mode ()
130- return uci :get (" openclash" , " config" , " restricted_mode" )
131- end
132-
133124local function is_watchdog ()
134125 return process_status (" openclash_watchdog.sh" )
135126end
@@ -158,14 +149,6 @@ local function lhie1()
158149 return os.date (" %Y-%m-%d %H:%M:%S" ,fs .mtime (" /usr/share/openclash/res/lhie1.yaml" ))
159150end
160151
161- local function ConnersHua ()
162- return os.date (" %Y-%m-%d %H:%M:%S" ,fs .mtime (" /usr/share/openclash/res/ConnersHua.yaml" ))
163- end
164-
165- local function ConnersHua_return ()
166- return os.date (" %Y-%m-%d %H:%M:%S" ,fs .mtime (" /usr/share/openclash/res/ConnersHua_return.yaml" ))
167- end
168-
169152local function chnroute ()
170153 return os.date (" %Y-%m-%d %H:%M:%S" ,fs .mtime (" /etc/openclash/china_ip_route.ipset" ))
171154end
@@ -238,29 +221,13 @@ local function coremodel()
238221end
239222
240223local function check_core ()
241- 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
224+ if not nixio .fs .access (meta_core_path ) then
242225 return " 0"
243226 else
244227 return " 1"
245228 end
246229end
247230
248- local function corecv ()
249- if not nixio .fs .access (dev_core_path ) then
250- return " 0"
251- else
252- return luci .sys .exec (string.format (" %s -v 2>/dev/null |awk -F ' ' '{print $2}'" , dev_core_path ))
253- end
254- end
255-
256- local function coretuncv ()
257- if not nixio .fs .access (tun_core_path ) then
258- return " 0"
259- else
260- return luci .sys .exec (string.format (" %s -v 2>/dev/null |awk -F ' ' '{print $2}'" , tun_core_path ))
261- end
262- end
263-
264231local function coremetacv ()
265232 if not nixio .fs .access (meta_core_path ) then
266233 return " 0"
271238
272239local function corelv ()
273240 luci .sys .call (" bash /usr/share/openclash/clash_version.sh" )
274- local core_lv = luci .sys .exec (" sed -n 1p /tmp/clash_last_version 2>/dev/null" )
275- local core_tun_lv = luci .sys .exec (" sed -n 2p /tmp/clash_last_version 2>/dev/null" )
276241 local core_meta_lv = luci .sys .exec (" sed -n 3p /tmp/clash_last_version 2>/dev/null" )
277- return core_lv .. " , " .. core_tun_lv .. " , " .. core_meta_lv
242+ return core_meta_lv
278243end
279244
280245local function opcv ()
@@ -354,13 +319,9 @@ function core_download()
354319 local cdn_url = luci .http .formvalue (" url" )
355320 if cdn_url then
356321 luci .sys .call (string.format (" rm -rf /tmp/clash_last_version 2>/dev/null && bash /usr/share/openclash/clash_version.sh '%s' >/dev/null 2>&1" , cdn_url ))
357- luci .sys .call (string.format (" bash /usr/share/openclash/openclash_core.sh 'Dev' '%s' >/dev/null 2>&1 &" , cdn_url ))
358- luci .sys .call (string.format (" bash /usr/share/openclash/openclash_core.sh 'TUN' '%s' >/dev/null 2>&1 &" , cdn_url ))
359322 luci .sys .call (string.format (" bash /usr/share/openclash/openclash_core.sh 'Meta' '%s' >/dev/null 2>&1 &" , cdn_url ))
360323 else
361324 luci .sys .call (" rm -rf /tmp/clash_last_version 2>/dev/null && bash /usr/share/openclash/clash_version.sh >/dev/null 2>&1" )
362- luci .sys .call (" bash /usr/share/openclash/openclash_core.sh 'Dev' >/dev/null 2>&1 &" )
363- luci .sys .call (" bash /usr/share/openclash/openclash_core.sh 'TUN' >/dev/null 2>&1 &" )
364325 luci .sys .call (" bash /usr/share/openclash/openclash_core.sh 'Meta' >/dev/null 2>&1 &" )
365326 end
366327
@@ -372,16 +333,6 @@ function download_rule()
372333 return state
373334end
374335
375- function download_disney_domains ()
376- local state = luci .sys .call (string.format (' /usr/share/openclash/openclash_download_rule_list.sh "%s" >/dev/null 2>&1' ," disney_domains" ))
377- return state
378- end
379-
380- function download_netflix_domains ()
381- local state = luci .sys .call (string.format (' /usr/share/openclash/openclash_download_rule_list.sh "%s" >/dev/null 2>&1' ," netflix_domains" ))
382- return state
383- end
384-
385336function action_flush_fakeip_cache ()
386337 local state = 0
387338 if is_running () then
@@ -751,7 +702,7 @@ function action_rule_mode()
751702 local daip = daip ()
752703 local dase = dase () or " "
753704 local cn_port = cn_port ()
754- core_type = uci :get (" openclash" , " config" , " core_type" ) or " Dev "
705+ core_type = uci :get (" openclash" , " config" , " core_type" ) or " Meta "
755706 if not daip or not cn_port then return end
756707 info = json .parse (luci .sys .exec (string.format (' curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XGET http://"%s":"%s"/configs' , dase , daip , cn_port )))
757708 if info then
@@ -773,9 +724,7 @@ function action_switch_rule_mode()
773724 local daip = daip ()
774725 local dase = dase () or " "
775726 local cn_port = cn_port ()
776- local core_type = uci :get (" openclash" , " config" , " core_type" ) or " Dev"
777727 mode = luci .http .formvalue (" rule_mode" )
778- if mode == script and core_type ~= " TUN" then luci .http .status (500 , " Switch Faild" ) return end
779728 if not daip or not cn_port then luci .http .status (500 , " Switch Faild" ) return end
780729 info = luci .sys .exec (string.format (' curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XPATCH http://"%s":"%s"/configs -d \' {\" mode\" : \" %s\" }\' ' , dase , daip , cn_port , mode ))
781730 if info ~= " " then
@@ -1081,17 +1030,14 @@ function action_status()
10811030 db_forward_ssl = db_foward_ssl (),
10821031 web = is_web (),
10831032 cn_port = cn_port (),
1084- restricted_mode = restricted_mode (),
1085- core_type = uci :get (" openclash" , " config" , " core_type" ) or " Dev" ;
1033+ core_type = uci :get (" openclash" , " config" , " core_type" ) or " Meta" ;
10861034 })
10871035end
10881036
10891037function action_state ()
10901038 luci .http .prepare_content (" application/json" )
10911039 luci .http .write_json ({
10921040 lhie1 = lhie1 (),
1093- ConnersHua = ConnersHua (),
1094- ConnersHua_return = ConnersHua_return (),
10951041 ipdb = ipdb (),
10961042 geosite = geosite (),
10971043 historychecktime = historychecktime (),
@@ -1117,8 +1063,6 @@ end
11171063function action_update ()
11181064 luci .http .prepare_content (" application/json" )
11191065 luci .http .write_json ({
1120- corecv = corecv (),
1121- coretuncv = coretuncv (),
11221066 coremetacv = coremetacv (),
11231067 coremodel = coremodel (),
11241068 opcv = opcv (),
@@ -1198,20 +1142,6 @@ function action_download_rule()
11981142 })
11991143end
12001144
1201- function action_download_netflix_domains ()
1202- luci .http .prepare_content (" application/json" )
1203- luci .http .write_json ({
1204- rule_download_status = download_netflix_domains ();
1205- })
1206- end
1207-
1208- function action_download_disney_domains ()
1209- luci .http .prepare_content (" application/json" )
1210- luci .http .write_json ({
1211- rule_download_status = download_disney_domains ();
1212- })
1213- end
1214-
12151145function action_refresh_log ()
12161146 luci .http .prepare_content (" application/json" )
12171147 local logfile = " /tmp/openclash.log"
@@ -1326,38 +1256,6 @@ function split(str,delimiter)
13261256 return arr
13271257end
13281258
1329- function action_write_netflix_domains ()
1330- local domains = luci .http .formvalue (" domains" )
1331- local dustom_file = " /etc/openclash/custom/openclash_custom_netflix_domains.list"
1332- local file = io.open (dustom_file , " a+" )
1333- file :seek (" set" )
1334- local domain = file :read (" *a" )
1335- for v , k in pairs (split (domains ," \n " )) do
1336- if not string.find (domain ,k ,1 ,true ) then
1337- file :write (k .. " \n " )
1338- end
1339- end
1340- file :close ()
1341- return
1342- end
1343-
1344- function action_catch_netflix_domains ()
1345- local cmd = " /usr/share/openclash/openclash_debug_getcon.lua 'netflix-nflxvideo'"
1346- luci .http .prepare_content (" text/plain" )
1347- local util = io.popen (cmd )
1348- if util and util ~= " " then
1349- while true do
1350- local ln = util :read (" *l" )
1351- if not ln then break end
1352- luci .http .write (ln )
1353- luci .http .write (" ," )
1354- end
1355- util :close ()
1356- return
1357- end
1358- luci .http .status (500 , " Bad address" )
1359- end
1360-
13611259function action_diag_connection ()
13621260 local addr = luci .http .formvalue (" addr" )
13631261 if addr and (datatype .hostname (addr ) or datatype .ipaddr (addr )) then
@@ -1425,8 +1323,8 @@ function action_backup()
14251323 local reader = ltn12_popen (" tar -C '/etc/openclash/' -cz . 2>/dev/null" )
14261324
14271325 luci .http .header (
1428- ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-%s.tar.gz"' % {
1429- os.date (" %Y-%m-%d-%H-%M-%S" )
1326+ ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-%s-%s-%s .tar.gz"' % {
1327+ device_name , device_arh , os.date (" %Y-%m-%d-%H-%M-%S" )
14301328 })
14311329
14321330 luci .http .prepare_content (" application/x-targz" )
@@ -1439,8 +1337,8 @@ function action_backup_ex_core()
14391337 local reader = ltn12_popen (" echo 'core' > /tmp/oc_exclude.txt && tar -C '/etc/openclash/' -X '/tmp/oc_exclude.txt' -cz . 2>/dev/null" )
14401338
14411339 luci .http .header (
1442- ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Exclude-Cores-%s.tar.gz"' % {
1443- os.date (" %Y-%m-%d-%H-%M-%S" )
1340+ ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Exclude-Cores-%s-%s-%s .tar.gz"' % {
1341+ device_name , device_arh , os.date (" %Y-%m-%d-%H-%M-%S" )
14441342 })
14451343
14461344 luci .http .prepare_content (" application/x-targz" )
@@ -1452,8 +1350,8 @@ function action_backup_only_config()
14521350 local reader = ltn12_popen (" tar -C '/etc/openclash' -cz './config' 2>/dev/null" )
14531351
14541352 luci .http .header (
1455- ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Config-%s.tar.gz"' % {
1456- os.date (" %Y-%m-%d-%H-%M-%S" )
1353+ ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Config-%s-%s-%s .tar.gz"' % {
1354+ device_name , device_arh , os.date (" %Y-%m-%d-%H-%M-%S" )
14571355 })
14581356
14591357 luci .http .prepare_content (" application/x-targz" )
@@ -1464,8 +1362,8 @@ function action_backup_only_core()
14641362 local reader = ltn12_popen (" tar -C '/etc/openclash' -cz './core' 2>/dev/null" )
14651363
14661364 luci .http .header (
1467- ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Cores-%s.tar.gz"' % {
1468- os.date (" %Y-%m-%d-%H-%M-%S" )
1365+ ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Cores-%s-%s-%s .tar.gz"' % {
1366+ device_name , device_arh , os.date (" %Y-%m-%d-%H-%M-%S" )
14691367 })
14701368
14711369 luci .http .prepare_content (" application/x-targz" )
@@ -1476,8 +1374,8 @@ function action_backup_only_rule()
14761374 local reader = ltn12_popen (" tar -C '/etc/openclash' -cz './rule_provider' 2>/dev/null" )
14771375
14781376 luci .http .header (
1479- ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Only-Rule-Provider-%s.tar.gz"' % {
1480- os.date (" %Y-%m-%d-%H-%M-%S" )
1377+ ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Only-Rule-Provider-%s-%s-%s .tar.gz"' % {
1378+ device_name , device_arh , os.date (" %Y-%m-%d-%H-%M-%S" )
14811379 })
14821380
14831381 luci .http .prepare_content (" application/x-targz" )
@@ -1488,8 +1386,8 @@ function action_backup_only_proxy()
14881386 local reader = ltn12_popen (" tar -C '/etc/openclash' -cz './proxy_provider' 2>/dev/null" )
14891387
14901388 luci .http .header (
1491- ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Proxy-Provider-%s.tar.gz"' % {
1492- os.date (" %Y-%m-%d-%H-%M-%S" )
1389+ ' Content-Disposition' , ' attachment; filename="Backup-OpenClash-Proxy-Provider-%s-%s-%s .tar.gz"' % {
1390+ device_name , device_arh , os.date (" %Y-%m-%d-%H-%M-%S" )
14931391 })
14941392
14951393 luci .http .prepare_content (" application/x-targz" )
0 commit comments