luci-app-clash: sync with upstream source

This commit is contained in:
CN_SZTL 2020-06-06 20:38:24 +08:00
parent 1634489add
commit 4fe4c28200
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
14 changed files with 95 additions and 75 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=1.7.0
PKG_VERSION:=1.7.1
PKG_MAINTAINER:=frainzy1477
@ -103,7 +103,6 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/share/clash
$(INSTALL_DIR) $(1)/usr/share/rpcd
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
$(INSTALL_DIR) $(1)/usr/share/clash/rules
$(INSTALL_DIR) $(1)/usr/share/clash/rules/g_rules
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard
@ -140,9 +139,6 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) ./root/usr/share/clash/logstatus_check $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/clash.txt $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/rpcd/acl.d/luci-app-clash.json $(1)/usr/share/rpcd/acl.d/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/index.html $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/main.1560b07adc97ac0ac265.css $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/img/ffac0fa1d89f15922b4594863b8b32e9.png $(1)/usr/share/clash/dashboard/img/

View File

@ -13,7 +13,7 @@ function index()
local page = entry({"admin", "services", "clash"},alias("admin", "services", "clash", "overview"), _("Clash"), 5)
page.dependent = true
page.acl_depends = { "luci-app-clash" }
page.acl_depends = {"luci-app-clash"}
entry({"admin", "services", "clash", "overview"},cbi("clash/overview"),_("Overview"), 10).leaf = true
entry({"admin", "services", "clash", "client"},cbi("clash/client"),_("Client"), 20).leaf = true

View File

@ -29,11 +29,6 @@ o:value("4", translate("Clash(dTun)"))
end
o.description = translate("Select core, clashr support ssr while clash does not.")
o = s:option(Flag, "old_conf", translate("Old Config"))
o.description = translate("Proxy/Proxy Groups/Rule")
o = s:option(ListValue, "g_rules", translate("Game Rules"))
o.default = "0"
o:value("0", translate("Disable"))

View File

@ -1,5 +1,6 @@
<%+cbi/valueheader%>
<%local fs=require"nixio.fs"%>
<input type="button" class="cbi-button cbi-button-apply" id="apply_update_button" value="<%:Download%>" onclick=" return apply_update() "/>
<br /><br />
<textarea id="core_download" class="cbi-input-textarea" style="width: 100%;display:none" data-update="change" rows="10" cols="100" readonly="readonly" > </textarea>
@ -16,14 +17,15 @@ function apply_update(){
function poll_check(){
var lv = document.getElementById('core_download');
lv.style.display="inline"
lv.innerText = ""
XHR.poll(2, '<%=url([[admin]], [[services]], [[clash]], [[check]])%>', null,
function(x, data) {
if(x && x.status === 200) {
if(typeof(x.responseText) === "string") {
lv.insertAdjacentText("beforeend", x.responseText);
lv.scrollTop = lv.scrollHeight;
}}});
function(x, data) {
var lv = document.getElementById('core_download');
if (x.responseText && lv) {
lv.innerHTML += x.responseText;
lv.scrollTop = lv.scrollHeight;
}
}
);
}
@ -54,11 +56,13 @@ function hide(){
btn.value = '<%:Download%>';
}
<% if fs.access("/var/run/core_update") then %>
var btn = document.getElementById('apply_update_button');
btn.disabled = true;
btn.value = '<%:Downloading...%>';
poll_check();
poll_check();
<%end%>

View File

@ -17,14 +17,12 @@ function apply_update(){
function poll_check(){
var lv = document.getElementById('geoip_download');
lv.style.display="inline"
lv.innerText = ""
XHR.poll(2, '<%=url([[admin]], [[services]], [[clash]], [[check_geoip]])%>', null,
function(x, data) {
scroll();
var lv = document.getElementById('geoip_download');
if (x.responseText && lv) {
lv.innerHTML += x.responseText;
lv.scrollTop = lv.scrollHeight;
lv.innerHTML += x.responseText;
lv.scrollTop = lv.scrollHeight;
}
}
);
@ -60,11 +58,6 @@ function hide(){
}
/*function scroll(){
var textarea = document.getElementById('geoip_download');
textarea.scrollTop = textarea.scrollHeight;
}*/
<% if fs.access("/var/run/geoip_update") then %>
var btn = document.getElementById('apply_update_geoip');

View File

@ -1,18 +1,22 @@
<%+cbi/valueheader%>
<textarea id="log" class="cbi-input-textarea" style="width: 100%;" data-update="change" rows="29" readonly="readonly" > </textarea>
<script type="text/javascript">//<![CDATA[
var lv = document.getElementById('log');
lv.innerText = ""
lv.style.display="inline"
XHR.poll(3, '<%=url([[admin]], [[services]], [[clash]], [[logstatus]])%>', null,
XHR.poll(1, '<%=url([[admin]], [[services]], [[clash]], [[logstatus]])%>', null,
function(x, data) {
if(x && x.status === 200) {
if(typeof(x.responseText) === "string") {
lv.insertAdjacentText("beforeend", x.responseText);
lv.scrollTop = lv.scrollHeight;
}}});
var lv = document.getElementById('log');
if (x.responseText && lv) {
lv.innerHTML += x.responseText;
lv.scrollTop = lv.scrollHeight;
}
}
);
//]]>
</script>
<%+cbi/valuefooter%>

View File

@ -205,10 +205,10 @@ yml_dns_change(){
check(){
sed -i 's/Proxy Group:/proxy-groups:/g' "$CONFIG_YAML"
sed -i 's/proxy-provider:/proxy-providers:/g' "$CONFIG_YAML"
sed -i 's/Proxy:/proxies:/g' "$CONFIG_YAML"
sed -i 's/Rule:/rules:/g' "$CONFIG_YAML"
sed -i 's/^Proxy Group:/proxy-groups:/g' "$CONFIG_YAML"
sed -i 's/^proxy-provider:/proxy-providers:/g' "$CONFIG_YAML"
sed -i 's/^Proxy:/proxies:/g' "$CONFIG_YAML"
sed -i 's/^Rule:/rules:/g' "$CONFIG_YAML"
}
@ -455,7 +455,7 @@ enable=$(uci get clash.config.enable 2>/dev/null)
core=$(uci get clash.config.core 2>/dev/null)
mode=$(uci get clash.config.mode 2>/dev/null)
tun_mode=$(uci get clash.config.tun_mode 2>/dev/null)
old_conf=$(uci get clash.config.old_conf 2>/dev/null)
if [ -f /etc/clash/config.yaml ];then
@ -508,11 +508,9 @@ elif [ "${core}" -eq 3 ] && [ ! -f /etc/clash/clashtun/clash ]; then
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
else
if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')" -ne 0 ] ; then
if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5)}')" -ne 0 ] ; then
if [ -z "$old_conf" ];then
check >/dev/null 2>&1
fi
yml_change >/dev/null 2>&1

