Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed Nov 9, 2024
2 parents fc741a8 + 870478a commit 1d0e744
Show file tree
Hide file tree
Showing 161 changed files with 31,505 additions and 58,533 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compile_meta_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.23"
check-latest: true

- name: Clone Clash Meta Repository
Expand Down
17 changes: 12 additions & 5 deletions luci-app-openclash/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-openclash
PKG_VERSION:=0.46.033
PKG_VERSION:=0.46.050
PKG_RELEASE:=beta
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>

Expand All @@ -27,14 +27,23 @@ define Package/$(PKG_NAME)/config

config PACKAGE_iptables-mod-extra
default y if ! PACKAGE_firewall4

config PACKAGE_dnsmasq_full_ipset
default y if ! PACKAGE_firewall4

config PACKAGE_dnsmasq_full_nftset
default y if PACKAGE_firewall4

config PACKAGE_ipset
default y if ! PACKAGE_firewall4
endef

define Package/$(PKG_NAME)
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI support for clash
PKGARCH:=all
DEPENDS:=+dnsmasq-full +coreutils +coreutils-nohup +bash +curl +ca-certificates +ipset +ip-full \
DEPENDS:=+dnsmasq-full +coreutils +coreutils-nohup +bash +curl +ca-certificates +ip-full \
+libcap +libcap-bin +ruby +ruby-yaml +kmod-tun +unzip
MAINTAINER:=vernesong
endef
Expand Down Expand Up @@ -64,9 +73,7 @@ define Build/Prepare
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
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
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
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
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
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
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_sniffer.yaml" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_sniffer.yaml" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_localnetwork_ipv4.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_localnetwork_ipv4.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_localnetwork_ipv6.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_localnetwork_ipv6.list" >/dev/null 2>&1
cp -f "$(PKG_BUILD_DIR)/root/etc/openclash/custom/openclash_custom_chnroute_pass.list" "$(PKG_BUILD_DIR)/root/usr/share/openclash/backup/openclash_custom_chnroute_pass.list" >/dev/null 2>&1
Expand Down
8 changes: 2 additions & 6 deletions luci-app-openclash/luasrc/controller/openclash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -830,23 +830,19 @@ end

function action_toolbar_show_sys()
local pid = luci.sys.exec("pidof clash |head -1 |tr -d '\n' 2>/dev/null")
local mem, cpu
local cpu
if pid and pid ~= "" then
mem = tonumber(luci.sys.exec(string.format("cat /proc/%s/status 2>/dev/null |grep -w VmRSS |awk '{print $2}'", pid)))
cpu = luci.sys.exec(string.format("top -b -n1 |grep -E '%s' 2>/dev/null |grep -v grep |awk '{for (i=1;i<=NF;i++) {if ($i ~ /clash/) break; else cpu=i}}; {print $cpu}' 2>/dev/null", pid))
if mem and cpu then
mem = fs.filesize(mem*1024) or "0 KB"
if cpu then
cpu = string.match(cpu, "%d+") or "0"
else
mem = "0 KB"
cpu = "0"
end
else
return
end
luci.http.prepare_content("application/json")
luci.http.write_json({
mem = mem,
cpu = cpu;
})
end
Expand Down
8 changes: 4 additions & 4 deletions luci-app-openclash/luasrc/model/cbi/openclash/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ for t,o in ipairs(fs.glob("/etc/openclash/config/*"))do
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
end
if uci:get("openclash", "config", "config_path") and string.sub(uci:get("openclash", "config", "config_path"), 23, -1) == e[t].name then
e[t].state=translate("Enable")
e[t].state=translate("Enabled")
else
e[t].state=translate("Disable")
e[t].state=translate("Disabled")
end
e[t].check=translate(config_check(o))
end
Expand All @@ -75,7 +75,7 @@ if a then
ck.template="openclash/cfg_check"
sb.template="openclash/sub_info_show"

