luci-app-clash: bump 0.33.0b

This commit is contained in:
CN_SZTL 2019-08-22 18:21:47 +08:00
parent 9de6b16218
commit 7adef39b34
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
30 changed files with 2681 additions and 205 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=0.31.0
PKG_VERSION:=0.33.0
PKG_RELEASE:=1
PKG_MAINTAINER:=frainzy1477
@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/luci-app-clash
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
SUBMENU:=2. Services
TITLE:=LuCI app for clash
DEPENDS:=+bash +coreutils-nohup +wget
PKGARCH:=all
@ -46,6 +46,7 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/clash
$(INSTALL_DIR) $(1)/www
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/usr/share/clash
$(INSTALL_DIR) $(1)/usr/share/clash/web
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard
@ -63,16 +64,18 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) ./root/usr/share/clash/rule.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/clash_version $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/check_version.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/check_core_version.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/installed_core.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/web/* $(1)/usr/share/clash/web
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/index.html $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/main.d32d2df9dcc55f57282d.css $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/main.71cb9fd91422722c5ceb.css $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/img/33343e6117c37aaef8886179007ba6b5.png $(1)/usr/share/clash/dashboard/img/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/img/logo.png $(1)/www/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/1.bundle.d32d2df9dcc55f57282d.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/bundle.d32d2df9dcc55f57282d.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/1.bundle.71cb9fd91422722c5ceb.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/bundle.71cb9fd91422722c5ceb.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_DATA) ./luasrc/clash.lua $(1)/usr/lib/lua/luci/
$(INSTALL_DATA) ./luasrc/controller/*.lua $(1)/usr/lib/lua/luci/controller/
$(INSTALL_DATA) ./luasrc/model/cbi/clash/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/
$(INSTALL_DATA) ./luasrc/view/clash/* $(1)/usr/lib/lua/luci/view/clash/

View File

@ -0,0 +1,244 @@
--[[
LuCI - Filesystem tools
Description:
A module offering often needed filesystem manipulation functions
FileId:
$Id$
License:
Copyright 2008 Steven Barth <steven@midlink.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]--
local io = require "io"
local os = require "os"
local ltn12 = require "luci.ltn12"
local fs = require "nixio.fs"
local nutil = require "nixio.util"
local type = type
--- LuCI filesystem library.
module "luci.clash"
--- Test for file access permission on given path.
-- @class function
-- @name access
-- @param str String value containing the path
-- @return Number containing the return code, 0 on sucess or nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
access = fs.access
--- Evaluate given shell glob pattern and return a table containing all matching
-- file and directory entries.
-- @class function
-- @name glob
-- @param filename String containing the path of the file to read
-- @return Table containing file and directory entries or nil if no matches
-- @return String containing the error description (if no matches)
-- @return Number containing the os specific errno (if no matches)
function glob(...)
local iter, code, msg = fs.glob(...)
if iter then
return nutil.consume(iter)
else
return nil, code, msg
end
end
--- Checks wheather the given path exists and points to a regular file.
-- @param filename String containing the path of the file to test
-- @return Boolean indicating wheather given path points to regular file
function isfile(filename)
return fs.stat(filename, "type") == "reg"
end
--- Checks wheather the given path exists and points to a directory.
-- @param dirname String containing the path of the directory to test
-- @return Boolean indicating wheather given path points to directory
function isdirectory(dirname)
return fs.stat(dirname, "type") == "dir"
end
--- Read the whole content of the given file into memory.
-- @param filename String containing the path of the file to read
-- @return String containing the file contents or nil on error
-- @return String containing the error message on error
readfile = fs.readfile
--- Write the contents of given string to given file.
-- @param filename String containing the path of the file to read
-- @param data String containing the data to write
-- @return Boolean containing true on success or nil on error
-- @return String containing the error message on error
writefile = fs.writefile
--- Copies a file.
-- @param source Source file
-- @param dest Destination
-- @return Boolean containing true on success or nil on error
copy = fs.datacopy
--- Renames a file.
-- @param source Source file
-- @param dest Destination
-- @return Boolean containing true on success or nil on error
rename = fs.move
--- Get the last modification time of given file path in Unix epoch format.
-- @param path String containing the path of the file or directory to read
-- @return Number containing the epoch time or nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
function mtime(path)
return fs.stat(path, "mtime")
end
--- Set the last modification time of given file path in Unix epoch format.
-- @param path String containing the path of the file or directory to read
-- @param mtime Last modification timestamp
-- @param atime Last accessed timestamp
-- @return 0 in case of success nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
function utime(path, mtime, atime)
return fs.utimes(path, atime, mtime)
end
--- Return the last element - usually the filename - from the given path with
-- the directory component stripped.
-- @class function
-- @name basename
-- @param path String containing the path to strip
-- @return String containing the base name of given path
-- @see dirname
basename = fs.basename
--- Return the directory component of the given path with the last element
-- stripped of.
-- @class function
-- @name dirname
-- @param path String containing the path to strip
-- @return String containing the directory component of given path
-- @see basename
dirname = fs.dirname
--- Return a table containing all entries of the specified directory.
-- @class function
-- @name dir
-- @param path String containing the path of the directory to scan
-- @return Table containing file and directory entries or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function dir(...)
local iter, code, msg = fs.dir(...)
if iter then
local t = nutil.consume(iter)
t[#t+1] = "."
t[#t+1] = ".."
return t
else
return nil, code, msg
end
end
--- Create a new directory, recursively on demand.
-- @param path String with the name or path of the directory to create
-- @param recursive Create multiple directory levels (optional, default is true)
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function mkdir(path, recursive)
return recursive and fs.mkdirr(path) or fs.mkdir(path)
end
--- Remove the given empty directory.
-- @class function
-- @name rmdir
-- @param path String containing the path of the directory to remove
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
rmdir = fs.rmdir
local stat_tr = {
reg = "regular",
dir = "directory",
lnk = "link",
chr = "character device",
blk = "block device",
fifo = "fifo",
sock = "socket"
}
--- Get information about given file or directory.
-- @class function
-- @name stat
-- @param path String containing the path of the directory to query
-- @return Table containing file or directory properties or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function stat(path, key)
local data, code, msg = fs.stat(path)
if data then
data.mode = data.modestr
data.type = stat_tr[data.type] or "?"
end
return key and data and data[key] or data, code, msg
end
--- Set permissions on given file or directory.
-- @class function
-- @name chmod
-- @param path String containing the path of the directory
-- @param perm String containing the permissions to set ([ugoa][+-][rwx])
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
chmod = fs.chmod
--- Create a hard- or symlink from given file (or directory) to specified target
-- file (or directory) path.
-- @class function
-- @name link
-- @param path1 String containing the source path to link
-- @param path2 String containing the destination path for the link
-- @param symlink Boolean indicating wheather to create a symlink (optional)
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function link(src, dest, sym)
return sym and fs.symlink(src, dest) or fs.link(src, dest)
end
--- Remove the given file.
-- @class function
-- @name unlink
-- @param path String containing the path of the file to remove
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
unlink = fs.unlink
--- Retrieve target of given symlink.
-- @class function
-- @name readlink
-- @param path String containing the path of the symlink to read
-- @return String containing the link target or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
readlink = fs.readlink

View File

@ -16,6 +16,7 @@ function index()
entry({"admin", "services", "clash", "config"},cbi("clash/config"),_("Config"), 140).leaf = true
entry({"admin","services","clash","status"},call("action_status")).leaf=true
entry({"admin", "services", "clash", "log"},cbi("clash/log"),_("Logs"), 150).leaf = true
entry({"admin", "services", "clash", "update"},cbi("clash/update"),_("Update"), 160).leaf = true
entry({"admin","services","clash","check_status"},call("check_status")).leaf=true
@ -44,6 +45,10 @@ local function check_version()
return luci.sys.exec("sh /usr/share/clash/check_version.sh")
end
local function check_core()
return luci.sys.exec("sh /usr/share/clash/check_core_version.sh")
end
local function current_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/clash_version")
end
@ -52,12 +57,23 @@ local function new_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/new_version")
end
local function new_core_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/new_core_version")
end
local function clash_core()
return luci.sys.exec("sh /usr/share/clash/installed_core.sh && sed -n 1p /usr/share/clash/installed_core")
end
function check_status()
luci.http.prepare_content("application/json")
luci.http.write_json({
check_version = check_version(),
check_core = check_core(),
current_version = current_version(),
new_version = new_version()
new_version = new_version(),
clash_core = clash_core(),
new_core_version = new_core_version()
})
end
@ -70,7 +86,9 @@ function action_status()
dash_port = dash_port(),
current_version = current_version(),
new_version = new_version(),
dash_pass = dash_pass()
dash_pass = dash_pass(),
clash_core = clash_core(),
new_core_version = new_core_version()
})
end

View File

@ -34,6 +34,11 @@ o:value("v2rayn2clash", translate("v2rayn2clash"))
o:value("surge2clash", translate("surge2clash"))
o.description = translate("Select Subcription Type, enter only your subcription url without https://tgbot.lbyczf.com/*?")
md = s:option(Flag, "cusrule", translate("Enabled Custom Rule"))
md.default = 1
md.rmempty = false
md.description = translate("Enabled Custom Rule")
md:depends("subcri", 'v2rayn2clash')
o = s:option(Value, "subscribe_url")
o.title = translate("Subcription Url")

View File

@ -5,7 +5,7 @@ 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
ful = Form("upload", nil)
@ -83,5 +83,34 @@ o.write = function()
os.execute("rm -rf /etc/clash/config.yaml")
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 ful , m

View File

@ -28,7 +28,7 @@ md.description = translate("Enabling Custom DNS will Overwrite your config.yaml
local dns = "/usr/share/clash/dns.yaml"
o = s:option(TextValue, "dns",translate("Modify yaml DNS"))
o.template = "clash/tvalue"
o.rows = 25
o.rows = 26
o.wrap = "off"
o.cfgvalue = function(self, section)
return NXFS.readfile(dns) or ""

View File

@ -0,0 +1,16 @@
local m
local sys = require "luci.sys"
local uci = luci.model.uci.cursor()
ful = Form("upload", nil)
ful.reset = false
ful.submit = false
m = Map("clash")
m:section(SimpleSection).template = "clash/update"
return m, ful

View File

@ -26,8 +26,8 @@
<fieldset class="cbi-section">
<table width="100%" cellspacing="10">
<tr><td class="align-left" width="50%"><span><%:Global IP%> </span>&nbsp;:&nbsp;<span id="ip-gb"></span> <span id="ip-geo"></span></td> <td class="align-right" width="25%"> <span><%:Google%></span>&nbsp;:&nbsp;<span id="_google"><em><%:Collecting data...%></em></span></td><td class="align-right"><%:Youtube%> </span>&nbsp;:&nbsp;<span id="_youtube"><em><%:Collecting data...%></em></span></td></tr>
<tr><td class="align-left" width="50%"><span><%:Domestic IP%> </span>&nbsp;:&nbsp;<span id="d-ip"></span></td> <td class="align-right" width="25%"> <span><%:Baidu%></span>&nbsp;:&nbsp;<span id="_baidu"><em><%:Collecting data...%></em></span></td> <td class="align-right"><%:Taobao%> </span>&nbsp;:&nbsp;<span id="_taobao"><em><%:Collecting data...%></em></span></td></tr>
<tr><td class="align-left" width="50%"><span><%:Global IP%> </span>&nbsp;:&nbsp;<span id="ip-ipify"><font color=red><%:Checking...%></font></span> <span id="ip-ipify-ipip"></span></td> <td class="align-right" width="25%"> <span><%:Google%></span>&nbsp;:&nbsp;<span id="_google"><em><%:Collecting data...%></em></span></td><td class="align-right"><%:Youtube%> </span>&nbsp;:&nbsp;<span id="_youtube"><em><%:Collecting data...%></em></span></td></tr>
<tr><td class="align-left" width="50%"><span><%:Domestic IP%> </span>&nbsp;:&nbsp;<span id="d-ip"><font color=red><%:Checking...%></font></span></td> <td class="align-right" width="25%"> <span><%:Baidu%></span>&nbsp;:&nbsp;<span id="_baidu"><em><%:Collecting data...%></em></span></td> <td class="align-right"><%:Taobao%> </span>&nbsp;:&nbsp;<span id="_taobao"><em><%:Collecting data...%></em></span></td></tr>
</table>
</fieldset>
@ -59,7 +59,17 @@ let IP = {
}).catch(error => {
throw error;
}),
parseIPIpip: (ip, elID) => {
IP.get(`https://api.skk.moe/network/parseIp/ipip/${ip}`, 'json')
.then(resp => {
let x = '';
for (let i of resp.data) {
x += (i !== '') ? `${i} ` : '';
}
document.getElementById(elID).innerHTML = x;
//$$.getElementById(elID).innerHTML = `${resp.data.country} ${resp.data.regionName} ${resp.data.city} ${resp.data.isp}`;
})
},
getIpipnetIP: () => {
IP.get(`https://myip.ipip.net/?z=${random}`, 'text')
@ -68,16 +78,20 @@ let IP = {
document.getElementById('d-ip').innerHTML = `${data[0]} ${data[1]}`;
});
},
getIpsbIP: (data) => {
document.getElementById('ip-gb').innerHTML = data.address;
document.getElementById('ip-geo').innerHTML = `${data.country} ${data.province} ${data.city} ${data.isp.name}`
},
getIpifyIP: () => {
IP.get(`https://api.ipify.org/?format=json&z=${random}`, 'json')
.then(resp => {
document.getElementById('ip-ipify').innerHTML = resp.data.ip;
return resp.data.ip;
})
.then(ip => {
IP.parseIPIpip(ip, 'ip-ipify-ipip');
})
}
}
IP.getIpipnetIP();
var HTTP = {
@ -101,6 +115,26 @@ var HTTP = {
}
function Load()
{
var tbip = document.getElementsByTagName('HEAD').item(0);
var tbipScript= document.createElement("script");
tbipScript.async = "async";
tbipScript.src='https://myip.ipip.net/?z=${random}';
tbip.appendChild( tbipScript);
var sbip = document.getElementsByTagName('HEAD').item(0);
var sbipScript= document.createElement("script");
sbipScript.async = "async";
sbipScript.src='https://api.skk.moe/network/parseIp/ipip';
sbip.appendChild( sbipScript);
const $$ = document;
random = parseInt(Math.random() * 100000000);
IP.getIpifyIP();
IP.getIpipnetIP();
setTimeout("Load()",1000*8);
}
var web = document.getElementById('_web');
var webb = document.getElementById('_webb');
var clash = document.getElementById('_clash');
@ -130,86 +164,24 @@ var HTTP = {
});
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
IP.getIpifyIP();
IP.getIpipnetIP();
getip();
//getip();
}
});
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', status.current_version, function(x, status) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
version.innerHTML = status.current_version ? '<b><font color=green><%:Current Version%>'+'&nbsp;:&nbsp;v'+status.current_version+'</font> </b><br><center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check Update%>" onclick="return version_check(this)"/></center>' : '<em><b><font color=red>NOT SET</font></b></em>';
version.innerHTML = status.current_version ? '<b><font color=green><%:Current Version%>'+'&nbsp;:&nbsp;v'+status.current_version+'</font> </b>' : '<em><b><font color=red>NOT SET</font></b></em>';
}
});
function version_check(btn)
{
btn.disabled = true;
btn.value = '<%:Checking...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
if(status.new_version > status.current_version)
{
version.innerHTML ='<font color="green"><b>'+'<%:New Version%>'+'&nbsp;:&nbsp;v'+status.new_version+'</b></font><br><center>' + '<input type="button" class="cbi-button cbi-button-apply" value="<%:Download%>" onclick="return download_update(this)"/>' + '&nbsp;&nbsp;&nbsp;' + '<input type="button" class="cbi-button cbi-button-reset" value="<%:Return Check%>" onclick="return check_return(this)"/></center>';
}
else if(status.new_version==0)
{
version.innerHTML ='<font color="red"><b>'+'<%:Check Error!%>'+'</b></font>'+'<br><center><input type="button" class="cbi-button cbi-button-reset" value="<%:Return Check%>" onclick="return check_return(this)"/></center>';
}
else if(status.current_version >= status.new_version)
{
version.innerHTML ='<font color="green"><b>'+'<%:No New Version%>'+'</b></font>'+'<br><center><input type="button" class="cbi-button cbi-button-reset" value="<%:Return Check%>" onclick="return check_return(this)"/></center>';
}
return false;
});
}
function download_update(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Download%>';
url='https://github.com/frainzy1477/luci-app-clash/releases/download/v'+status.new_version+'/luci-app-clash_'+status.new_version+'-1_all.ipk';
window.open(url);
btn.disabled = false;
return false;
});
}
function check_return(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', status.current_version, function(x, status) {
btn.disabled = true;
btn.value = '<%:Return Check%>';
version.innerHTML = '<b><font color="green">'+'<%:Current Version%>'+'&nbsp;:&nbsp;v'+status.current_version+'</font></b>'+'<br><center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check Update%>" onclick="return version_check(this)"/></center>';
});
}
//]]></script>
<script src="https://ipv4.ip.sb/addrinfo?callback=IP.getIpsbIP"></script>
<script type="application/javascript">
function getip() {
$.getJSON("https://ipv4.ip.sb/addrinfo?callback=?",
function(json) {
console.log(json)
document.getElementById('ip-gb').innerHTML = json.address;
document.getElementById('ip-geo').innerHTML = `${json.country} ${json.province} ${json.city} ${json.isp.name}`
}
);
}
</script>

View File

@ -0,0 +1,159 @@
<fieldset class="cbi-section">
<table width="100%" cellspacing="10">
<thead align="center">
<tr>
<th align="center"><%:App Name%></th>
<th align="center"><%:Installed Version%></th>
<th align="center"><%:Check Update%></th>
</tr>
</thead>
<tbody>
<tr>
<td align="center" width="35%">Clash</td> <td align="center" width="35%" id="_core"><%:Collecting data...%></td> <td width="35%" align="center" id="_corebutt"></td>
</tr>
<tr>
<td align="center" width="35%">Luci-app-clash</td> <td align="center" width="35%" id="_version"><%:Collecting data...%> </td> <td width="35%" align="center" id="_versionbutt"></td>
</tr>
</tbody>
</table>
</fieldset>
<script type="text/javascript">//<![CDATA[
var version = document.getElementById('_version');
var core = document.getElementById('_core');
var version_butt = document.getElementById('_versionbutt');
var core_butt = document.getElementById('_corebutt');
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
core_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return core_check(this)"/></center>' : '<em></em>';
version_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return version_check(this)"/></center>' : '<em></em>';
}
});
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if(status.clash_core==0){
core.innerHTML = status.clash_core ? '<b><font color=red><%:Not Installed%></font> </b>' : '<em><b><font color=red><%:Checking...%></font></b></em>';
}
else
{
core.innerHTML = status.clash_core ? '<b><font color=green>'+status.clash_core+'</font> </b>' : '<em><b><font color=red><%:Checking...%></font></b></em>';
}
version.innerHTML = status.current_version ? '<b><font color=green>'+status.current_version+'</font> </b>' : '<em><b><font color=red><%:Checking...%></font></b></em>';
}
});
function version_check(btn)
{
btn.disabled = true;
btn.value = '<%:Checking...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
if(status.new_version > status.current_version)
{
version_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-apply" value="<%:Download%>" onclick="return download_update(this)"/>' + '&nbsp;&nbsp;&nbsp;' + '<input type="button" class="cbi-button cbi-button-reset" value="<%:Return%>" onclick="return check_return(this)"/></center>';
}
else if(status.new_version==0)
{
version_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-reset" value="<%:Error Occured | Return%>" onclick="return check_return(this)"/></center>';
}
else if(status.current_version >= status.new_version)
{
version_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-reset" value="<%:No Update | Return%>" onclick="return check_return(this)"/></center>';
}
return false;
});
}
function core_check(btn)
{
btn.disabled = true;
btn.value = '<%:Checking...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
if(status.new_core_version > status.clash_core)
{
core_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-apply" value="<%:Download%>" onclick="return download_core(this)"/>' + '&nbsp;&nbsp;&nbsp;' + '<input type="button" class="cbi-button cbi-button-reset" value="<%:Return%>" onclick="return core_return(this)"/></center>';
}
else if(status.new_core_version==0)
{
core_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-reset" value="<%:Error Occured |Return%>" onclick="return core_return(this)"/></center>';
}
else if(status.clash_core >= status.new_core_version)
{
core_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-reset" value="<%:No Update | Return%>" onclick="return core_return(this)"/></center>';
}
return false;
});
}
function download_update(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Download%>';
url='https://github.com/frainzy1477/luci-app-clash/releases/download/v'+status.new_version+'/luci-app-clash_'+status.new_version+'-1_all.ipk';
window.open(url);
btn.disabled = false;
return false;
});
}
function download_core(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Download%>';
url='https://github.com/frainzy1477/clash/releases/tag/v'+status.new_core_version+'';
window.open(url);
btn.disabled = false;
return false;
});
}
function check_return(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', status.current_version, function(x, status) {
btn.disabled = true;
btn.value = '<%:Return Check%>';
version_butt.innerHTML = '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return version_check(this)"/></center>';
});
}
function core_return(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', status.clash_core, function(x, status) {
btn.disabled = true;
btn.value = '<%:Return Check%>';
core_butt.innerHTML = '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return core_check(this)"/></center>';
});
}
//]]></script>

View File

@ -1,6 +1,12 @@
msgid "Update Config"
msgstr "更新配置"
msgid "Enabled Custom Rule"
msgstr "启用自定义规则"
msgid "Download Config"
msgstr "下载配置"
msgid "Enable/Start/Restart Client"
msgstr "启用/启动/重新启动客户端"
@ -43,8 +49,8 @@ msgstr "socks代理端口"
msgid "Redir Port"
msgstr "redir代理端口"
msgid "No New Version"
msgstr "已安装最新本"
msgid "No Update | Return"
msgstr "已安装最新本 | 返回"
msgid "Log level"
msgstr "日志级别"
@ -61,24 +67,33 @@ msgstr "下载新版本"
msgid "Checking..."
msgstr "正在检查..."
msgid "Not Installed"
msgstr "未安装"
msgid "Installed Version"
msgstr "已安装版本"
msgid "App Name"
msgstr "应用程序名称"
msgid "Rule-based Custom Proxy Client"
msgstr "基于规则的自定义代理客户端"
msgid "Check Error!"
msgstr "检查错误"
msgid "New Version"
msgstr "最新版本"
msgid "Error Occured | Return"
msgstr "检查错误 | 返回"
msgid "Current Version"
msgstr "当前版本"
msgid "Return Check"
msgid "Return"
msgstr "返回检查"
msgid "Check Update"
msgstr "检查更新"
msgid "Check"
msgstr "检查"
msgid "DNS Forwarding"
msgstr "DNS转发"

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ config clash 'config'
option proxylan '0'
option rejectlan '0'
option dnsforwader '0'
option subcri 'clash'
option v2ray 'https://tgbot.lbyczf.com/v2rayn2clash?url='
option surge 'https://tgbot.lbyczf.com/surge2clash?url='
option subcri 'clash'
option cusrule '0'

View File

@ -55,6 +55,7 @@ yml_change(){
dash_port=$(uci get clash.config.dash_port 2>/dev/null)
log_level=$(uci get clash.config.level 2>/dev/null)
subtype=$(uci get clash.config.subcri 2>/dev/null)
if [ $mode -eq 1 ]; then
sed -i "/Proxy:/i\#clash-openwrt" $CONFIG_YAML
@ -86,11 +87,14 @@ else
mv $CONFIG_YAML /etc/clash/dns.yaml
cat /usr/share/clash/dns.yaml /etc/clash/dns.yaml > $CONFIG_YAML
rm -rf /etc/clash/dns.yaml
else
sed -i "/dns:/i\#clash-openwrt" $CONFIG_YAML
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML
fi
sed -i "1i\port: ${http_port}" $CONFIG_YAML
sed -i "2i\socks-port: ${socks_port}" $CONFIG_YAML
sed -i "3i\redir-port: ${redir_port}" $CONFIG_YAML
@ -235,8 +239,10 @@ lan=$(uci get clash.config.proxylan 2>/dev/null)
lanac=$(uci get clash.config.rejectlan 2>/dev/null)
if [ $enable -eq 1 ]; then
if [ $size -ne 0 ]; then
if [ ! -f /etc/clash/clash ]; then
echo "===============================$(date "+%Y-%m-%d %H:%M:%S") /etc/clash/clash not found, download and install clash ipk =====================================" >> /tmp/clash.log
else
if [ $size -ne 0 ] && [ -f /etc/clash/clash ]; then
if [ $lan ]; then
@ -276,6 +282,7 @@ else
fi
fi
fi

View File

@ -0,0 +1,10 @@
#!/bin/sh
if [ -f /usr/share/clash/new_core_version ];then
rm -rf /usr/share/clash/new_core_version
fi
new_core_version=`wget -qO- "https://github.com/frainzy1477/clash/tags"| grep "/frainzy1477/clash/releases/tag/"| head -n 1| awk -F "/tag/v" '{print $2}'| sed 's/\">//'`
if [ $new_core_version ]; then
echo $new_core_version > /usr/share/clash/new_core_version 2>&1 & >/dev/null
elif [ $new_core_version =="" ]; then
echo 0 > /usr/share/clash/new_core_version 2>&1 & >/dev/null
fi

View File

@ -3,6 +3,7 @@ subscribe_url=$(uci get clash.config.subscribe_url 2>/dev/null)
subtype=$(uci get clash.config.subcri 2>/dev/null)
urlv2ray=$(uci get clash.config.v2ray 2>/dev/null)
urlsurge=$(uci get clash.config.surge 2>/dev/null)
cusrule=$(uci get clash.config.cusrule 2>/dev/null)
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_TEMP="/etc/clash/server.yaml"
CONFIG_YAML_RULE="/usr/share/clash/rule.yaml"
@ -12,13 +13,17 @@ rm -rf /etc/clash/config.bak 2> /dev/null
if [ $subtype == "clash" ];then
wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $subscribe_url -O 2>&1 >1 $CONFIG_YAML
elif [ $subtype == "v2rayn2clash" ];then
wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML_TEMP
if [ $cusrule == 1 ];then
wget-ssl --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML_TEMP
if [ -f $CONFIG_YAML_TEMP ];then
sed -i '/Rule:/,$d' $CONFIG_YAML_TEMP
cat $CONFIG_YAML_TEMP $CONFIG_YAML_RULE > $CONFIG_YAML
fi
else
wget-ssl --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
elif [ $subtype == "surge2clash" ];then
wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
wget-ssl --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
rm -rf $CONFIG_YAML_TEMP 2> /dev/null
uci set clash.config.enable=1 2> /dev/null
@ -27,15 +32,19 @@ uci commit clash 2> /dev/null
else
rm -rf /etc/clash/config.bak 2> /dev/null
if [ $subtype == "clash" ];then
wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $subscribe_url -O 2>&1 >1 $CONFIG_YAML
wget-ssl --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla" $subscribe_url -O 2>&1 >1 $CONFIG_YAML
elif [ $subtype == "v2rayn2clash" ];then
wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML_TEMP
if [ $cusrule == 1 ];then
wget-ssl --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML_TEMP
if [ -f $CONFIG_YAML_TEMP ];then
sed -i '/Rule:/,$d' $CONFIG_YAML_TEMP
cat $CONFIG_YAML_TEMP $CONFIG_YAML_RULE > $CONFIG_YAML
fi
else
wget-ssl --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
elif [ $subtype == "surge2clash" ];then
wget-ssl --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
wget-ssl --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
rm -rf $CONFIG_YAML_TEMP 2> /dev/null
fi

View File

@ -3,9 +3,9 @@
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>CLASH -DASHBOARD</title>
<link href="main.d32d2df9dcc55f57282d.css" rel="stylesheet"></head>
<title>Clash Dashboard</title>
<link href="main.71cb9fd91422722c5ceb.css" rel="stylesheet"></head>
<body>
<div id="root"></div>
<script type="text/javascript" src="js/1.bundle.d32d2df9dcc55f57282d.min.js"></script><script type="text/javascript" src="js/bundle.d32d2df9dcc55f57282d.min.js"></script></body>
<script type="text/javascript" src="js/1.bundle.71cb9fd91422722c5ceb.min.js"></script><script type="text/javascript" src="js/bundle.71cb9fd91422722c5ceb.min.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,17 +8,19 @@
dns:
enable: true
# ipv6: false
listen: 0.0.0.0:5300
enhanced-mode: fake-ip
#fake-ip-range: 198.18.0.1/16
# # experimental hosts, support wildcard
# (e.g. *.clash.dev Even *.foo.*.example.com)
# # static domain has a higher priority
# than wildcard domain (foo.example.com > *.example.com)
# # NOTE: hosts don't work with `fake-ip`
# hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'
nameserver:
- 101.132.183.99
- 119.29.29.29
- 114.114.114.114
- 114.114.115.115
- tls://dns.rubyfish.cn:853
- https://1.1.1.1/dns-query
# fallback:
# - tls://1.1.1.1:853

View File

@ -0,0 +1,11 @@
#!/bin/sh
if [ -f /usr/share/clash/installed_core ];then
rm -rf /usr/share/clash/installed_core
fi
check_core=$(opkg list-installed | grep 'clash' |awk -F ' - ' 'NR==1{print $1}' 2>/dev/null)
if [ $check_core == 'clash' ];then
curent_core=$(opkg list-installed | grep 'clash' |awk -F ' - ' 'NR==1{print $2}' 2>/dev/null)
echo $curent_core > /usr/share/clash/installed_core 2>&1 & >/dev/null
elif [ $check_core == 'luci-app-clash' ];then
echo 0 > /usr/share/clash/installed_core 2>&1 & >/dev/null
fi

View File

@ -1,29 +1,23 @@
- name: "Overseas"
type: select
proxies:
- "Proxy"
- "DIRECT"
- name: "GlobalTV"
type: select
proxies:
- "Proxy"
- "DIRECT"
- name: AsianTV
type: select
proxies:
- "DIRECT"
- "Proxy"
- "Proxy"
- name: AdBlock
type: select
proxies:
- "REJECT"
Rule:
- DOMAIN-SUFFIX,zjhu.edu.cn,DIRECT
- DOMAIN,gs.apple.com,Proxy
@ -1868,4 +1862,4 @@ Rule:
- IP-CIDR,209.237.192.0/19,Proxy
- GEOIP,CN,DIRECT
- MATCH,Overseas
- MATCH,Overseas

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,16 +7,21 @@
<link rel="icon" type="image/png" sizes="128x128" href="yacd-128.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name="application-name" content="YACD">
<meta name="description" content="YACD">
<meta name="theme-color" content="#fff000">
<title>YAC - DASHBOARD</title>
<meta name="application-name" content="yacd">
<meta name="description" content="Yet Another Clash Dashboard">
<meta name="theme-color" content="#202020">
<title>yacd - Yet Another Clash Dashboard</title>
<link rel="prefetch" href="https://cdn.jsdelivr.net/npm/@hsjs/fonts@0.0.1/robotomono/v5/L0x5DF4xlVMF-BfR8bXMIjhLq3-cXbKD.woff2">
<link rel="prefetch" href="https://fonts.loli.net/css?family=Merriweather+Sans:400,700&display=swap" rel="stylesheet">
<meta property="og:image" content="https://user-images.githubusercontent.com/1166872/47304841-536f3d80-d65a-11e8-8908-1917127dafc5.png">
<meta property="og:site_name" content="yacd">
<meta property="og:type" content="object">
<meta property="og:title" content="yacd">
<meta property="og:url" content="http://yacd.haishan.me">
<meta property="og:description" content="Yet Another Clash Dashboard">
<link href="app.5a1265735d78e67da9fe.css" rel="stylesheet">
<link href="app.83f6698cbf7891b130e2.css" rel="stylesheet">
<body>
@ -29,7 +34,7 @@
<script src="react~app.6097406f382313d294e3.js" type="text/javascript"></script>
<script src="app.6cc7f04cc66718dd2c90.js" type="text/javascript"></script>
<script src="app.99489dd938c57b6c22da.js" type="text/javascript"></script>
</body>

File diff suppressed because one or more lines are too long