@@ -32,10 +32,6 @@ function index()
32
32
entry ({" admin" , " services" , " openclash" , " coreupdate" },call (" action_coreupdate" ))
33
33
entry ({" admin" , " services" , " openclash" , " flush_fakeip_cache" }, call (" action_flush_fakeip_cache" ))
34
34
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" ))
39
35
entry ({" admin" , " services" , " openclash" , " restore" }, call (" action_restore_config" ))
40
36
entry ({" admin" , " services" , " openclash" , " backup" }, call (" action_backup" ))
41
37
entry ({" admin" , " services" , " openclash" , " backup_ex_core" }, call (" action_backup_ex_core" ))
@@ -103,18 +99,17 @@ local json = require "luci.jsonc"
103
99
local uci = require (" luci.model.uci" ).cursor ()
104
100
local datatype = require " luci.cbi.datatypes"
105
101
local opkg
102
+ local device_name = uci :get (" system" , " @system[0]" , " hostname" )
103
+ local device_arh = luci .sys .exec (" uname -m |tr -d '\n '" )
104
+
106
105
if pcall (require , " luci.model.ipkg" ) then
107
106
opkg = require " luci.model.ipkg"
108
107
end
109
108
110
109
local core_path_mode = uci :get (" openclash" , " config" , " small_flash_memory" )
111
110
if core_path_mode ~= " 1" then
112
- dev_core_path = " /etc/openclash/core/clash"
113
- tun_core_path = " /etc/openclash/core/clash_tun"
114
111
meta_core_path = " /etc/openclash/core/clash_meta"
115
112
else
116
- dev_core_path = " /tmp/etc/openclash/core/clash"
117
- tun_core_path = " /tmp/etc/openclash/core/clash_tun"
118
113
meta_core_path = " /tmp/etc/openclash/core/clash_meta"
119
114
end
120
115
@@ -126,10 +121,6 @@ local function is_web()
126
121
return luci .sys .call (" pidof clash >/dev/null" ) == 0
127
122
end
128
123
129
- local function restricted_mode ()
130
- return uci :get (" openclash" , " config" , " restricted_mode" )
131
- end
132
-
133
124
local function is_watchdog ()
134
125
return process_status (" openclash_watchdog.sh" )
135
126
end
@@ -158,14 +149,6 @@ local function lhie1()
158
149
return os.date (" %Y-%m-%d %H:%M:%S" ,fs .mtime (" /usr/share/openclash/res/lhie1.yaml" ))
159
150
end
160
151
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
-
169
152
local function chnroute ()
170
153
return os.date (" %Y-%m-%d %H:%M:%S" ,fs .mtime (" /etc/openclash/china_ip_route.ipset" ))
171
154
end
@@ -238,29 +221,13 @@ local function coremodel()
238
221
end
239
222
240
223
local 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
242
225
return " 0"
243
226
else
244
227
return " 1"
245
228
end
246
229
end
247
230
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
-
264
231
local function coremetacv ()
265
232
if not nixio .fs .access (meta_core_path ) then
266
233
return " 0"
271
238
272
239
local function corelv ()
273
240
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" )
276
241
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
278
243
end
279
244
280
245
local function opcv ()
@@ -354,13 +319,9 @@ function core_download()
354
319
local cdn_url = luci .http .formvalue (" url" )
355
320
if cdn_url then
356
321
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 ))
359
322
luci .sys .call (string.format (" bash /usr/share/openclash/openclash_core.sh 'Meta' '%s' >/dev/null 2>&1 &" , cdn_url ))
360
323
else
361
324
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 &" )
364
325
luci .sys .call (" bash /usr/share/openclash/openclash_core.sh 'Meta' >/dev/null 2>&1 &" )
365
326
end
366
327
@@ -372,16 +333,6 @@ function download_rule()
372
333
return state
373
334
end
374
335
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
-
385
336
function action_flush_fakeip_cache ()
386
337
local state = 0
387
338
if is_running () then
@@ -751,7 +702,7 @@ function action_rule_mode()
751
702
local daip = daip ()
752
703
local dase = dase () or " "
753
704
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 "
755
706
if not daip or not cn_port then return end
756
707
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 )))
757
708
if info then
@@ -773,9 +724,7 @@ function action_switch_rule_mode()
773
724
local daip = daip ()
774
725
local dase = dase () or " "
775
726
local cn_port = cn_port ()
776
- local core_type = uci :get (" openclash" , " config" , " core_type" ) or " Dev"
777
727
mode = luci .http .formvalue (" rule_mode" )
778
- if mode == script and core_type ~= " TUN" then luci .http .status (500 , " Switch Faild" ) return end
779
728
if not daip or not cn_port then luci .http .status (500 , " Switch Faild" ) return end
780
729
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 ))
781
730
if info ~= " " then
@@ -1081,17 +1030,14 @@ function action_status()
1081
1030
db_forward_ssl = db_foward_ssl (),
1082
1031
web = is_web (),
1083
1032
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" ;
1086
1034
})
1087
1035
end
1088
1036
1089
1037
function action_state ()
1090
1038
luci .http .prepare_content (" application/json" )
1091
1039
luci .http .write_json ({
1092
1040
lhie1 = lhie1 (),
1093
- ConnersHua = ConnersHua (),
1094
- ConnersHua_return = ConnersHua_return (),
1095
1041
ipdb = ipdb (),
1096
1042
geosite = geosite (),
1097
1043
historychecktime = historychecktime (),
@@ -1117,8 +1063,6 @@ end
1117
1063
function action_update ()
1118
1064
luci .http .prepare_content (" application/json" )
1119
1065
luci .http .write_json ({
1120
- corecv = corecv (),
1121
- coretuncv = coretuncv (),
1122
1066
coremetacv = coremetacv (),
1123
1067
coremodel = coremodel (),
1124
1068
opcv = opcv (),
@@ -1198,20 +1142,6 @@ function action_download_rule()
1198
1142
})
1199
1143
end
1200
1144
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
-
1215
1145
function action_refresh_log ()
1216
1146
luci .http .prepare_content (" application/json" )
1217
1147
local logfile = " /tmp/openclash.log"
@@ -1326,38 +1256,6 @@ function split(str,delimiter)
1326
1256
return arr
1327
1257
end
1328
1258
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
-
1361
1259
function action_diag_connection ()
1362
1260
local addr = luci .http .formvalue (" addr" )
1363
1261
if addr and (datatype .hostname (addr ) or datatype .ipaddr (addr )) then
@@ -1425,8 +1323,8 @@ function action_backup()
1425
1323
local reader = ltn12_popen (" tar -C '/etc/openclash/' -cz . 2>/dev/null" )
1426
1324
1427
1325
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" )
1430
1328
})
1431
1329
1432
1330
luci .http .prepare_content (" application/x-targz" )
@@ -1439,8 +1337,8 @@ function action_backup_ex_core()
1439
1337
local reader = ltn12_popen (" echo 'core' > /tmp/oc_exclude.txt && tar -C '/etc/openclash/' -X '/tmp/oc_exclude.txt' -cz . 2>/dev/null" )
1440
1338
1441
1339
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" )
1444
1342
})
1445
1343
1446
1344
luci .http .prepare_content (" application/x-targz" )
@@ -1452,8 +1350,8 @@ function action_backup_only_config()
1452
1350
local reader = ltn12_popen (" tar -C '/etc/openclash' -cz './config' 2>/dev/null" )
1453
1351
1454
1352
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" )
1457
1355
})
1458
1356
1459
1357
luci .http .prepare_content (" application/x-targz" )
@@ -1464,8 +1362,8 @@ function action_backup_only_core()
1464
1362
local reader = ltn12_popen (" tar -C '/etc/openclash' -cz './core' 2>/dev/null" )
1465
1363
1466
1364
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" )
1469
1367
})
1470
1368
1471
1369
luci .http .prepare_content (" application/x-targz" )
@@ -1476,8 +1374,8 @@ function action_backup_only_rule()
1476
1374
local reader = ltn12_popen (" tar -C '/etc/openclash' -cz './rule_provider' 2>/dev/null" )
1477
1375
1478
1376
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" )
1481
1379
})
1482
1380
1483
1381
luci .http .prepare_content (" application/x-targz" )
@@ -1488,8 +1386,8 @@ function action_backup_only_proxy()
1488
1386
local reader = ltn12_popen (" tar -C '/etc/openclash' -cz './proxy_provider' 2>/dev/null" )
1489
1387
1490
1388
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" )
1493
1391
})
1494
1392
1495
1393
luci .http .prepare_content (" application/x-targz" )
0 commit comments