luci-app-clash: bump to 1.7.0

This commit is contained in:
CN_SZTL 2020-05-30 18:52:40 +08:00
parent f54312b341
commit 02aac23c3d
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
12 changed files with 49 additions and 112 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=1.6.9c
PKG_VERSION:=1.7.0
PKG_MAINTAINER:=frainzy1477
@ -101,6 +101,7 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/usr/share/
$(INSTALL_DIR) $(1)/usr/share/clash
$(INSTALL_DIR) $(1)/usr/share/clash/rules
$(INSTALL_DIR) $(1)/usr/share/clash/rules/g_rules
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard
@ -124,7 +125,6 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) ./root/usr/share/clash/*.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/dns.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/rules/g_rules/Steam.rules $(1)/usr/share/clash/rules/g_rules
$(INSTALL_BIN) ./root//usr/share/clash/rules/rules.list $(1)/usr/share/clash/rules
@ -137,6 +137,8 @@ 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/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

@ -11,7 +11,10 @@ function index()
return
end
entry({"admin", "services", "clash"},alias("admin", "services", "clash", "overview"), _("Clash"), 5)
local page = entry({"admin", "services", "clash"},alias("admin", "services", "clash", "overview"), _("Clash"), 5)
page.dependent = true
page.acl_depends = { "luci-app-oclash" }
entry({"admin", "services", "clash", "overview"},cbi("clash/overview"),_("Overview"), 10).leaf = true
entry({"admin", "services", "clash", "client"},cbi("clash/client"),_("Client"), 20).leaf = true
@ -69,7 +72,6 @@ local function uhttp_port()
end
end
local function download_rule()
local filename = luci.http.formvalue("filename")
local rule_file_dir="/usr/share/clash/rules/g_rules/" .. filename
@ -89,7 +91,7 @@ function action_update_rule()
end
function action_update()
luci.sys.exec("kill $(pgrep /usr/share/clash/update.sh) ; (bash /usr/share/clash/update.sh >>/usr/share/clash/clash.txt 2>&1) &")
luci.sys.exec("kill $(pgrep /usr/share/clash/update.sh) ; (bash /usr/share/clash/update.sh >/usr/share/clash/clash.txt 2>&1) &")
end
@ -317,7 +319,6 @@ function action_status()
web = is_web(),
clash = is_running(),
localip = localip(),
uhttp_port = uhttp_port(),
dash_port = dash_port(),
current_version = current_version(),
clash_core = clash_core(),
@ -328,6 +329,7 @@ function action_status()
e_mode = e_mode(),
in_use = in_use(),
conf_path = conf_path(),
uhttp_port = uhttp_port(),
typeconf = typeconf()
})
end
@ -390,11 +392,15 @@ function check_geoip_log()
local fdp=tonumber(fs.readfile("/var/run/geoiplog")) or 0
local f=io.open("/tmp/geoip_update.txt", "r+")
f:seek("set",fdp)
local a=f:read(2048000) or "."
local a=f:read(2048000) or ""
fdp=f:seek()
fs.writefile("/var/run/geoiplog",tostring(fdp))
f:close()
if fs.access("/var/run/geoip_update") then
luci.http.write(a)
else
luci.http.write(a.."\0")
end
end

View File

@ -1,69 +0,0 @@
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local uci = require("luci.model.uci").cursor()
local fs = require "luci.clash"
local http = luci.http
m = Map("clash")
s = m:section(TypedSection, "clash")
m.pageaction = false
s.anonymous = true
s.addremove=false
local conf = "/etc/clash/config.yaml"
sev = s:option(TextValue, "conf")
sev.readonly=true
sev.rows = 20
sev.wrap = "off"
sev.cfgvalue = function(self, section)
return NXFS.readfile(conf) or ""
end
sev.write = function(self, section, value)
end
o = s:option(Button,"configrm")
o.inputtitle = translate("Delete Config")
o.write = function()
os.execute("rm -rf /etc/clash/config.yaml 2>&1 &")
end
o = s:option(Button, "Download")
o.inputtitle = translate("Download Config")
o.inputstyle = "apply"
o.write = function ()
local sPath, sFile, fd, block
sPath = "/etc/clash/config.yaml"
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".tar.gz"
else
fd = nixio.open(sPath, "r")
end
if not fd then
return
end
HTTP.header('Content-Disposition', 'attachment; filename="%s"' % {sFile})
HTTP.prepare_content("application/octet-stream")
while true do
block = fd:read(nixio.const.buffersize)
if (not block) or (#block ==0) then
break
else
HTTP.write(block)
end
end
fd:close()
HTTP.close()
end
return m

View File

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

View File

@ -1,10 +1,15 @@
local m, s, o
local clash = "clash"
local uci = luci.model.uci.cursor()
local fs = require "nixio.fs"
local sys = require "luci.sys"
local sid = arg[1]
local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
local server_table = {}
local encrypt_methods_ss = {
"rc4-md5",
@ -81,7 +86,6 @@ if m.uci:get(clash, sid) ~= "servers" then
return
end
-- [[ Servers Setting ]]--
s = m:section(NamedSection, sid, "servers")
s.anonymous = true
@ -101,8 +105,6 @@ o:value("http", translate("HTTP(S)"))
o:value("snell", translate("Snell"))
o:value("trojan", translate("trojan"))
o.description = translate("Using incorrect encryption mothod may causes service fail to start")
o = s:option(Value, "name", translate("Alias"))

View File

@ -1,6 +1,5 @@
<%+cbi/valueheader%>
<%local fs=require"nixio.fs"%>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<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>
@ -17,15 +16,14 @@ 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) {
scroll();
var lv = document.getElementById('core_download');
if (x.responseText && lv) {
lv.innerHTML += x.responseText;
}
}
);
function(x, data) {
if(x && x.status === 200) {
if(typeof(x.responseText) === "string") {
lv.insertAdjacentText("beforeend", x.responseText);
lv.scrollTop = lv.scrollHeight;
}}});
}
@ -56,13 +54,6 @@ function hide(){
btn.value = '<%:Download%>';
}
function scroll(){
var textarea = document.getElementById('core_download');
textarea.scrollTop = textarea.scrollHeight;
}
<% if fs.access("/var/run/core_update") then %>
var btn = document.getElementById('apply_update_button');
btn.disabled = true;

View File

@ -1,6 +1,6 @@
<%+cbi/valueheader%>
<%local fs=require"nixio.fs"%>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="button" class="cbi-button cbi-button-apply" id="apply_update_geoip" value="<%:Download%>" onclick=" return apply_update() "/>
<br /><br />
<textarea id="geoip_download" class="cbi-input-textarea" style="width: 100%;display:none" data-update="change" rows="10" cols="100" readonly="readonly" > </textarea>
@ -17,12 +17,14 @@ 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;
}
}
);
@ -58,10 +60,10 @@ function hide(){
}
function scroll(){
/*function scroll(){
var textarea = document.getElementById('geoip_download');
textarea.scrollTop = textarea.scrollHeight;
}
}*/
<% if fs.access("/var/run/geoip_update") then %>