btnis=tb:option(Button,"switch",translate("Switch Config"))
btnis=tb:option(Button,"switch",translate("Switch"))
btnis.template="openclash/other_button"
btnis.render=function(o,t,a)
if not e[t] then return false end
Expand Down Expand Up @@ -172,4 +172,4 @@ if uci:get("openclash", "config", "dler_token") then
return m, dler, form, s, ap, d
else
return m, form, s, ap, d
end
end
74 changes: 13 additions & 61 deletions luci-app-openclash/luasrc/model/cbi/openclash/config-overwrite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ if not lan_ip or lan_ip == "" then
end
m = Map("openclash", translate("Overwrite Settings"))
m.pageaction = false
m.description = translate("Note: To restore the default configuration, try accessing:").." <a href='javascript:void(0)' onclick='javascript:restore_config(this)'>http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore</a>"
m.description = translate("Note: To restore the default configuration, try accessing:").." <a href='javascript:void(0)' onclick='javascript:restore_config(this)'>http://"..lan_ip.."/cgi-bin/luci/admin/services/openclash/restore</a>"..
"<br/>"..font_green..translate("For More Useful Meta Core Functions Go Wiki")..": "..font_off.."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://wiki.metacubex.one/\")'>"..translate("https://wiki.metacubex.one/").."</a>"

