luci-app-clash: bump to v1.1.7 with core v0.15.5

This commit is contained in:
CN_SZTL 2019-10-01 09:17:42 +08:00
parent d3044d4a68
commit eb7d4b576e
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
78 changed files with 3369 additions and 7401 deletions

View File

@ -1,15 +1,14 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=clash
PKG_VERSION:=0.15.1
PKG_RELEASE:=1
PKG_VERSION:=0.15.5
PKG_MAINTAINER:=frainzy1477
ifeq ($(ARCH),mipsel)
PKG_ARCH:=mipsle
endif
ifeq ($(ARCH),mips)
PKG_ARCH:=mips64
PKG_ARCH:=mips
endif
ifeq ($(ARCH),i386)
PKG_ARCH:=386
@ -18,13 +17,13 @@ ifeq ($(ARCH),x86_64)
PKG_ARCH:=amd64
endif
ifeq ($(ARCH),arm)
PKG_ARCH:=armv6
ifneq ($(BOARD),bcm53xx)
PKG_ARCH:=armv7
endif
ifeq ($(BOARD),kirkwood)
PKG_ARCH:=armv5
endif
PKG_ARCH:=armv6
ifneq ($(BOARD),bcm53xx)
PKG_ARCH:=armv7
endif
ifeq ($(BOARD),kirkwood)
PKG_ARCH:=armv5
endif
endif
ifeq ($(ARCH),aarch64)
PKG_ARCH:=armv8
@ -58,7 +57,10 @@ endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/clash
$(INSTALL_DIR) $(1)/usr/share/clash
$(INSTALL_BIN) $(PKG_BUILD_DIR)/clash-linux-$(PKG_ARCH) $(1)/etc/clash/clash
$(INSTALL_BIN) ./file/core_version $(1)/usr/share/clash/
endef

View File

