Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
vernesong committed Jun 10, 2024
2 parents d0141ee + 50ef8b8 commit dd5e07d
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 121 deletions.
3 changes: 1 addition & 2 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.011
PKG_VERSION:=0.46.014
PKG_RELEASE:=beta
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>

Expand Down Expand Up @@ -100,7 +100,6 @@ endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
sed -i "s/v0.00.00-beta/v$(PKG_VERSION)-beta/g" /www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1
/etc/init.d/network restart >/dev/null 2>&1 &
exit 0
endef

Expand Down
11 changes: 0 additions & 11 deletions luci-app-openclash/luasrc/model/cbi/openclash/other-rules-edit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,6 @@ end
o:value("DIRECT")
o:value("REJECT")

o = s:option(ListValue, "AntiIP", translate("Anti IP"))
o:depends("rule_name", "lhie1")
o.rmempty = true
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
if groupname ~= nil and groupname ~= "" then
o:value(groupname)
end
end
o:value("DIRECT")
o:value("REJECT")

o = s:option(ListValue, "Domestic", translate("Domestic"))
o:depends("rule_name", "lhie1")
o:depends("rule_name", "ConnersHua")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end

m = Map(openclash, translate("Edit Rule Providers"))
m.pageaction = false
m.description=translate("规则集使用介绍:https://lancellc.gitbook.io/clash/clash-config-file/rule-provider")
m.description=translate("规则集使用介绍:https://wiki.metacubex.one/config/rule-providers/content/")
m.redirect = luci.dispatcher.build_url("admin/services/openclash/rule-providers-settings")
if m.uci:get(openclash, sid) ~= "rule_providers" then
luci.http.redirect(m.redirect)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ m.description=translate("Attention:")..
"<br/>"..
"<br/>"..translate("When setting this page, if the groups is empty, please go to the <server and group management> page to add")..
"<br/>"..
"<br/>"..translate("Introduction to rule set usage: https://lancellc.gitbook.io/clash/clash-config-file/rule-provider")
"<br/>"..translate("Introduction to rule set usage: https://wiki.metacubex.one/config/rule-providers/content/")

function IsRuleFile(e)
e=e or""
Expand Down
4 changes: 2 additions & 2 deletions luci-app-openclash/luasrc/model/cbi/openclash/servers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ m.description=translate("Attention:")..
"<br/>"..translate("1. Before modifying the configuration file, please click the button below to read the configuration file")..
"<br/>"..translate("2. Proxy-providers address can be directly filled in the subscription link")..
"<br/>"..
"<br/>"..translate("Introduction to proxy usage: https://lancellc.gitbook.io/clash/clash-config-file/proxies")..
"<br/>"..translate("Introduction to proxy-provider usage: https://lancellc.gitbook.io/clash/clash-config-file/proxy-provider")
"<br/>"..translate("Introduction to proxy usage: https://wiki.metacubex.one/config/proxies/")..
"<br/>"..translate("Introduction to proxy-provider usage: https://wiki.metacubex.one/config/proxy-providers/")

s = m:section(TypedSection, "openclash")
s.anonymous = true
Expand Down
73 changes: 69 additions & 4 deletions luci-app-openclash/luasrc/view/openclash/select_git_cdn.htm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@