s = m:section(TypedSection, "openclash")
s.anonymous = true
Expand Down Expand Up @@ -147,7 +148,7 @@ o = s:taboption("dns", Flag, "enable_custom_dns", font_red..bold_on..translate("
o.description = font_red..bold_on..translate("Set OpenClash Upstream DNS Resolve Server")..bold_off..font_off
o.default = 0

o = s:taboption("dns", Flag, "enable_respect_rules", font_red..bold_on..translate("Respect Rules")..bold_off..font_off)
o = s:taboption("dns", Flag, "enable_respect_rules", font_red..bold_on..translate("Respect Rules").."(respect-rules)"..bold_off..font_off)
o.description = font_red..bold_on..translate("Whether or not The Connection to the DNS Server Follow the Rules in Config")..bold_off..font_off
o.default = 0

Expand Down Expand Up @@ -292,14 +293,6 @@ o = s:taboption("meta", Flag, "enable_unified_delay", font_red..bold_on..transla
o.description = font_red..bold_on..translate("Change The Delay Calculation Method To Remove Extra Delays Such as Handshaking")..bold_off..font_off
o.default = "0"

o = s:taboption("meta", ListValue, "keep_alive_interval", font_red..bold_on..translate("TCP Keep-alive Interval(s)")..bold_off..font_off)
o.description = font_red..bold_on..translate("Change The TCP Keep-alive Interval, Selecting a Larger Value Avoids Abnormal Resource Consumption")..bold_off..font_off
o:value("0", translate("Disable"))
o:value("15")
o:value("1800")
o:value("3600")
o.default = "0"

o = s:taboption("meta", ListValue, "find_process_mode", translate("Enable Process Rule"))
o.description = translate("Whether to Enable Process Rules, If You Are Not Sure, Please Choose off Which Useful in Router Environment")
o:value("0", translate("Disable"))
Expand Down Expand Up @@ -347,62 +340,21 @@ o.description = translate("Custom The Force and Skip Sniffing Doamin Lists")
o.default = 0
o:depends("enable_meta_sniffer", "1")

sniffing_domain_force = s:taboption("meta", Value, "sniffing_domain_force")
sniffing_domain_force:depends("enable_meta_sniffer_custom", "1")
sniffing_domain_force.template = "cbi/tvalue"
sniffing_domain_force.description = translate("Will Override Dns Queries If Domains in The List")
sniffing_domain_force.rows = 20
sniffing_domain_force.wrap = "off"

function sniffing_domain_force.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_force_sniffing_domain.yaml") or ""
end
function sniffing_domain_force.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_force_sniffing_domain.yaml")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_force_sniffing_domain.yaml", value)
end
end
end

sniffing_port_filter = s:taboption("meta", Value, "sniffing_port_filter")
sniffing_port_filter:depends("enable_meta_sniffer_custom", "1")
sniffing_port_filter.template = "cbi/tvalue"
sniffing_port_filter.description = translate("Will Only Sniffing If Ports in The List")
sniffing_port_filter.rows = 20
sniffing_port_filter.wrap = "off"

function sniffing_port_filter.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_sniffing_ports_filter.yaml") or ""
end
function sniffing_port_filter.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_sniffing_ports_filter.yaml")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_sniffing_ports_filter.yaml", value)
end
end
end

sniffing_domain_filter = s:taboption("meta", Value, "sniffing_domain_filter")
sniffing_domain_filter:depends("enable_meta_sniffer_custom", "1")
sniffing_domain_filter.template = "cbi/tvalue"
sniffing_domain_filter.description = translate("Will Disable Sniffing If Domains(sni) in The List")
sniffing_domain_filter.rows = 20
sniffing_domain_filter.wrap = "off"
sniffer_custom = s:taboption("meta", Value, "sniffer_custom")
sniffer_custom:depends("enable_meta_sniffer_custom", "1")
sniffer_custom.template = "cbi/tvalue"
sniffer_custom.rows = 20
sniffer_custom.wrap = "off"

function sniffing_domain_filter.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_sniffing_domain_filter.yaml") or ""
function sniffer_custom.cfgvalue(self, section)
return NXFS.readfile("/etc/openclash/custom/openclash_custom_sniffer.yaml") or ""
end
function sniffing_domain_filter.write(self, section, value)
function sniffer_custom.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_sniffing_domain_filter.yaml")
local old_value = NXFS.readfile("/etc/openclash/custom/openclash_custom_sniffer.yaml")
if value ~= old_value then
NXFS.writefile("/etc/openclash/custom/openclash_sniffing_domain_filter.yaml", value)
NXFS.writefile("/etc/openclash/custom/openclash_custom_sniffer.yaml", value)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ o = a:option(Button, "Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
fs.unlink("/tmp/Proxy_Group")
m.uci:commit("openclash")
end

o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Update Config")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
fs.unlink("/tmp/Proxy_Group")
m.uci:set("openclash", "config", "enable", 1)
m.uci:commit("openclash")
uci:foreach("openclash", "config_subscribe",
Expand Down
6 changes: 3 additions & 3 deletions luci-app-openclash/luasrc/model/cbi/openclash/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ else
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
end
if uci:get("openclash", "config", "config_path") and string.sub(uci:get("openclash", "config", "config_path"), 23, -1) == e[t].name then
e[t].state=translate("Enable")
e[t].state=translate("Enabled")
else
e[t].state=translate("Disable")
e[t].state=translate("Disabled")
end
e[t].size=fs.filesize(a.size)
e[t].check=translate(config_check(o))
Expand All @@ -201,7 +201,7 @@ st.template="openclash/cfg_check"
ck.template="openclash/cfg_check"
sb.template="openclash/sub_info_show"

btnis=tb:option(Button,"switch",translate("Switch Config"))
btnis=tb:option(Button,"switch",translate("Switch"))
btnis.template="openclash/other_button"
btnis.render=function(o,t,a)
if not e[t] then return false end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ o.rempty = false

---- interface
o = s:option(Value, "interface", translate("Specific Interface"))
o.description = translate("DNS Lookup Only Through The Specific Interface")..translate("(Only TUN Core)")
o.description = translate("DNS Lookup Only Through The Specific Interface")
local interfaces = SYS.exec("ls -l /sys/class/net/ 2>/dev/null |awk '{print $9}' 2>/dev/null")
for interface in string.gmatch(interfaces, "%S+") do
o:value(interface)
Expand All @@ -68,6 +68,11 @@ o:value("Disable", translate("Disable"))
o.default = "Disable"
o.rempty = false

---- direct-nameserver
o = s:option(Flag, "direct_nameserver", translate("Direct Nameserver"), translate("Use For Domain Need Direct")..translate("(Only Meta Core)"))
o.rmempty = false
o.default = o.disbled

---- Node Domain Resolve
o = s:option(Flag, "node_resolve", translate("Node Domain Resolve"), translate("Use For Node Domain Resolve")..translate("(Only Meta Core)"))
o.rmempty = false
Expand All @@ -79,6 +84,12 @@ o:depends("type", "https")
o.rmempty = false
o.default = o.disbled

---- Skip-cert-verify
o = s:option(Flag, "skip_cert_verify", translate("skip-cert-verify"), translate("skip-cert-verify")..translate("(Only Meta Core)"))
o:depends("type", "https")
o.rmempty = false
o.default = o.disbled

---- ECS Subnet
o = s:option(Value, "ecs_subnet", translate("ECS Subnet"),translate("Specify the ECS Subnet Address")..translate("(Only Meta Core)"))
o:depends("type", "https")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ end
o:value("DIRECT")
o:value("REJECT")

o = s:option(ListValue, "OpenAI", translate("OpenAI"))
o = s:option(ListValue, "AI_Suite", translate("AI Suite"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
Expand Down Expand Up @@ -407,24 +407,24 @@ o:value("REJECT")
end

local t = {
{Commit, Back}
{Commit, Back}
}
a = m:section(Table, t)

o = a:option(Button,"Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
m.uci:commit(openclash)
--luci.http.redirect(m.redirect)
m.uci:commit(openclash)
--luci.http.redirect(m.redirect)
end

o = a:option(Button,"Back", " ")
o.inputtitle = translate("Back Settings")
o.inputstyle = "reset"
o.write = function()
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
m.uci:revert(openclash, sid)
luci.http.redirect(m.redirect)
end

m:append(Template("openclash/toolbar_show"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ return r
end

local t = {
{Refresh, Create, Delete_all, Apply}
{Refresh, Create, Delete_all, Apply}
}

a = proxy_form:section(Table, t)
Expand Down
10 changes: 2 additions & 8 deletions luci-app-openclash/luasrc/model/cbi/openclash/servers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ o = a:option(Button,"Load_Config", " ")
o.inputtitle = translate("Read Config")
o.inputstyle = "apply"
o.write = function()
m.uci:set("openclash", "config", "enable", 0)
m.uci:commit("openclash")
luci.sys.call("/usr/share/openclash/yml_groups_get.sh 2>/dev/null &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash"))
end
Expand All @@ -265,18 +263,14 @@ o = a:option(Button, "Commit", " ")
o.inputtitle = translate("Commit Settings")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
m.uci:set("openclash", "config", "enable", 0)
m.uci:commit("openclash")
fs.unlink("/tmp/Proxy_Group")
end

o = a:option(Button, "Apply", " ")
o.inputtitle = translate("Apply Settings")
o.inputstyle = "apply"
o.write = function()
fs.unlink("/tmp/Proxy_Group")
m.uci:set("openclash", "config", "enable", 0)
m.uci:commit("openclash")
fs.unlink("/tmp/Proxy_Group")
luci.sys.call("/usr/share/openclash/yml_groups_set.sh >/dev/null 2>&1 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "openclash"))
end
Expand Down
3 changes: 3 additions & 0 deletions luci-app-openclash/luasrc/model/cbi/openclash/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1101,13 +1101,16 @@ o = s:taboption("ipv6", ListValue, "ipv6_mode", translate("IPv6 Proxy Mode"))
o:value("0", translate("TProxy Mode"))
o:value("1", translate("Redirect Mode"))
o:value("2", translate("TUN Mode")..translate("(Only Meta Core)"))
o:value("3", translate("Mix Mode")..translate("(Only Meta Core)"))
o.default = "0"
o:depends("ipv6_enable", "1")

o = s:taboption("ipv6", ListValue, "stack_type_v6", translate("Select Stack Type"))
o.description = translate("Select Stack Type For TUN Mode, According To The Running Speed on Your Machine")
o:depends({ipv6_mode= "2", en_mode = "redir-host"})
o:depends({ipv6_mode= "2", en_mode = "fake-ip"})
o:depends({ipv6_mode= "3", en_mode = "redir-host"})
o:depends({ipv6_mode= "3", en_mode = "fake-ip"})
o:value("system", translate("System "))
o:value("gvisor", translate("gVisor"))
o:value("mixed", translate("Mixed")..translate("(Only Meta Core)"))
Expand Down
2 changes: 1 addition & 1 deletion luci-app-openclash/luasrc/view/openclash/cfg_check.htm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div>
<%
local val = self:cfgvalue(section)
if val == translate("Enable") or val == translate("Config Normal") or val == translate("Exist") then
if val == translate("Enable") or val == translate("Enabled") or val == translate("Config Normal") or val == translate("Exist") then
%>
<div style="color: green; font-weight:bold;">
<%
Expand Down
Loading

0 comments on commit 1d0e744

Please sign in to comment.