@ -0,0 +1 @@
0.15.5

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_VERSION:=1.1.7
PKG_RELEASE:=2
PKG_MAINTAINER:=frainzy1477
@ -13,23 +13,20 @@ define Package/luci-app-clash
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI app for clash
DEPENDS:=+bash +coreutils-nohup +wget
DEPENDS:=+luci +luci-base +wget +iptables +coreutils +coreutils-nohup +bash +ipset +libustream-openssl +libopenssl +openssl-util
PKGARCH:=all
MAINTAINER:=frainzy1477
endef
define Package/luci-app-clash/description
LuCI configuration for clash.
Luci Interface for clash.
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
rm -rf /tmp/luci*
endef
define Build/Prepare
chmod 777 -R ${CURDIR}/tools/po2lmo
${CURDIR}/tools/po2lmo/src/po2lmo ${CURDIR}/po/zh-cn/clash.po ${CURDIR}/po/zh-cn/clash.zh-cn.lmo
endef
define Build/Configure
@ -38,6 +35,74 @@ endef
define Build/Compile
endef
define Package/$(PKG_NAME)/preinst
#!/bin/sh
if [ -f "/tmp/dnsmasq.d/custom_list.conf" ]; then
rm -rf /tmp/dnsmasq.d/custom_list.conf
fi
if [ -d "/tmp/dnsmasq.clash" ]; then
rm -rf /tmp/dnsmasq.clash
fi
if [ -f "/etc/config/clash" ]; then
mv /etc/config/clash /etc/config/clash.bak
fi
if [ -d "/usr/lib/lua/luci/model/cbi/clash" ]; then
rm -rf /usr/lib/lua/luci/model/cbi/clash
fi
if [ -d "/usr/lib/lua/luci/view/clash" ]; then
rm -rf /usr/lib/lua/luci/view/clash
fi
if [ -f /usr/share/clash/new_core_version ]; then
rm -rf /usr/share/clash/new_core_version
fi
if [ -f /usr/share/clash/new_luci_version ]; then
rm -rf /usr/share/clash/new_luci_version
fi
if [ -d /usr/share/clash/web ]; then
rm -rf /usr/share/clash/web
fi
if [ -f /usr/share/clash/config/sub/config.yaml ] && [ "$(ls -l /usr/share/clash/config/sub/config.yaml | awk '{print int($5/1024)}')" -ne 0 ];then
mv /usr/share/clash/config/sub/config.yaml /usr/share/clash/config/sub/config.bak
fi
if [ -f /usr/share/clash/config/upload/config.yaml ] && [ "$(ls -l /usr/share/clash/config/upload/config.yaml | awk '{print int($5/1024)}')" -ne 0 ];then
mv /usr/share/clash/config/upload/config.yaml /usr/share/clash/config/upload/config.bak
fi
if [ -f /usr/share/clash/config/custom/config.yaml ] && [ "$(ls -l /usr/share/clash/config/custom/config.yaml | awk '{print int($5/1024)}')" -ne 0 ];then
mv /usr/share/clash/config/custom/config.yaml /usr/share/clash/config/custom/config.bak
fi
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
rm -rf /tmp/luci*
if [ -f "/etc/config/clash.bak" ]; then
mv /etc/config/clash.bak /etc/config/clash
fi
if [ -f /usr/share/clash/config/sub/config.bak ];then
mv /usr/share/clash/config/sub/config.bak /usr/share/clash/config/sub/config.yaml
fi
if [ -f /usr/share/clash/config/upload/config.bak ];then
mv /usr/share/clash/config/upload/config.bak /usr/share/clash/config/upload/config.yaml
fi
if [ -f /usr/share/clash/config/custom/config.bak ];then
mv /usr/share/clash/config/custom/config.bak /usr/share/clash/config/custom/config.yaml
fi
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash
@ -46,13 +111,22 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/init.d
$(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/
$(INSTALL_DIR) $(1)/usr/share/clash
$(INSTALL_DIR) $(1)/usr/share/clash/web
$(INSTALL_DIR) $(1)/usr/share/clash/yac
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard/img
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard/js
$(INSTALL_DIR) $(1)/usr/share/clash/config
$(INSTALL_DIR) $(1)/usr/share/clash/config/sub
$(INSTALL_DIR) $(1)/usr/share/clash/config/upload
$(INSTALL_DIR) $(1)/usr/share/clash/config/custom
$(INSTALL_BIN) ./root/usr/share/clash/config/upload/config.yaml $(1)/usr/share/clash/config/upload/
$(INSTALL_BIN) ./root/usr/share/clash/config/custom/config.yaml $(1)/usr/share/clash/config/custom/
$(INSTALL_BIN) ./root/usr/share/clash/config/sub/config.yaml $(1)/usr/share/clash/config/sub/
$(INSTALL_BIN) ./root/etc/init.d/clash $(1)/etc/init.d/clash
$(INSTALL_CONF) ./root/etc/config/clash $(1)/etc/config/clash
@ -61,23 +135,26 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) ./root/usr/share/clash/clash-watchdog.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/clash.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/ipdb.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/get_proxy.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/proxy.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/dns.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/rule.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/custom_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/luci_version $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/check_luci_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/proxy.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/yum_change.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/web/* $(1)/usr/share/clash/web
$(INSTALL_BIN) ./root/usr/share/clash/groups.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/rule.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/list.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/server.list $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/yac/* $(1)/usr/share/clash/yac/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/index.html $(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/main.557c7e0375c2286ea607.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.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_BIN) ./root/usr/share/clash/dashboard/js/1.bundle.557c7e0375c2286ea607.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/bundle.557c7e0375c2286ea607.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/
@ -87,4 +164,6 @@ define Package/$(PKG_NAME)/install
endef
$(eval $(call BuildPackage,luci-app-clash))

View File

@ -6,19 +6,30 @@ function index()
return
end
entry({"admin", "services", "clash"},alias("admin", "services", "clash", "overview"), _("Clash"), 60).dependent = false
entry({"admin", "services", "clash"},alias("admin", "services", "clash", "overview"), _("Clash"), 10).dependent = false
entry({"admin", "services", "clash", "overview"},cbi("clash/overview"),_("Overview"), 10).leaf = true
entry({"admin", "services", "clash", "client"},cbi("clash/client"),_("Client"), 20).leaf = true
entry({"admin", "services", "clash", "settings"}, firstchild(),_("Settings"), 100)
entry({"admin", "services", "clash", "settings", "port"},cbi("clash/port"),_("Proxy Ports"), 100).leaf = true
entry({"admin", "services", "clash", "settings", "dns"},cbi("clash/dns"),_("DNS Settings"), 120).leaf = true
entry({"admin", "services", "clash", "settings", "access"},cbi("clash/access"),_("Access Control"), 130).leaf = true
entry({"admin", "services", "clash", "servers"}, arcombine(cbi("clash/servers"),cbi("clash/servers-config")),_("Servers"), 140).leaf = true
entry({"admin", "services", "clash", "config"},cbi("clash/config"),_("Config"), 150).leaf = true
entry({"admin", "services", "clash", "servers"},cbi("clash/servers"),_("Servers"), 30).leaf = true
entry({"admin", "services", "clash", "servers-config"},cbi("clash/servers-config"), nil).leaf = true
entry({"admin", "services", "clash", "groups"},cbi("clash/groups"), nil).leaf = true
entry({"admin", "services", "clash", "settings"}, firstchild(),_("Settings"), 40)
entry({"admin", "services", "clash", "settings", "port"},cbi("clash/port"),_("Proxy Ports"), 40).leaf = true
entry({"admin", "services", "clash", "settings", "dns"},cbi("clash/dns"),_("DNS Settings"), 50).leaf = true
entry({"admin", "services", "clash", "settings", "list"},cbi("clash/list"),_("Custom List"), 60).leaf = true
entry({"admin", "services", "clash", "settings", "access"},cbi("clash/access"),_("Access Control"), 70).leaf = true
entry({"admin", "services", "clash", "config"},firstchild(),_("Config"), 80)
entry({"admin", "services", "clash", "config", "actconfig"},cbi("clash/actconfig"),_("Config In Use"), 90).leaf = true
entry({"admin", "services", "clash", "config", "subconfig"},cbi("clash/subconfig"),_("Subscribe Config"), 100).leaf = true
entry({"admin", "services", "clash", "config", "upconfig"},cbi("clash/upconfig"),_("Uploaded Config"), 110).leaf = true
entry({"admin", "services", "clash", "config", "cusconfig"},cbi("clash/cusconfig"),_("Custom Config"), 120).leaf = true
entry({"admin","services","clash","status"},call("action_status")).leaf=true
entry({"admin", "services", "clash", "log"},cbi("clash/log"),_("Logs"), 160).leaf = true
entry({"admin", "services", "clash", "update"},cbi("clash/update"),_("Update"), 170).leaf = true
entry({"admin", "services", "clash", "log"},cbi("clash/log"),_("Log"), 130).leaf = true
entry({"admin", "services", "clash", "update"},cbi("clash/update"),_("Update"), 140).leaf = true
entry({"admin","services","clash","check_status"},call("check_status")).leaf=true
entry({"admin", "services", "clash", "ping"}, call("act_ping")).leaf=true
end
@ -43,7 +54,7 @@ local function localip()
end
local function check_version()
return luci.sys.exec("sh /usr/share/clash/check_version.sh")
return luci.sys.exec("sh /usr/share/clash/check_luci_version.sh")
end
local function check_core()
@ -51,11 +62,11 @@ local function check_core()
end
local function current_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/clash_version")
return luci.sys.exec("sed -n 1p /usr/share/clash/luci_version")
end
local function new_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/new_version")
return luci.sys.exec("sed -n 1p /usr/share/clash/new_luci_version")
end
local function new_core_version()
@ -63,11 +74,16 @@ local function new_core_version()
end
local function e_mode()
return luci.sys.exec("grep enhanced-mode: /etc/clash/config.yaml |awk -F ':' '{print $2}'")
return luci.sys.exec("egrep '^ {0,}enhanced-mode' /etc/clash/config.yaml |grep enhanced-mode: |awk -F ': ' '{print $2}'")
end
local function clash_core()
return luci.sys.exec("sh /usr/share/clash/installed_core.sh && sed -n 1p /usr/share/clash/installed_core")
if nixio.fs.access("/usr/share/clash/core_version") then
return luci.sys.exec("sed -n 1p /usr/share/clash/core_version")
else
return "0"
end
end
function check_status()
@ -78,8 +94,8 @@ function check_status()
current_version = current_version(),
new_version = new_version(),
clash_core = clash_core(),
new_core_version = new_core_version(),
e_mode = e_mode()
new_core_version = new_core_version()
})
end
@ -91,12 +107,19 @@ function action_status()
localip = localip(),
dash_port = dash_port(),
current_version = current_version(),
new_version = new_version(),
dash_pass = dash_pass(),
clash_core = clash_core(),
new_core_version = new_core_version(),
dash_pass = dash_pass(),
e_mode = e_mode()
})
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"))
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -4,16 +4,20 @@ local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.clash"
local uci = require "luci.model.uci".cursor()
m = Map("clash")
s = m:section(TypedSection, "clash")
--m.pageaction = false
s.anonymous = true
s.addremove=false
md = s:option(Flag, "proxylan", translate("Proxy Lan IP"))
md.default = 1
md.rmempty = false
md.description = translate("Only selected IPs will be proxied if enabled")
md.description = translate("Only selected IPs will be proxied if enabled. fake-ip mode not supported")
md:depends("rejectlan", 0)
@ -28,6 +32,7 @@ end)
o:depends("proxylan", 1)
update_time = SYS.exec("ls -l --full-time /etc/clash/Country.mmdb|awk '{print $6,$7;}'")
o = s:option(Button,"update",translate("Update GEOIP Database"))
o.title = translate("GEOIP Database")
@ -45,7 +50,7 @@ end
md = s:option(Flag, "rejectlan", translate("Bypass Lan IP"))
md.default = 1
md.rmempty = false
md.description = translate("Selected IPs will not be proxied if enabled")
md.description = translate("Selected IPs will not be proxied if enabled. fake-ip mode not supported")
md:depends("proxylan", 0)
@ -61,5 +66,12 @@ o:depends("rejectlan", 1)
local apply = luci.http.formvalue("cbi.apply")
if apply then
uci:commit("clash")
if luci.sys.call("pidof clash >/dev/null") == 0 then
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
end
end
return m

View File

@ -0,0 +1,69 @@
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

@ -4,84 +4,34 @@ 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 clash = "clash"
ful = Form("upload", nil)
ful.reset = false
ful.submit = false
m = Map("clash")
s = m:section(TypedSection, "clash")
s.anonymous = true
o = s:option(Flag, "auto_update", translate("Auto Update"))
o = s:option(Flag, "enable", translate("Enable"))
o.default = 0
o.rmempty = false
o.description = translate("Auto Update Server subscription")
o.description = translate("Enable")
o = s: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.rmempty = false
o.description = translate("Daily Server subscription update time")
o = s:option(ListValue, "config_type", translate("Config Type"))
o.default = "sub"
o:value("sub", translate("Subscription Config"))
o:value("upl", translate("Uploaded Config"))
o:value("cus", translate("Custom Config"))
o.description = translate("Select Configuration type")
o = s:option(ListValue, "subcri", translate("Subcription Type"))
o.default = clash
o:value("clash", translate("clash"))
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")
o.description = translate("Server Subscription Address")
o.rmempty = true
o = s:option(Button,"update")
o.title = translate("Update Subcription")
o.inputtitle = translate("Update")
o.description = translate("Update Config")
o.inputstyle = "reload"
o.write = function()
os.execute("sed -i '/enable/d' /etc/config/clash")
uci:commit("clash")
os.execute("mv /etc/clash/config.yaml /etc/clash/config.bak")
os.execute("rm -rf /tmp/clash.log")
SYS.call("sh /usr/share/clash/clash.sh >>/tmp/clash.log 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "clash", "client"))
local apply = luci.http.formvalue("cbi.apply")
if apply then
uci:commit("clash")
os.execute("/etc/init.d/clash restart >/dev/null 2>&1 &")
end
o = s:option(Button,"enable")
o.title = translate("Start Client")
o.inputtitle = translate("Start Client")
o.description = translate("Enable/Start/Restart Client")
o.inputstyle = "apply"
o.write = function()
uci:set("clash", "config", "enable", 1)
uci:commit("clash")
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
end
o = s:option(Button,"disable")
o.title = translate("Stop Client")
o.inputtitle = translate("Stop Client")
o.description = translate("Disable/Stop Client")
o.inputstyle = "reset"
o.write = function()
uci:set("clash", "config", "enable", 0)
uci:commit("clash")
SYS.call("/etc/init.d/clash stop >/dev/null 2>&1 &")
end
return m, ful
return m

View File

@ -1,121 +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
ful = Form("upload", nil)
ful.reset = false
ful.submit = false
sul =ful:section(SimpleSection, "", translate(""))
o = sul:option(FileUpload, "")
o.title = translate("Upload Config")
o.template = "clash/clash_upload"
o.description = translate("NB: Only upload file with name config.yml or config.yaml")
um = sul:option(DummyValue, "", nil)
um.template = "clash/clash_dvalue"
local dir, fd
dir = "/etc/clash/"
http.setfilehandler(
function(meta, chunk, eof)
if not fd then
if not meta then return end
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
if not fd then
um.value = translate("upload file error.")
return
end
end
if chunk and fd then
fd:write(chunk)
end
if eof and fd then
fd:close()
fd = nil
local clash_conf = "/etc/clash/config.yml"
if NXFS.access(clash_conf) then
os.execute("mv /etc/clash/config.yml /etc/clash/config.yaml")
os.execute("rm -rf /etc/clash/config.yml")
end
um.value = translate("File saved to") .. ' "/etc/clash/config.yaml"'
os.execute("/etc/init.d/clash restart >/dev/null 2>&1 &")
end
end
)
if luci.http.formvalue("upload") then
local f = luci.http.formvalue("ulfile")
if #f <= 0 then
um.value = translate("No specify upload file.")
end
end
m = Map("clash")
s = m:section(TypedSection, "clash")
s.anonymous = true
s.addremove=false
local conf = "/etc/clash/config.yaml"
sev = s:option(TextValue, "conf")
sev.readonly=true
--update_time = SYS.exec("ls -l --full-time /etc/clash/config.yaml|awk '{print $6,$7;}'")
--sev.description = update_time
--sev.description = translate("Changes to config file must be made from source")
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")
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

@ -0,0 +1,68 @@
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 = "/usr/share/clash/config/custom/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()
SYS.call("rm -rf /usr/share/clash/config/custom/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 = "/usr/share/clash/config/custom/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

@ -8,6 +8,7 @@ local uci = require("luci.model.uci").cursor()
m = Map("clash")
s = m:section(TypedSection, "clash")
--m.pageaction = false
s.anonymous = true
s.addremove=false
@ -39,15 +40,20 @@ end
o.description = translate("NB: press ENTER to create a blank line at the end of input.")
o:depends("mode", 1)
local clash_conf = "/etc/clash/config.yaml"
if NXFS.access(clash_conf) then
local apply = luci.http.formvalue("cbi.apply")
if apply then
if NXFS.access(clash_conf) then
uci:commit("clash")
SYS.call("sh /usr/share/clash/yum_change.sh 2>&1 &")
if luci.sys.call("pidof clash >/dev/null") == 0 then
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
end
end
end
return m

View File

@ -0,0 +1,68 @@
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]
m = Map(clash, translate("Edit Group"))
--m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/clash/servers")
if m.uci:get(clash, sid) ~= "groups" then
luci.http.redirect(m.redirect)
return
end
-- [[ Groups Setting ]]--
s = m:section(NamedSection, sid, "groups")
s.anonymous = true
s.addremove = false
o = s:option(ListValue, "type", translate("Group Type"))
o.rmempty = true
o.description = translate("Choose The Operation Mode")
o:value("select", translate("Select"))
o:value("url-test", translate("URL-Test"))
o:value("fallback", translate("Fallback"))
o:value("load-balance", translate("Load-Balance"))
o = s:option(Value, "name", translate("Group Name"))
o.rmempty = false
o = s:option(Value, "test_url", translate("Test URL"))
o.default = "http://www.gstatic.com/generate_204"
o.rmempty = true
o:depends("type", "url-test")
o:depends("type", "fallback")
o:depends("type", "load-balance")
o = s:option(Value, "test_interval", translate("Test Interval(s)"))
o.default = "300"
o.rmempty = true
o:depends("type", "url-test")
o:depends("type", "fallback")
o:depends("type", "load-balance")
o = s:option(DynamicList, "other_group", translate("Other Group"))
o.description = translate("Proxy Groups Must Exist In Rule")
uci:foreach("clash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil and s.name ~= m.uci:get(clash, sid, "name") then
o:value(s.name)
end
end)
o:value("DIRECT")
o:value("REJECT")
o:depends("type", "select")
o.rmempty = true
local apply = luci.http.formvalue("cbi.apply")
if apply then
uci:commit(clash, sid)
sys.call("/usr/share/clash/groups.sh start")
end
return m

View File

@ -0,0 +1,57 @@
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 clash = "clash"
m = Map("clash")
s = m:section(TypedSection, "clash")
--m.pageaction = false
s.anonymous = true
y = s:option(ListValue, "cus_list", translate("Status"))
y.default = 0
y:value("0", translate("disabled"))
y:value("1", translate("enabled"))
o = s:option(Value, "custom_dns", translate("Custom List DNS"))
o:value("114.114.114.114", "114.114.114.114")
o:value("114.114.115.115", "114.114.115.115")
o:value("119.29.29.29", "119.29.29.29")
o:value("4.2.2.1", "4.2.2.1")
o:value("4.2.2.2", "4.2.2.2")
o:value("4.2.2.3", "4.2.2.3")
o:value("4.2.2.4", "4.2.2.4")
o:depends("cus_list", "1")
local conffile = "/usr/share/clash/server.list"
sev = s:option(TextValue, "conffile")
sev.rows = 20
sev.wrap = "off"
sev.cfgvalue = function(self, section)
return NXFS.readfile(conffile) or ""
end
sev.write = function(self, section, value)
NXFS.writefile(conffile, value:gsub("\r\n", "\n"))
end
local apply = luci.http.formvalue("cbi.apply")
if apply then
uci:commit("clash")
if luci.sys.call("pidof clash >/dev/null") == 0 then
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
end
end
return m

View File

@ -6,13 +6,10 @@ local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local uci = require("luci.model.uci").cursor()
ful = Form("upload", nil)
ful.reset = false
ful.submit = false
m = Map("clash")
s = m:section(TypedSection, "clash")
m.pageaction = false
s.anonymous = true
s.addremove=false
@ -26,14 +23,13 @@ log.cfgvalue = function(self, section)
return NXFS.readfile(clog) or ""
end
log.write = function(self, section, value)
NXFS.writefile(clog, value:gsub("\r\n", "\n"))
end
o = s:option(Button,"log")
o.inputtitle = translate("Clear Logs")
o.write = function()
SYS.call('echo "" > /tmp/clash.log')
SYS.call('echo "" > /tmp/clash.log 2>&1 &')
HTTP.redirect(DISP.build_url("admin", "services", "clash", "log"))
end
return m, ful
return m

View File

@ -3,14 +3,11 @@ 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/status"
m.pageaction = false
return m, ful
return m

View File

@ -7,6 +7,7 @@ local uci = require("luci.model.uci").cursor()
m = Map("clash")
s = m:section(TypedSection, "clash")
--m.pageaction = false
s.anonymous = true
o = s:option(Value, "http_port")
@ -30,6 +31,34 @@ o.datatype = "port"
o.rmempty = false
o.description = translate("Redir Port")
o = s:option(ListValue, "allow_lan")
o.title = translate("Allow Lan")
o.default = true
o.rmempty = false
o:value("true", "true")
o:value("false", "false")
o.description = translate("Allow Lan")
o = s:option(Value, "bind_addr")
o.title = translate("Bind Address")
o:value("*", translate("Bind All IP Addresses"))
luci.ip.neighbors({ family = 4 }, function(entry)
if entry.reachable then
o:value(entry.dest:string())
end
end)
luci.ip.neighbors({ family = 6 }, function(entry)
if entry.reachable then
o:value(entry.dest:string())
end
end)
o.description = translate("Bind Address")
o:depends("allow_lan", "true")
o = s:option(Value, "dash_port")
o.title = translate("Dashboard Port")
o.default = 9191
@ -52,11 +81,14 @@ o:value("error", "error")
o:value("debug", "debug")
local clash_conf = "/etc/clash/config.yaml"
if NXFS.access(clash_conf) then
local apply = luci.http.formvalue("cbi.apply")
if apply then
if NXFS.access(clash_conf) then
uci:commit("clash")
SYS.call("sh /usr/share/clash/yum_change.sh 2>&1 &")
if luci.sys.call("pidof clash >/dev/null") == 0 then
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
end
end
end

View File

@ -1,5 +1,3 @@
-- Copyright (C) 2017 yushi studio <ywb94@qq.com> github.com/ywb94
-- Licensed to the public under the GNU General Public License v3.
local m, s, o
local clash = "clash"
@ -14,13 +12,7 @@ local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
local server_table = {}
local encrypt_methods_ss = {
-- aead
"AEAD_AES_128_GCM",
"AEAD_AES_192_GCM",
"AEAD_AES_256_GCM",
"AEAD_CHACHA20_POLY1305",
-- stream
"rc4-md5",
"aes-128-cfb",
"aes-192-cfb",
@ -33,6 +25,7 @@ local encrypt_methods_ss = {
"aes-256-gcm",
"chacha20",
"chacha20-ietf",
"xchacha20",
"chacha20-ietf-poly1305",
"xchacha20-ietf-poly1305",
}
@ -93,7 +86,6 @@ o:depends("type", "vmess")
o = s:option(ListValue, "obfs", translate("obfs-mode"))
o.rmempty = false
o.default = " "
o:value(" ", translate("none"))
o:value("tls")
@ -102,7 +94,6 @@ o:value("websocket", translate("websocket (ws)"))
o:depends("type", "ss")
o = s:option(ListValue, "obfs_vmess", translate("obfs-mode"))
o.rmempty = false
o.default = "none"
o:value("none")
o:value("websocket", translate("websocket (ws)"))
@ -115,14 +106,11 @@ o:depends("obfs", "tls")
o:depends("obfs", "http")
o = s:option(ListValue, "udp", translate("udp"))
o.rmempty = false
o.default = "false"
o:value("true")
o:value("false")
o:depends("type", "ss")
o = s:option(ListValue, "tls_custom", translate("tls"))
o.rmempty = false
o.default = "false"
o:value("true")
o:value("false")
@ -142,6 +130,11 @@ o.rmempty = true
o:depends("obfs", "websocket")
o:depends("obfs_vmess", "websocket")
o = s:option(ListValue, "mux", translate("Mux"))
o.default = "false"
o:value("true")
o:value("false")
o:depends("obfs", "websocket")
o = s:option(Value, "custom", translate("headers"))
o.rmempty = true

View File

@ -3,16 +3,35 @@ 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 uci = require "luci.model.uci".cursor()
local m, s, o, k
local clash = "clash"
local http = luci.http
m = Map("clash")
s = m:section(TypedSection, "clash")
s = m:section(TypedSection, "clash" , translate("Rule"))
s.anonymous = true
s.addremove=false
o = s:option(Value, "rule_url")
o.title = translate("Custom Rule Url")
o.description = translate("Insert your custom rule Url and click download")
o.rmempty = true
o = s:option(Button,"rule_update")
o.title = translate("Download Rule")
o.inputtitle = translate("Download Rule")
o.description = translate("Download Rule")
o.inputstyle = "reload"
o.write = function()
uci:commit("clash")
SYS.call("sh /usr/share/clash/rule.sh >>/tmp/clash.log 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "clash", "servers"))
end
local rule = "/usr/share/clash/custom_rule.yaml"
sev = s:option(TextValue, "rule")
sev.description = translate("NB: Attention to Proxy Group and Rule when making changes to this section")
@ -25,51 +44,177 @@ sev.write = function(self, section, value)
NXFS.writefile(rule, value:gsub("\r\n", "\n"))
end
o = s:option(Button,"del_rule")
o.inputtitle = translate("Delete Rule")
o.write = function()
SYS.call("rm -rf /usr/share/clash/custom_rule.yaml >/dev/null 2>&1 &")
end
kr = Map(clash)
s = kr:section(TypedSection, "clash", translate("Subscription Config"))
s.anonymous = true
y = s:option(Flag, "cus_servers", translate("Status"))
y.description = translate("enabled to create custom configuration")
y.default = 0
y.rmempty = false
o = s:option(ListValue, "loadservers", translate("Load Config From"))
o.default = sub
o:value("sub", translate("Subscription Config"))
o:value("upl", translate("Upload Config"))
o.description = translate("Select from which configuration custom server should be loaded from")
o = s: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)"))
for t = 0,23 do
o:value(t, t..":00")
end
o.default=0
o.description = translate("Daily Server subscription update time")
o = s:option(ListValue, "subcri", translate("Subcription Type"))
o.default = clash
o:value("clash", translate("clash"))
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.description = translate("Enabled Custom Rule")
md:depends("subcri", 'v2rayn2clash')
o = s:option(Value, "subscribe_url")
o.title = translate("Subcription Url")
o.description = translate("Server Subscription Address")
o.rmempty = true
o = s:option(Button,"update")
o.title = translate("Update Subcription")
o.inputtitle = translate("Update")
o.description = translate("Update Config")
o.inputstyle = "reload"
o.write = function()
--os.execute("sed -i '/enable/d' /etc/config/clash")
--SYS.call("rm -rf /tmp/clash.log >/dev/null 2>&1 &")
SYS.call("sh /usr/share/clash/clash.sh >>/tmp/clash.log 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "clash", "servers"))
end
k = Map(clash)
--k.pageaction = false
s = k:section(TypedSection, "clash")
s.anonymous = true
k.reset = false
k.submit = false
sul =k:section(TypedSection, "clash", translate("Upload Config"))
sul.anonymous = true
sul.addremove=false
o = sul:option(FileUpload, "")
o.title = translate(" ")
o.template = "clash/clash_upload"
um = sul:option(DummyValue, "", nil)
um.template = "clash/clash_dvalue"
y = s:option(ListValue, "enable_servers", translate("Enable Create Config"))
y.default = 0
y:value("0", translate("disabled"))
y:value("1", translate("enabled"))
y.description = translate("Enable to create custom config.yaml. Note that this will overide any configuration you already have")
local dir, fd
dir = "/usr/share/clash/config/upload/"
http.setfilehandler(
function(meta, chunk, eof)
if not fd then
if not meta then return end
if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
o = s:option(Button,"Delete_Severs")
o.title = translate("Delete Severs")
o.inputtitle = translate("Delete Severs")
o.description = translate("Perform this action to delete all servers")
o.inputstyle = "reset"
o.write = function()
uci:delete_all("clash", "servers", function(s) return true end)
luci.sys.call("uci commit clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "servers"))
if not fd then
um.value = translate("upload file error.")
return
end
end
if chunk and fd then
fd:write(chunk)
end
if eof and fd then
fd:close()
fd = nil
local clash_conf = "/usr/share/clash/config/upload/config.yml"
if NXFS.access(clash_conf) then
SYS.call("mv /usr/share/clash/config/upload/config.yml /usr/share/clash/config/upload/config.yaml >/dev/null 2>&1 &")
end
um.value = translate("File saved to") .. ' "/usr/share/clash/config/upload/"'
end
end
)
if luci.http.formvalue("upload") then
local f = luci.http.formvalue("ulfile")
if #f <= 0 then
um.value = translate("No specify upload file.")
end
end
o = s:option(Button,"Create_Severs")
o.title = translate("Create Config")
o.inputtitle = translate("Create Config")
o.description = translate("Perform this action to generate new configuration")
o:depends("enable_servers", "1")
local t = {
{Load_Config, Delete_Severs, Delete_Groups}
}
b = k:section(Table, t)
o = b:option(Button,"Load_Config")
o.inputtitle = translate("Load Servers")
o.inputstyle = "apply"
o.write = function()
uci:set("clash", "enable_servers", "enable", 1)
luci.sys.call("uci commit clash")
SYS.call("sh /usr/share/clash/proxy.sh 2>&1 &")
k.uci:delete_all("clash", "servers", function(s) return true end)
k.uci:commit("clash")
luci.sys.call("sh /usr/share/clash/get_proxy.sh 2>/dev/null &")
SYS.call("sleep 2")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "servers"))
end
o = b:option(Button,"Delete_Severs")
o.inputtitle = translate("Delete Severs")
o.inputstyle = "reset"
o.write = function()
k.uci:delete_all("clash", "servers", function(s) return true end)
k.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "servers"))
end
o = b:option(Button,"Delete_Groups")
o.inputtitle = translate("Delete Groups")
o.inputstyle = "reset"
o.write = function()
k.uci:delete_all("clash", "groups", function(s) return true end)
k.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "servers"))
end
s = k:section(TypedSection, "servers")
s = k:section(TypedSection, "servers", translate("Proxies"))
s.anonymous = true
s.addremove = true
s.sortable = false
s.sortable = true
s.template = "cbi/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/clash/servers/%s")
s.extedit = luci.dispatcher.build_url("admin/services/clash/servers-config/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
@ -78,6 +223,7 @@ function s.create(...)
end
end
o = s:option(DummyValue, "type", translate("Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
@ -98,8 +244,43 @@ function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "server" ,translate("Latency"))
o.template="clash/ping"
o.width="10%"
r = k:section(TypedSection, "groups", translate("Policy Groups"))
r.anonymous = true
r.addremove = true
r.sortable = true
r.template = "clash/tblsection"
r.extedit = luci.dispatcher.build_url("admin/services/clash/groups/%s")
function r.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(r.extedit % sid)
return
end
end
o = r:option(DummyValue, "type", translate("Group Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = r:option(DummyValue, "name", translate("Group Name"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
return k, m
k:append(Template("clash/list"))
local apply = luci.http.formvalue("cbi.apply")
if apply then
uci:commit("clash")
SYS.call("sleep 1")
SYS.call("sh /usr/share/clash/proxy.sh >/dev/null 2>&1 &")
end
return kr, k, m

View File

@ -0,0 +1,70 @@
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 = "/usr/share/clash/config/sub/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()
SYS.call("rm -rf /usr/share/clash/config/sub/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 = "/usr/share/clash/config/sub/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

@ -0,0 +1,36 @@
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 = "/usr/share/clash/config/upload/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()
SYS.call("rm -rf /usr/share/clash/config/upload/config.yaml >/dev/null 2>&1 &")
end
return m

View File

@ -1,16 +1,16 @@
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 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"
m.pageaction = false
return m, ful
return m

View File

@ -6,3 +6,4 @@
%>
</span>
<%+cbi/valuefooter%>

View File

@ -3,3 +3,4 @@
<input class="cbi-input-file" style="width: 400px" type="file" id="ulfile" name="ulfile" />
<input type="submit" class="cbi-button cbi-input-apply" name="upload" value="<%:Upload%>" />
<%+cbi/valuefooter%>

View File

@ -0,0 +1,31 @@
<%
local dsp = require "luci.dispatcher"
-%>
<script type="text/javascript">
//<![CDATA[
var pings = document.getElementsByClassName('ping');
for(var i = 0; i < pings.length; i++) {
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "ping")%>',{
index: i,
domain: pings[i].getAttribute("hint")
},
function(x, result) {
pings[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
}
);
XHR.poll(10,'<%=luci.dispatcher.build_url("admin", "services", "clash", "ping")%>',{
index: i,
domain: pings[i].getAttribute("hint")
},
function(x, result) {
pings[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
}
);
}
//]]>
</script>

View File

@ -0,0 +1,5 @@
<%+cbi/valueheader%>
<span class="ping" hint="<%=self:cfgvalue(section)%>">-- ms</span>
<%+cbi/valuefooter%>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,142 @@
<%-
local rowcnt = 1
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
end
function width(o)
if o.width then
if type(o.width) == 'number' then
return ' style="width:%dpx"' % o.width
end
return ' style="width:%s"' % o.width
end
return ''
end
-%>
<!-- tblsection -->
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<div class="cbi-section-descr"><%=self.description%></div>
<div class="cbi-section-node">
<%- local count = 0 -%>
<table class="cbi-section-table">
<tr class="cbi-section-table-titles">
<%- if not self.anonymous then -%>
<%- if self.sectionhead then -%>
<th class="cbi-section-table-cell"><%=self.sectionhead%></th>
<%- else -%>
<th>&#160;</th>
<%- end -%>
<%- count = count +1; end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<th class="cbi-section-table-cell"<%=width(k)%>>
<%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
<%-=k.title-%>
<%- if k.titleref then -%></a><%- end -%>
</th>
<%- count = count + 1; end; end; if self.sortable then -%>
<%- count = count + 1; end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell">&#160;</th>
<%- count = count + 1; end -%>
</tr>
<tr class="cbi-section-table-descr">
<%- if not self.anonymous then -%>
<%- if self.sectiondesc then -%>
<th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
<%- else -%>
<th></th>
<%- end -%>
<%- end -%>
<%- for i, k in pairs(self.children) do if not k.optional then -%>
<th class="cbi-section-table-cell"<%=width(k)%>><%=k.description%></th>
<%- end; end; if self.sortable then -%>
<%- end; if self.extedit or self.addremove then -%>
<th class="cbi-section-table-cell"></th>
<%- end -%>
</tr>
<%- local isempty = true
for i, k in ipairs(self:cfgsections()) do
section = k
isempty = false
scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
-%>
<tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
<% if not self.anonymous then -%>
<th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
<%- end %>
<%-
for k, node in ipairs(self.children) do
if not node.optional then
node:render(section, scope or {})
end
end
-%>
<%- if self.extedit or self.addremove then -%>
<td class="cbi-section-table-cell">
<%- if self.extedit then -%>
<input class="cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
<%- if type(self.extedit) == "string" then
%> onclick="location.href='<%=self.extedit:format(section)%>'"
<%- elseif type(self.extedit) == "function" then
%> onclick="location.href='<%=self:extedit(section)%>'"
<%- end
%> alt="<%:Edit%>" title="<%:Edit%>" />
<%- end; if self.addremove then %>
<input class="cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
<%- end -%>
</td>
<%- end -%>
</tr>
<%- end -%>
<%- if isempty then -%>
<tr class="cbi-section-table-row">
<td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
</tr>
<%- end -%>
</table>
<% if self.error then %>
<div class="cbi-section-error">
<ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
<li><%=pcdata(e):gsub("\n","<br />")%></li>
<%- end end %></ul>
</div>
<% end %>
<%- if self.addremove then -%>
<% if self.template_addremove then include(self.template_addremove) else -%>
<div class="cbi-section-create cbi-tblsection-create">
<% if self.anonymous then %>
<input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
<% else %>
<% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
<input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" />
<input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
<% if self.invalid_cts then -%>
<br /><%:Invalid%></div>
<%- end %>
<% end %>
</div>
<%- end %>
<%- end -%>
</div>
</fieldset>
<!-- /tblsection -->

View File

@ -3,3 +3,4 @@
<%-=pcdata(self:cfgvalue(section))-%>
</textarea>
<%+cbi/valuefooter%>

View File

@ -4,17 +4,17 @@
<tr>
<th align="center"><%:App Name%></th>
<th align="center"><%:Version%></th>
<th align="center"><%:Check Update%></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>
<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>
<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>
@ -36,27 +36,21 @@
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;
@ -69,7 +63,7 @@ function version_check(btn)
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>';
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)
@ -110,7 +104,7 @@ 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';
url='https://github.com/frainzy1477/luci-app-clash/releases/download/v'+status.new_version+'/luci-app-clash_'+status.new_version+'-2_all.ipk';
window.open(url);
btn.disabled = false;
return false;

View File

@ -1,6 +1,39 @@
msgid "Custom List DNS"
msgstr "自定义列表DNS"
msgid "Apply Custom List"
msgstr "应用自定义列表"
msgid "Custom List"
msgstr "自定义列表"
msgid "Allow Lan"
msgstr "允许局域网"
msgid "Bind All IP Addresses"
msgstr "绑定所有IP地址"
msgid "Bind Address"
msgstr "绑定地址"
msgid "enabled to create custom configuration"
msgstr "已启用以创建自定义配置"
msgid "Status"
msgstr "状态"
msgid "Click to create custom server configuration"
msgstr "单击以创建自定义服务器配置"
msgid "Log"
msgstr "日志"
msgid "Update Config"
msgstr "更新配置"
msgid "NOT RUNNING"
msgstr "末运行"
msgid "Enabled Custom Rule"
msgstr "启用自定义规则"
@ -109,8 +142,8 @@ msgstr "在DHCP和DNS设置自定义DNS转发"
msgid "Proxy Lan IP"
msgstr "走代理的局域网IP"
msgid "Only selected IPs will be proxied if enabled"
msgstr "如果启用仅选择IP只走代理"
msgid "Only selected IPs will be proxied if enabled. fake-ip mode not supported"
msgstr "如果启用仅选择IP只走代理,不支持fake-ip模式"
msgid "Proxy Lan List"
msgstr "走代理的IP列表"
@ -121,8 +154,8 @@ msgstr "选择IP只走代理"
msgid "Bypass Lan IP"
msgstr "不走代理的局域网IP"
msgid "Selected IPs will not be proxied if enabled"
msgstr "如果启用仅选择IP只不走代理"
msgid "Selected IPs will not be proxied if enabled. fake-ip mode not supported"
msgstr "如果启用仅选择IP只不走代理,不支持fake-ip模式"
msgid "Bypass Lan List"
msgstr "不走代理的IP列表"
@ -149,19 +182,25 @@ msgid "Google"
msgstr "谷歌网"
msgid "Youtube"
msgstr "Youtube"
msgstr "Youtube"
msgid "Baidu"
msgstr "百度网"
msgid "Github"
msgstr "Github"
msgid "Music.163"
msgstr "网易云音乐"
msgid "Taobao"
msgstr "淘宝网"
msgid "CONNECT OK"
msgstr "连接正常"
msgid "NORMAL"
msgstr "正常"
msgid "TIMEOUT"
msgstr "连接超时"
msgstr "超时"
msgid "NOT SET"
msgstr "未设置"
@ -184,7 +223,7 @@ msgstr "打开外部控制"
msgid "Clash Dashboard"
msgstr "Clash外部控制"
msgid "Yacd Dashboard"
msgid "Yac Dashboard"
msgstr "Yacd外部控制"
msgid "Client"
@ -205,9 +244,6 @@ msgstr "自定义DNS"
msgid "Modify yaml DNS"
msgstr "修改 DNS"
msgid "Logs"
msgstr "日志"
msgid "Enable"
msgstr "启用"
@ -262,6 +298,9 @@ msgstr "更新"
msgid "Enable Client"
msgstr "启用客户端"
msgid "Config In Use"
msgstr "使用中的配置"
msgid "Server Subscription Address"
msgstr "服务器订阅地址"
@ -292,6 +331,9 @@ msgstr "执行此操作以生成新配置"
msgid "Delete Severs"
msgstr "清空节点"
msgid "Load Servers"
msgstr "读取节点"
msgid "Type"
msgstr "节点类型"
@ -341,4 +383,121 @@ msgid "None"
msgstr "未配置"
msgid "NB: Attention to Proxy Group and Rule when making changes to this section"
msgstr "注意:更改时,请注意代理组和规则"
msgstr "注意:更改时,请注意代理组和规则"
msgid "Subscription Config"
msgstr "订阅配置"
msgid "Subscribe Config"
msgstr "订阅配置"
msgid "Uploaded Config"
msgstr "上传的配置"
msgid "Custom Config"
msgstr "自定义配置"
msgid "Custom"
msgstr "自定义"
msgid "Config Type"
msgstr "配置类型"
msgid "Select Configuration type"
msgstr "选择配置类型”"
msgid "Create Config"
msgstr "一键生成配置文件"
msgid "Create Config By One-Click Only Need Proxys"
msgstr "一键生成配置文件功能只需要配置服务器节点信息"
msgid "Proxy Groups(No Need Set when Config Create)"
msgstr "策略组配置(使用一键生成配置文件功能时无需设置)"
msgid "Proxies"
msgstr "代理"
msgid "Edit Group"
msgstr "编辑策略组配置"
msgid "Group Type"
msgstr "策略组类型"
msgid "Choose The Operation Mode"
msgstr "设置策略组挑选服务器节点的工作方式"
msgid "Group Name"
msgstr "策略组别名(请勿重名)"
msgid "Test URL"
msgstr "检测地址URL"
msgid "Test Interval(s)"
msgstr "检测频率(秒)"
msgid "Select"
msgstr "手动选择"
msgid "URL-Test"
msgstr "最低延迟"
msgid "Fallback"
msgstr "故障切换"
msgid "Load-Balance"
msgstr "负载均衡"
msgid "Other Group"
msgstr "包含其他策略组"
msgid "Proxy Groups Must Exist In Rule"
msgstr "添加的策略组必须存在规则创建"
msgid "Policy Groups"
msgstr "添加到策略组"
msgid "Rule"
msgstr "规则"
msgid "Custom Rule Url"
msgstr "自定义规则URL"
msgid "Download Rule"
msgstr "下载规则"
msgid "Insert your custom rule Url and click download"
msgstr "输入自定义规则URL并单击下载"
msgid "Delete Rule"
msgstr "删除规则"
msgid "Latency"
msgstr "延迟"
msgid "Delete Groups"
msgstr "删除策略组"
msgid "Perform this action to delete all policy groups"
msgstr "执行此操作以删除所有策略组"
msgid "Upload Config"
msgstr "上传配置文件"
msgid "Upload"
msgstr "上传"
msgid "File saved to"
msgstr "文件已成功上传到"
msgid "upload file error."
msgstr "文件上传失败"
msgid "Load Config From"
msgstr "从哪读取自定义节点"
msgid "Select from which configuration custom server should be loaded from"
msgstr "选择从哪个配置文件读取自定义节点"
msgid "Servers"
msgstr "服务器"

View File

@ -10,10 +10,60 @@ config clash 'config'
option auto_update_time '0'
option level 'info'
option proxylan '0'
option allow_lan 'true'
option bind_addr '*'
option rejectlan '0'
option dnsforwader '0'
option subcri 'clash'
option cus_list '1'
option custom_dns '114.114.114.114'
option v2ray 'https://tgbot.lbyczf.com/v2rayn2clash?url='
option surge 'https://tgbot.lbyczf.com/surge2clash?url='
option cusrule '0'
option enable_servers '0'
option cus_servers '1'
option config_type 'sub'
option loadservers 'sub'
config groups
option old_name '❌AdBlock'
option old_name_cfg '❌AdBlock'
option type 'select'
list other_group 'REJECT'
option name '❌AdBlock'
config groups
option old_name '🖥AsianTV'
option old_name_cfg '🖥AsianTV'
option type 'select'
option name '🖥AsianTV'
list other_group 'DIRECT'
list other_group '🔑Proxy'
config groups
option old_name '📺GlobalTV'
option old_name_cfg '📺GlobalTV'
option type 'select'
option name '📺GlobalTV'
list other_group '🔑Proxy'
list other_group 'DIRECT'
config groups
option type 'select'
option name '🔑Proxy'
list other_group '⚙LoadBalance'
list other_group '✈UrlTest'
config groups
option old_name '✈UrlTest'
option old_name_cfg '✈UrlTest'
option test_url 'http://www.gstatic.com/generate_204'
option type 'url-test'
option test_interval '600'
option name '✈UrlTest'
config groups
option type 'load-balance'
option test_url 'http://www.gstatic.com/generate_204'
option test_interval '300'
option name '⚙LoadBalance'

View File

@ -10,6 +10,11 @@ CRON_FILE="/etc/crontabs/root"
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_OLD="/etc/clash/config.yml"
CONFIG_YAML_SUB="/usr/share/clash/config/sub/config.yaml"
CONFIG_YAML_UPL="/usr/share/clash/config/upload/config.yaml"
CONFIG_YAML_CUS="/usr/share/clash/config/custom/config.yaml"
revert_dns() {
#===========================================================================================================================
@ -24,14 +29,17 @@ revert_dns() {
}
add_cron(){
config_type=$(uci get clash.config.config_type 2>/dev/null)
#===========================================================================================================================
sed -i '/clash.log/d' $CRON_FILE
echo '0 0 * * 0 echo "" > /tmp/clash.log' >> $CRON_FILE
if [ $config_type == "sub" ];then
[ -n "$(grep -w "/usr/share/clash/clash.sh" $CRON_FILE)" ] && sed -i '/\/usr\/share\/clash\/clash.sh/d' $CRON_FILE
auto=$(uci get clash.config.auto_update 2>/dev/null)
if [ $auto -eq 1 ]; then
[ -z "$(grep -w "/usr/share/clash/clash.sh" $CRON_FILE)" ] && echo "0 $(uci get clash.config.auto_update_time 2>/dev/null) * * * /usr/share/clash/clash.sh" >> $CRON_FILE
fi
fi
crontab $CRON_FILE
#===========================================================================================================================
}
@ -45,29 +53,54 @@ del_cron(){
}
yml_change() {
sh /usr/share/clash/yum_change.sh >/dev/null 2>&1
select_config(){
#===========================================================================================================================
config_type=$(uci get clash.config.config_type 2>/dev/null)
if [ $config_type == "sub" ];then
if [ -f $CONFIG_YAML_SUB ] && [ "$(ls -l $CONFIG_YAML_SUB|awk '{print int($5/1024)}')" -ne 0 ];then
cp $CONFIG_YAML_SUB $CONFIG_YAML
fi
elif [ $config_type == "upl" ];then
if [ -f $CONFIG_YAML_UPL ] && [ "$(ls -l $CONFIG_YAML_UPL|awk '{print int($5/1024)}')" -ne 0 ];then
cp $CONFIG_YAML_UPL $CONFIG_YAML
fi
elif [ $config_type == "cus" ];then
if [ -f $CONFIG_YAML_CUS ] && [ "$(ls -l $CONFIG_YAML_CUS|awk '{print int($5/1024)}')" -ne 0 ];then
cp $CONFIG_YAML_CUS $CONFIG_YAML
fi
fi
#===========================================================================================================================
}
yml_change() {
#===========================================================================================================================
sh /usr/share/clash/yum_change.sh >/dev/null 2>&1
#===========================================================================================================================
}
yml_dns_change(){
#===========================================================================================================================
dns_port=$(grep listen: $CONFIG_YAML |awk -F ':' '{print $3}' |tr -cd "[0-9]")
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
dnsforwader=$(uci get clash.config.dnsforwader 2>/dev/null)
if [ $dns_port -eq 53 ]; then
sed -i '/listen:/ d' $CONFIG_YAML
sed -i "/nameserver:/i\ listen: 0.0.0.0:5300" $CONFIG_YAML
sed -i 's/0.0.0.0:53/0.0.0.0:5300/g' $CONFIG_YAML
fi
if [ $dnsforwader -eq 1 ]; then
if [ $dnsforwader -ne 0 ]; then
if [ $dns_port -eq 53 ]; then
dns_serve1=$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)
if [ $dns_serve1 ]; then
uci del dhcp.@dnsmasq[-1].server
fi
fi
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#5300 >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].resolvfile
uci set dhcp.@dnsmasq[0].noresolv=1
@ -76,8 +109,8 @@ yml_dns_change(){
dns_serve1=$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)
if [ $dns_serve1 ]; then
uci del dhcp.@dnsmasq[-1].server
fi
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#$dns_port >/dev/null 2>&1
fi
uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#$dns_port >/dev/null 2>&1
uci delete dhcp.@dnsmasq[0].resolvfile
uci set dhcp.@dnsmasq[0].noresolv=1
uci commit dhcp
@ -148,7 +181,7 @@ rules(){
iptables -t nat -A PREROUTING -p tcp -j clash_tcp
iptables -t nat -A OUTPUT -p tcp -d 198.18.0.1/24 -j REDIRECT --to-ports $redir_port
iptables -t nat -A OUTPUT -p tcp -d 198.18.0.1/24 -j REDIRECT --to-ports $redir_port
@ -157,32 +190,66 @@ rules(){
yml_yaml(){
#===========================================================================================================================
subscribe_url=$(uci get clash.config.subscribe_url 2>/dev/null)
size=$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')
if [ -f $CONFIG_YAML_OLD ] && [ ! -f $CONFIG_YAML ] || [ -f $CONFIG_YAML_OLD ] && [ -f $CONFIG_YAML ] && [ $size -eq 0 ];then
if [ -f $CONFIG_YAML_OLD ] && [ ! -f $CONFIG_YAML ];then
mv $CONFIG_YAML_OLD $CONFIG_YAML
elif [ -f $CONFIG_YAML_OLD ] && [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML_OLD|awk '{print int($5/1024)}')" -ne 0 ];then
mv $CONFIG_YAML_OLD $CONFIG_YAML
elif [ ! -f $CONFIG_YAML ] && [ $subscribe_url ];then
sh /usr/share/clash/clash.sh >>/tmp/clash.log >/dev/null 2>&1
fi
#===========================================================================================================================
}
yml_sub(){
#===========================================================================================================================
subscribe_url=$(uci get clash.config.subscribe_url 2>/dev/null)
config_type=$(uci get clash.config.config_type 2>/dev/null)
if [ $config_type == "sub" ];then
if [ ! -f $CONFIG_YAML_SUB ] && [ $subscribe_url ];then
rm -rf /tmp/clash.log
sh /usr/share/clash/clash.sh >>/tmp/clash.log
elif [ -f $CONFIG_YAML_SUB ] && [ "$(ls -l $CONFIG_YAML_SUB | awk '{print int($5/1024)}')" -eq 0 ] && [ $subscribe_url ];then
rm -rf /tmp/clash.log
sh /usr/share/clash/clash.sh >>/tmp/clash.log
fi
fi
#===========================================================================================================================
}
custom_list() {
(/usr/share/clash/list.sh && sleep 2 >/dev/null 2>&1) &
}
start(){
lang=$(uci get luci.main.lang 2>/dev/null)
#===========================================================================================================================
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
enable=$(uci get clash.config.enable 2>/dev/null)
yml_yaml
size=$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')
yml_sub
select_config
lan=$(uci get clash.config.proxylan 2>/dev/null)
lanac=$(uci get clash.config.rejectlan 2>/dev/null)
if [ $enable -eq 1 ]; 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
if [ $lang == "en" ];then
echo "$(date "+%Y-%m-%d %H:%M:%S") - /etc/clash/clash not found, from "https://github.com/frainzy1477/clash/releases" , download and install clash ipk " >> /tmp/clash.log
elif [ $lang == "zh_cn" ];then
echo "$(date "+%Y-%m-%d %H:%M:%S") - 找不到 /etc/clash/clash 请,从"https://github.com/frainzy1477/clash/releases" , 下载然后安装Clash ipk" >> /tmp/clash.log
fi
else
if [ $size -ne 0 ] && [ -f /etc/clash/clash ]; then
if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')" -ne 0 ] && [ -f /etc/clash/clash ]; then
if [ $lan ]; then
@ -197,11 +264,10 @@ if [ $size -ne 0 ] && [ -f /etc/clash/clash ]; then
yml_dns_change
nohup $CLASH -d "$CLASH_CONFIG" > /tmp/clash.log 2>&1 &
ln -s /usr/share/clash/web /www/clash
uci set firewall.@defaults[0].flow_offloading=1
nohup $CLASH -d "$CLASH_CONFIG" > /tmp/clash.log 2>&1 &
ln -s /usr/share/clash/yac /www/clash
uci commit firewall
/etc/init.d/firewall restart >/dev/null 2>&1
@ -209,8 +275,9 @@ if [ $size -ne 0 ] && [ -f /etc/clash/clash ]; then
killall -1 dnsmasq
custom_list
/etc/init.d/dnsmasq restart >/dev/null 2>&1
if pidof clash >/dev/null; then
add_cron
@ -218,8 +285,12 @@ if [ $size -ne 0 ] && [ -f /etc/clash/clash ]; then
fi
else
echo "===============================$(date "+%Y-%m-%d %H:%M:%S") problem with config.yaml, config.yaml is either empty or not found =====================================" >> /tmp/clash.log
if [ $lang == "en" ];then
echo "$(date "+%Y-%m-%d %H:%M:%S") - problem with config.yaml, config.yaml is either empty or not found " >> /tmp/clash.log
elif [ $lang == "zh_cn" ];then
echo "$(date "+%Y-%m-%d %H:%M:%S") - 你的config.yaml有问题还是为了空 0kb " >> /tmp/clash.log
fi
fi
fi
@ -233,6 +304,7 @@ fi
stop(){
lang=$(uci get luci.main.lang 2>/dev/null)
#===========================================================================================================================
iptables -t nat -F clash_tcp >/dev/null 2>&1
iptables -t nat -X clash_tcp >/dev/null 2>&1
@ -240,6 +312,7 @@ stop(){
iptables -t nat -X clash_udp >/dev/null 2>&1
iptables -t nat -D PREROUTING -p tcp -j clash_tcp >/dev/null 2>&1
iptables -t nat -D PREROUTING -p udp -j clash_udp >/dev/null 2>&1
ipset -! flush clash_lan_ac >/dev/null 2>&1
ipset -! flush clash_lan >/dev/null 2>&1
@ -250,19 +323,23 @@ stop(){
revert_dns
uci set firewall.@defaults[0].flow_offloading=1
uci commit firewall
/etc/init.d/firewall restart >/dev/null 2>&1
/etc/init.d/dnsmasq restart >/dev/null 2>&1
rm -rf /www/clash 2> /dev/null
del_cron
rm -rf /www/clash 2> /dev/null
rm -rf /tmp/clash.log
echo "===============================$(date "+%Y-%m-%d %H:%M:%S") CLIENT IS DISABLED =====================================" >> /tmp/clash.log
if [ $lang == "en" ];then
echo "$(date "+%Y-%m-%d %H:%M:%S") - CLIENT IS DISABLED " >> /tmp/clash.log
elif [ $lang == "zh_cn" ];then
echo "$(date "+%Y-%m-%d %H:%M:%S") - 客户端被禁用 " >> /tmp/clash.log
fi
#===========================================================================================================================
}
@ -275,10 +352,8 @@ restart(){
stop
start
else
start
start
fi
#===========================================================================================================================
}

View File

@ -8,3 +8,4 @@ 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

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

View File

@ -1,5 +1,5 @@
#!/bin/sh
sleeptime=300
logfile="/tmp/clash.log"
CLASH="/etc/clash/clash"

View File

@ -4,48 +4,53 @@ 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_type=$(uci get clash.config.config_type 2>/dev/null)
CONFIG_YAML="/usr/share/clash/config/sub/config.yaml"
CONFIG_YAML_TEMP="/etc/clash/server.yaml"
CONFIG_YAML_RULE="/usr/share/clash/rule.yaml"
if pidof clash >/dev/null; then
/etc/init.d/clash stop 2>/dev/null
rm -rf /etc/clash/config.bak 2> /dev/null
if [ $subtype == "clash" ];then
wget-ssl --no-check-certificate --timeout=30 --tries=2 --user-agent="User-Agent: Mozilla/OpenWRT" $subscribe_url -O 2>&1 >1 $CONFIG_YAML
elif [ $subtype == "v2rayn2clash" ];then
if [ $cusrule == 1 ];then
wget-ssl --no-check-certificate --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla/OpenWRT" $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 --no-check-certificate --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla/OpenWRT" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
elif [ $subtype == "surge2clash" ];then
wget-ssl --no-check-certificate --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla/OpenWRT" $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
uci commit clash 2> /dev/null
/etc/init.d/clash restart 2>/dev/null
else
rm -rf /etc/clash/config.bak 2> /dev/null
if [ $subtype == "clash" ];then
wget-ssl --no-check-certificate --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla/OpenWRT" $subscribe_url -O 2>&1 >1 $CONFIG_YAML
elif [ $subtype == "v2rayn2clash" ];then
if [ $cusrule == 1 ];then
wget-ssl --no-check-certificate --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla/OpenWRT" $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 --no-check-certificate --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla/OpenWRT" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
elif [ $subtype == "surge2clash" ];then
wget-ssl --no-check-certificate --timeout=30 --tries=5 --user-agent="User-Agent: Mozilla/OpenWRT" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
rm -rf $CONFIG_YAML_TEMP 2> /dev/null
fi
if pidof clash >/dev/null; then
if [ $subtype == "clash" ];then
wget --no-check-certificate --user-agent="Clash/OpenWRT" $subscribe_url -O 2>&1 >1 $CONFIG_YAML
elif [ $subtype == "v2rayn2clash" ];then
if [ $cusrule == 1 ];then
wget --no-check-certificate --user-agent="Clash/OpenWRT" $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 --no-check-certificate --user-agent="Clash/OpenWRT" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
elif [ $subtype == "surge2clash" ];then
wget --no-check-certificate --user-agent="Clash/OpenWRT" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
rm -rf $CONFIG_YAML_TEMP 2>/dev/null
if [ $config_type == "sub" ];then
/etc/init.d/clash restart 2>/dev/null
fi
else
if [ $subtype == "clash" ];then
wget --no-check-certificate --user-agent="Clash/OpenWRT" $subscribe_url -O 2>&1 >1 $CONFIG_YAML
elif [ $subtype == "v2rayn2clash" ];then
if [ $cusrule == 1 ];then
wget --no-check-certificate --user-agent="Clash/OpenWRT" $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 --no-check-certificate --user-agent="Clash-/OpenWRT" $urlv2ray.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
elif [ $subtype == "surge2clash" ];then
wget --no-check-certificate --user-agent="Clash/OpenWRT" $urlsurge.$subscribe_url -O 2>&1 >1 $CONFIG_YAML
fi
rm -rf $CONFIG_YAML_TEMP 2>/dev/null
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -3,9 +3,10 @@
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/x-icon" href="https://cdn.jsdelivr.net/gh/Dreamacro/clash/docs/logo.png" />
<title>Clash Dashboard</title>
<link href="main.71cb9fd91422722c5ceb.css" rel="stylesheet"></head>
<link href="main.557c7e0375c2286ea607.css" rel="stylesheet"></head>
<body>
<div id="root"></div>
<script type="text/javascript" src="js/1.bundle.71cb9fd91422722c5ceb.min.js"></script><script type="text/javascript" src="js/bundle.71cb9fd91422722c5ceb.min.js"></script></body>
<script type="text/javascript" src="js/1.bundle.557c7e0375c2286ea607.min.js"></script><script type="text/javascript" src="js/bundle.557c7e0375c2286ea607.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

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,23 +1,28 @@
#experimental:
# ignore-resolve-fail: true
experimental:
ignore-resolve-fail: true
#local SOCKS5/HTTP(S) server
#authentication:
# - "user1:pass1"
# - "user2:pass2"
# hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'
dns:
enable: true
listen: 0.0.0.0:5300
enhanced-mode: fake-ip
# hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'
fake-ip-range: 198.18.0.1/24
nameserver:
- 101.132.183.99
- 8.8.8.8
- 119.29.29.29
- 114.114.114.114
- 114.114.115.115
- 114.114.114.114
- tls://dns.rubyfish.cn:853
- https://1.1.1.1/dns-query
- https://dns.google/dns-query
- https://1.1.1.1/dns-query
#fallback:
# - tcp://1.1.1.1
# - tcp://8.8.8.8
#fallback-filter:
# geoip: true
# ipcidr:
# - 240.0.0.0/4

View File

@ -0,0 +1,146 @@
#!/bin/bash
. /lib/functions.sh
load_from=$(uci get clash.config.loadservers 2>/dev/null)
if [ "$load_from" == "sub" ];then
load="/usr/share/clash/config/sub/config.yaml"
elif [ "$load_from" == "upl" ];then
load="/usr/share/clash/config/upload/config.yaml"
fi
awk '/^ {0,}Proxy:/,/^ {0,}Proxy Group:/{print}' $load 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\t/ /g' 2>/dev/null >/tmp/yaml_proxy.yaml 2>&1
server_file="/tmp/yaml_proxy.yaml"
single_server="/tmp/servers.yaml"
count=1
line=$(sed -n '/^ \{0,\}-/=' $server_file)
num=$(grep -c "^ \{0,\}-" $server_file)
cfg_get()
{
echo "$(grep "$1" $single_server 2>/dev/null |awk -v tag=$1 'BEGIN{FS=tag} {print $2}' 2>/dev/null |sed 's/,.*//' 2>/dev/null |sed 's/^ \{0,\}//g' 2>/dev/null |sed 's/ \{0,\}$//g' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null)"
}
for n in $line
do
[ "$count" -eq 1 ] && {
startLine="$n"
}
count=$(expr "$count" + 1)
if [ "$count" -gt "$num" ]; then
endLine=$(sed -n '$=' $server_file)
else
endLine=$(expr $(echo "$line" | sed -n "${count}p") - 1)
fi
sed -n "${startLine},${endLine}p" $server_file >$single_server
startLine=$(expr "$endLine" + 1)
#type
server_type="$(cfg_get "type:")"
#name
server_name="$(cfg_get "name:")"
#server
server="$(cfg_get "server:")"
#port
port="$(cfg_get "port:")"
#cipher
cipher="$(cfg_get "cipher:")"
#password
password="$(cfg_get "password:")"
#udp
udp="$(cfg_get "udp:")"
#plugin:
plugin="$(cfg_get "plugin:")"
#plugin-opts:
plugin_opts="$(cfg_get "plugin-opts:")"
#obfs:
obfs="$(cfg_get "obfs:")"
#obfs-host:
obfs_host="$(cfg_get "obfs-host:")"
#mode:
mode="$(cfg_get "mode:")"
#tls:
tls="$(cfg_get "tls:")"
#skip-cert-verify:
verify="$(cfg_get "skip-cert-verify:")"
#mux:
mux="$(cfg_get "mux:")"
#host:
host="$(cfg_get "host:")"
#Host:
Host="$(cfg_get "Host:")"
#path:
path="$(cfg_get "path:")"
#ws-path:
ws_path="$(cfg_get "ws-path:")"
#headers_custom:
headers="$(cfg_get "custom:")"
#uuid:
uuid="$(cfg_get "uuid:")"
#alterId:
alterId="$(cfg_get "alterId:")"
#network
network="$(cfg_get "network:")"
#username
username="$(cfg_get "username:")"
name=clash
uci_name_tmp=$(uci add $name servers)
uci_set="uci -q set $name.$uci_name_tmp."
uci_add="uci -q add_list $name.$uci_name_tmp."
${uci_set}name="$server_name"
${uci_set}type="$server_type"
${uci_set}server="$server"
${uci_set}port="$port"
if [ "$server_type" = "vmess" ]; then
${uci_set}securitys="$cipher"
else
${uci_set}cipher="$cipher"
fi
${uci_set}udp="$udp"
${uci_set}obfs="$obfs"
${uci_set}host="$obfs_host"
[ -z "$obfs" ] && ${uci_set}obfs="$mode"
[ -z "$mode" ] && [ ! -z "$network" ] && ${uci_set}obfs_vmess="websocket"
[ -z "$mode" ] && [ -z "$network" ] && ${uci_set}obfs_vmess="none"
[ -z "$obfs_host" ] && ${uci_set}host="$host"
if [ $tls ];then
${uci_set}tls="$tls"
fi
if [ $verify ];then
${uci_set}skip_cert_verify="$verify"
fi
${uci_set}path="$path"
[ -z "$path" ] && ${uci_set}path="$ws_path"
${uci_set}mux="$mux"
${uci_set}custom="$headers"
[ -z "$headers" ] && ${uci_set}custom="$Host"
if [ "$server_type" = "vmess" ]; then
#v2ray
${uci_set}alterId="$alterId"
${uci_set}uuid="$uuid"
fi
if [ "$server_type" = "socks5" ] || [ "$server_type" = "http" ]; then
${uci_set}auth_name="$username"
${uci_set}auth_pass="$password"
else
${uci_set}password="$password"
fi
done
sleep 3
uci commit clash
rm -rf /tmp/servers.yaml 2>/dev/null
rm -rf /tmp/yaml_proxy.yaml 2>/dev/null

