luci-app-clash: sync with upstream source

This commit is contained in:
CN_SZTL 2020-01-26 01:56:34 +08:00
parent c9c2fdffb4
commit 036c0fbab1
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
12 changed files with 131 additions and 131 deletions

View File

@ -188,14 +188,22 @@ local function clashr_core()
end
end
local function clashtun_core()
if nixio.fs.access("/etc/clash/clashtun/clash") then
return luci.sys.exec("/etc/clash/clashtun/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
local tun=luci.sys.exec("/etc/clash/clashtun/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
if tun ~= "" then
return luci.sys.exec("/etc/clash/clashtun/clash -v 2>/dev/null |awk -F ' ' '{print $2}'")
else
return luci.sys.exec("sed -n 1p /usr/share/clash/tun_version")
end
else
return "0"
end
end
local function readlog()
return luci.sys.exec("sed -n '$p' /usr/share/clash/clash_real.txt 2>/dev/null")
end
@ -262,8 +270,9 @@ function check_status()
clashtun_core = clashtun_core(),
new_core_version = new_core_version(),
new_clashtun_core_version =new_clashtun_core_version(),
check_clashtun_core = check_clashtun_core()
check_clashtun_core = check_clashtun_core(),
conf_path = conf_path(),
typeconf = typeconf()
})
end
function action_status()
@ -279,7 +288,10 @@ function action_status()
dash_pass = dash_pass(),
clashtun_core = clashtun_core(),
e_mode = e_mode(),
in_use = in_use()
in_use = in_use(),
conf_path = conf_path(),
typeconf = typeconf()
})

View File

@ -31,7 +31,7 @@ o.default = "0"
o:value("0", translate("Disable"))
o:value("1", translate("Enable"))
o.description = translate("Set rules under Setting=>Game Rules, will take effect when client start")
o:depends("core", 3)
o = s:option(Button, "Apply")
o.title = translate("Save & Apply")

View File

