Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed Feb 15, 2025
2 parents 2cb62f3 + 582e294 commit 39a3dbb
Show file tree
Hide file tree
Showing 74 changed files with 12,989 additions and 11,828 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/clear_cache.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Clean jsDelivr Cache

on:
# push
# https://github.com/qinxs/cdn-assets
push:
branches:
- master
Expand All @@ -18,19 +16,26 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Apt Update
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get -y install jq
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/git-changesets
- id: changed_files
name: git-changesets
uses: collin-miller/git-changesets@v0.0.4
uses: collin-miller/git-changesets@v1
with:
# Default format is 'csv'. Other valid options are 'space-delimited' and 'json'.
format: space-delimited
format: json

- name: Clean jsDelivr Cache
run: |
for i in ${{ steps.changed_files.outputs.added_modified }}; do
# echo ${{ steps.changed_files.outputs.all }}
curl -sL --retry 3 https://purge.jsdelivr.net/gh/vernesong/OpenClash@${{ github.ref_name }}/$i
done
echo '${{ steps.changed_files.outputs.added_modified }}' | jq -r '.[]' | while read file; do
# echo ${{ steps.changed_files.outputs.all }}
curl -sL --retry 3 "https://purge.jsdelivr.net/gh/vernesong/OpenClash@${{ github.ref_name }}/${file}"
done
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.23"
go-version: "1.24"
check-latest: true

- name: Clone Clash Meta Repository
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@
* luci
* luci-base
* dnsmasq-full
* coreutils
* coreutils-nohup
* bash
* curl
* ca-certificates
* ca-bundle
* ipset
* ip-full
* libcap
* libcap-bin
* ruby
* ruby-yaml
* unzip
Expand Down
10 changes: 5 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.064
PKG_VERSION:=0.46.075
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
Expand Down Expand Up @@ -42,8 +42,8 @@ define Package/$(PKG_NAME)
SUBMENU:=3. Applications
TITLE:=LuCI support for clash
PKGARCH:=all
DEPENDS:=+dnsmasq-full +coreutils +coreutils-nohup +bash +curl +ca-certificates +ip-full \
+libcap +libcap-bin +ruby +ruby-yaml +kmod-tun +unzip
DEPENDS:=+dnsmasq-full +bash +curl +ca-bundle +ip-full \
+ruby +ruby-yaml +kmod-tun +unzip
MAINTAINER:=vernesong
endef

Expand Down Expand Up @@ -122,9 +122,9 @@ endef

define Package/$(PKG_NAME)/postrm
#!/bin/sh
DEFAULT_DNSMASQ_CFGID="$$(uci -q show "dhcp.@dnsmasq[0]" | awk 'NR==1 {split($0, conf, /[.=]/); print conf[2]}')"
DEFAULT_DNSMASQ_CFGID="$$(uci -q show "dhcp.@dnsmasq[0]" | awk 'NR==1 {split($0, conf, /[.=]/); print conf[2]}' 2>/dev/null)"
if [ -f "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID" ]; then
DNSMASQ_CONF_DIR="$$(awk -F '=' '/^conf-dir=/ {print $2}' "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID")"
DNSMASQ_CONF_DIR="$$(awk -F '=' '/^conf-dir=/ {print $2}' "/tmp/etc/dnsmasq.conf.$DEFAULT_DNSMASQ_CFGID" 2>/dev/null)"
else
DNSMASQ_CONF_DIR="/tmp/dnsmasq.d"
fi
Expand Down
16 changes: 12 additions & 4 deletions luci-app-openclash/luasrc/controller/openclash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function index()
entry({"admin", "services", "openclash", "opupdate"},call("action_opupdate"))
entry({"admin", "services", "openclash", "coreupdate"},call("action_coreupdate"))
entry({"admin", "services", "openclash", "flush_fakeip_cache"}, call("action_flush_fakeip_cache"))
entry({"admin", "services", "openclash", "update_config"}, call("action_update_config"))
entry({"admin", "services", "openclash", "download_rule"}, call("action_download_rule"))
entry({"admin", "services", "openclash", "restore"}, call("action_restore_config"))
entry({"admin", "services", "openclash", "backup"}, call("action_backup"))
Expand Down Expand Up @@ -252,7 +253,7 @@ local function opcv()
if fs.access("/bin/opkg") then
return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print \"v\"$2}'")
elseif fs.access("/usr/bin/apk") then
return "v" .. luci.sys.exec("apk list luci-app-openclash 2>/dev/null |grep 'installed' | grep -oE '\\d+(\\.\\d+)*' | head -1")
return "v" .. luci.sys.exec("apk list luci-app-openclash 2>/dev/null|grep 'installed' | grep -oE '[0-9]+(\\.[0-9]+)*' | head -1")
end
end
end
Expand Down Expand Up @@ -347,14 +348,19 @@ function action_flush_fakeip_cache()
local dase = dase() or ""
local cn_port = cn_port()
if not daip or not cn_port then return end
state = luci.sys.exec(string.format('curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XPOST http://"%s":"%s"/cache/fakeip/flush', dase, daip, cn_port))
end
luci.http.prepare_content("application/json")
state = luci.sys.exec(string.format('curl -sL -m 3 -H "Content-Type: application/json" -H "Authorization: Bearer %s" -XPOST http://"%s":"%s"/cache/fakeip/flush', dase, daip, cn_port))
end
luci.http.prepare_content("application/json")
luci.http.write_json({
flush_status = state;
})
end