<body>
<div id="selectPopup" class="select-popup hidden">
<table width="100%"><tr>
<td width="25%" align="center"><%:Compiled Version Selected (Auto-save when you click to update or download)%></td>
<td width="25%" align="center"><select id="CORE_VERSION_CDN">
<option value="linux-386"><%:linux-386%></option>
<option value="linux-amd64"><%:linux-amd64(x86-64)%></option>
<option value="linux-amd64-v3"><%:linux-amd64-v3(x86-64)%></option>
<option value="linux-armv5"><%:linux-armv5%></option>
<option value="linux-armv6"><%:linux-armv6%></option>
<option value="linux-armv7"><%:linux-armv7%></option>
<option value="linux-arm64"><%:linux-arm64(armv8)%></option>
<option value="linux-loong64-abi1"><%:linux-loong64-abi1%></option>
<option value="linux-loong64-abi2"><%:linux-loong64-abi2%></option>
<option value="linux-riscv64"><%:linux-riscv64%></option>
<option value="linux-s390x"><%:linux-s390x%></option>
<option value="linux-mips-hardfloat"><%:linux-mips-hardfloat%></option>
<option value="linux-mips-softfloat"><%:linux-mips-softfloat%></option>
<option value="linux-mips64"><%:linux-mips64%></option>
<option value="linux-mips64le"><%:linux-mips64le%></option>
<option value="linux-mipsle-softfloat"><%:linux-mipsle-softfloat%></option>
<option value="linux-mipsle-hardfloat"><%:linux-mipsle-hardfloat%></option>
<option value="0"><%:Not Set%></option>
</select></td>
<td width="25%" align="center"><%:Release Branch Selected (Auto-save when you click to update or download)%></td>
<td width="25%" align="center"><select id="RELEASE_BRANCH_CDN">
<option value="master">Master</option>
<option value="dev">Developer</option>
</select></td>
</tr></table>
<div class="select-popup-header"><%:Choose CDN For Downloading:%></div>
<div class="select-popup-body">
<div class="select-option" data-value="https://fastly.jsdelivr.net/">https://fastly.jsdelivr.net/</div>
Expand All @@ -66,6 +94,33 @@

<script type="text/javascript">
//<![CDATA[

var core_version_cdn = document.getElementById('CORE_VERSION_CDN');
var release_branch_cdn = document.getElementById('RELEASE_BRANCH_CDN');

function get_update_info() {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "update_info")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if ( status.corever != "0" && status.corever != "" ) {
core_version_cdn.value = status.corever;
}
else {
core_version_cdn.value = "0";
}
if ( status.release_branch != "" ) {
release_branch_cdn.value = status.release_branch;
}
else {
release_branch_cdn.value = "master";
}
}
else {
core_version_cdn.value = "0";
release_branch_cdn.value = "master";
}
});
};

function isValidURL(str) {
var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
Expand Down Expand Up @@ -108,6 +163,7 @@

function select_git_cdn(btn, type) {
var selectPopup = document.getElementById('selectPopup');
get_update_info();
selectPopup.classList.remove('hidden');

var customOptionInput = document.getElementById('customOptionInput');
Expand Down Expand Up @@ -141,6 +197,8 @@
};

function select_window(event, type) {
var v = core_version_cdn.value;
var r = release_branch_cdn.value;
var selectOptions = document.getElementsByClassName('select-option');
var target = event.target;
if (target.classList.contains('select-option') && target.dataset.value === 'custom') {
Expand Down Expand Up @@ -168,12 +226,19 @@
customOptionInput.style.display = 'none';
addCustomOption.style.display = 'none';
if (type === 'core_download') {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "core_download")%>', {url: target.dataset.value}, function(x, status) {
});
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "save_corever_branch")%>', {core_ver: v, release_branch: r}, function(x, status) {
if (x && x.status == 200) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "core_download")%>', {url: target.dataset.value}, function(x, status) {});
}
});
}
else {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update")%>', {url: target.dataset.value}, function(x, status) {
});
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "save_corever_branch")%>', {core_ver: v, release_branch: r}, function(x, status) {
if (x && x.status == 200) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "one_key_update")%>', {url: target.dataset.value}, function(x, status) {});
}
});

}