@ -9,9 +9,27 @@ local UTIL = require "luci.util"
local fs = require "luci.clash"
local uci = require "luci.model.uci".cursor()
font_red = [[<font color="red">]]
font_blue = [[<font color="blue">]]
font_off = [[</font>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
m = Map(clash)
m.pageaction = false
m.description=''..font_red..bold_on..translate("Usage Steps:")..bold_off..font_off..' '
.."<br />"
..font_blue..bold_on..translate("1.Load Policy Group, make sure you have selected a config on config page")..bold_off..font_off..' '
.."<br />"
..font_blue..bold_on..translate("2.Download the game rules you want to use from the game rules list on this page")..bold_off..font_off..' '
.."<br />"
..font_blue..bold_on..translate("3. Make sure your game and servers support UDP")..bold_off..font_off..' '
.."<br />"
..font_blue..bold_on..translate("4.Click on ADD, Set the corresponding policy group of the downloaded game rules and save, recommended: FallBack")..bold_off..font_off..' '
.."<br />"
..font_blue..bold_on..translate("5.Select ClashTun Core type and start client")..bold_off..font_off..' '
SYS.call("awk -F ',' '{print $1}' /usr/share/clash/rules/rules.list > /tmp/rules_name 2>/dev/null")
file = io.open("/tmp/rules_name", "r");

View File

@ -9,31 +9,31 @@ local fs = require "luci.clash"
local http = luci.http
local clash = "clash"
kk = Map(clash)
r = kk:section(TypedSection, "clash", translate("Auto Update Config"))
r.anonymous = true
kk.pageaction = false
kr = Map(clash)
s = kr:section(TypedSection, "clash", translate("Auto Update Config"))
s.anonymous = true
kr.pageaction = false
o = s:option(Flag, "auto_update", translate("Auto Update"))
o = r:option(Flag, "auto_update", translate("Auto Update"))
o.description = translate("Auto Update Server subscription")
o = s:option(ListValue, "auto_update_time", translate("Update time (every day)"))
o = r:option(ListValue, "auto_update_time", translate("Update time (every day)"))
for t = 0,23 do
o:value(t, t..":00")
end
o.default=0
o.description = translate("Daily Server subscription update time. Only update config in use")
o = s:option(Button, "Apply")
o = r:option(Button, "Apply")
o.title = translate("Save & Apply")
o.inputtitle = translate("Save & Apply")
o.inputstyle = "apply"
o.write = function()
kr.uci:commit("clash")
kk.uci:commit("clash")
end
kr = Map(clash)
s = kr:section(TypedSection, "clash", translate("Subscription Config"))
s.anonymous = true
kr.pageaction = false
@ -54,11 +54,6 @@ o.description = translate("Clash Subscription Address")
o.rmempty = true
o:depends("subcri", 'clash')
o = s:option(Value, "subscribe_url")
o.title = translate("Subcription Url")
o.description = translate("V2/SSR Subscription Address, Only input your subscription address without any api conversion url")
o.rmempty = true
o:depends("subcri", 'v2ssr2clash')
o = s:option(Button,"update")
o.title = translate("Download Config")
@ -72,6 +67,13 @@ o.write = function()
end
o:depends("subcri", 'clash')
o = s:option(Value, "subscribe_url")
o.title = translate("Subcription Url")
o.description = translate("V2/SSR Subscription Address, Only input your subscription address without any api conversion url")
o.rmempty = true
o:depends("subcri", 'v2ssr2clash')
o = s:option(Button,"updatee")
o.title = translate("Download Config")
o.inputtitle = translate("Download Config")
@ -136,4 +138,4 @@ if luci.http.formvalue("upload") then
end
return kr,ko
return kr,kk,ko

View File

@ -17,14 +17,6 @@ s.addremove=false
log = s:option(TextValue, "clog")
log.template = "clash/status_log"
o = s:option(Button,"log")
o.inputtitle = translate("Clear Logs")
o.write = function()
SYS.call('echo "0" > /usr/share/clash/logstatus_check 2>&1 &')
SYS.call('echo "" > /tmp/clash.txt 2>&1 &')
HTTP.redirect(DISP.build_url("admin", "services", "clash", "log"))
end
o = s:option(Button, "Download")
o.inputtitle = translate("Download logs")
o.inputstyle = "apply"

View File

@ -10,7 +10,7 @@
<table width="100%" cellspacing="10">
<tr><td width="50%"><span><%:Clash Client%></span></td><td id="_clash"><em><%:Collecting data...%></em></td> </tr>
<tr><td width="50%"><span><%:Clash Mode%></span></td><td id="_emode"><em><%:Collecting data...%></em></td> </tr>
<tr><td width="50%"><span><%:Clash Config%></span></td><td id="_conf_path"><em><%:Collecting data...%></em></td> </tr>
<tr><td width="50%"><span><%:Clash Config%></span></td><td id="_conf_path"><b><font color="red"><%:NOT RUNNING%></font></b></td> </tr>
<tr><td width="50%"><span><%:View Config%></span></td><td id="_conf"><em><%:Collecting data...%></em></td> </tr>
<tr><td width="50%"><span><%:Clash Dashboard%></span></td><td id="_web"><em> <%:Collecting data...%> </em></td> </tr>
@ -154,22 +154,7 @@ var HTTP = {
var logo = document.getElementById('_logo');
var conf = document.getElementById('_conf');
var conf_path = document.getElementById('_conf_path');
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "conf")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if(status.typeconf==1){
conf_path.innerHTML = status.conf_path ? '<b><font color="green"><%:SUBSCRIBE%> </font></b>' : '<b><font color="red"><%:NOT SELECTED%></font></b>';
}
if(status.typeconf==2){
conf_path.innerHTML = status.conf_path ? '<b><font color="green"><%:UPLOAD%></font></b>' : '<b><font color="red"><%:NOT SELECTED%></font></b>';
}
if(status.typeconf==3){
conf_path.innerHTML = status.conf_path ? '<b><font color="green"><%:CUSTOM%></font></b>' : '<b><font color="red"><%:NOT SELECTED%></font></b>';
}
}
});
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
@ -178,8 +163,17 @@ var HTTP = {
ip.innerHTML = status.localip ? '<b><font color="green">'+status.localip+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
port.innerHTML = status.dash_port ? '<b><font color="green">'+status.dash_port+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
secret.innerHTML = status.dash_pass ? '<b><font color="green">'+status.dash_pass+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
emode.innerHTML = status.e_mode ? '<b><font color="green" style="text-transform: uppercase;">'+status.e_mode+'</font> </b>' : '<b><font color="red"><%:NOT SET%></font></b>';
emode.innerHTML = status.clash ? '<b><font color="green" style="text-transform: uppercase;">'+status.e_mode+'</font> </b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
conf.innerHTML = status.clash ? '<b><input type="button" class="btn" style="background-color:black;padding: 5px;font-color:green;color:green;font-weight:bold" value="<%:VIEW CONFIG%>" onclick="return view(this)"/></b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
if(status.typeconf==1){
conf_path.innerHTML = status.clash ? '<b><font color="green"><%:SUBSCRIBE%> </font></b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
}
if(status.typeconf==2){
conf_path.innerHTML = status.clash ? '<b><font color="green"><%:UPLOAD%></font></b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
}
if(status.typeconf==3){
conf_path.innerHTML = status.clash ? '<b><font color="green"><%:CUSTOM%></font></b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
}
IP.getIpifyIP();
IP.getIpipnetIP();
@ -236,7 +230,7 @@ var HTTP = {
position: fixed;
z-index: 100;
width: 70%;
height: 600px;
height: 650px;
background: #FFFFFF;
left: 20%;
top: 15%;
@ -255,7 +249,7 @@ var HTTP = {
.modals h3 {
font-size: 14px;
color: #ffcc00;
color: red;
background: transparent;
margin: 0;
padding: 0;
@ -265,7 +259,7 @@ var HTTP = {
position: fixed;
z-index: 100;
width: 80%;
height: 500px;
height: 550px;
background: #FFFFFF;
left: 10%;
top: 15%;
@ -305,10 +299,10 @@ var HTTP = {
<div class="modals-bg">
<div class="modals">
<span class="close">&times;</span>
<h2><%:Config In Use%></h2>
<textarea style="width:100%;height:85%; font-family:'Lucida Console'; font-size:12px;padding-left:3px;padding-right:22px;" readonly="readonly" wrap="off" rows="25"><%=nixio.fs.readfile("/etc/clash/config.yaml")%></textarea>
</div>
<span><input type="button" class="cbi-button cbi-button-apply" value="<%:Download%>" style=" display:inline;" onclick=" return download_conf()" /></span><br/><span class="close">&times;</span>
<br/><h3 style="margin-left:0;"><%:If config does not show refresh page%></h3><br/>
<span><textarea id="cbid.logview.1.conf" style="width:100%;height:80%; font-family:'Lucida Console'; font-size:12px;padding-left:3px;padding-right:22px;" readonly="readonly" wrap="off" rows="25"><%=nixio.fs.readfile("/etc/clash/config.yaml")%></textarea></span>
</div>
</div>
<script>
var btn = document.getElementById("myBtn");
@ -319,5 +313,20 @@ span.onclick = function() {
function view(btn) {
$(".modals-bg").show();
}
function createAndDownloadFile(fileName, content) {
var aTag = document.createElement('a');
var blob = new Blob([content]);
aTag.download = fileName;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(blob);
}
function download_conf(){
var lv = document.getElementById('cbid.logview.1.conf');
var dt = new Date();
createAndDownloadFile("config.yaml",lv.innerHTML)
return
}
</script>

View File

@ -265,8 +265,8 @@ msgstr "国外网IP"
msgid "clash"
msgstr "clash"
msgid "OPEN DASHBOARD"
msgstr "打开外部控制"
msgid "DASHBOARD"
msgstr "外部控制"
msgid "Clash Dashboard"
msgstr "Clash外部控制"
@ -870,10 +870,10 @@ msgid "Update Rule"
msgstr "点击更新规则"
msgid "Game Rule Tag"
msgstr "游戏规则评论"
msgstr "游戏规则名字"
msgid "Rule Tag"
msgstr "游戏评论"
msgstr "游戏名字"
msgid "Edit Game Rule & Group"
msgstr "编辑游戏规则策略组"
@ -915,4 +915,25 @@ msgid "VIEW CONFIG"
msgstr "查看配置"
msgid "View Config"
msgstr "查看配置"
msgstr "查看配置"
msgid "If config does not show refresh page"
msgstr "如果配置不显示刷新页"
msgid "Usage Steps:"
msgstr "使用步骤:"
msgid "1.Load Policy Group, make sure you have selected a config on config page"
msgstr "1. 加载策略组,确保已在配置页上选择配置。"
msgid "2.Download the game rules you want to use from the game rules list on this page"
msgstr "2. 从该页的游戏规则列表中下载要使用的游戏规则。"
msgid "3. Make sure your game and servers support UDP"
msgstr "3. 确保游戏和服务器支持UDP。"
msgid "4.Click on ADD, Set the corresponding policy group of the downloaded game rules and save, recommended: FallBack"
msgstr "4. 单击添加,设置下载游戏规则的相应策略组(策略组类型建议:FallBack。"
msgid "5.Select ClashTun Core type and start client"
msgstr "5. 在客户端页选择ClashTun内核(https://github.com/comzyh/clash/releases)和启用游戏规则。"

View File

@ -27,7 +27,7 @@ revert_dns() {
rm -rf $CUSLIST $CUSLITT $CUSLISTV $CUSLITTV 2>/dev/null
uci commit dhcp
/etc/init.d/dnsmasq restart >/dev/null 2>&1
#===========================================================================================================================
#===========================================================================================================================
}
add_cron(){
@ -74,7 +74,6 @@ del_cron(){
select_config(){
#===========================================================================================================================
config_type=$(uci get clash.config.config_type 2>/dev/null)
lang=$(uci get luci.main.lang 2>/dev/null)
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Checking Config file..." >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
@ -130,7 +129,6 @@ game_rules() {
yml_dns_change(){
#===========================================================================================================================
lang=$(uci get luci.main.lang 2>/dev/null)
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
dnsforwader=$(uci get clash.config.dnsforwader 2>/dev/null)
dnscache=$(egrep '^ {0,}enhanced-mode' /etc/clash/config.yaml |grep enhanced-mode: |awk -F ': ' '{print $2}')
@ -293,42 +291,12 @@ rules(){
}
yml_sub(){
#===========================================================================================================================
subscribe_url=$(uci get clash.config.subscribe_url 2>/dev/null)
config_type=$(uci get clash.config.config_type 2>/dev/null)
subscri=$(uci get clash.config.subcri 2>/dev/null)
subscribe_url_clash=$(uci get clash.config.subscribe_url_clash 2>/dev/null)
if [ "${config_type}" == "1" ];then
if [ "${subscri}" == "clash" ];then
if [ ! -f $CONFIG_YAML_PATH ] && [ ! -z "${subscribe_url_clash}" ];then
sh /usr/share/clash/clash.sh >>/tmp/clash.txt
elif [ -f $CONFIG_YAML_PATH ] && [ "$(ls -l $CONFIG_YAML_PATH | awk '{print int($5)}')" -eq 0 ] && [ ! -z "${subscribe_url_clash}" ];then
sh /usr/share/clash/clash.sh >>/tmp/clash.txt
fi
fi
if [ "${subscri}" == "v2ssr2clash" ];then
if [ ! -f $CONFIG_YAML_PATH ] && [ ! -z "${subscribe_url}" ];then
sh /usr/share/clash/v2ssr.sh >>/tmp/clash.txt
elif [ -f $CONFIG_YAML_PATH ] && [ "$(ls -l $CONFIG_YAML_PATH | awk '{print int($5)}')" -eq 0 ] && [ ! -z "${subscribe_url}" ];then
sh /usr/share/clash/v2ssr.sh >>/tmp/clash.txt
fi
fi
fi
#===========================================================================================================================
}
custom_list() {
sh /usr/share/clash/list.sh >/dev/null 2>&1
}
start(){
#===========================================================================================================================
if pidof clash >/dev/null; then
kill $(pidof clash) >/dev/null 2>&1 || kill -9 $(ps | grep clash | grep -v grep | awk '{print $1}') >/dev/null 2>&1
fi
lang=$(uci get luci.main.lang 2>/dev/null)
landns=$(uci get clash.config.landns 2>/dev/null)
enable=$(uci get clash.config.enable 2>/dev/null)
@ -343,11 +311,6 @@ if [ "${enable}" -eq 1 ]; then
fi
sleep 2
sleep 2
yml_sub >/dev/null 2>&1
select_config >/dev/null 2>&1
if [ "${core}" -eq 1 ] && [ ! -f /etc/clash/clash ]; then
@ -605,10 +568,6 @@ remove_mark(){
/etc/init.d/dnsmasq restart >/dev/null 2>&1
}
del_list() {
sh /usr/share/clash/del_servers.sh >/dev/null 2>&1
}
stop(){
#===========================================================================================================================
delandns=$(uci get clash.config.delan 2>/dev/null)
@ -661,7 +620,7 @@ stop(){
fi
kill -9 `pidof clash|sed "s/$//g"` 2>/dev/null
sleep 1
if [ ! -z "${delandns}" ];then
@ -687,7 +646,7 @@ stop(){
elif [ "${lang}" == "zh_cn" ];then
echo "重启 Dnsmasq 程序" >$REAL_LOG
fi
del_list >/dev/null 2>&1
revert_dns >/dev/null 2>&1
sleep 1
@ -695,6 +654,11 @@ stop(){
echo "0" > /usr/share/clash/logstatus_check >/dev/null 2>&1
rm -rf /etc/clash/*.yaml /etc/clash/*.yml >/dev/null 2>&1
mv /usr/share/clash/list.bak /usr/share/clash/server.list >/dev/null 2>&1
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - CLIENT IS DISABLED " >> /tmp/clash.txt
echo "Client is Disabled " >$REAL_LOG
@ -706,6 +670,11 @@ stop(){
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
if pidof clash >/dev/null; then
kill $(pidof clash) >/dev/null 2>&1 || kill -9 $(ps | grep clash | grep -v grep | awk '{print $1}') >/dev/null 2>&1
fi
#===========================================================================================================================
}

View File

@ -165,6 +165,9 @@ update(){
mv /tmp/clash /etc/clash/clashtun/clash >/dev/null 2>&1
rm -rf /usr/share/clash/tun_version >/dev/null 2>&1
mv /usr/share/clash/download_tun_version /usr/share/clash/tun_version >/dev/null 2>&1
tun=$(sed -n 1p /usr/share/clash/tun_version 2>/dev/null)
sed -i "s/${tun}/v${tun}/g" /usr/share/clash/tun_version 2>&1
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - ClashTun内核更新成功" >$LOG_FILE
@ -200,7 +203,7 @@ if [ $CORETYPE -eq 1 ] && [ $VER != $CLASHVER ]; then
update
elif [ $CORETYPE -eq 2 ] && [ $VERR != $CLASHRVER ]; then
update
elif [ $CORETYPE -eq 2 ] && [ $VERS != $CLASHTUN ]; then
elif [ $CORETYPE -eq 3 ] && [ $VERS != $CLASHTUN ]; then
update
else
if [ $lang == "zh_cn" ];then

View File

@ -1,11 +1,4 @@
Rule:
- DOMAIN-SUFFIX,netflix.com,🎬Netflix
- DOMAIN-SUFFIX,netflix.net,🎬Netflix
- DOMAIN-SUFFIX,nflxext.com,🎬Netflix
- DOMAIN-SUFFIX,nflximg.com,🎬Netflix
- DOMAIN-SUFFIX,nflximg.net,🎬Netflix
- DOMAIN-SUFFIX,nflxso.net,🎬Netflix
- DOMAIN-SUFFIX,nflxvideo.net,🎬Netflix
# (GlobalTV)
# > ABC
- DOMAIN-SUFFIX,edgedatg.com,📺GlobalTV

View File

@ -1,19 +0,0 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
del_address(){
countt=$(grep -c '' /usr/share/clashbackup/address.list)
count_nums=1
while [[ $count_nums -le $countt ]]
do
line=$(sed -n "$count_nums"p /usr/share/clashbackup/address.list)
check_addr=$(grep -F "$line" "/usr/share/clash/server.list")
line_no=$(grep -n "$check_addr" /usr/share/clash/server.list |awk -F ':' '{print $1}')
if [ ! -z $check_addr ];then
sed -i "${line_no}d" /usr/share/clash/server.list
fi
count_nums=$(( $count_nums + 1))
done
rm -rf /usr/share/clashbackup/address.list >/dev/null 2>&1
}
del_address >/dev/null 2>&1

View File

@ -2,7 +2,7 @@
. /lib/functions.sh
dnsforwader=$(uci get clash.config.dnsforwader 2>/dev/null)
cp /usr/share/clash/server.list /usr/share/clash/list.bak
add_address(){
servers_get()
{
@ -28,7 +28,7 @@ cat /usr/share/clashbackup/address.list /usr/share/clash/server.list > /usr/shar
rm -rf /usr/share/clash/server.list
mv /usr/share/clash/me.list /usr/share/clash/server.list
chmod 755 /usr/share/clash/server.list
rm -rf /tmp/server.conf >/dev/null 2>&1
rm -rf /tmp/server.conf /usr/share/clashbackup/address.list >/dev/null 2>&1
}
if [ "${dnsforwader}" -eq 1 ];then
add_address >/dev/null 2>&1