View File

@ -1,5 +1,4 @@
<%
local dsp = require "luci.dispatcher"
-%>
@ -44,4 +43,5 @@ local dsp = require "luci.dispatcher"
);
}
//]]>
</script>
</script>

View File

@ -4,7 +4,7 @@
<script type="text/javascript">//<![CDATA[
var lv = document.getElementById('log');
lv.innerText = "Reading..."
lv.innerText = ""
lv.style.display="inline"
XHR.poll(3, '<%=url([[admin]], [[services]], [[clash]], [[logstatus]])%>', null,
function(x, data) {

View File

@ -1,4 +1,4 @@
#!/bin/bash /etc/rc.common
#!/bin/sh /etc/rc.common
START=99
STOP=15
@ -37,12 +37,12 @@ config_type=$(uci get clash.config.config_type 2>/dev/null)
[ -z "$(grep -w "/usr/share/clash/kill_watchdog.sh" $CRON_FILE)" ] && echo "*/1 * * * * /usr/share/clash/kill_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
[ -z "$(grep -w "/usr/share/clash/clash.txt" $CRON_FILE)" ] && echo "* */$(uci get clash.config.clear_time 2>/dev/null) * * * echo '' >/usr/share/clash/clash.txt" >> $CRON_FILE
fi
auto=$(uci get clash.config.auto_update 2>/dev/null)
if [ "${auto}" -eq 1 ]; then
[ -z "$(grep -w "/usr/share/clash/update_all.sh" $CRON_FILE)" ] && echo "0 */$(uci get clash.config.auto_update_time 2>/dev/null) * * * bash /usr/share/clash/update_all.sh >/usr/share/clash/clash.txt 2>&1 &" >> $CRON_FILE
[ -z "$(grep -w "/usr/share/clash/update_all.sh" $CRON_FILE)" ] && echo "* */$(uci get clash.config.auto_update_time 2>/dev/null) * * * bash /usr/share/clash/update_all.sh >/usr/share/clash/clash.txt 2>&1 &" >> $CRON_FILE
fi
auto_geoip=$(uci get clash.config.auto_update_geoip 2>/dev/null)
@ -255,8 +255,8 @@ rules(){
if [ "${enable_udp}" -eq 1 ]; then
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE"
ip route add local 0.0.0.0/0 dev lo table "$PROXY_ROUTE_TABLE"
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" pref 789
ip route add local default dev lo table "$PROXY_ROUTE_TABLE"
iptables -t mangle -N clash
iptables -t mangle -A clash -d 0.0.0.0/8 -j RETURN
@ -273,7 +273,7 @@ rules(){
done
fi
iptables -t mangle -A clash -p udp -j TPROXY --on-port "${redir_port}" --on-ip 0.0.0.0 --tproxy-mark "$PROXY_FWMARK"
iptables -t mangle -A clash -p udp -j TPROXY --on-port "${redir_port}" --tproxy-mark "$PROXY_FWMARK"
iptables -t mangle -A PREROUTING -p udp -j clash
fi
@ -283,11 +283,13 @@ rules(){
if [ ! -z "${fake_ip_range}" ];then
if [ "${enable_udp}" -eq 1 ]; then
iptables -t nat -A OUTPUT -p tcp -d $fake_ip_range -j REDIRECT --to-ports "${redir_port}"
iptables -t mangle -A OUTPUT -p udp -d $fake_ip_range -j MARK --set-mark "$PROXY_FWMARK"
iptables -t mangle -A OUTPUT -p udp -d $fake_ip_range -j MARK --set-mark "$PROXY_FWMARK"
fi
else
iptables -t nat -A OUTPUT -p tcp -d 198.18.0.1/16 -j REDIRECT --to-ports "${redir_port}"
if [ "${enable_udp}" -eq 1 ]; then
iptables -t mangle -A OUTPUT -p udp -d 198.18.0.1/16 -j MARK --set-mark "$PROXY_FWMARK"
fi
fi
@ -306,7 +308,7 @@ rules(){
fi
done
fi
ip6tables -t mangle -A clash -p udp -j TPROXY --on-port "$proxy_port" --on-ip 0.0.0.0 --tproxy-mark "$PROXY_FWMARK"
ip6tables -t mangle -A clash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark "$PROXY_FWMARK"
ip6tables -t mangle -A PREROUTING -p udp -j clash
fi

View File

@ -48,7 +48,7 @@ fi
if [ "${create}" -eq 1 ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Starting to Create Custom Config.. " >$REAL_LOG
echo "Starting to Create Custom Config.. " >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "开始创建自定义配置..." >$REAL_LOG
fi