View File

@ -0,0 +1,31 @@
#!/bin/sh /etc/rc.common
. /lib/functions.sh
cfg_groups_set()
{
CFG_FILE="/etc/config/clash"
local section="$1"
config_get "name" "$section" "name" ""
config_get "old_name_cfg" "$section" "old_name_cfg" ""
config_get "old_name" "$section" "old_name" ""
if [ -z "$name" ]; then
return
fi
if [ "$name" != "$old_name_cfg" ]; then
sed -i "s/\'${old_name_cfg}\'/\'${name}\'/g" $CFG_FILE 2>/dev/null
sed -i "s/old_name \'${name}\'/old_name \'${old_name}\'/g" $CFG_FILE 2>/dev/null
config_load "clash"
fi
}
start(){
status=$(ps|grep -c /usr/share/clash/groups.sh)
[ "$status" -gt "3" ] && exit 0
config_load "clash"
config_foreach cfg_groups_set "groups"
}

View File

@ -1,11 +0,0 @@
#!/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

@ -6,3 +6,4 @@
&& mv /tmp/GeoLite2-Country_*/GeoLite2-Country.mmdb /etc/clash/Country.mmdb\
&& rm -rf /tmp/GeoLite2-Country_* >/dev/null 2>&1
fi

View File

@ -0,0 +1,26 @@
#!/bin/sh
enable_list=$(uci get clash.config.cus_list 2>/dev/null)
if [ $enable_list -eq 1 ];then
if [ -d /tmp/dnsmasq.clash ];then
rm -rf /tmp/dnsmasq.clash
fi
if [ -f /tmp/dnsmasq.d/custom_list.conf ];then
rm -rf /tmp/dnsmasq.d/custom_list.conf
fi
cutom_dns=$(uci get clash.config.custom_dns 2>/dev/null)
if [ ! -d /tmp/dnsmasq.d ];then
mkdir -p /tmp/dnsmasq.d
fi
if [ ! -d /tmp/dnsmasq.clash ];then
mkdir -p /tmp/dnsmasq.clash
fi
awk '!/^$/&&!/^#/{printf("server=/%s/'"$cutom_dns"'\n",$0)}' /usr/share/clash/server.list >> /tmp/dnsmasq.clash/custom_list.conf
ln -s /tmp/dnsmasq.clash/custom_list.conf /tmp/dnsmasq.d/custom_list.conf
fi

