luci-app-clash: bump to 1.5.9d

This commit is contained in:
CN_SZTL 2020-02-29 19:16:22 +08:00
parent 6dddb63c28
commit eec89ca1dc
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
11 changed files with 70 additions and 22 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=1.5.8
PKG_VERSION:=1.5.9
PKG_MAINTAINER:=frainzy1477

View File

@ -56,6 +56,7 @@ function index()
entry({"admin", "services", "clash", "conf"},call("action_conf")).leaf=true
entry({"admin", "services", "clash", "update_config"},call("action_update")).leaf=true
entry({"admin", "services", "clash", "game_rule"},call("action_update_rule")).leaf=true
entry({"admin", "services", "clash", "ping_check"},call("action_ping_status")).leaf=true
end
@ -90,6 +91,11 @@ local function in_use()
end
local function ping_enable()
return luci.sys.exec("uci get clash.config.ping_enable")
end
local function conf_path()
if nixio.fs.access(string.sub(luci.sys.exec("uci get clash.config.use_config"), 1, -2)) then
return fss.basename(string.sub(luci.sys.exec("uci get clash.config.use_config"), 1, -2))
@ -315,16 +321,20 @@ function action_status()
in_use = in_use(),
conf_path = conf_path(),
typeconf = typeconf()
})
end
function action_ping_status()
luci.http.prepare_content("application/json")
luci.http.write_json({
ping_enable = ping_enable()
})
end
function act_ping()
local e={}
e.index=luci.http.formvalue("index")
e.ping=luci.sys.exec("ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*.[0-9]' | awk -F '=' '{print$2}'"%luci.http.formvalue("domain"))
e.ping=luci.sys.exec("ping -c 1 -W 1 -w 10 %q 2>&1 | grep -o 'time=[0-9]*.[0-9]' | awk -F '=' '{print$2}'"%luci.http.formvalue("domain"))
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -62,6 +62,10 @@ cc = s:option(Flag, "create", translate("Enable Create"))
cc.default = 1
cc.description = translate("Enable to create configuration")
cc = s:option(Flag, "ping_enable", translate("Enable Ping Servers"))
cc.default = 0
cc.description = translate("Enable Ping Servers")
o = s:option(Value, "create_tag")
o.title = translate("Config Name")
o.rmempty = true

View File

@ -48,5 +48,7 @@ o.description = translate("Select a policy group to add rule")
o = s:option(Value, "ipaaddr", translate("IP/Domain/Address/Keyword/Port"))
o.rmempty = false
o = s:option(Flag, "res", translate("No Resolve"))
o.default = 0
return m

View File

@ -12,17 +12,35 @@ local dsp = require "luci.dispatcher"
domain: pings[i].getAttribute("hint")
},
function(x, result) {
pings[result.index].innerHTML = (result.ping ? '<b><font color="green">'+result.ping+'</font></b> ms' : '<b><font color="red"><%:Error%></font></b>');
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "ping_check")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if(status.ping_enable==1){
pings[result.index].innerHTML = (result.ping ? '<b><font color="green">'+result.ping+'</font></b> ms' : '<b><font color="red"><%:Error%></font></b>');
}else{
pings[result.index].innerHTML = result.ping ? '<b><font color="red"><%:DISABLED%></font></b>' : '<b><font color="red"><%:DISABLED%></font></b>';
}
}
})
}
);
XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "services", "clash", "ping")%>',{
XHR.poll(15,'<%=luci.dispatcher.build_url("admin", "services", "clash", "ping")%>',{
index: i,
domain: pings[i].getAttribute("hint")
},
function(x, result) {
pings[result.index].innerHTML = (result.ping ? '<b><font color="green">'+result.ping+'</font></b> ms' : '<b><font color="red"><%:Error%></font></b>');
XHR.poll(15,'<%=luci.dispatcher.build_url("admin", "services", "clash", "ping_check")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if(status.ping_enable==1){
pings[result.index].innerHTML = (result.ping ? '<b><font color="green">'+result.ping+'</font></b> ms' : '<b><font color="red"><%:Error%></font></b>');
}else{
pings[result.index].innerHTML = result.ping ? '<b><font color="red"><%:DISABLED%></font></b>' : '<b><font color="red"><%:DISABLED%></font></b>';
}
}
})
}
);
}

View File

@ -1020,4 +1020,10 @@ msgid "Download Online"
msgstr "在线下载"
msgid "Yacd Dashboard"
msgstr "Yacd控制面板"
msgstr "Yacd控制面板"
msgid "Enable Ping Servers"
msgstr "启用Ping服务器"
msgid "DISABLED"
msgstr "禁用"

