Skip to content

Commit f9cc20c

Browse files
committed
Merge branch 'dev'
2 parents 5c6b112 + 468f9a4 commit f9cc20c

File tree

109 files changed

+86976
-113976
lines changed

Some content is hidden

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

109 files changed

+86976
-113976
lines changed

.github/workflows/compile_dev_core.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name: Compile The New Clash Dev Core
33

44
on:
5-
schedule:
6-
- cron: "0 19 * * 1,3,5,6"
5+
#schedule:
6+
# - cron: "0 19 * * 1,3,5,6"
77
workflow_dispatch:
88

99
jobs:

.github/workflows/compile_meta_core.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
111111
- name: Setup loongarch abi1 Go
112112
run: |
113-
wget -q https://github.com/xishang0128/loongarch64-golang/releases/download/1.21.5/go1.21.5.linux-amd64-abi1.tar.gz
113+
wget -q https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.22.4/go1.22.4.linux-amd64-abi1.tar.gz
114114
sudo tar zxf go1.21.5.linux-amd64-abi1.tar.gz -C /usr/local
115115
echo "/usr/local/go/bin" >> $GITHUB_PATH
116116
@@ -126,7 +126,7 @@ jobs:
126126
127127
- name: Setup loongarch abi2 Go
128128
run: |
129-
wget -q https://github.com/xishang0128/loongarch64-golang/releases/download/1.21.5/go1.21.5.linux-amd64-abi2.tar.gz
129+
wget -q https://github.com/MetaCubeX/loongarch64-golang/releases/download/1.22.4/go1.22.4.linux-amd64-abi2.tar.gz
130130
sudo tar zxf go1.21.5.linux-amd64-abi2.tar.gz -C /usr/local
131131
132132
- name: Compile Meta loongarch abi2 Clash

.github/workflows/compile_premium_core.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name: Compile The New Clash Premium Core
33

44
on:
5-
schedule:
6-
- cron: "0 21 * * 1,3,5"
5+
#schedule:
6+
# - cron: "0 21 * * 1,3,5"
77
workflow_dispatch:
88

99
jobs:

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 vernesong
3+
Copyright (c) 2019-2024 vernesong
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

luci-app-openclash/Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=luci-app-openclash
4-
PKG_VERSION:=0.46.014
4+
PKG_VERSION:=0.46.031
55
PKG_RELEASE:=beta
66
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>
77

@@ -64,7 +64,6 @@ define Build/Prepare
6464
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_domain_dns.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_domain_dns.list" >/dev/null 2>&1
6565
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_domain_dns_policy.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_domain_dns_policy.list" >/dev/null 2>&1
6666
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_fallback_filter.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_fallback_filter.yaml" >/dev/null 2>&1
67-
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_netflix_domains.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_netflix_domains.list" >/dev/null 2>&1
6867
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_force_sniffing_domain.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_force_sniffing_domain.yaml" >/dev/null 2>&1
6968
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_sniffing_domain_filter.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_sniffing_domain_filter.yaml" >/dev/null 2>&1
7069
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_sniffing_ports_filter.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_sniffing_ports_filter.yaml" >/dev/null 2>&1
@@ -132,11 +131,9 @@ define Package/$(PKG_NAME)/postrm
132131
rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1
133132
rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_chnroute_pass.conf >/dev/null 2>&1
134133
rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_chnroute6_pass.conf >/dev/null 2>&1
135-
rm -rf ${dnsmasqconfdir}/dnsmasq_accelerated-domains.china.conf >/dev/null 2>&1
136134
rm -rf /tmp/dler* >/dev/null 2>&1
137135
rm -rf /tmp/etc/openclash >/dev/null 2>&1
138136
rm -rf /tmp/openclash_edit_file_name >/dev/null 2>&1
139-
rm -rf /tmp/openclash_*_region>/dev/null 2>&1
140137
sed -i '/OpenClash Append/,/OpenClash Append End/d' "/usr/lib/lua/luci/model/network.lua" >/dev/null 2>&1
141138
sed -i '/.*kB maximum content size*/c\HTTP_MAX_CONTENT = 1024*100 -- 100 kB maximum content size' /usr/lib/lua/luci/http.lua >/dev/null 2>&1
142139
sed -i '/.*kB maximum content size*/c\export let HTTP_MAX_CONTENT = 1024*100; // 100 kB maximum content size' /usr/share/ucode/luci/http.uc >/dev/null 2>&1

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

+19-121
Original file line numberDiff line numberDiff line change
@@ -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"
10399
local uci = require("luci.model.uci").cursor()
104100
local datatype = require "luci.cbi.datatypes"
105101
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+
106105
if pcall(require, "luci.model.ipkg") then
107106
opkg = require "luci.model.ipkg"
108107
end
109108

110109
local core_path_mode = uci:get("openclash", "config", "small_flash_memory")
111110
if 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"
115112
else
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"
119114
end
120115

@@ -126,10 +121,6 @@ local function is_web()
126121
return luci.sys.call("pidof clash >/dev/null") == 0
127122
end
128123

129-
local function restricted_mode()
130-
return uci:get("openclash", "config", "restricted_mode")
131-
end
132-
133124
local function is_watchdog()
134125
return process_status("openclash_watchdog.sh")
135126
end
@@ -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"))
159150
end
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-
169152
local function chnroute()
170153
return os.date("%Y-%m-%d %H:%M:%S",fs.mtime("/etc/openclash/china_ip_route.ipset"))
171154
end
@@ -238,29 +221,13 @@ local function coremodel()
238221
end
239222

240223
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
242225
return "0"
243226
else
244227
return "1"
245228
end
246229
end
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-
264231
local function coremetacv()
265232
if not nixio.fs.access(meta_core_path) then
266233
return "0"
@@ -271,10 +238,8 @@ end
271238

272239
local 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
278243
end
279244

280245
local 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
373334
end
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-
385336
function 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
})
10871035
end
10881036

10891037
function 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
11171063
function 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
})
11991143
end
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-
12151145
function 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
13271257
end
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-
13611259
function 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

Comments
 (0)