function action_update_config()
local filename = luci.http.formvalue("filename") or "config"
luci.sys.exec(string.format("/usr/share/openclash/openclash.sh '%s' >/dev/null 2>&1 &", filename))
end

function action_restore_config()
uci:set("openclash", "config", "enable", "0")
uci:commit("openclash")
Expand All @@ -364,6 +370,8 @@ function action_restore_config()
luci.sys.call("cp /usr/share/openclash/backup/openclash_force_sniffing* /etc/openclash/custom/ >/dev/null 2>&1 &")
luci.sys.call("cp /usr/share/openclash/backup/openclash_sniffing* /etc/openclash/custom/ >/dev/null 2>&1 &")
luci.sys.call("cp /usr/share/openclash/backup/yml_change.sh /usr/share/openclash/yml_change.sh >/dev/null 2>&1 &")
luci.sys.call("cp /usr/share/openclash/backup/china_ip_route.ipset /etc/openclash/china_ip_route.ipset >/dev/null 2>&1 &")
luci.sys.call("cp /usr/share/openclash/backup/china_ip6_route.ipset /etc/openclash/china_ip6_route.ipset >/dev/null 2>&1 &")
luci.sys.call("rm -rf /etc/openclash/history/* >/dev/null 2>&1 &")
end

Expand Down
25 changes: 20 additions & 5 deletions luci-app-openclash/luasrc/model/cbi/openclash/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ if a then
btnis.template="openclash/other_button"
btnis.render=function(o,t,a)
if not e[t] then return false end
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
a.display=""
else
a.display="none"
end
if IsYamlFile(e[t].name) or IsYmlFile(e[t].name) then
a.display=""
else
a.display="none"
end
o.inputstyle="apply"
Button.render(o,t,a)
end
Expand All @@ -95,6 +95,20 @@ if a then
SYS.call("/etc/init.d/openclash restart >/dev/null 2>&1 &")
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "openclash", "client"))
end

up=tb:option(DummyValue, "name", translate("Update"))
up.template = "openclash/update_config"
up.render = function(o,t,a)
local display = "none"
uci:foreach("openclash", "config_subscribe",
function(s)
if s.name == fs.filename(e[t].name) then
display = ""
end
end)
o.display = display
DummyValue.render(o,t,a)
end
end