View File

@ -20,7 +20,7 @@ REAL_LOG="/usr/share/clash/clash_real.txt"
revert_dns() {
#===========================================================================================================================
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
uci del_list dhcp.@dnsmasq[0].server=127.0.0.1#$dns_port >/dev/null 2>&1
uci set dhcp.@dnsmasq[0].noresolv=0
uci delete dhcp.@dnsmasq[0].cachesize
@ -34,7 +34,9 @@ add_cron(){
config_type=$(uci get clash.config.config_type 2>/dev/null)
#===========================================================================================================================
sed -i '/clash.txt/d' $CRON_FILE
[ -z "$(grep -w "/usr/share/clash/clash-watchdog.sh" $CRON_FILE)" ] && echo "*/1 * * * * /usr/share/clash/clash-watchdog.sh" >> $CRON_FILE
clear=$(uci get clash.config.auto_clear_log 2>/dev/null)
if [ "${clear}" -eq 1 ]; then
[ -z "$(grep -w "/usr/share/clash/clash.txt" $CRON_FILE)" ] && echo "0 */$(uci get clash.config.clear_time 2>/dev/null) * * * echo '' >/usr/share/clash/clash.txt" >> $CRON_FILE
@ -68,7 +70,7 @@ config_type=$(uci get clash.config.config_type 2>/dev/null)
del_cron(){
#===========================================================================================================================
sed -i '/clash/d' $CRON_FILE
sed -i '/update_all.sh/d' $CRON_FILE
sed -i '/clash.txt/d' $CRON_FILE
/etc/init.d/cron restart
#===========================================================================================================================
@ -521,7 +523,7 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
echo "Clash for OpenWRT" >$REAL_LOG
fi
nohup /usr/share/clash/kill.sh >/dev/null 2>&1
#nohup /usr/share/clash/clash-watchdog.sh >/dev/null 2>&1
else
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - problem with config.yaml, config.yaml is either empty or not found " >> /usr/share/clash/clash.txt
@ -693,7 +695,7 @@ stop(){
echo "" >/usr/share/clash/clash.txt >/dev/null 2>&1
echo "0" > /usr/share/clash/logstatus_check >/dev/null 2>&1
sh /usr/share/clash/kill.sh
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - CLIENT IS DISABLED " >> /usr/share/clash/clash.txt
echo "Client is Disabled " >$REAL_LOG

View File

@ -3,22 +3,17 @@
enable=$(uci get clash.config.enable 2>/dev/null)
if [ "${enable}" -eq 1 ];then
while [ $enable -eq 1 ];
do
if ! pidof clash>/dev/null; then
/etc/init.d/clash restart 2>&1 &
fi
sleep 60
continue
done
elif [ "${enable}" -eq 0 ];then
if [ -f /tmp/watchlist ];then
rm -rf /tmp/watchlist
fi
line=$(ps | grep -n '/usr/share/clash/kill.sh'|awk -F ':' '{print $2}' |awk -F ' ' '{print $1}'>/tmp/watchlist)
line=$(ps | grep -n 'clash-watchdog.sh'|awk -F ':' '{print $2}' |awk -F ' ' '{print $1}'>/tmp/watchlist)
line_no=$(grep -n '' /tmp/watchlist|awk -F ':' '{print $1}')
num=$(grep -c '' /tmp/watchlist| awk '{print $1}')
nums=1

View File

@ -21,7 +21,12 @@ ipadd()
config_get "pgroup" "$section" "pgroup" ""
config_get "ipaaddr" "$section" "ipaaddr" ""
config_get "type" "$section" "type" ""
echo "- $type,$ipaaddr,$pgroup">>/tmp/ipadd.conf
config_get "res" "$section" "res" ""
if [ "${res}" -eq 1 ] || [ ! -z "${res}" ];then
echo "- $type,$ipaaddr,$pgroup,no-resolve">>/tmp/ipadd.conf
else
echo "- $type,$ipaaddr,$pgroup">>/tmp/ipadd.conf
fi
}

View File

@ -1,6 +1,10 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
#ping=$(uci get clash.config.ping_enable 2>/dev/null)
enable_list=$(uci get clash.config.cus_list 2>/dev/null)
if [ $enable_list -eq 1 ];then
@ -36,7 +40,9 @@ add_address(){
rm -rf /tmp/server.conf /usr/share/clashbackup/address.list >/dev/null 2>&1
}
#if [ $ping -eq 1 ];then
add_address >/dev/null 2>&1
#fi
if [ -d /tmp/dnsmasq.clash ];then
rm -rf /tmp/dnsmasq.clash