View File

@ -19,13 +19,19 @@ if [ $config_name == "" ] || [ -z $config_name ];then
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
exit 0
fi
if [ ! -f "/usr/share/clashbackup/confit_list.conf" ];then
touch /usr/share/clashbackup/confit_list.conf
fi
check_name=$(grep -F "${config_name}.yaml" "/usr/share/clashbackup/confit_list.conf")
if [ ! -z $check_name ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
@ -48,14 +54,14 @@ else
sleep 1
if [ "$subtype" = "clash" ];then
curl -sL --connect-timeout 10 --retry 2 "$clash_url" -O 2>&1 >1 $CONFIG_YAML
wget -c4 --no-check-certificate --user-agent="Clash/OpenWRT" "$clash_url" -O 2>&1 >1 $CONFIG_YAML
if [ "$?" -eq "0" ]; then
echo "${config_name}.yaml#$clash_url#$subtype" >>/usr/share/clashbackup/confit_list.conf
fi
fi
if [ "$subtype" = "ssr2clash" ];then
curl -sL --connect-timeout 10 --retry 2 "https://ssrsub2clashr.herokuapp.com/ssrsub2clash?sub=$ssr_url" -O 2>&1 >1 $CONFIG_YAML
wget -c4 --no-check-certificate --user-agent="Clash/OpenWRT" "https://gfwsb.114514.best/sub?target=clashr&url=$ssr_url" -O 2>&1 >1 $CONFIG_YAML
if [ "$?" -eq "0" ]; then
echo "${config_name}.yaml#$ssr_url#$subtype" >>/usr/share/clashbackup/confit_list.conf
CONFIG_YAMLL="/tmp/conf"
@ -100,7 +106,7 @@ else
fi
if [ "$subtype" = "v2clash" ];then
curl -sL --connect-timeout 10 --retry 2 "https://tgbot.lbyczf.com/v2rayn2clash?url=$v2_url" -O 2>&1 >1 $CONFIG_YAML
wget -c4 --no-check-certificate --user-agent="Clash/OpenWRT" "https://tgbot.lbyczf.com/v2rayn2clash?url=$v2_url" -O 2>&1 >1 $CONFIG_YAML
if [ "$?" -eq "0" ]; then
echo "${config_name}.yaml#$v2_url#$subtype" >>/usr/share/clashbackup/confit_list.conf
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,37 +1,31 @@
#!/bin/sh /etc/rc.common
if [ -f /usr/share/clashbackup/history ];then
HISTORY_PATH="/usr/share/clashbackup/history"
SECRET=$(uci get clash.config.dash_pass 2>/dev/null)
LAN_IP=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
PORT=$(uci get clash.config.dash_port 2>/dev/null)
urlencode() {
local data
if [ "$#" -eq "1" ]; then
data=$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "")
if [ ! -z "$data" ]; then
echo "${data##/?}"
fi
if [ "$#" != 1 ]; then
return 1
fi
data=$(curl -s -o /dev/null -w %{url_effective} --get --data-urlencode "$1" "")
if [ ! -z "$data" ]; then
echo "${data##/?}"
fi
return 0
}
GROUP_STATE() {
echo "$(curl -m 5 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies/"$1" 2>/dev/null |sed -n '$p' 2>/dev/null)"
}
restore_history() {
GROUP_NAME=$(urlencode "$GROUP_NAME")
NOW_NAME=$(echo $line |awk -F '#*#' '{print $3}')
GROUP_STATE=$(GROUP_STATE "$GROUP_NAME")
GROUP_STATE_NUM=0
while ( [ ! -z "$(pidof clash)" ] && [ "$GROUP_STATE" != "200" ] && [ "$GROUP_STATE_NUM" -le 1 ] )
do
sleep 3
GROUP_STATE_NUM=$(expr "$GROUP_STATE_NUM" + 1)
GROUP_STATE=$(GROUP_STATE "$GROUP_NAME")
done
curl -m 5 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GROUP_NAME" >/dev/null 2>&1
}
fi
cat $HISTORY_PATH |while read line
do
if [ -z "$(echo $line |grep "#*#")" ]; then
continue
else
GORUP_NAME=$(urlencode "$(echo $line |awk -F '#*#' '{print $1}')")
NOW_NAME=$(echo $line |awk -F '#*#' '{print $3}')
curl -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X PUT -d '{"name":"'"$NOW_NAME"'"}' http://"$LAN_IP":"$PORT"/proxies/"$GORUP_NAME" >/dev/null 2>&1
fi
done >/dev/null 2>&1
fi