View File

@ -0,0 +1 @@
1.1.7

View File

@ -1,25 +1,29 @@
#!/bin/sh /etc/rc.common
. /lib/functions.sh
enable_create=$(uci get clash.config.cus_servers 2>/dev/null)
if [ "$enable_create" == "1" ];then
config_type=$(uci get clash.config.config_type 2>/dev/null)
if [ $config_type == "cus" ];then
if pidof clash >/dev/null; then
/etc/init.d/clash stop 2>/dev/null
else
uci set clash.config.enable=1 2> /dev/null
uci commit clash 2> /dev/null
fi
enable_create=$(uci get clash.config.enable_servers 2>/dev/null)
if [ "$enable_create" == "1" ];then
fi
status=$(ps|grep -c /usr/share/clash/proxy.sh)
[ "$status" -gt "3" ] && exit 0
CONFIG_YAML_RULE="/usr/share/clash/custom_rule.yaml"
SERVER_FILE="/tmp/servers.yaml"
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_BAK="/etc/clash/config.bak"
CONFIG_YAML="/usr/share/clash/config/custom/config.yaml"
TEMP_FILE="/tmp/dns_temp.yaml"
SERVERS="/tmp/servers_temp.yaml"
Proxy_Group="/tmp/Proxy_Group"
Proxy_Group_url="/tmp/Proxy_url"
RULE_PROXY="/tmp/tempserv.yaml"
GROUP_FILE="/tmp/groups.yaml"
CONFIG_FILE="/tmp/y_groups"
CFG_FILE="/etc/config/clash"
DNS_FILE="/usr/share/clash/dns.yaml"
servers_set()
{
@ -45,6 +49,7 @@ servers_set()
config_get "uuid" "$section" "uuid" ""
config_get "auth_name" "$section" "auth_name" ""
config_get "auth_pass" "$section" "auth_pass" ""
config_get "mux" "$section" "mux" ""
if [ -z "$type" ]; then
@ -54,6 +59,10 @@ servers_set()
if [ -z "$server" ]; then
return
fi
if [ ! -z "$mux" ]; then
muxx="mux: $mux"
fi
if [ -z "$name" ]; then
name="Server"
@ -79,6 +88,8 @@ servers_set()
if [ "$obfs_vmess" = "websocket" ]; then
obfs_vmesss=", network: ws"
else
obfs_vmesss=" "
fi
if [ ! -z "$host" ]; then
@ -89,10 +100,14 @@ servers_set()
custom=", ws-headers: { Host: $custom }"
fi
if [ "$tls" = "true" ] && [ "$type" = "vmess" ]; then
tlss=", tls: $tls"
elif [ "$tls" = "true" ]; then
if [ "$tls" ]; then
tlss=", tls: $tls"
elif [ ! "$tls" ]; then
tlss=""
elif [ "$tls" = "true" ] && [ "$type" = "http" ]; then
tls_hs=", tls: $tls"
elif [ "$tls" = "true" ] && [ "$type" = "socks5" ]; then
tls_hs=", tls: $tls"
fi
if [ ! -z "$path" ]; then
@ -105,8 +120,8 @@ servers_set()
if [ "$skip_cert_verify" = "true" ] && [ "$type" != "ss" ]; then
skip_cert_verifys=", skip-cert-verify: $skip_cert_verify"
elif [ "$skip_cert_verify" = "true" ]; then
skip_cert_verifys=", skip-cert-verify: $skip_cert_verify"
elif [ ! "$skip_cert_verify" ]; then
skip_cert_verifys=""
fi
@ -148,19 +163,26 @@ EOF
fi
if [ "$skip_cert_verify" = "true" ] && [ "$type" = "ss" ]; then
cat >> "$SERVER_FILE" <<-EOF
skip_cert_verifys: true
skip_cert_verify: true
EOF
fi
if [ ! -z "$path" ]; then
if [ ! -z "$custom_host" ]; then
cat >> "$SERVER_FILE" <<-EOF
host: $custom_host
EOF
fi
if [ ! -z "$path" ]; then
cat >> "$SERVER_FILE" <<-EOF
$paths
EOF
fi
if [ ! -z "$custom_host" ]; then
if [ "$mux" = "true" ]; then
cat >> "$SERVER_FILE" <<-EOF
host: "$custom_host"
$muxx
EOF
fi
@ -177,41 +199,104 @@ EOF
fi
if [ "$type" = "socks5" ] || [ "$type" = "http" ]; then
echo "- { name: \"$name\", type: $type, server: $server, port: $port, username: $auth_name, password: $auth_pass$skip_cert_verify$tls }" >>$SERVER_FILE
echo "- { name: \"$name\", type: $type, server: $server, port: $port, username: $auth_name, password: $auth_pass$skip_cert_verify$tls_hs }" >>$SERVER_FILE
fi
}
config_load clash
config_foreach servers_set "servers"
size=$(ls -l $SERVER_FILE|awk '{print $5}')
if [ $size -ne 0 ]; then
sed -i "1i\Proxy:" $SERVER_FILE
if [ "$(ls -l $SERVER_FILE|awk '{print $5}')" -ne 0 ]; then
sed -i "1i\ " $SERVER_FILE
sed -i "2i\Proxy:" $SERVER_FILE
egrep '^ {0,}-' $SERVER_FILE |grep name: |awk -F 'name: ' '{print $2}' |sed 's/,.*//' >$Proxy_Group 2>&1
sed -i "s/^ \{0,\}/ - /" $Proxy_Group 2>/dev/null
sed -i "s/^ \{0,\}/ - /" $Proxy_Group 2>/dev/null
cat >> "$Proxy_Group_url" <<-EOF
- name: Auto - UrlTest
type: url-test
proxies:
EOF
cat $Proxy_Group >> $Proxy_Group_url 2>/dev/null
cat >> "$Proxy_Group_url" <<-EOF
url: http://www.gstatic.com/generate_204
interval: "600"
- name: Proxy
type: select
proxies:
- Auto - UrlTest
- DIRECT
EOF
cat $Proxy_Group >> $Proxy_Group_url 2>/dev/null
sed -i "1i " $Proxy_Group_url
sed -i "2i\Proxy Group:" $Proxy_Group_url
yml_servers_add()
{
local section="$1"
config_get "name" "$section" "name" ""
config_list_foreach "$section" "groups" set_groups "$name" "$2"
}
set_groups()
{
if [ "$1" = "$3" ]; then
echo " - \"${2}\"" >>$GROUP_FILE
fi
}
set_other_groups()
{
echo " - ${1}" >>$GROUP_FILE
}
yml_groups_set()
{
local section="$1"
config_get "type" "$section" "type" ""
config_get "name" "$section" "name" ""
config_get "old_name" "$section" "old_name" ""
config_get "test_url" "$section" "test_url" ""
config_get "test_interval" "$section" "test_interval" ""
if [ -z "$type" ]; then
return
fi
if [ -z "$name" ]; then
return
fi
echo "- name: $name" >>$GROUP_FILE
echo " type: $type" >>$GROUP_FILE
if [ "$type" == "url-test" ] || [ "$type" == "load-balance" ] || [ "$name" == "Proxy" ] || [ "$name" == "🔑Proxy" ]; then
echo " proxies:" >>$GROUP_FILE
cat $Proxy_Group >> $GROUP_FILE 2>/dev/null
else
echo " proxies:" >>$GROUP_FILE
fi
if [ "$name" != "$old_name" ]; then
sed -i "s/,${old_name}$/,${name}#d/g" $CONFIG_FILE 2>/dev/null
sed -i "s/:${old_name}$/:${name}#d/g" $CONFIG_FILE 2>/dev/null
sed -i "s/\'${old_name}\'/\'${name}\'/g" $CFG_FILE 2>/dev/null
config_load "clash"
fi
config_list_foreach "$section" "other_group" set_other_groups
config_foreach yml_servers_add "servers" "$name"
[ ! -z "$test_url" ] && {
echo " url: $test_url" >>$GROUP_FILE
}
[ ! -z "$test_interval" ] && {
echo " interval: \"$test_interval\"" >>$GROUP_FILE
}
}
config_load clash
config_foreach yml_groups_set "groups"
if [ "$(ls -l $GROUP_FILE|awk '{print $5}')" -ne 0 ]; then
sed -i "1i\ " $GROUP_FILE
sed -i "2i\Proxy Group:" $GROUP_FILE
fi
cat $Proxy_Group_url $CONFIG_YAML_RULE > $RULE_PROXY
mode=$(uci get clash.config.mode 2>/dev/null)
da_password=$(uci get clash.config.dash_pass 2>/dev/null)
@ -219,55 +304,55 @@ redir_port=$(uci get clash.config.redir_port 2>/dev/null)
http_port=$(uci get clash.config.http_port 2>/dev/null)
socks_port=$(uci get clash.config.socks_port 2>/dev/null)
dash_port=$(uci get clash.config.dash_port 2>/dev/null)
bind_addr=$(uci get clash.config.bind_addr 2>/dev/null)
allow_lan=$(uci get clash.config.allow_lan 2>/dev/null)
log_level=$(uci get clash.config.level 2>/dev/null)
cat >> "$TEMP_FILE" <<-EOF
port: ${http_port}
socks-port: ${socks_port}
redir-port: ${redir_port}
allow-lan: true
mode: Rule
log-level: ${log_level}
external-controller: 0.0.0.0:${dash_port}
secret: '${da_password}'
external-ui: "/usr/share/clash/dashboard"
#experimental:
# ignore-resolve-fail: true
subtype=$(uci get clash.config.subcri 2>/dev/null)
#local SOCKS5/HTTP(S) server
#authentication:
# - "user1:pass1"
# - "user2:pass2"
dns:
enable: true
listen: 0.0.0.0:5300
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/24
# hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'
nameserver:
- 101.132.183.99
- 8.8.8.8
- 119.29.29.29
- 114.114.114.114
- 114.114.115.115
- tls://dns.rubyfish.cn:853
- https://1.1.1.1/dns-query
cat >> "$TEMP_FILE" <<-EOF
#config-start-here
EOF
cat $TEMP_FILE $SERVER_FILE > $SERVERS
sed -i "1i\port: ${http_port}" $TEMP_FILE
sed -i "2i\socks-port: ${socks_port}" $TEMP_FILE
sed -i "3i\redir-port: ${redir_port}" $TEMP_FILE
sed -i "4i\allow-lan: ${allow_lan}" $TEMP_FILE
if [ $allow_lan == "true" ]; then
sed -i "5i\bind-address: '${bind_addr}'" $TEMP_FILE
else
sed -i "5i\#bind-address: " $TEMP_FILE
fi
sed -i "6i\mode: Rule" $TEMP_FILE
sed -i "7i\log-level: ${log_level}" $TEMP_FILE
sed -i "8i\external-controller: 0.0.0.0:${dash_port}" $TEMP_FILE
sed -i "9i\secret: '${da_password}'" $TEMP_FILE
sed -i "10i\external-ui: "/usr/share/clash/dashboard"" $TEMP_FILE
sed -i "11i\ " $TEMP_FILE
sed -i "12i\ " $TEMP_FILE
sed -i '/#config-start-here/ d' $TEMP_FILE
if [ -f $CONFIG_YAML ]; then
rm -rf $CONFIG_YAML
fi
cat $DNS_FILE >> $TEMP_FILE 2>/dev/null
cat $SERVERS $RULE_PROXY > $CONFIG_YAML
rm -rf $SERVERS $RULE_PROXY $Proxy_Group $TEMP_FILE $Proxy_Group_url
cat $SERVER_FILE >> $TEMP_FILE 2>/dev/null
cat $GROUP_FILE >> $TEMP_FILE 2>/dev/null
if [ -f $CONFIG_YAML ];then
rm -rf $CONFIG_YAML
fi
rm -rf $SERVER_FILE
sed -i "1i\ " $CONFIG_YAML_RULE
sed -i "2i\ " $CONFIG_YAML_RULE
cat $TEMP_FILE $CONFIG_YAML_RULE > $CONFIG_YAML
rm -rf $TEMP_FILE $GROUP_FILE $Proxy_Group $CONFIG_FILE
if [ $config_type == "cus" ];then
/etc/init.d/clash restart 2>/dev/null
fi
fi
rm -rf $SERVER_FILE
fi
/etc/init.d/clash restart 2>/dev/null