selectPopup.classList.add('hidden');
Expand Down
2 changes: 1 addition & 1 deletion luci-app-openclash/luasrc/view/openclash/update.htm
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@
if (x && x.status == 200) {
btn.value = '<%:One Click Check Update With CDN%>';
btn.disabled = true;
var r = confirm("<%:Check and Update all Cores and OpenClash?%>")
var r = confirm("<%:Check and Update all Cores and OpenClash?%>");
if (r == true) {
btn.disabled = false;
return select_git_cdn("one_key_update");
Expand Down
2 changes: 1 addition & 1 deletion luci-app-openclash/po/zh-cn/openclash.zh-cn.po
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ msgid "Has No Rules Field, Update Exit..."
msgstr "规则部分校验失败,请稍后再试..."

msgid "Has Incompatible Proxy-Group, Update Exit, Please Wait For OpenClash Update To Adapt..."
msgstr "含有未支持的新策略组,更新停止,请等待 OpenClash 版本更新适配..."
msgstr "含有未支持的策略组,更新停止,请等待 OpenClash 版本更新适配..."

msgid "Check The Downloaded Rule File For Updates..."
msgstr "检查下载的规则文件是否有更新..."
Expand Down
32 changes: 19 additions & 13 deletions luci-app-openclash/root/etc/init.d/openclash
Original file line number Diff line number Diff line change
Expand Up @@ -3118,6 +3118,7 @@ revert_firewall()

get_config()
{
enable=$(uci -q get openclash.config.enable)
rule_source=$(uci -q get openclash.config.rule_source)
enable_custom_clash_rules=$(uci -q get openclash.config.enable_custom_clash_rules)
da_password=$(uci -q get openclash.config.dashboard_password)
Expand Down Expand Up @@ -3295,17 +3296,7 @@ stop()
fi

LOG_OUT "Step 5: Restart Dnsmasq..."
redirect_dns=$(uci -q get openclash.config.redirect_dns)
dnsmasq_server=$(uci -q get openclash.config.dnsmasq_server)
dnsmasq_noresolv=$(uci -q get openclash.config.dnsmasq_noresolv)
dnsmasq_resolvfile=$(uci -q get openclash.config.dnsmasq_resolvfile)
cachesize_dns=$(uci -q get openclash.config.cachesize_dns)
dnsmasq_cachesize=$(uci -q get openclash.config.dnsmasq_cachesize)
filter_aaaa_dns=$(uci -q get openclash.config.filter_aaaa_dns)
dnsmasq_filter_aaaa=$(uci -q get openclash.config.dnsmasq_filter_aaaa)
default_resolvfile=$(uci -q get openclash.config.default_resolvfile)
revert_dns "$redirect_dns" "$enable" "$default_resolvfile" "$dnsmasq_noresolv" "$dnsmasq_resolvfile" "$cachesize_dns" "$dnsmasq_cachesize" "$filter_aaaa_dns" "$dnsmasq_filter_aaaa" "$dnsmasq_server"
/etc/init.d/dnsmasq restart >/dev/null 2>&1
revert_dnsmasq

LOG_OUT "Step 6: Delete OpenClash Residue File..."
if [ "$enable" != "1" ]; then
Expand Down Expand Up @@ -3334,6 +3325,21 @@ stop()
echo "OpenClash Already Stop!"
}

revert_dnsmasq()
{
get_config
redirect_dns=$(uci -q get openclash.config.redirect_dns)
dnsmasq_server=$(uci -q get openclash.config.dnsmasq_server)
dnsmasq_noresolv=$(uci -q get openclash.config.dnsmasq_noresolv)
dnsmasq_resolvfile=$(uci -q get openclash.config.dnsmasq_resolvfile)
cachesize_dns=$(uci -q get openclash.config.cachesize_dns)
dnsmasq_cachesize=$(uci -q get openclash.config.dnsmasq_cachesize)
filter_aaaa_dns=$(uci -q get openclash.config.filter_aaaa_dns)
dnsmasq_filter_aaaa=$(uci -q get openclash.config.dnsmasq_filter_aaaa)
default_resolvfile=$(uci -q get openclash.config.default_resolvfile)
revert_dns "$redirect_dns" "$enable" "$default_resolvfile" "$dnsmasq_noresolv" "$dnsmasq_resolvfile" "$cachesize_dns" "$dnsmasq_cachesize" "$filter_aaaa_dns" "$dnsmasq_filter_aaaa" "$dnsmasq_server"
/etc/init.d/dnsmasq restart >/dev/null 2>&1
}

restart()
{
Expand Down Expand Up @@ -3368,7 +3374,7 @@ reload()
if pidof clash >/dev/null && [ "$enable" == "1" ] && [ "$1" == "revert" ]; then
set_lock
revert_firewall 2>/dev/null
/etc/init.d/dnsmasq restart >/dev/null 2>&1
revert_dnsmasq 2>/dev/null
SLOG_CLEAN
del_lock
fi
Expand All @@ -3377,7 +3383,7 @@ reload()
do_run_mode 2>/dev/null
get_config 2>/dev/null
set_firewall 2>/dev/null
/etc/init.d/dnsmasq restart >/dev/null 2>&1
change_dns "$enable_redirect_dns" "$disable_masq_cache"
SLOG_CLEAN
del_lock
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
UNPACK_FILE_DIR="/usr/share/openclash/ui/dashboard/"
BACKUP_FILE_DIR="/usr/share/openclash/ui/dashboard_backup/"
if [ "$DASH_TYPE" == "Official" ]; then
DOWNLOAD_PATH="https://codeload.github.com/Dreamacro/clash-dashboard/zip/refs/heads/gh-pages"
DOWNLOAD_PATH="https://codeload.github.com/ayanamist/clash-dashboard/zip/refs/heads/gh-pages"
FILE_PATH_INCLUDE="clash-dashboard-gh-pages"
else
DOWNLOAD_PATH="https://codeload.github.com/MetaCubeX/Razord-meta/zip/refs/heads/gh-pages"
Expand Down
10 changes: 9 additions & 1 deletion luci-app-openclash/root/usr/share/openclash/openclash_rule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,15 @@
Value_1 = YAML.load_file('/tmp/rules.yaml');
OLD_GROUP = Value['rules'].collect{|x| x.split(',')[2] or x.split(',')[1]}.uniq;
NEW_GROUP = Value_1['rules'].collect{|x| x.split(',')[2] or x.split(',')[1]}.uniq;
puts (OLD_GROUP | NEW_GROUP).eql?(OLD_GROUP)
if (OLD_GROUP | NEW_GROUP).eql?(OLD_GROUP) then
if (OLD_GROUP | NEW_GROUP).eql?(NEW_GROUP) then
puts true
else
puts false
end
else
puts false
end
")" && [ -f "/usr/share/openclash/res/${rule_name}.yaml" ]; then
LOG_OUT "Error: Updated Others Rules【$rule_name】Has Incompatible Proxy-Group, Update Exit, Please Wait For OpenClash Update To Adapt..."
rm -rf /tmp/rules.yaml >/dev/null 2>&1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,13 @@ end
function get_auth_info()
port = UCI:get("openclash", "config", "cn_port")
passwd = UCI:get("openclash", "config", "dashboard_password") or ""
ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'")

local lan_int_name = UCI:get("openclash", "config", "lan_interface_name") or "0"
if lan_int_name == "0" then
ip = SYS.exec("uci -q get network.lan.ipaddr |awk -F '/' '{print $1}' 2>/dev/null |tr -d '\n'")
else
ip = SYS.exec(string.format("ip address show %s | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'", lan_int_name))
end

if not ip or ip == "" then
ip = SYS.exec("ip address show $(uci -q -p /tmp/state get network.lan.ifname || uci -q -p /tmp/state get network.lan.device) | grep -w 'inet' 2>/dev/null |grep -Eo 'inet [0-9\.]+' | awk '{print $2}' | tr -d '\n'")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ uci -q commit openclash
opkg remove --force-depends --force-remove luci-app-openclash
LOG_OUT "Installing The New Version, Please Do Not Refresh The Page or Do Other Operations..."
opkg install /tmp/openclash.ipk
if [ "$?" == "0" ]; then
if [ "$?" != "0" ] || [ -z "$(opkg info *openclash |grep Installed-Time)" ]; then
opkg install /tmp/openclash.ipk
fi
if [ "$?" == "0" ] && [ -n "$(opkg info *openclash |grep Installed-Time)" ]; then
rm -rf /tmp/openclash.ipk >/dev/null 2>&1
LOG_OUT "OpenClash Update Successful, About To Restart!"
uci -q set openclash.config.enable=1
Expand Down
Loading

0 comments on commit dd5e07d

Please sign in to comment.