if not a then
Expand Down Expand Up @@ -152,6 +166,7 @@ o.inputstyle = "reset"
o.write = function()
uci:set("openclash", "config", "enable", 0)
uci:commit("openclash")
SYS.call("ps | grep openclash | grep -v grep | awk '{print $1}' | xargs -r kill -9 >/dev/null 2>&1")
SYS.call("/etc/init.d/openclash stop >/dev/null 2>&1 &")
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ o.description = font_red..bold_on..translate("Change The Delay Calculation Metho
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.description = translate("Whether to Enable Process Rules, Only Works on Routerself, If You Are Not Sure, Please Choose off Which Useful in Router Environment, Depend on kmod-inet-diag")
o:value("0", translate("Disable"))
o:value("off", translate("OFF "))
o:value("always", translate("Always "))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ o:depends("sub_convert", "1")

---- custom params
o = s:option(DynamicList, "custom_params", translate("Custom Params"))
o.description = font_red..bold_on..translate("eg: \"rename=\\s+([2-9])[xX]@ (HIGH:$1)\"")..bold_off..font_off
o.description = font_red..bold_on..translate("eg: \"rename=match@replace\" , \"rename=\\s+([2-9])[xX]@ (HIGH:$1)\"")..bold_off..font_off
o.rmempty = false
o:depends("sub_convert", "1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ function o.cfgvalue(...)
end
end

---- update
o = s:option(DummyValue, "name", translate("Update"))
o.template = "openclash/update_config"

local t = {
{Commit, Apply}
}
Expand Down
2 changes: 1 addition & 1 deletion luci-app-openclash/luasrc/model/cbi/openclash/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ btnrn.template="openclash/input_rename"
btnrn.rawhtml = true
btnrn.render=function(c,t,a)
c.value = e[t].name
Button.render(c,t,a)
DummyValue.render(c,t,a)
end

btndl = tb:option(Button,"download",translate("Download Config"))
Expand Down
10 changes: 0 additions & 10 deletions luci-app-openclash/luasrc/model/cbi/openclash/groups-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ o = s:option(Value, "policy_filter", translate("Provider Filter"))
o.rmempty = true
o.placeholder = "bgp|sg"

-- [[ interface-name ]]--
o = s:option(Value, "interface_name", translate("interface-name"))
o.rmempty = true
o.placeholder = translate("eth0")

-- [[ routing-mark ]]--
o = s:option(Value, "routing_mark", translate("routing-mark"))
o.rmempty = true
o.placeholder = translate("2333")

o = s:option(DynamicList, "other_group", translate("Other Group (Support Regex)"))
o.description = font_red..bold_on..translate("The Added Proxy Groups Must Exist Except 'DIRECT' & 'REJECT'")..bold_off..font_off
o:value("all", translate("All Groups"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ o.rmempty = true
o.description = translate("Choose The Provider Type")
o:value("http")
o:value("file")
o:value("inline")

o = s:option(Value, "name", translate("Provider Name"))
o.rmempty = false
Expand Down Expand Up @@ -134,7 +135,16 @@ function o.cfgvalue(self, section)
"# proxy-name:\n"..
"# - pattern: \"IPLC-(.*?)倍\"\n"..
"# target: \"iplc x $1\"\n"..
"# exclude-type: \"ss|http\""
"# exclude-type: \"ss|http\"\n"..
"\n"..
"# inline Example:\n"..
"# payload:\n"..
"# - name: \"ss1\"\n"..
"# type: ss\n"..
"# server: server\n"..
"# port: 443\n"..
"# cipher: chacha20-ietf-poly1305\n"..
"# password: \"password\""
else
return Value.cfgvalue(self, section)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,25 @@ o.default = "Rule-provider - "..sid
o = s:option(ListValue, "type", translate("Rule Providers Type"))
o.rmempty = true
o.description = translate("Choose The Rule Providers Type")
o:value("http", translate("http"))
o:value("file", translate("file"))
o:value("http")
o:value("file")
o:value("inline")

o = s:option(ListValue, "behavior", translate("Rule Behavior"))
o.rmempty = true
o.description = translate("Choose The Rule Behavior")
o:value("domain")
o:value("ipcidr")
o:value("classical")

o = s:option(ListValue, "format", translate("Rule Format")..translate("(TUN&Meta Core)"))
o = s:option(ListValue, "format", translate("Rule Format"))
o.rmempty = true
o.description = translate("Choose The Rule File Format, For More Info:").." ".."<a href='javascript:void(0)' onclick='javascript:return winOpen(\"https://wiki.metacubex.one/config/rule-providers/content/\")'>https://wiki.metacubex.one/config/rule-providers/content/</a>"
o:value("yaml")
o:value("text")
o:value("mrs")
o:depends("type", "file")
o:depends("type", "http")

o = s:option(ListValue, "behavior", translate("Rule Behavior"))
o.rmempty = true
o.description = translate("Choose The Rule Behavior")
o:value("domain")
o:value("ipcidr")
o:value("classical", translate("classical").." "..translate("(Not Support mrs Format)"))

o = s:option(ListValue, "path", translate("Rule Providers Path"))
o.description = translate("Update Your Rule Providers File From Config Luci Page")
Expand Down Expand Up @@ -136,6 +139,36 @@ m.uci:foreach("openclash", "groups",
o:value("DIRECT")
o:value("REJECT")

-- [[ other-setting ]]--
o = s:option(Value, "other_parameters", translate("Other Parameters"))
o.template = "cbi/tvalue"
o.rows = 20
o.wrap = "off"
o.description = font_red..bold_on..translate("Edit Your Other Parameters Here")..bold_off..font_off
o.rmempty = true
function o.cfgvalue(self, section)
if self.map:get(section, "other_parameters") == nil then
return "# Example:\n"..
"# Only support YAML, four spaces need to be reserved at the beginning of each line to maintain formatting alignment\n"..
"# 示例:\n"..
"# 仅支持 YAML, 每行行首需要多保留四个空格以使脚本处理后能够与上方配置保持格式对齐\n"..
"# inline Example:\n"..
"# payload:\n"..
"# - '.blogger.com'\n"..
"# - '*.*.microsoft.com'\n"..
"# - 'books.itunes.apple.com'\n"
else
return Value.cfgvalue(self, section)
end
end
function o.validate(self, value)
if value then
value = value:gsub("\r\n?", "\n")
value = value:gsub("%c*$", "")
end
return value
end

local t = {
{Commit, Back}
}
Expand All @@ -159,4 +192,5 @@ o.write = function()
end

m:append(Template("openclash/toolbar_show"))
m:append(Template("openclash/config_editor"))
return m
Loading

0 comments on commit 39a3dbb

Please sign in to comment.