View File

@ -0,0 +1,23 @@
#!/bin/bash
rule=$(uci get clash.config.rule_url 2>/dev/null)
RULE_YAML="/tmp/Rule"
wget --no-check-certificate $rule -O 2>&1 >1 $RULE_YAML
if [ -f "$RULE_YAML" ]; then
status=$(egrep '^ {0,}Rule:' /tmp/Rule)
if [ $status ];then
sed -i "/Rule:/i\===" $RULE_YAML
sed -i "1i\ " $RULE_YAML
mv $RULE_YAML /tmp/test
sed -i '1,/===/d' /tmp/test
mv /tmp/test /usr/share/clash/custom_rule.yaml
else
sed -i "1i\Rule:" $RULE_YAML
mv $RULE_YAML /tmp/test
sed -i "1i\ " /tmp/test
mv /tmp/test /usr/share/clash/custom_rule.yaml
fi
fi

View File

@ -1820,3 +1820,4 @@ Rule:
- IP-CIDR,209.237.192.0/19,Proxy
- GEOIP,CN,DIRECT
- MATCH,Proxy

View File

@ -0,0 +1,56 @@
time.windows.com
time.nist.gov
time.apple.com
time.asia.apple.com
cn.ntp.org.cn
edu.ntp.org.cn
hk.ntp.org.cn
tw.ntp.org.cn
us.ntp.org.cn
sgp.ntp.org.cn
kr.ntp.org.cn
jp.ntp.org.cn
de.ntp.org.cn
ina.ntp.org.cn
0.openwrt.pool.ntp.org
1.openwrt.pool.ntp.org
2.openwrt.pool.ntp.org
3.openwrt.pool.ntp.org
ntp.aliyun.com
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
time1.aliyun.com
time2.aliyun.com
time3.aliyun.com
time4.aliyun.com
time5.aliyun.com
time6.aliyun.com
time7.aliyun.com
s1c.time.edu.cn
s2m.time.edu.cn
s1b.time.edu.cn
s1e.time.edu.cn
s2a.time.edu.cn
s2b.time.edu.cn
time1.apple.com
time2.apple.com
time3.apple.com
time4.apple.com
time5.apple.com
time6.apple.com
time7.apple.com
time1.google.com
time2.google.com
time3.google.com
time4.google.com
.music.163.com
.music.126.net
interface.music.163.com
msftconnecttest.com
msftncsi.com
qq.com

View File

@ -0,0 +1 @@
yacd.haishan.me

View File

@ -8,9 +8,9 @@
<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="Yet Another Clash Dashboard">
<meta name="description" content="YAC Dashboard">
<meta name="theme-color" content="#202020">
<title>Yet Another Clash Dashboard</title>
<title>YAC 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">

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,5 +1,34 @@
#!/bin/bash
#!/bin/sh
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_SUB="/usr/share/clash/config/sub/config.yaml"
CONFIG_YAML_UPL="/usr/share/clash/config/upload/config.yaml"
CONFIG_YAML_CUS="/usr/share/clash/config/custom/config.yaml"
config_type=$(uci get clash.config.config_type 2>/dev/null)
if [ $config_type == "sub" ];then
if [ -f $CONFIG_YAML_SUB ] && [ "$(ls -l $CONFIG_YAML_SUB|awk '{print int($5/1024)}')" -ne 0 ];then
cp $CONFIG_YAML_SUB $CONFIG_YAML
fi
elif [ $config_type == "upl" ];then
if [ -f $CONFIG_YAML_UPL ] && [ "$(ls -l $CONFIG_YAML_UPL|awk '{print int($5/1024)}')" -ne 0 ];then
cp $CONFIG_YAML_UPL $CONFIG_YAML
fi
elif [ $config_type == "cus" ];then
if [ -f $CONFIG_YAML_CUS ] && [ "$(ls -l $CONFIG_YAML_CUS|awk '{print int($5/1024)}')" -ne 0 ];then
cp $CONFIG_YAML_CUS $CONFIG_YAML
fi
fi
if [ -f $CONFIG_YAML ];then
if [ -z "$(grep "^ \{0,\}listen:" $CONFIG_YAML)" ] || [ -z "$(grep "^ \{0,\}enhanced-mode:" $CONFIG_YAML)" ] || [ -z "$(grep "^ \{0,\}enable:" $CONFIG_YAML)" ] || [ -z "$(grep "^ \{0,\}dns:" $CONFIG_YAML)" ] ;then
#===========================================================================================================================
uci set clash.config.mode="1" && uci commit clash
#===========================================================================================================================
fi
#===========================================================================================================================
mode=$(uci get clash.config.mode 2>/dev/null)
da_password=$(uci get clash.config.dash_pass 2>/dev/null)
@ -7,8 +36,11 @@ CONFIG_YAML="/etc/clash/config.yaml"
http_port=$(uci get clash.config.http_port 2>/dev/null)
socks_port=$(uci get clash.config.socks_port 2>/dev/null)
dash_port=$(uci get clash.config.dash_port 2>/dev/null)
bind_addr=$(uci get clash.config.bind_addr 2>/dev/null)
allow_lan=$(uci get clash.config.allow_lan 2>/dev/null)
log_level=$(uci get clash.config.level 2>/dev/null)
subtype=$(uci get clash.config.subcri 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
@ -21,14 +53,19 @@ if [ $mode -eq 1 ]; then
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
sed -i "4i\allow-lan: true" $CONFIG_YAML
sed -i "5i\mode: Rule" $CONFIG_YAML
sed -i "6i\log-level: ${log_level}" $CONFIG_YAML
sed -i "7i\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML
sed -i "8i\secret: '${da_password}'" $CONFIG_YAML
sed -i "9i\external-ui: "/usr/share/clash/dashboard"" $CONFIG_YAML
sed -i "10i\ " $CONFIG_YAML
sed -i "4i\allow-lan: ${allow_lan}" $CONFIG_YAML
if [ $allow_lan == "true" ]; then
sed -i "5i\bind-address: '${bind_addr}'" $CONFIG_YAML
else
sed -i "5i\#bind-address: " $CONFIG_YAML
fi
sed -i "6i\mode: Rule" $CONFIG_YAML
sed -i "7i\log-level: ${log_level}" $CONFIG_YAML
sed -i "8i\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML
sed -i "9i\secret: '${da_password}'" $CONFIG_YAML
sed -i "10i\external-ui: "/usr/share/clash/dashboard"" $CONFIG_YAML
sed -i "11i\ " $CONFIG_YAML
sed -i "12i\ " $CONFIG_YAML
sed -i '/#=============/ d' $CONFIG_YAML
else
if [ $subtype == "v2rayn2clash" ];then
@ -50,14 +87,20 @@ else
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
sed -i "4i\allow-lan: true" $CONFIG_YAML
sed -i "5i\mode: Rule" $CONFIG_YAML
sed -i "6i\log-level: ${log_level}" $CONFIG_YAML
sed -i "7i\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML
sed -i "8i\secret: '${da_password}'" $CONFIG_YAML
sed -i "9i\external-ui: "/usr/share/clash/dashboard"" $CONFIG_YAML
sed -i "10i\ " $CONFIG_YAML
sed -i "4i\allow-lan: ${allow_lan}" $CONFIG_YAML
if [ $allow_lan == "true" ]; then
sed -i "5i\bind-address: '${bind_addr}'" $CONFIG_YAML
else
sed -i "5i\#bind-address: " $CONFIG_YAML
fi
sed -i "6i\mode: Rule" $CONFIG_YAML
sed -i "7i\log-level: ${log_level}" $CONFIG_YAML
sed -i "8i\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML
sed -i "9i\secret: '${da_password}'" $CONFIG_YAML
sed -i "10i\external-ui: "/usr/share/clash/dashboard"" $CONFIG_YAML
sed -i "11i\ " $CONFIG_YAML
sed -i "12i\ " $CONFIG_YAML
sed -i '/#=============/ d' $CONFIG_YAML
fi
#===========================================================================================================================
fi