luci-app-clash: merge upstream source

This commit is contained in:
CN_SZTL 2020-01-01 01:01:48 +08:00
parent ca4b384f03
commit 1150d85acd
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
70 changed files with 7750 additions and 3211 deletions

View File

@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=1.1.7
PKG_RELEASE:=2
PKG_VERSION:=1.4.0
#PKG_RELEASE:=3
PKG_MAINTAINER:=frainzy1477
@ -11,9 +11,9 @@ include $(INCLUDE_DIR)/package.mk
define Package/luci-app-clash
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
SUBMENU:=2. Clash
TITLE:=LuCI app for clash
DEPENDS:=+luci +luci-base +wget +iptables +coreutils +coreutils-nohup +bash +ipset +libustream-openssl +libopenssl +openssl-util +clash
DEPENDS:=+luci +luci-base +clash +wget +iptables +coreutils-base64 +coreutils +coreutils-nohup +bash +ipset
PKGARCH:=all
MAINTAINER:=frainzy1477
endef
@ -37,70 +37,89 @@ endef
define Package/$(PKG_NAME)/preinst
#!/bin/sh
mkdir -p /usr/share/clashbackup 2>/dev/null
if [ -f "/tmp/dnsmasq.d/custom_list.conf" ]; then
rm -rf /tmp/dnsmasq.d/custom_list.conf
rm -rf /tmp/dnsmasq.d/custom_list.conf 2>/dev/null
fi
if [ -d "/tmp/dnsmasq.clash" ]; then
rm -rf /tmp/dnsmasq.clash
rm -rf /tmp/dnsmasq.clash 2>/dev/null
fi
if [ -f "/etc/config/clash" ]; then
mv /etc/config/clash /etc/config/clash.bak
mv /etc/config/clash /etc/config/clash.bak 2>/dev/null
fi
if [ -d "/usr/lib/lua/luci/model/cbi/clash" ]; then
rm -rf /usr/lib/lua/luci/model/cbi/clash
rm -rf /usr/lib/lua/luci/model/cbi/clash 2>/dev/null
fi
if [ -d "/usr/lib/lua/luci/view/clash" ]; then
rm -rf /usr/lib/lua/luci/view/clash
rm -rf /usr/lib/lua/luci/view/clash 2>/dev/null
fi
if [ -f /usr/share/clash/new_core_version ]; then
rm -rf /usr/share/clash/new_core_version
rm -rf /usr/share/clash/new_core_version 2>/dev/null
fi
if [ -f /usr/share/clash/new_clashr_core_version ]; then
rm -rf /usr/share/clash/new_clashr_core_version 2>/dev/null
fi
if [ -f /usr/share/clash/new_luci_version ]; then
rm -rf /usr/share/clash/new_luci_version
rm -rf /usr/share/clash/new_luci_version 2>/dev/null
fi
if [ -d /usr/share/clash/web ]; then
rm -rf /usr/share/clash/web
rm -rf /usr/share/clash/web 2>/dev/null
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
if [ -f /usr/share/clash/config/sub/config.yaml ];then
mv /usr/share/clash/config/sub/config.yaml /usr/share/clashbackup/config.bak1 2>/dev/null
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
if [ -f /usr/share/clash/config/upload/config.yaml ];then
mv /usr/share/clash/config/upload/config.yaml /usr/share/clashbackup/config.bak2 2>/dev/null
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
if [ -f /usr/share/clash/config/custom/config.yaml ];then
mv /usr/share/clash/config/custom/config.yaml /usr/share/clashbackup/config.bak3 2>/dev/null
fi
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
rm -rf /tmp/luci*
rm -rf /tmp/luci*
if [ -f "/etc/config/clash.bak" ]; then
mv /etc/config/clash.bak /etc/config/clash
mv /etc/config/clash.bak /etc/config/clash 2>/dev/null
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
if [ -f /usr/share/clashbackup/config.bak1 ];then
mv /usr/share/clashbackup/config.bak1 /usr/share/clash/config/sub/config.yaml 2>/dev/null
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
if [ -f /usr/share/clashbackup/config.bak2 ];then
mv /usr/share/clashbackup/config.bak2 /usr/share/clash/config/upload/config.yaml 2>/dev/null
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
if [ -f /usr/share/clashbackup/config.bak3 ];then
mv /usr/share/clashbackup/config.bak3 /usr/share/clash/config/custom/config.yaml 2>/dev/null
fi
if [ -f "/etc/init.d/clash" ]; then
/etc/init.d/clash disable 2>/dev/null
fi
echo "Clash for OpenWRT" >/usr/share/clash/clash_real.txt 2>/dev/null
echo "0" > /usr/share/clash/logstatus_check 2>/dev/null
echo "" > /tmp/clash.txt 2>/dev/null
endef
define Package/$(PKG_NAME)/install
@ -114,7 +133,6 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/usr/share/
$(INSTALL_DIR) $(1)/usr/share/clash
$(INSTALL_DIR) $(1)/usr/share/clash/yac
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard/img
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard/js
@ -123,6 +141,7 @@ define Package/$(PKG_NAME)/install
$(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_DIR) $(1)/usr/share/clash/v2ssr
$(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/
@ -132,29 +151,32 @@ define Package/$(PKG_NAME)/install
$(INSTALL_CONF) ./root/etc/config/clash $(1)/etc/config/clash
$(INSTALL_CONF) ./root/etc/clash/* $(1)/etc/clash/
$(INSTALL_BIN) ./root/usr/share/clash/v2ssr/v2ssr_custom_rule.yaml $(1)/usr/share/clash/v2ssr/
$(INSTALL_BIN) ./root/usr/share/clash/v2ssr/policygroup $(1)/usr/share/clash/v2ssr/
$(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/load.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/core_download.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/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/check_clashr_core_version.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/yum_change.sh $(1)/usr/share/clash/
$(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/v2ssr.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.557c7e0375c2286ea607.css $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/main.aee3e3fc24cd46786598.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/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_BIN) ./root/usr/share/clash/dashboard/js/1.bundle.aee3e3fc24cd46786598.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/bundle.aee3e3fc24cd46786598.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/
@ -166,4 +188,4 @@ endef
$(eval $(call BuildPackage,luci-app-clash))
$(eval $(call BuildPackage,$(PKG_NAME)))

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,9 @@
module("luci.controller.clash", package.seeall)
local fs=require"nixio.fs"
local http=require"luci.http"
local uci=require"luci.model.uci".cursor()
function index()
@ -9,28 +14,38 @@ function index()
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", "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", "import"},cbi("clash/import"),_("Import Config"), 30).leaf = true
entry({"admin", "services", "clash", "create"},cbi("clash/create"),_("Create Config"), 40).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", "settings"}, firstchild(),_("Settings"), 50)
entry({"admin", "services", "clash", "settings", "port"},cbi("clash/port"),_("Proxy Ports"), 60).leaf = true
entry({"admin", "services", "clash", "settings", "dns"},cbi("clash/dns"),_("DNS Settings"), 70).leaf = true
entry({"admin", "services", "clash", "settings", "list"},cbi("clash/list"),_("Custom List"), 80).leaf = true
entry({"admin", "services", "clash", "settings", "access"},cbi("clash/access"),_("Access Control"), 90).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", "config"},firstchild(),_("Config"), 100)
entry({"admin", "services", "clash", "config", "actconfig"},cbi("clash/actconfig"),_("Config In Use"), 110).leaf = true
entry({"admin", "services", "clash", "config", "subconfig"},cbi("clash/subconfig"),_("Subscribe Config"), 120).leaf = true
entry({"admin", "services", "clash", "config", "upconfig"},cbi("clash/upconfig"),_("Uploaded Config"), 130).leaf = true
entry({"admin", "services", "clash", "config", "cusconfig"},cbi("clash/cusconfig"),_("Custom Config"), 140).leaf = true
entry({"admin","services","clash","status"},call("action_status")).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", "log"},cbi("clash/log"),_("Log"), 150).leaf = true
entry({"admin", "services", "clash", "update"},cbi("clash/update"),_("Update"), 160).leaf = true
entry({"admin","services","clash","check_status"},call("check_status")).leaf=true
entry({"admin", "services", "clash", "ping"}, call("act_ping")).leaf=true
entry({"admin", "services", "clash", "readlog"},call("action_read")).leaf=true
entry({"admin", "services", "clash", "check"}, call("check_update_log")).leaf=true
entry({"admin", "services", "clash", "doupdate"}, call("do_update")).leaf=true
entry({"admin", "services", "clash", "start"}, call("do_start")).leaf=true
entry({"admin", "services", "clash", "stop"}, call("do_stop")).leaf=true
entry({"admin", "services", "clash", "getlog"}, call("get_log")).leaf=true
entry({"admin", "services", "clash", "corelog"},call("down_check")).leaf=true
entry({"admin", "services", "clash", "logstatus"},call("logstatus_check")).leaf=true
end
@ -61,6 +76,10 @@ local function check_core()
return luci.sys.exec("sh /usr/share/clash/check_core_version.sh")
end
local function check_clashr_core()
return luci.sys.exec("sh /usr/share/clash/check_clashr_core_version.sh")
end
local function current_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/luci_version")
end
@ -73,6 +92,10 @@ local function new_core_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/new_core_version")
end
local function new_clashr_core_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/new_clashr_core_version")
end
local function e_mode()
return luci.sys.exec("egrep '^ {0,}enhanced-mode' /etc/clash/config.yaml |grep enhanced-mode: |awk -F ': ' '{print $2}'")
end
@ -86,14 +109,54 @@ local function clash_core()
end
end
local function clashr_core()
if nixio.fs.access("/usr/share/clash/corer_version") then
return luci.sys.exec("sed -n 1p /usr/share/clash/corer_version")
else
return "0"
end
end
local function readlog()
return luci.sys.exec("sed -n '$p' /usr/share/clash/clash_real.txt 2>/dev/null")
end
local function downcheck()
if nixio.fs.access("/var/run/core_update_error") then
return "0"
elseif nixio.fs.access("/var/run/core_update") then
return "1"
elseif nixio.fs.access("/usr/share/clash/core_down_complete") then
return "2"
end
end
function action_read()
luci.http.prepare_content("application/json")
luci.http.write_json({
readlog = readlog();
})
end
function down_check()
luci.http.prepare_content("application/json")
luci.http.write_json({
downcheck = downcheck();
})
end
function check_status()
luci.http.prepare_content("application/json")
luci.http.write_json({
check_version = check_version(),
check_core = check_core(),
current_version = current_version(),
check_clashr_core = check_clashr_core(),
new_version = new_version(),
new_clashr_core_version = new_clashr_core_version(),
clash_core = clash_core(),
clashr_core = clashr_core(),
new_core_version = new_core_version()
@ -108,6 +171,7 @@ function action_status()
dash_port = dash_port(),
current_version = current_version(),
clash_core = clash_core(),
clashr_core = clashr_core(),
dash_pass = dash_pass(),
e_mode = e_mode()
@ -123,3 +187,50 @@ function act_ping()
end
function do_update()
fs.writefile("/var/run/clashlog","0")
luci.sys.exec("(rm /var/run/core_update_error ; touch /var/run/core_update ; sh /usr/share/clash/core_download.sh >/tmp/clash_update.txt 2>&1 || touch /var/run/core_update_error ;rm /var/run/core_update) &")
end
function do_start()
luci.sys.exec("/etc/init.d/clash restart 2>&1 &")
end
function do_stop()
luci.sys.exec("/etc/init.d/clash stop 2>&1 &")
end
function check_update_log()
luci.http.prepare_content("text/plain; charset=utf-8")
local fdp=tonumber(fs.readfile("/var/run/clashlog")) or 0
local f=io.open("/tmp/clash_update.txt", "r+")
f:seek("set",fdp)
local a=f:read(2048000) or ""
fdp=f:seek()
fs.writefile("/var/run/clashlog",tostring(fdp))
f:close()
if fs.access("/var/run/core_update") then
luci.http.write(a)
else
luci.http.write(a.."\0")
end
end
function logstatus_check()
luci.http.prepare_content("text/plain; charset=utf-8")
local fdp=tonumber(fs.readfile("/usr/share/clash/logstatus_check")) or 0
local f=io.open("/tmp/clash.txt", "r+")
f:seek("set",fdp)
local a=f:read(2048000) or ""
fdp=f:seek()
fs.writefile("/usr/share/clash/logstatus_check",tostring(fdp))
f:close()
if fs.access("/var/run/logstatus") then
luci.http.write(a)
else
luci.http.write(a.."\0")
end
end

View File

@ -6,11 +6,13 @@ local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local fs = require "luci.clash"
local uci = require "luci.model.uci".cursor()
local clash = "clash"
local http = luci.http
m = Map("clash")
s = m:section(TypedSection, "clash")
--m.pageaction = false
m.pageaction = false
s.anonymous = true
s.addremove=false
@ -33,15 +35,47 @@ 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")
o.inputtitle = translate("Update GEOIP Database")
o.description = update_time
o.inputstyle = "reload"
o.write = function()
SYS.call("bash /usr/share/clash/ipdb.sh >>/tmp/clash.log 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "clash","settings", "access"))
o = s:option(FileUpload, "",translate("Update GEOIP Database"))
o.description = translate("NB: Upload GEOIP Database file Country.mmdb")
o.title = translate("Update GEOIP Database")
o.template = "clash/clash_upload"
um = s: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
um.value = translate("File saved to") .. ' "/etc/clash/"'
SYS.call("chmod + x /etc/clash/Country.mmdb")
if luci.sys.call("pidof clash >/dev/null") == 0 then
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
end
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
@ -51,7 +85,7 @@ 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. fake-ip mode not supported")
md:depends("proxylan", 0)
md:depends("proxylan", 0)
o = s:option(DynamicList, "lan_ips", translate("Bypass Lan List"))
@ -66,12 +100,18 @@ 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
o = s:option(Button, "Apply")
o.title = translate("Save & Apply")
o.inputtitle = translate("Save & Apply")
o.inputstyle = "apply"
o.write = function()
m.uci:commit("clash")
if luci.sys.call("pidof clash >/dev/null") == 0 then
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash"))
end
end
return m

View File

@ -11,12 +11,23 @@ local clash = "clash"
m = Map("clash")
s = m:section(TypedSection, "clash")
s.anonymous = true
m.pageaction = false
o = s:option(Flag, "enable", translate("Enable"))
o.default = 0
o.rmempty = false
o.description = translate("Enable")
o = s:option(ListValue, "core", translate("Core"))
o.default = "clashcore"
if nixio.fs.access("/etc/clash/clash") then
o:value("1", translate("Clash"))
end
if nixio.fs.access("/usr/bin/clash") then
o:value("2", translate("Clashr"))
end
o.description = translate("Select core, clashr support ssr while clash does not.")
o = s:option(ListValue, "config_type", translate("Config Type"))
o.default = "sub"
@ -25,13 +36,21 @@ o:value("upl", translate("Uploaded Config"))
o:value("cus", translate("Custom Config"))
o.description = translate("Select Configuration type")
local apply = luci.http.formvalue("cbi.apply")
if apply then
uci:commit("clash")
os.execute("/etc/init.d/clash restart >/dev/null 2>&1 &")
o = s:option(Button, "Apply")
o.title = translate("Save & Apply")
o.inputtitle = translate("Save & Apply")
o.inputstyle = "apply"
o.write = function()
m.uci:commit("clash")
end
o = s:option(Button,"action")
o.title = translate("Action")
o.template = "clash/start_stop"
return m

View File

@ -0,0 +1,195 @@
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 fs = require "luci.clash"
local uci = require "luci.model.uci".cursor()
local m, s, o, krk
local clash = "clash"
local http = luci.http
m = Map("clash")
s = m:section(TypedSection, "clash" , translate("Rule"))
s.anonymous = true
s.addremove=false
m.pageaction = 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.txt 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")
sev.rows = 20
sev.wrap = "off"
sev.cfgvalue = function(self, section)
return NXFS.readfile(rule) or ""
end
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
krk = Map(clash)
s = krk:section(TypedSection, "clash", translate("Load Config"))
s.anonymous = true
cc = s:option(Flag, "create", translate("Enable Create"))
cc.default = 1
cc.description = translate("Enable to create configuration")
o = s:option(ListValue, "loadfrom", translate("Load From"))
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(ListValue, "loadservers", translate("Load Servers"))
o:value("1", translate("enabled"))
o:value("0", translate("disabled"))
o.description = translate("Enable to read servers")
o = s:option(ListValue, "loadgroups", translate("Load Groups"))
o:value("1", translate("enabled"))
o:value("0", translate("disabled"))
o.description = translate("Enable to read policy group")
local t = {
{Load_Config, Creat_Config, Delete_Severs, Delete_Groups}
}
b = krk:section(Table, t)
o = b:option(Button,"Load_Config")
o.inputtitle = translate("Load Config")
o.inputstyle = "apply"
o.write = function()
krk.uci:commit("clash")
luci.sys.call("sh /usr/share/clash/load.sh >/dev/null 2>&1 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash"))
end
o = b:option(Button,"Creat_Config")
o.inputtitle = translate("Create Config")
o.inputstyle = "apply"
o.write = function()
krk.uci:commit("clash")
luci.sys.call("sh /usr/share/clash/proxy.sh >/dev/null 2>&1 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash"))
end
o = b:option(Button,"Delete_Severs")
o.inputtitle = translate("Delete Severs")
o.inputstyle = "reset"
o.write = function()
krk.uci:delete_all("clash", "servers", function(s) return true end)
krk.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "create"))
end
o = b:option(Button,"Delete_Groups")
o.inputtitle = translate("Delete Groups")
o.inputstyle = "reset"
o.write = function()
krk.uci:delete_all("clash", "groups", function(s) return true end)
krk.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "create"))
end
s = krk:section(TypedSection, "servers", translate("Proxies"))
s.anonymous = true
s.addremove = true
s.sortable = false
s.template = "cbi/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/clash/servers-config/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(s.extedit % sid)
return
end
end
o = s:option(DummyValue, "type", translate("Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "name", translate("Alias"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "server", translate("Server Address"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "port", translate("Server Port"))
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 = krk:section(TypedSection, "groups", translate("Policy Groups"))
r.anonymous = true
r.addremove = true
s.sortable = false
r.template = "cbi/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
krk:append(Template("clash/list"))
return krk, m

View File

@ -8,24 +8,39 @@ local uci = require("luci.model.uci").cursor()
m = Map("clash")
s = m:section(TypedSection, "clash")
--m.pageaction = false
m.pageaction = false
s.anonymous = true
s.addremove=false
y = s:option(ListValue, "dnsforwader", translate("DNS Forwarding"))
y.default = 1
y:value("0", translate("disabled"))
y:value("1", translate("enabled"))
y.description = translate("Set custom DNS forwarder in DHCP and DNS Settings")
y.description = translate("Set custom DNS forwarder in DHCP and DNS Settings and forward all dns traffic to clash")
deldns = s:option(Flag, "delan", translate("Remove Lan DNS"))
deldns.description = translate("Remove Lan custom DNS Servers when client is disabled")
cdns = s:option(Flag, "culan", translate("Enable Lan DNS"))
cdns.default = 1
cdns.description = translate("Enabling will set custom DNS Servers for Lan")
cdns:depends("dnsforwader", 0)
dns = s:option(DynamicList, "landns", translate("Lan DNS servers"))
dns.description = translate("Set custom DNS Servers for Lan")
dns.datatype = "ipaddr"
dns.cast = "string"
dns:depends("culan", 1)
y = s:option(ListValue, "ipv6", translate("Enable ipv6"))
y:value("0", translate("disabled"))
y:value("1", translate("enabled"))
y.description = translate("Allow ipv6 traffic through clash")
md = s:option(Flag, "mode", translate("Custom DNS"))
md.default = 1
md.rmempty = false
md.description = translate("Enabling Custom DNS will Overwrite your config.yaml dns section")
local dns = "/usr/share/clash/dns.yaml"
o = s:option(TextValue, "dns",translate("Modify yaml DNS"))
o.template = "clash/tvalue"
@ -41,15 +56,22 @@ o.description = translate("NB: press ENTER to create a blank line at the end of
o:depends("mode", 1)
o = s:option(Button, "Apply")
o.title = translate("Save & Apply")
o.inputtitle = translate("Save & Apply")
o.inputstyle = "apply"
o.write = function()
local clash_conf = "/etc/clash/config.yaml"
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 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash"))
end
else
uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash" , "settings", "dns"))
end
end

View File

@ -9,7 +9,7 @@ local sid = arg[1]
m = Map(clash, translate("Edit Group"))
--m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/clash/servers")
m.redirect = luci.dispatcher.build_url("admin/services/clash/create")
if m.uci:get(clash, sid) ~= "groups" then
luci.http.redirect(m.redirect)
return
@ -46,7 +46,15 @@ o:depends("type", "fallback")
o:depends("type", "load-balance")
o = s:option(DynamicList, "other_group", translate("Other Group"))
o.rmempty = false
o.description = translate("Proxy Groups Must Exist In Rule")
o:value("ALL", translate("All Servers"))
uci:foreach("clash", "servers",
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)
uci:foreach("clash", "groups",
function(s)
if s.name ~= "" and s.name ~= nil and s.name ~= m.uci:get(clash, sid, "name") then
@ -55,14 +63,13 @@ uci:foreach("clash", "groups",
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")
m.uci:commit(clash, sid)
sys.call("sh /usr/share/clash/groups.sh start")
end
return m

View File

@ -0,0 +1,128 @@
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 fs = require "luci.clash"
local uci = require "luci.model.uci".cursor()
local kr
local clash = "clash"
local http = luci.http
kr = Map(clash)
s = kr:section(TypedSection, "clash", translate("Subscription Config"))
s.anonymous = true
kr.pageaction = false
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("v2ssr2clash", translate("v2ssr2clash"))
o.description = translate("Select Subcription Type")
o = s:option(Value, "subscribe_url_clash")
o.title = translate("Subcription Url")
o.description = translate("Clash Subscription Address")
o.rmempty = true
o:depends("subcri", 'clash')
o = s:option(DynamicList, "subscribe_url")
o.title = translate("Subcription Url")
o.description = translate("V2/SSR Subscription Address, Only input your subscription address without any api conversion url")
o.rmempty = true
o:depends("subcri", 'v2ssr2clash')
o = s:option(Button,"update")
o.title = translate("Update Subcription")
o.inputtitle = translate("Update")
o.description = translate("Update Config")
o.inputstyle = "reload"
o.write = function()
kr.uci:commit("clash")
SYS.call("sh /usr/share/clash/clash.sh >>/tmp/clash.txt 2>&1 &")
SYS.call("sleep 1")
HTTP.redirect(DISP.build_url("admin", "services", "clash"))
end
o:depends("subcri", 'clash')
o = s:option(Button,"updatee")
o.title = translate("Update Subcription")
o.inputtitle = translate("Update")
o.description = translate("Update Config")
o.inputstyle = "reload"
o.write = function()
kr.uci:commit("clash")
SYS.call("cp /etc/config/clash /usr/share/clash/v2ssr/config.bak 2>/dev/null")
SYS.call("sleep 1")
luci.sys.call("bash /usr/share/clash/v2ssr.sh >>/tmp/clash.txt 2>&1 &")
HTTP.redirect(DISP.build_url("admin", "services", "clash"))
end
o:depends("subcri", 'v2ssr2clash')
k = Map(clash)
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.description = translate("NB: Only upload file with name config.yml or config.yaml")
o.title = translate(" ")
o.template = "clash/clash_upload"
um = sul:option(DummyValue, "", nil)
um.template = "clash/clash_dvalue"
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
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
return kr, k

View File

@ -10,7 +10,7 @@ local clash = "clash"
m = Map("clash")
s = m:section(TypedSection, "clash")
--m.pageaction = false
m.pageaction = false
s.anonymous = true
@ -32,6 +32,19 @@ o:value("4.2.2.4", "4.2.2.4")
o:depends("cus_list", "1")
o = s:option(Button, "Apply")
o.title = translate("Apply Custom List")
o.inputtitle = translate("Apply Custom List")
o.inputstyle = "apply"
o.write = function()
m.uci:commit("clash")
--SYS.call("sh /usr/share/clash/list.sh 2>&1 &")
if luci.sys.call("pidof clash >/dev/null") == 0 then
SYS.call("/etc/init.d/clash restart >/dev/null 2>&1 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash"))
end
end
local conffile = "/usr/share/clash/server.list"
sev = s:option(TextValue, "conffile")
@ -44,14 +57,4 @@ 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

@ -5,7 +5,8 @@ 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")
@ -13,23 +14,45 @@ m.pageaction = false
s.anonymous = true
s.addremove=false
local clog = "/tmp/clash.log"
log = s:option(TextValue, "clog")
log.readonly=true
log.description = translate("")
log.rows = 29
log.wrap = "off"
log.cfgvalue = function(self, section)
return NXFS.readfile(clog) or ""
end
log.write = function(self, section, value)
end
log.template = "clash/status_log"
o = s:option(Button,"log")
o.inputtitle = translate("Clear Logs")
o.write = function()
SYS.call('echo "" > /tmp/clash.log 2>&1 &')
SYS.call('echo "0" > /usr/share/clash/logstatus_check 2>&1 &')
SYS.call('echo "" > /tmp/clash.txt 2>&1 &')
HTTP.redirect(DISP.build_url("admin", "services", "clash", "log"))
end
o = s:option(Button, "Download")
o.inputtitle = translate("Download logs")
o.inputstyle = "apply"
o.write = function ()
local sPath, sFile, fd, block
sPath = "/tmp/clash.txt"
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('txt -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".txt"
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

@ -7,7 +7,7 @@ local uci = require("luci.model.uci").cursor()
m = Map("clash")
s = m:section(TypedSection, "clash")
--m.pageaction = false
m.pageaction = false
s.anonymous = true
o = s:option(Value, "http_port")
@ -80,15 +80,22 @@ o:value("warning", "warning")
o:value("error", "error")
o:value("debug", "debug")
o = s:option(Button, "Apply")
o.title = translate("Save & Apply")
o.inputtitle = translate("Save & Apply")
o.inputstyle = "apply"
o.write = function()
local clash_conf = "/etc/clash/config.yaml"
local apply = luci.http.formvalue("cbi.apply")
if apply then
if NXFS.access(clash_conf) then
uci:commit("clash")
m.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 &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash"))
end
else
m.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash" , "settings", "port"))
end
end

View File

@ -23,7 +23,6 @@ local encrypt_methods_ss = {
"aes-128-gcm",
"aes-192-gcm",
"aes-256-gcm",
"chacha20",
"chacha20-ietf",
"xchacha20",
"chacha20-ietf-poly1305",
@ -37,8 +36,52 @@ local securitys = {
"chacha20-poly1305"
}
local encrypt_methods_ssr = {
"aes-128-cfb",
"aes-192-cfb",
"aes-256-cfb",
"aes-128-ctr",
"aes-192-ctr",
"aes-256-ctr",
"aes-128-ofb",
"aes-192-ofb",
"aes-256-ofb",
"des-cfb",
"bf-cfb",
"cast5-cfb",
"rc4-md5",
"chacha20",
"chacha20-ietf",
"salsa20",
"camellia-128-cfb",
"camellia-192-cfb",
"camellia-256-cfb",
"idea-cfb",
"rc2-cfb",
"seed-cfb",
}
local protocol_ssr = {
"origin",
"auth_sha1_v4",
"auth_aes128_md5",
"auth_aes128_sha1",
}
local obfs_ssr_list = {
"plain",
"http_simple",
"http_post",
"tls1.2_ticket_auth",
}
m = Map(clash, translate("Edit Server"))
m.redirect = luci.dispatcher.build_url("admin/services/clash/servers")
m.redirect = luci.dispatcher.build_url("admin/services/clash/create")
if m.uci:get(clash, sid) ~= "servers" then
luci.http.redirect(m.redirect)
return
@ -51,9 +94,11 @@ s.addremove = false
o = s:option(ListValue, "type", translate("Server Node Type"))
o:value("ss", translate("Shadowsocks"))
o:value("ssr", translate("ShadowsocksR"))
o:value("vmess", translate("Vmess"))
o:value("socks5", translate("Socks5"))
o:value("http", translate("HTTP(S)"))
o:value("snell", translate("Snell"))
o.description = translate("Using incorrect encryption mothod may causes service fail to start")
@ -73,12 +118,49 @@ o = s:option(Value, "password", translate("Password"))
o.password = true
o.rmempty = true
o:depends("type", "ss")
o:depends("type", "ssr")
o = s:option(Value, "psk", translate("Psk"))
o.rmempty = false
o:depends("type", "snell")
o = s:option(ListValue, "cipher", translate("Encrypt Method"))
for _, v in ipairs(encrypt_methods_ss) do o:value(v) end
o.rmempty = true
o:depends("type", "ss")
o = s:option(ListValue, "cipher_ssr", translate("Encrypt Method"))
for _, v in ipairs(encrypt_methods_ssr) do o:value(v) end
o.rmempty = true
o:depends("type", "ssr")
o = s:option(ListValue, "protocol", translate("Protocol"))
for _, v in ipairs(protocol_ssr) do o:value(v) end
o.rmempty = true
o:depends("type", "ssr")
o = s:option(Value, "protocolparam", translate("Protocol Param"))
o.rmempty = true
o:depends("type", "ssr")
o = s:option(ListValue, "obfs_ssr", translate("Obfs"))
for _, v in ipairs(obfs_ssr_list) do o:value(v) end
o.rmempty = true
o:depends("type", "ssr")
o = s:option(ListValue, "obfs_snell", translate("obfs-mode"))
o.rmempty = true
o.default = "none"
o:value("none")
o:value("tls")
o:value("http")
o:depends("type", "snell")
o = s:option(Value, "obfsparam", translate("Obfs Param"))
o.rmempty = true
o:depends("type", "ssr")
o = s:option(ListValue, "securitys", translate("Encrypt Method"))
for _, v in ipairs(securitys) do o:value(v, v:upper()) end
o.rmempty = true
@ -99,11 +181,14 @@ o:value("none")
o:value("websocket", translate("websocket (ws)"))
o:depends("type", "vmess")
o = s:option(Value, "host", translate("obfs-hosts"))
o = s:option(Value, "host", translate("hosts"))
o.datatype = "host"
o.rmempty = true
o:depends("obfs", "tls")
o:depends("obfs", "http")
o:depends("obfs", "websocket")
o:depends("obfs_snell", "tls")
o:depends("obfs_snell", "http")
o = s:option(ListValue, "udp", translate("udp"))
o:value("true")
@ -117,10 +202,6 @@ o:value("false")
o:depends("obfs", "websocket")
o = s:option(Value, "custom_host", translate("host"))
o.rmempty = true
o:depends("obfs", "websocket")
-- [[ WS部分 ]]--
@ -188,4 +269,9 @@ o:depends("type", "vmess")
o:depends("type", "socks5")
o:depends("type", "http")
local apply = luci.http.formvalue("cbi.apply")
if apply then
m.uci:commit("clash")
end
return m

View File

@ -1,286 +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 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" , 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")
sev.rows = 20
sev.wrap = "off"
sev.cfgvalue = function(self, section)
return NXFS.readfile(rule) or ""
end
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.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"
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
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
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()
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", translate("Proxies"))
s.anonymous = true
s.addremove = true
s.sortable = true
s.template = "cbi/tblsection"
s.extedit = luci.dispatcher.build_url("admin/services/clash/servers-config/%s")
function s.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(s.extedit % sid)
return
end
end
o = s:option(DummyValue, "type", translate("Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "name", translate("Alias"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "server", translate("Server Address"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = s:option(DummyValue, "port", translate("Server Port"))
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
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

@ -6,11 +6,56 @@ local UTIL = require "luci.util"
local uci = require("luci.model.uci").cursor()
local m
font_green = [[<font color="green">]]
font_off = [[</font>]]
bold_on = [[<strong>]]
bold_off = [[</strong>]]
m = Map("clash")
m:section(SimpleSection).template = "clash/update"
m.pageaction = false
k = Map("clash")
s = k:section(TypedSection, "clash")
s.anonymous = true
o = s:option(ListValue, "dcore", translate("Core Type"))
o.default = "clashcore"
o:value("1", translate("Clash"))
o:value("2", translate("Clashr"))
o.description = translate("Select core, clashr support ssr while clash does not.")
local cpu_model=SYS.exec("opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null")
o = s:option(ListValue, "download_core", translate("Select Core"))
o.description = translate("CPU Model")..': '..font_green..bold_on..cpu_model..bold_off..font_off..' '
o:value("linux-386")
o:value("linux-amd64", translate("linux-amd64(x86-64)"))
o:value("linux-armv5")
o:value("linux-armv6")
o:value("linux-armv7")
o:value("linux-armv8")
o:value("linux-mips-hardfloat")
o:value("linux-mips-softfloat")
o:value("linux-mips64")
o:value("linux-mips64le")
o:value("linux-mipsle-softfloat")
o:value("linux-mipsle-hardfloat")
o=s:option(Button,"down_core")
o.inputtitle = translate("Save & Apply")
o.title = translate("Save & Apply")
o.inputstyle = "reload"
o.write = function()
k.uci:commit("clash")
end
o = s:option(Button,"download")
o.title = translate("Download")
o.template = "clash/core_check"
return m, k
return m

View File

@ -1,6 +1,6 @@
<%+cbi/valueheader%>
<label class="cbi-value" style="display:inline-block;" for="ulfile"></label>
<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%>" />
<input class="cbi-input-file" style="width: 80%" type="file" id="ulfile" name="ulfile" />
<input type="submit" style="width: 100%" class="cbi-button cbi-input-apply" name="upload" value="<%:Upload%>" />
<%+cbi/valuefooter%>

View File

@ -0,0 +1,76 @@
<%+cbi/valueheader%>
<%local fs=require"nixio.fs"%>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="button" class="cbi-button cbi-button-apply" id="apply_update_button" value="<%:Download%>" onclick=" return apply_update() "/>
<br><br>
<textarea id="core_download" class="cbi-input-textarea" style="width: 100%;display:none" data-update="change" rows="10" cols="100" readonly="readonly" > </textarea>
<script type="text/javascript">//<![CDATA[
function apply_update(){
XHR.get('<%=url([[admin]], [[services]], [[clash]], [[doupdate]])%>',null,function(x, data){}
);
poll_check();
return
}
function poll_check(){
var lv = document.getElementById('core_download');
lv.style.display="inline"
XHR.poll(2, '<%=url([[admin]], [[services]], [[clash]], [[check]])%>', null,
function(x, data) {
scroll();
var lv = document.getElementById('core_download');
if (x.responseText && lv) {
lv.innerHTML += x.responseText;
}
}
);
}
XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "clash", "corelog")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if(status.downcheck==0||status.downcheck==2){
hide();
}
if(status.downcheck==1){
var btn = document.getElementById('apply_update_button');
btn.disabled = false;
btn.value = '<%:Download%>';
poll_check();
}
}
});
//]]>
function hide(){
$('#core_download').hide();
var btn = document.getElementById('apply_update_button');
btn.disabled = false;
btn.value = '<%:Download%>';
}
function scroll(){
var textarea = document.getElementById('core_download');
textarea.scrollTop = textarea.scrollHeight;
}
<% if fs.access("/var/run/core_update") then %>
var btn = document.getElementById('apply_update_button');
btn.disabled = true;
btn.value = '<%:Downloading...%>';
poll_check();
<%end%>
</script>
<%+cbi/valuefooter%>

View File

@ -12,7 +12,7 @@ local dsp = require "luci.dispatcher"
domain: pings[i].getAttribute("hint")
},
function(x, result) {
pings[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
pings[result.index].innerHTML = (result.ping ? "<b><font color=green>"+result.ping+"</font></b> ms" : "<b><font color=red><%:Error%></font></b>");
}
);
@ -22,7 +22,7 @@ local dsp = require "luci.dispatcher"
domain: pings[i].getAttribute("hint")
},
function(x, result) {
pings[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
pings[result.index].innerHTML = (result.ping ? "<b><font color=green>"+result.ping+"</font></b> ms" : "<b><font color=red><%:Error%></font></b>");
}
);
}

View File

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

View File

@ -0,0 +1,23 @@
<%+cbi/valueheader%>
<input type="button" class="cbi-button cbi-button-apply" value="<%:Start Client%>" onclick=" return start() "/>
<input type="button" class="cbi-button cbi-button-apply" style="background-color:#ea4368;" value="<%:Stop Client%>" onclick=" return stop() "/>
<script type="text/javascript">//<![CDATA[
function start(){
XHR.get('<%=url([[admin]], [[services]], [[clash]], [[start]])%>',null,function(x, data){}
);
window.setTimeout("location.href='/cgi-bin/luci/admin/services/clash/'", 500);
return
}
function stop(){
XHR.get('<%=url([[admin]], [[services]], [[clash]], [[stop]])%>',null,function(x, data){}
);
window.setTimeout("location.href='/cgi-bin/luci/admin/services/clash/'", 500);
return
}
</script>
<%+cbi/valuefooter%>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,26 @@
<%+cbi/valueheader%>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<textarea id="log" class="cbi-input-textarea" style="width: 100%;" data-update="change" rows="29" readonly="readonly" > </textarea>
<script type="text/javascript">//<![CDATA[
var lv = document.getElementById('log');
lv.style.display="inline"
XHR.poll(1, '<%=url([[admin]], [[services]], [[clash]], [[logstatus]])%>', null,
function(x, data) {
scroll();
var lv = document.getElementById('log');
if (x.responseText && lv) {
lv.innerHTML += x.responseText;
}
}
);
function scroll(){
var textarea = document.getElementById('log');
textarea.scrollTop = textarea.scrollHeight;
}
scroll();
//]]>
</script>
<%+cbi/valuefooter%>

View File

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

@ -1,6 +1,6 @@
<%+cbi/valueheader%>
<textarea class="cbi-input-textarea" <% if not self.size then %> style="width: 280px"<% else %> cols="<%=self.size%>"<% end %> data-update="change"<%= attr("name", cbid) .. attr("id", cbid) .. ifattr(self.rows, "rows") .. ifattr(self.wrap, "wrap") .. ifattr(self.readonly, "readonly") %>>
<textarea class="cbi-input-textarea" style="width: 100%" rows="30" cols="45" data-update="change" <%= attr("name", cbid) .. attr("id", cbid) %>>
<%-=pcdata(self:cfgvalue(section))-%>
</textarea>
<%+cbi/valuefooter%>

View File

@ -13,6 +13,9 @@
<tr>
<td align="center" width="35%">clash</td> <td align="center" width="35%" id="_core"><%:Collecting data...%></td> <td width="35%" align="center" id="_corebutt"></td>
</tr>
<tr>
<td align="center" width="35%">clashr</td> <td align="center" width="35%" id="_corer"><%:Collecting data...%></td> <td width="35%" align="center" id="_corerbutt"></td>
</tr>
<tr>
<td align="center" width="35%">luci-app-clash</td> <td align="center" width="35%" id="_version"><%:Collecting data...%> </td> <td width="35%" align="center" id="_versionbutt"></td>
</tr>
@ -29,27 +32,40 @@
var version = document.getElementById('_version');
var core = document.getElementById('_core');
var corer = document.getElementById('_corer');
var version_butt = document.getElementById('_versionbutt');
var core_butt = document.getElementById('_corebutt');
var corer_butt = document.getElementById('_corerbutt');
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
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>';
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>';
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>';
}
else
{
core.innerHTML = status.clash_core ? '<b><font color=green>'+status.clash_core+'</font> </b>' : '<em><b><font color=red><%:Checking...%></font></b></em>';
}
if(status.clashr_core==0){
corer.innerHTML = status.clashr_core ? '<b><font color=red><%:Not Installed%></font> </b>' : '<em><b><font color=red><%:Checking...%></font></b></em>';
}else{
corer.innerHTML = status.clashr_core ? '<b><font color=green>'+status.clashr_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>';
}
});
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
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>';
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>';
corer_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return clashr_core_check(this)"/></center>' : '<em></em>';
}
});
function version_check(btn)
{
@ -82,7 +98,7 @@ function core_check(btn)
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
if(status.new_core_version > status.clash_core)
{
core_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-apply" value="<%:Download%>" onclick="return download_core(this)"/>' + '&nbsp;&nbsp;&nbsp;' + '<input type="button" class="cbi-button cbi-button-reset" value="<%:Return%>" onclick="return core_return(this)"/></center>';
core_butt.innerHTML ='<center><b><font color=green><%:New Version :%>'+status.new_core_version+'</font> </b></center>';
}
else if(status.new_core_version==0)
@ -98,25 +114,35 @@ function core_check(btn)
});
}
function clashr_core_check(btn)
{
btn.disabled = true;
btn.value = '<%:Checking...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
if(status.new_clashr_core_version > status.clashr_core)
{
corer_butt.innerHTML ='<center><b><font color=green><%:New Version :%>'+status.new_clashr_core_version+'</font> </b></center>';
}
else if(status.new_clashr_core_version==0)
{
corer_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-reset" value="<%:Error Occured |Return%>" onclick="return clashr_core_return(this)"/></center>';
}
else if(status.clashr_core >= status.new_clashr_core_version)
{
corer_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-reset" value="<%:No Update | Return%>" onclick="return clashr_core_return(this)"/></center>';
}
return false;
});
}
function download_update(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Download%>';
url='https://github.com/frainzy1477/luci-app-clash/releases/download/v'+status.new_version+'/luci-app-clash_'+status.new_version+'-2_all.ipk';
window.open(url);
btn.disabled = false;
return false;
});
}
function download_core(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Download%>';
url='https://github.com/frainzy1477/clash/releases/tag/v'+status.new_core_version+'';
url='https://github.com/frainzy1477/luci-app-clash/releases/download/v'+status.new_version+'/luci-app-clash_'+status.new_version+'_all.ipk';
window.open(url);
btn.disabled = false;
return false;
@ -144,6 +170,18 @@ function core_return(btn)
}
function clashr_core_return(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', status.clashr_core, function(x, status) {
btn.disabled = true;
btn.value = '<%:Return Check%>';
corer_butt.innerHTML = '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return clashr_core_check(this)"/></center>';
});
}
//]]></script>
@ -151,3 +189,5 @@ function core_return(btn)

View File

@ -1,3 +1,51 @@
msgid "Do not edit Policy Group with Group Name Proxy or proxy and or 🔑Proxy and it's other policy group"
msgstr "不要编辑策略组别名Proxy或proxy或🔑proxy和它的其他策略组"
msgid "Enable Lan DNS"
msgstr "启用局域网DNS"
msgid "Enabling will set custom DNS Servers for Lan"
msgstr "启用将为自定义局域网DNS服务器"
msgid "Lan DNS servers"
msgstr "局域网DNS服务器"
msgid "Set custom DNS Servers for Lan"
msgstr "设置自定义局域网DNS服务器"
msgid "Cache DNS"
msgstr "缓存的DNS"
msgid "Fake IP Range"
msgstr "假IP范围"
msgid "Ip range will be added to iptables"
msgstr "Ip范围将添加到iptables"
msgid "New Version :"
msgstr "新版本:"
msgid "Core Type"
msgstr "内核类型"
msgid "Select Core"
msgstr "选择内核"
msgid "Obfs"
msgstr "混淆"
msgid "Obfs Param"
msgstr "混淆参数"
msgid "Protocol"
msgstr "协议"
msgid "Protocol Param"
msgstr "协议参数"
msgid "Servers"
msgstr "服务器"
msgid "Custom List DNS"
msgstr "自定义列表DNS"
@ -58,8 +106,8 @@ msgstr "启用"
msgid "Subcription Type"
msgstr "服务器订阅类型"
msgid "Select Subcription Type, enter only your subcription url without https://tgbot.lbyczf.com/*?"
msgstr "选择服务器订阅类型,输入服务器订阅不要带https://tgbot.lbyczf.com/*?"
msgid "Select Subcription Type"
msgstr "选择服务器订阅类型"
msgid "disabled"
msgstr "停用"
@ -136,8 +184,8 @@ msgstr "检查"
msgid "DNS Forwarding"
msgstr "DNS转发"
msgid "Set custom DNS forwarder in DHCP and DNS Settings"
msgstr "在DHCP和DNS设置自定义DNS转发"
msgid "Set custom DNS forwarder in DHCP and DNS Settings and forward all dns traffic to clash"
msgstr "在DHCP和DNS设置自定义DNS转发,转发所有dns流量到clash"
msgid "Proxy Lan IP"
msgstr "走代理的局域网IP"
@ -284,7 +332,7 @@ msgid "Upload Config"
msgstr "上传配置"
msgid "NB: Only upload file with name config.yml or config.yaml"
msgstr "注意:上载名为config.yml或config.yaml的文件"
msgstr "注意上载config.yml或config.yaml的文件"
msgid "Subcription Url"
msgstr "订阅URL"
@ -304,17 +352,21 @@ msgstr "使用中的配置"
msgid "Server Subscription Address"
msgstr "服务器订阅地址"
msgid "Clash Subscription Address"
msgstr "Clash订阅地址"
msgid "V2/SSR Subscription Address, Only input your subscription address without any api conversion url"
msgstr "V2/SSR订阅地址,输入订阅地址不要添加api转换地址"
msgid "Changes to config file must be made from source"
msgstr "必须从源文件更改配置文件"
msgid "Servers"
msgstr "自定义节点"
msgid "Import Config"
msgstr "导入配置"
msgid "Enable to create custom config.yaml. Note that this will overide any configuration you already have"
msgstr "启用以创建自定义config.yaml。注意这会覆盖/etc/clash/config.yaml"
msgid "Create Config"
msgstr "创建配置"
msgid "host"
msgstr "主机名"
@ -331,9 +383,27 @@ msgstr "执行此操作以生成新配置"
msgid "Delete Severs"
msgstr "清空节点"
msgid "Load Config"
msgstr "读取配置"
msgid "Error"
msgstr "错误"
msgid "Load Groups"
msgstr "读取代理组"
msgid "Load Servers"
msgstr "读取节点"
msgid "Load From"
msgstr "从读取"
msgid "Enable to read servers"
msgstr "启用读取节点"
msgid "Enable to read policy group"
msgstr "启用读取代理组"
msgid "Type"
msgstr "节点类型"
@ -344,7 +414,7 @@ msgid "Server Address"
msgstr "服务器地址"
msgid "Server Port"
msgstr "服务器端口"
msgstr "端口"
msgid "Edit Server"
msgstr "编辑服务器配置"
@ -407,7 +477,7 @@ msgid "Select Configuration type"
msgstr "选择配置类型”"
msgid "Create Config"
msgstr "一键生成配置文件"
msgstr "创建配置"
msgid "Create Config By One-Click Only Need Proxys"
msgstr "一键生成配置文件功能只需要配置服务器节点信息"
@ -499,5 +569,38 @@ msgstr "从哪读取自定义节点"
msgid "Select from which configuration custom server should be loaded from"
msgstr "选择从哪个配置文件读取自定义节点"
msgid "Servers"
msgstr "服务器"
msgid "All Servers"
msgstr "所有节点"
msgid "Core"
msgstr "内核"
msgid "Select core, clashr support ssr while clash does not."
msgstr "选择内核clash不支持ssr, clashr支持ssr"
msgid "Downloading..."
msgstr "正在下载。。。"
msgid "Remove Lan DNS"
msgstr "删除局域网DNS"
msgid "Remove Lan custom DNS Servers when client is disabled"
msgstr "禁用客户端时删除局域网自定义DNS服务器"
msgid "Enable ipv6"
msgstr "启用ipv6"
msgid "Allow ipv6 traffic through clash"
msgstr "允许ipv6流量通过clash"
msgid "NB: Upload GEOIP Database file Country.mmdb"
msgstr "注意上传GEOIP数据库文件Country.mmdb"
msgid "Download logs"
msgstr "下载日志"
msgid "Enable Create"
msgstr "启用创建"
msgid "Enable to create configuration"
msgstr "启用以创建配置"

View File

@ -2,28 +2,29 @@ config clash 'config'
option redir_port '7892'
option http_port '7890'
option socks_port '7891'
option mode '0'
option mode '1'
option enable '0'
option dash_port '9191'
option dash_port '9090'
option dash_pass '123456'
option auto_update '0'
option auto_update_time '0'
option level 'info'
option proxylan '0'
option core '1'
option allow_lan 'true'
option bind_addr '*'
option rejectlan '0'
option dnsforwader '0'
option dnsforwader '1'
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 cus_servers '1'
option config_type 'sub'
option loadservers 'sub'
option loadfrom 'sub'
option loadservers '1'
option loadgroups '1'
option fake_ip_range '198.18.0.0/16'
option dnscache '0'
config groups
option old_name '❌AdBlock'
@ -45,25 +46,30 @@ config groups
option old_name_cfg '📺GlobalTV'
option type 'select'
option name '📺GlobalTV'
list other_group '🔑Proxy'
list other_group 'DIRECT'
list other_group 'ALL'
config groups
option type 'select'
option name '🔑Proxy'
list other_group 'ALL'
list other_group '⚙LoadBalance'
list other_group '✈UrlTest'
config groups
option name '✈UrlTest'
option old_name '✈UrlTest'
option old_name_cfg '✈UrlTest'
option test_url 'http://www.gstatic.com/generate_204'
option type 'url-test'
option test_url 'http://www.gstatic.com/generate_204'
option test_interval '600'
option name '✈UrlTest'
list other_group 'ALL'
config groups
option name '⚙LoadBalance'
option old_name '⚙LoadBalance'
option old_name_cfg '⚙LoadBalance'
option type 'load-balance'
option test_url 'http://www.gstatic.com/generate_204'
option test_interval '300'
option name '⚙LoadBalance'
option test_interval '600'
list other_group 'ALL'

View File

@ -5,6 +5,7 @@ STOP=15
CLASH="/etc/clash/clash"
CLASHR="/usr/bin/clash"
CLASH_CONFIG="/etc/clash"
CRON_FILE="/etc/crontabs/root"
CONFIG_YAML="/etc/clash/config.yaml"
@ -13,8 +14,11 @@ 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"
CUSLIST="/tmp/dnsmasq.d/custom_list.conf"
CUSLITT="/tmp/dnsmasq.clash"
CUSLISTV="/var/dnsmasq.d/custom_list.conf"
CUSLITTV="/var/dnsmasq.clash"
REAL_LOG="/usr/share/clash/clash_real.txt"
revert_dns() {
#===========================================================================================================================
@ -24,30 +28,37 @@ revert_dns() {
fi
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto
uci set dhcp.@dnsmasq[0].noresolv=0
uci delete dhcp.@dnsmasq[0].cachesize
uci commit dhcp
rm -rf $CUSLIST $CUSLITT $CUSLISTV $CUSLITTV 2>/dev/null
#===========================================================================================================================
}
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
#===========================================================================================================================
sed -i '/clash.txt/d' $CRON_FILE
echo '0 0 * * 0 echo "" >> /tmp/clash.txt' >> $CRON_FILE
[ -n "$(grep -w "/usr/share/clash/clash.sh" $CRON_FILE)" ] && sed -i '/\/usr\/share\/clash\/clash.sh/d' $CRON_FILE
[ -n "$(grep -w "/usr/share/clash/v2ssr.sh" $CRON_FILE)" ] && sed -i '/\/usr\/share\/clash\/v2ssr.sh/d' $CRON_FILE
auto=$(uci get clash.config.auto_update 2>/dev/null)
if [ $auto -eq 1 ]; then
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
[ -z "$(grep -w "/usr/share/clash/v2ssr.sh" $CRON_FILE)" ] && echo "0 $(uci get clash.config.auto_update_time 2>/dev/null) * * * /usr/share/clash/v2ssr.sh" >> $CRON_FILE
fi
fi
crontab $CRON_FILE
#===========================================================================================================================
}
del_cron(){
#===========================================================================================================================
sed -i '/clash/d' $CRON_FILE
sed -i '/clash.log/d' $CRON_FILE
sed -i '/clash.txt/d' $CRON_FILE
/etc/init.d/cron restart
#===========================================================================================================================
}
@ -58,17 +69,23 @@ select_config(){
config_type=$(uci get clash.config.config_type 2>/dev/null)
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Checking Config file..." >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "正在检查配置文件。。。" >$REAL_LOG
fi
sleep 1
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
if [ -f $CONFIG_YAML_SUB ] && [ "$(ls -l $CONFIG_YAML_SUB|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_SUB $CONFIG_YAML 2>/dev/null
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
if [ -f $CONFIG_YAML_UPL ] && [ "$(ls -l $CONFIG_YAML_UPL|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_UPL $CONFIG_YAML 2>/dev/null
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
if [ -f $CONFIG_YAML_CUS ] && [ "$(ls -l $CONFIG_YAML_CUS|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_CUS $CONFIG_YAML 2>/dev/null
fi
fi
@ -78,8 +95,8 @@ fi
yml_change() {
#===========================================================================================================================
sh /usr/share/clash/yum_change.sh >/dev/null 2>&1
#===========================================================================================================================
sh /usr/share/clash/yum_change.sh 2>/dev/null
#===========================================================================================================================
}
@ -89,14 +106,22 @@ yml_dns_change(){
#===========================================================================================================================
dns_port=$(grep "^ \{0,\}listen:" $CONFIG_YAML |awk -F ':' '{print $3}' 2>/dev/null)
dnsforwader=$(uci get clash.config.dnsforwader 2>/dev/null)
dnscache=$(egrep '^ {0,}enhanced-mode' /etc/clash/config.yaml |grep enhanced-mode: |awk -F ': ' '{print $2}')
if [ $dns_port -eq 53 ]; then
if [ "${dns_port}" -eq 53 ]; then
sed -i 's/0.0.0.0:53/0.0.0.0:5300/g' $CONFIG_YAML
fi
if [ $dnsforwader -ne 0 ]; then
if [ $dns_port -eq 53 ]; then
if [ "${dnsforwader}" -ne 0 ]; then
if [ "${dns_port}" -eq 53 ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Setting dns forwarder" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "设置dns转发器" >$REAL_LOG
fi
dns_serve1=$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)
if [ $dns_serve1 ]; then
uci del dhcp.@dnsmasq[-1].server
@ -104,8 +129,17 @@ yml_dns_change(){
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
uci commit dhcp
if [ "${dnscache}" == "fake-ip" ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Disabling dns cache" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "禁用dns缓存" >$REAL_LOG
fi
uci set dhcp.@dnsmasq[0].cachesize=0
uci commit dhcp
fi
else
echo "Setting dns forwarder" >$REAL_LOG
dns_serve1=$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)
if [ $dns_serve1 ]; then
uci del dhcp.@dnsmasq[-1].server
@ -113,8 +147,31 @@ yml_dns_change(){
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
if [ "${dnscache}" == "fake-ip" ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Disabling dns cache" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "禁用dns缓存" >$REAL_LOG
fi
sleep 1
uci set dhcp.@dnsmasq[0].cachesize=0
uci commit dhcp
fi
fi
elif [ "${dnsforwader}" -eq 0 ]; then
if [ "${dnscache}" == "fake-ip" ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Disabling dns cache" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "禁用dns缓存" >$REAL_LOG
fi
sleep 1
uci set dhcp.@dnsmasq[0].cachesize=0
uci commit dhcp
fi
fi
#===========================================================================================================================
}
@ -123,6 +180,8 @@ yml_dns_change(){
access() {
#===========================================================================================================================
lan_ac_ips=$(uci get clash.config.lan_ac_ips)
ipset -! -R <<-EOF
create clash_lan_ac hash:net
@ -134,6 +193,7 @@ EOF
reject_access() {
#===========================================================================================================================
lan_ac=$(uci get clash.config.lan_ips)
ipset -! -R <<-EOF
create clash_lan hash:net
@ -145,13 +205,16 @@ EOF
rules(){
#===========================================================================================================================
lan_ip=$(uci get network.lan.ipaddr 2>/dev/null)
lanac=$(uci get clash.config.rejectlan 2>/dev/null)
lan=$(uci get clash.config.proxylan 2>/dev/null)
dns_port=$(grep listen: $CONFIG_YAML |awk -F ':' '{print $3}' |tr -cd "[0-9]")
redir_port=$(uci get clash.config.redir_port 2>/dev/null)
fake_ip_range=$(uci get clash.config.fake_ip_range 2>/dev/null)
ipv6=$(uci get clash.config.ipv6 2>/dev/null)
iptables -t nat -N clash_tcp
iptables -t nat -N clash_udp
iptables -t nat -A clash_tcp -d 0.0.0.0/8 -j RETURN
@ -163,27 +226,49 @@ rules(){
iptables -t nat -A clash_tcp -d 224.0.0.0/4 -j RETURN
iptables -t nat -A clash_tcp -d 240.0.0.0/4 -j RETURN
iptables -t nat -A clash_tcp -d $lan_ip -j RETURN
iptables -t nat -N clash_dns
iptables -t nat -A PREROUTING -p tcp --dport 53 -d 198.19.0.0/24 -jclash_dns
iptables -t nat -A PREROUTING -p udp --dport 53 -d 198.19.0.0/24 -j clash_dns
iptables -t nat -A clash_dns -p udp --dport 53 -d 198.19.0.0/24 -j DNAT --to-destination $lan_ip:"${dns_port}"
iptables -t nat -A clash_dns -p tcp --dport 53 -d 198.19.0.0/24 -j DNAT --to-destination $lan_ip:"${dns_port}"
iptables -t nat -A clash_tcp -p tcp --dport 22 -j ACCEPT
iptables -t nat -A clash_udp -p udp -j REDIRECT --to-ports $dns_port
iptables -t nat -A clash_udp -p udp -j REDIRECT --to-ports "${dns_port}"
if [ $lanac -eq 1 ]; then
if [ "${lanac}" -eq 1 ]; then
iptables -t nat -A clash_tcp -p tcp -m set --match-set clash_lan src -j RETURN
iptables -t nat -A clash_tcp -p tcp -j REDIRECT --to-ports $redir_port
elif [ $lan -eq 1 ]; then
iptables -t nat -A clash_tcp -p tcp -m set --match-set clash_lan_ac src -j REDIRECT --to-ports $redir_port
iptables -t nat -A clash_tcp -p tcp -j REDIRECT --to-ports "${redir_port}"
elif [ "${lan}" -eq 1 ]; then
iptables -t nat -A clash_tcp -p tcp -m set --match-set clash_lan_ac src -j REDIRECT --to-ports "${redir_port}"
else
iptables -t nat -A clash_tcp -p tcp -j REDIRECT --to-ports $redir_port
iptables -t nat -A clash_tcp -p tcp -j REDIRECT --to-ports "${redir_port}"
fi
fake_ip_range=$(egrep '^ {0,}fake-ip-range' /etc/clash/config.yaml |grep fake-ip-range: |awk -F ': ' '{print $2}')
if [ ! -z "${fake_ip_range}" ];then
iptables -t nat -A OUTPUT -p tcp -d $fake_ip_range -j REDIRECT --to-ports "${redir_port}"
else
iptables -t nat -A OUTPUT -p tcp -d 198.18.0.0/16 -j REDIRECT --to-ports "${redir_port}"
fi
iptables -t nat -I PREROUTING 1 -p udp --dport 53 -j clash_udp
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
if [ "$(brctl show | grep -o "br-lan" | wc -l)" -gt 0 ];then
iptables -t nat -A PREROUTING --in-interface br-lan -p tcp -j clash_tcp
iptables -t nat -A PREROUTING --in-interface br-lan -p udp -j clash_tcp
elif [ "$(brctl show | grep -o "br-lan" | wc -l)" -lt 1 ];then
iptables -t nat -A PREROUTING -p tcp -j clash_tcp
iptables -t nat -A PREROUTING -p udp -j clash_tcp
fi
if [ -f /usr/sbin/ip6tables ] && [ "${ipv6}" -eq 1 ]; then
ip6tables -t nat -N clash_ipv6
ip6tables -t nat -A clash_ipv6 -p tcp -j REDIRECT --to-ports "${redir_port}"
ip6tables -t nat -A PREROUTING --in-interface br-lan -p tcp -j clash_ipv6
fi
#===========================================================================================================================
}
@ -192,10 +277,10 @@ yml_yaml(){
#===========================================================================================================================
if [ -f $CONFIG_YAML_OLD ] && [ ! -f $CONFIG_YAML ];then
mv $CONFIG_YAML_OLD $CONFIG_YAML
mv $CONFIG_YAML_OLD $CONFIG_YAML 2>/dev/null
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_OLD ] && [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML_OLD|awk '{print int($5)}')" -ne 0 ];then
mv $CONFIG_YAML_OLD $CONFIG_YAML 2>/dev/null
fi
#===========================================================================================================================
}
@ -206,96 +291,276 @@ 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
subscri=$(uci get clash.config.subcri 2>/dev/null)
subscribe_url_clash=$(uci get clash.config.subscribe_url_clash 2>/dev/null)
if [ "${config_type}" == "sub" ];then
if [ "${subscri}" == "clash" ];then
if [ ! -f $CONFIG_YAML_SUB ] && [ ! -z "${subscribe_url_clash}" ];then
sh /usr/share/clash/clash.sh >>/tmp/clash.txt
elif [[ -f $CONFIG_YAML_SUB ] && [ "$(ls -l $CONFIG_YAML_SUB | awk '{print int($5)}')" -eq 0 ] && [ ! -z "${subscribe_url_clash}" ]] && [[ -f $CONFIG_YAML_OLD ] && [ "$(ls -l $CONFIG_YAML_OLD | awk '{print int($5/1024)}')" -eq 0 ]];then
sh /usr/share/clash/clash.sh >>/tmp/clash.txt
elif [ -f $CONFIG_YAML_SUB ] && [ "$(ls -l $CONFIG_YAML_SUB | awk '{print int($5)}')" -eq 0 ] && [ ! -z "${subscribe_url_clash}" ] && [ ! -f $CONFIG_YAML_OLD ];then
sh /usr/share/clash/clash.sh >>/tmp/clash.txt
fi
fi
if [ "${subscri}" == "v2ssr2clash" ];then
if [ ! -f $CONFIG_YAML_CUS ] && [ ! -z "${subscribe_url}" ];then
sh /usr/share/clash/v2ssr.sh >>/tmp/clash.txt
elif [[ -f $CONFIG_YAML_CUS ] && [ "$(ls -l $CONFIG_YAML_CUS | awk '{print int($5)}')" -eq 0 ] && [ ! -z "${subscribe_url}" ]] && [[ -f $CONFIG_YAML_OLD ] && [ "$(ls -l $CONFIG_YAML_OLD | awk '{print int($5/1024)}')" -eq 0 ]] ;then
sh /usr/share/clash/v2ssr.sh >>/tmp/clash.txt
elif [ -f $CONFIG_YAML_CUS ] && [ "$(ls -l $CONFIG_YAML_CUS | awk '{print int($5)}')" -eq 0 ] && [ ! -z "${subscribe_url}" ] && [ -f $CONFIG_YAML_OLD ] ;then
sh /usr/share/clash/v2ssr.sh >>/tmp/clash.txt
fi
fi
fi
#===========================================================================================================================
}
custom_list() {
(/usr/share/clash/list.sh && sleep 2 >/dev/null 2>&1) &
sh /usr/share/clash/list.sh >/dev/null 2>&1
}
start(){
config_load clash
local enabled
config_get_bool enabled clash enabled 0
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
landns=$(uci get clash.config.landns 2>/dev/null)
enable=$(uci get clash.config.enable 2>/dev/null)
yml_yaml
yml_sub
select_config
lan=$(uci get clash.config.proxylan 2>/dev/null)
core=$(uci get clash.config.core 2>/dev/null)
lana=$(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
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
if [ "${enable}" -eq 1 ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Starting Client.. " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "启动客户端..." >$REAL_LOG
fi
sleep 2
yml_yaml >/dev/null 2>&1
yml_sub >/dev/null 2>&1
select_config >/dev/null 2>&1
if [ "${core}" -eq 1 ] && [ ! -f /etc/clash/clash ]; then
if [ "${lang}" == "en" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - clash core not found, download and install clash from update page " >> /tmp/clash.txt
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 找不到/etc/clash/clash,请从更新页下载clash内核" >> /tmp/clash.txt
echo "找不到/etc/clash/clash,请从更新页下载clash内核" >> $REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
elif [ "${core}" -eq 2 ] && [ ! -f /usr/bin/clash ]; then
if [ "${lang}" == "en" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - clashr core not found in /usr/bin/clash download and install clashr from update page " >> /tmp/clash.txt
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 找不到/usr/bin/clash,请从更新页下载clashr内核" >> /tmp/clash.txt
echo "找不到/usr/bin/clash,请从更新页下载clashr内核" >> $REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
else
if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')" -ne 0 ] && [ -f /etc/clash/clash ]; then
if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')" -ne 0 ] ; then
if [ $lan ]; then
yml_change >/dev/null 2>&1
checktype=$(grep -c "type: ssr" /etc/clash/config.yaml 2>/dev/null)
if [ "${checktype}" -gt 0 ] && [ "${core}" -eq 1 ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clash Core does not Support Config, use clashr core" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "Clash内核不支持你的配置改用Clashr内核" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
fi
checkaccess=$(egrep '^ {0,}enhanced-mode' /etc/clash/config.yaml |grep enhanced-mode: |awk -F ': ' '{print $2}')
if [ "${checkaccess}" = "fake-ip" ] && [ "${lana}" -eq 1 ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clash fake-ip mode does not support Proxy Lan IP " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "Clash模式fake-ip不支持走代理的局域网IP" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
elif [ "${checkaccess}" = "fake-ip" ] && [ "${lanac}" -eq 1 ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clash fake-ip mode does not support Bypass Lan IP" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "Clash模式fake-ip不支持不走代理的局域网IP" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
fi
if [ "${lana}" -eq 1 ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Setting up Custom ip list for clash traffic " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "设置自定义IP列表走clash流量" >$REAL_LOG
fi
sleep 1
access >/dev/null 2>&1
fi
if [ $lanac ]; then
if [ "${lanac}" -eq 1 ]; then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Setting up Custom ip list to bypass clash traffic " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "设置自定义IP列表以绕过clash流量" >$REAL_LOG
fi
sleep 1
reject_access >/dev/null 2>&1
fi
yml_change
yml_dns_change
if [ ! -z "${landns}" ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Setting up Custom lan dns server " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "设置自定义lan dns服务器" >$REAL_LOG
fi
sleep 1
uci set network.lan.dns="${landns}" && uci commit network && /etc/init.d/network reload >/dev/null 2>&1
fi
yml_dns_change >/dev/null 2>&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
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "$(date "+%Y-%m-%d %H:%M:%S") - Starting Client..." >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "$(date "+%Y-%m-%d %H:%M:%S") - 启动客户端..." >$REAL_LOG
fi
if [ "${core}" -eq 1 ];then
nohup $CLASH -d "$CLASH_CONFIG" > /tmp/clash.txt 2>&1 &
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clash Core Started Successfully " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "Clash 计划任务,启动进程守护程序..." >$REAL_LOG
fi
elif [ "${core}" -eq 2 ];then
nohup $CLASHR -d "$CLASH_CONFIG" > /tmp/clash.txt 2>&1 &
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clashr Core Started Successfully " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "Clashr 计划任务,启动进程守护程序..." >$REAL_LOG
fi
fi
sleep 1
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Setting up clash iptables rules" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "设置 Clash iptables" >$REAL_LOG
fi
rules >/dev/null 2>&1
killall -1 dnsmasq
custom_list
custom_list >/dev/null 2>&1
sleep 1
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Restarting Dnsmasq " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "重启 Dnsmasq 程序" >$REAL_LOG
fi
/etc/init.d/dnsmasq restart >/dev/null 2>&1
sleep 1
if pidof clash >/dev/null; then
add_cron
nohup /usr/share/clash/clash-watchdog.sh >/dev/null 2>&1
add_cron
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Setting Cron Job" >$REAL_LOG
sleep 1
echo "Clash Started Successfully " >$REAL_LOG
sleep 2
echo "Clash is Running " >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "设置Cron" >$REAL_LOG
sleep 1
echo "Clash 启动成功,请等待服务器上线!" >$REAL_LOG
sleep 2
echo "Clash运行中" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
nohup /usr/share/clash/clash-watchdog.sh >/dev/null 2>&1
fi
else
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
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - problem with config.yaml, config.yaml is either empty or not found " >> /tmp/clash.txt
echo " problem with config file " >$REAL_LOG
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 你的config.yaml有问题还是为了空 0kb " >> /tmp/clash.txt
echo " 你的config.yaml有问题还是为了空 0kb " >$REAL_LOG
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
fi
fi
fi
else
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Enable Client and Start Client Again" >$REAL_LOG
echo " $(date "+%Y-%m-%d %H:%M:%S") - Enable Client and Start Client Again" >>/tmp/clash.txt
sleep 3
echo "Clash for OpenWRT" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "启用客户端并重新启动客户端" >$REAL_LOG
echo " $(date "+%Y-%m-%d %H:%M:%S") - 启用客户端并重新启动客户端" >>/tmp/clash.txt
sleep 3
echo "Clash for OpenWRT" >$REAL_LOG
fi
fi
#===========================================================================================================================
@ -304,40 +569,128 @@ fi
stop(){
delandns=$(uci get clash.config.delan 2>/dev/null)
landns=$(uci get clash.config.landns 2>/dev/null)
lang=$(uci get luci.main.lang 2>/dev/null)
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Stopping Client..." >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "正在停止客户端..." >$REAL_LOG
fi
sleep 2
#===========================================================================================================================
iptables -t nat -F clash_tcp >/dev/null 2>&1
iptables -t nat -X clash_tcp >/dev/null 2>&1
iptables -t nat -F clash_udp >/dev/null 2>&1
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
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Removing clash iptables rules" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "删除clash防火墙规则" >$REAL_LOG
fi
#iptables -t nat -F clash_tcp >/dev/null 2>&1
#iptables -t nat -X clash_tcp >/dev/null 2>&1
#iptables -t nat -F clash_udp >/dev/null 2>&1
#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
#ip6tables -t nat -F clash_ipv6 >/dev/null 2>&1
#ip6tables -t nat -X clash_ipv6 >/dev/null 2>&1
#ipset -! flush clash_lan_ac >/dev/null 2>&1
#ipset -! flush clash_lan >/dev/null 2>&1
iptables -t nat -D PREROUTING -p tcp -j clash_tcp >/dev/null 2>&1
iptables -t mangle -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
iptables -t mangle -D PREROUTING -p udp -j clash_udp >/dev/null 2>&1
iptables -t nat -D PREROUTING -p tcp -j clash_dns >/dev/null 2>&1
iptables -t mangle -D PREROUTING -p tcp -j clash_dns >/dev/null 2>&1
ip6tables -t nat -D PREROUTING -p tcp -j clash_ipv6 >/dev/null 2>&1
ip6tables -t mangle -D PREROUTING -p udp -j clash_ipv6 >/dev/null 2>&1
nat_indexs=$(iptables -nvL PREROUTING -t nat | sed 1,2d | sed -n '/clash/=' | sort -r)
for nat_index in $nat_indexs; do
iptables -t nat -D PREROUTING $nat_index >/dev/null 2>&1
done
mangle_indexs=$(iptables -nvL PREROUTING -t mangle | sed 1,2d | sed -n '/clash/=' | sort -r)
for mangle_index in $mangle_indexs; do
iptables -t mangle -D PREROUTING $mangle_index >/dev/null 2>&1
done
fake=$(iptables -nvL OUTPUT -t nat |sed 1,2d |sed -n '/198.18.0.0\/16/=' |sort -r)
for fake in $fake; do
iptables -t nat -D OUTPUT $fake >/dev/null 2>&1
done
# flush iptables rules
ip6tables -t nat -F clash_ipv6 >/dev/null 2>&1 && ip6tables -t nat -X clash_ipv6 >/dev/null 2>&1
ip6tables -t mangle -F clash_ipv6 >/dev/null 2>&1 && ip6tables -t mangle -X clash_ipv6 >/dev/null 2>&1
iptables -t nat -F clash_udp >/dev/null 2>&1 && iptables -t nat -X clash_udp >/dev/null 2>&1
iptables -t mangle -F clash_udp >/dev/null 2>&1 && iptables -t mangle -X clash_udp >/dev/null 2>&1
iptables -t nat -F clash_tcp >/dev/null 2>&1 && iptables -t nat -X clash_tcp >/dev/null 2>&1
iptables -t mangle -F clash_tcp >/dev/null 2>&1 && iptables -t mangle -X clash_tcp >/dev/null 2>&1
iptables -t nat -F clash_dns >/dev/null 2>&1 && iptables -t nat -X clash_dns >/dev/null 2>&1
iptables -t mangle -F clash_dns >/dev/null 2>&1 && iptables -t mangle -X clash_dns >/dev/null 2>&1
ipset -! flush clash_lan_ac >/dev/null 2>&1
ipset -! flush clash_lan >/dev/null 2>&1
kill -9 $(ps | grep clash-watchdog.sh | grep -v grep | awk '{print $1}') >/dev/null 2>&1
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Clash Core Stoped Successfully " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "Clash 停止进程守护程序" >$REAL_LOG
fi
kill -9 `pidof clash|sed "s/$//g"` 2>/dev/null
revert_dns
uci commit firewall
/etc/init.d/firewall restart >/dev/null 2>&1
/etc/init.d/dnsmasq restart >/dev/null 2>&1
del_cron
sleep 1
rm -rf /www/clash 2> /dev/null
if [ ! -z "${delandns}" ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Removing Custom lan dns server " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "删除自定义lan dns服务器" >$REAL_LOG
fi
uci delete network.lan.dns && uci commit network && /etc/init.d/network reload >/dev/null 2>&1
fi
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Restarting Dnsmasq " >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "重启 Dnsmasq 程序" >$REAL_LOG
fi
revert_dns >/dev/null 2>&1
rm -rf /tmp/clash.log
/etc/init.d/dnsmasq restart >/dev/null 2>&1
sleep 1
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Deleting Cron Job" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "删除Cron" >$REAL_LOG
fi
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
del_cron >/dev/null 2>&1
sleep 1
echo "" >/tmp/clash.txt >/dev/null 2>&1
echo "0" > /usr/share/clash/logstatus_check >/dev/null 2>&1
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - CLIENT IS DISABLED " >> /tmp/clash.txt
echo "Client is Disabled " >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo " $(date "+%Y-%m-%d %H:%M:%S") - 客户端被禁用 " >> /tmp/clash.txt
echo "客户端被禁用 " >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
@ -349,11 +702,12 @@ restart(){
#===========================================================================================================================
if pidof clash >/dev/null; then
stop
start
stop >/dev/null 2>&1
start >/dev/null 2>&1
else
start
start >/dev/null 2>&1
fi
#===========================================================================================================================
}

View File

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

View File

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

View File

@ -24,7 +24,7 @@ do
clean_log
fi
if ! pidof clash>/dev/null; then
nohup $CLASH -d $CLASH_CONFIG > /tmp/clash.log 2>&1 &
/etc/init.d/clash restart 2>&1 &
echo "$curtime Clash Is Restarting" >> ${logfile}
fi

View File

@ -1,56 +1,48 @@
#!/bin/sh
subscribe_url=$(uci get clash.config.subscribe_url 2>/dev/null)
#!/bin/sh /etc/rc.common
subscribe_url=$(uci get clash.config.subscribe_url_clash 2>/dev/null)
subtype=$(uci get clash.config.subcri 2>/dev/null)
urlv2ray=$(uci get clash.config.v2ray 2>/dev/null)
urlsurge=$(uci get clash.config.surge 2>/dev/null)
cusrule=$(uci get clash.config.cusrule 2>/dev/null)
config_type=$(uci get clash.config.config_type 2>/dev/null)
REAL_LOG="/usr/share/clash/clash_real.txt"
lang=$(uci get luci.main.lang 2>/dev/null)
CONFIG_YAML="/usr/share/clash/config/sub/config.yaml"
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 [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Downloading Configuration..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "正在下载配置..." >$REAL_LOG
fi
sleep 1
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 [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Downloading Configuration Completed" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "下载配置完成" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
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
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Downloading Configuration Completed" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "下载配置完成" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
fi

View File

@ -0,0 +1,170 @@
#!/bin/sh
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
LOG_FILE="/tmp/clash_update.txt"
MODELTYPE=$(uci get clash.config.download_core 2>/dev/null)
CORETYPE=$(uci get clash.config.dcore 2>/dev/null)
CORE=$(uci get clash.config.core 2>/dev/null)
lang=$(uci get luci.main.lang 2>/dev/null)
if [ -f /tmp/clash.tar.gz ];then
rm -rf /tmp/clash.tar.gz >/dev/null 2>&1
fi
echo '' >/tmp/clash_update.txt 2>/dev/null
if [ /usr/share/clash/core_down_complete ];then
rm -rf /usr/share/clash/core_down_complete 2>/dev/null
fi
if [ $CORETYPE -eq 2 ];then
if [ -f /usr/share/clash/download_corer_version ];then
rm -rf /usr/share/clash/download_corer_version
fi
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - 正在检查最新版本。。" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Checking latest version.." >$LOG_FILE
fi
new_clashr_core_version=`wget -qO- "https://github.com/frainzy1477/clashrdev/tags"| grep "/frainzy1477/clashrdev/releases/tag/"| head -n 1| awk -F "/tag/v" '{print $2}'| sed 's/\">//'`
if [ $new_clashr_core_version ]; then
echo $new_clashr_core_version > /usr/share/clash/download_corer_version 2>&1 & >/dev/null
elif [ $new_clashr_core_version =="" ]; then
echo 0 > /usr/share/clash/download_corer_version 2>&1 & >/dev/null
fi
sleep 8
if [ -f /usr/share/clash/download_corer_version ];then
CLASHRVER=$(sed -n 1p /usr/share/clash/download_corer_version 2>/dev/null)
fi
fi
if [ $CORETYPE -eq 1 ];then
if [ -f /usr/share/clash/download_core_version ];then
rm -rf /usr/share/clash/download_core_version
fi
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - 正在检查最新版本。。" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Checking latest version.." >$LOG_FILE
fi
new_clashr_core_version=`wget -qO- "https://github.com/frainzy1477/clash_dev/tags"| grep "/frainzy1477/clash_dev/releases/tag/"| head -n 1| awk -F "/tag/v" '{print $2}'| sed 's/\">//'`
if [ $new_clashr_core_version ]; then
echo $new_clashr_core_version > /usr/share/clash/download_core_version 2>&1 & >/dev/null
elif [ $new_clashr_core_version =="" ]; then
echo 0 > /usr/share/clash/download_core_version 2>&1 & >/dev/null
fi
sleep 8
if [ -f /usr/share/clash/download_core_version ];then
CLASHVER=$(sed -n 1p /usr/share/clash/download_core_version 2>/dev/null)
fi
fi
if [ -f /usr/share/clash/core_version ];then
VER=$(sed -n 1p /usr/share/clash/core_version 2>/dev/null)
else
VER=0
fi
if [ -f /usr/share/clash/corer_version ];then
VERR=$(sed -n 1p /usr/share/clash/corer_version 2>/dev/null)
else
VERR=0
fi
sleep 2
update(){
if [ -f /tmp/clash.gz ];then
rm -rf /tmp/clash.gz >/dev/null 2>&1
fi
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - 开始下载 Clash 内核..." >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Starting Clash Core download" >$LOG_FILE
fi
if [ $CORETYPE -eq 1 ];then
wget --no-check-certificate https://github.com/frainzy1477/clash_dev/releases/download/v"$CLASHVER"/clash-"$MODELTYPE"-v"$CLASHVER".gz -O 2>&1 >1 /tmp/clash.gz
elif [ $CORETYPE -eq 2 ];then
wget --no-check-certificate https://github.com/frainzy1477/clashrdev/releases/download/v"$CLASHRVER"/clashr-"$MODELTYPE"-v"$CLASHRVER".gz -O 2>&1 >1 /tmp/clash.gz
fi
if [ "$?" -eq "0" ] && [ "$(ls -l /tmp/clash.gz |awk '{print int($5)}')" -ne 0 ]; then
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - 开始解压缩文件" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Beginning to unzip file" >$LOG_FILE
fi
gunzip /tmp/clash.gz >/dev/null 2>&1\
&& rm -rf /tmp/clash.gz >/dev/null 2>&1\
&& chmod 755 /tmp/clash\
&& chown root:root /tmp/clash
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - 完成下载内核,正在更新..." >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Successfully downloaded core, updating now..." >$LOG_FILE
fi
if [ $CORETYPE -eq 1 ];then
rm -rf /etc/clash/clash >/dev/null 2>&1
mv /tmp/clash /etc/clash/clash >/dev/null 2>&1
rm -rf /usr/share/clash/core_version >/dev/null 2>&1
mv /usr/share/clash/download_core_version /usr/share/clash/core_version >/dev/null 2>&1
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - Clash内核更新成功" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Clash Core Update Successful" >$LOG_FILE
fi
elif [ $CORETYPE -eq 2 ];then
rm -rf /usr/bin/clash >/dev/null 2>&1
mv /tmp/clash /usr/bin/clash >/dev/null 2>&1
rm -rf /usr/share/clash/corer_version >/dev/null 2>&1
mv /usr/share/clash/download_corer_version /usr/share/clash/corer_version >/dev/null 2>&1
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - Clashr内核更新成功" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Clashr Core Update Successful" >>$LOG_FILE
fi
fi
sleep 2
touch /usr/share/clash/core_down_complete >/dev/null 2>&1
sleep 2
rm -rf /var/run/core_update >/dev/null 2>&1
echo "" > /tmp/clash_update.txt >/dev/null 2>&1
else
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - 核心程序下载失败,请检查网络或稍后再试!" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Core Update Error" >$LOG_FILE
fi
rm -rf /tmp/clash.tar.gz >/dev/null 2>&1
echo "" > /tmp/clash_update.txt >/dev/null 2>&1
fi
if pidof clash >/dev/null; then
if [ $CORETYPE == $CORE ];then
/etc/init.d/clash restart >/dev/null
fi
fi
}
if [ $CORETYPE -eq 1 ] && [ $VER != $CLASHVER ]; then
update
elif [ $CORETYPE -eq 2 ] && [ $VERR != $CLASHRVER ]; then
update
else
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - 在用中是最新的内核!" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Currently using latest core" >$LOG_FILE
fi
sleep 2
touch /usr/share/clash/core_down_complete >/dev/null 2>&1
sleep 2
rm -rf /var/run/core_update >/dev/null 2>&1
fi

View File

@ -1,5 +1,3 @@
Rule:
# (GlobalTV)
# > ABC
@ -1110,6 +1108,8 @@ Rule:
- DOMAIN-SUFFIX,jiji.com,🔑Proxy
- DOMAIN-SUFFIX,jinx.com,🔑Proxy
- DOMAIN-SUFFIX,jkforum.net,🔑Proxy
- DOMAIN-SUFFIX,cloudflare.com,🔑Proxy
- DOMAIN-KEYWORD,cloudflare,🔑Proxy
- DOMAIN-SUFFIX,joinmastodon.org,🔑Proxy
- DOMAIN-SUFFIX,kakao.com,🔑Proxy
- DOMAIN-SUFFIX,lihkg.com,🔑Proxy
@ -1508,10 +1508,9 @@ Rule:
- IP-CIDR,202.160.128.0/22,🔑Proxy
- IP-CIDR,209.237.192.0/19,🔑Proxy
#- SRC-IP-CIDR,192.168.1.201/32,DIRECT
#- DST-PORT,80,DIRECT
#- DST-PORT,443,DIRECT
# GeoIP China
- GEOIP,CN,DIRECT
- MATCH,🔑Proxy
- GEOIP,CN,DIRECT
- MATCH,🔑Proxy

View File

@ -5,8 +5,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.557c7e0375c2286ea607.css" rel="stylesheet"></head>
<link href="main.aee3e3fc24cd46786598.css" rel="stylesheet"></head>
<body>
<div id="root"></div>
<script type="text/javascript" src="js/1.bundle.557c7e0375c2286ea607.min.js"></script><script type="text/javascript" src="js/bundle.557c7e0375c2286ea607.min.js"></script></body>
<script type="text/javascript" src="js/1.bundle.aee3e3fc24cd46786598.min.js"></script><script type="text/javascript" src="js/bundle.aee3e3fc24cd46786598.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

File diff suppressed because one or more lines are too long

View File

@ -1,28 +1,31 @@
experimental:
ignore-resolve-fail: true
#authentication:
# - "user1:pass1"
# hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'
dns:
enable: true
listen: 0.0.0.0:5300
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/24
nameserver:
- 119.29.29.29
fake-ip-range: 198.18.0.1/16
# fake-ip-filter: # fake ip white domain
# - *.lan
# - localhost.ptlogin2.qq.com
nameserver:
- 114.114.114.114
- tls://dns.rubyfish.cn:853
- 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
- tls://118.89.110.78:853
- tls://47.96.179.163:853
- udp://8.8.8.8:53
- udp://8.8.4.4:53
- tcp://1.1.1.1
fallback:
- tls://118.89.110.78:853
- tls://47.96.179.163:853
- tcp://1.1.1.1
- tcp://8.8.8.8
fallback-filter:
geoip: true
ipcidr:
- 240.0.0.0/4

View File

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

@ -1,9 +0,0 @@
#!/bin/sh
wget-ssl --no-check-certificate --user-agent="User-Agent: Mozilla" https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz -O /tmp/ipdb.tar.gz
if [ "$?" -eq "0" ]; then
tar zxvf /tmp/ipdb.tar.gz -C /tmp\
&& rm -rf /tmp/ipdb.tar.gz >/dev/null 2>&1\
&& 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,467 @@
#!/bin/sh /etc/rc.common
. /lib/functions.sh
lang=$(uci get luci.main.lang 2>/dev/null)
loadgroups=$(uci get clash.config.loadgroups 2>/dev/null)
loadservers=$(uci get clash.config.loadservers 2>/dev/null)
load_from=$(uci get clash.config.loadfrom 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
CFG_FILE="/etc/config/clash"
REAL_LOG="/usr/share/clash/clash_real.txt"
if [ $loadgroups -eq 1 ];then
if [ ! -f $load ] && [ ! -f $load ]; then
exit 0
fi
if [ $lang == "zh_cn" ];then
echo "开始更新策略组配置..." >$REAL_LOG
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Start updating policy group config" >$REAL_LOG
fi
sleep 3
if [ -f "$load" ]; then
[ ! -z "$(grep "^ \{0,\}'Proxy':" "$load")" ] || [ ! -z "$(grep '^ \{0,\}"Proxy":' "$load")" ] && {
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$load"
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$load"
}
[ ! -z "$(grep "^ \{0,\}'Proxy Group':" "$load")" ] || [ ! -z "$(grep '^ \{0,\}"Proxy Group":' "$load")" ] && {
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$load"
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$load"
}
[ ! -z "$(grep "^ \{0,\}'Rule':" "$load")" ] || [ ! -z "$(grep '^ \{0,\}"Rule":' "$load")" ] && {
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$load"
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$load"
}
[ ! -z "$(grep "^ \{0,\}'dns':" "$load")" ] || [ ! -z "$(grep '^ \{0,\}"dns":' "$load")" ] && {
sed -i "/^ \{0,\}\'dns\':/c\dns:" "$load"
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$load"
}
awk '/Proxy:/,/Rule:/{print}' $load 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed 's/\t/ /g' 2>/dev/null |grep name: |awk -F 'name:' '{print $2}' |sed 's/,.*//' |sed 's/^ \{0,\}//' 2>/dev/null |sed 's/ \{0,\}$//' 2>/dev/null |sed 's/ \{0,\}\}\{0,\}$//g' 2>/dev/null >/tmp/Proxy_Group 2>&1
if [ "$?" -eq "0" ]; then
echo 'DIRECT' >>/tmp/Proxy_Group
echo 'REJECT' >>/tmp/Proxy_Group
else
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Read error, configuration file exception!" >/tmp/Proxy_Group
elif [ $lang == "zh_cn" ];then
echo '读取错误,配置文件异常!' >/tmp/Proxy_Group
fi
fi
else
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Read error, configuration file exception!" >/tmp/Proxy_Group
elif [ $lang == "zh_cn" ];then
echo '读取错误,配置文件异常!' >/tmp/Proxy_Group
fi
fi
if [ $lang == "en" ] || [ $lang == "auto" ];then
[ ! -z "$(grep "Read error" /tmp/Proxy_Group)"] && {
echo "Read error, configuration file exception!" >$REAL_LOG
uci commit clash
sleep 5
echo "" >$REAL_LOG
exit 0
}
elif [ $lang == "zh_cn" ];then
[ ! -z "$(grep "读取错误" /tmp/Proxy_Group)"] && {
echo "读取错误,配置文件异常!" >$REAL_LOG
uci commit clash
sleep 5
echo "" >$REAL_LOG
exit 0
}
fi
awk '/Proxy Group:/,/Rule:/{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_group.yaml 2>&1
if [ -f /tmp/yaml_group.yaml ] && [ "$(ls -l /tmp/yaml_group.yaml | awk '{print int($5)}')" -eq 0 ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "No policy group found. Aborting Operation .." >$REAL_LOG
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "找不到策略组。中止操作..." >$REAL_LOG
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
fi
exit 0
else
while [[ "$( grep -c "config groups" $CFG_FILE )" -ne 0 ]]
do
uci delete clash.@groups[0] && uci commit clash >/dev/null 2>&1
done
fi
count=1
file_count=1
match_group_file="/tmp/Proxy_Group"
group_file="/tmp/yaml_group.yaml"
line=$(sed -n '/name:/=' $group_file)
num=$(grep -c "name:" $group_file)
cfg_get()
{
echo "$(grep "$1" "$2" 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
single_group="/tmp/group_$file_count.yaml"
[ "$count" -eq 1 ] && {
startLine="$n"
}
count=$(expr "$count" + 1)
if [ "$count" -gt "$num" ]; then
endLine=$(sed -n '$=' $group_file)
else
endLine=$(expr $(echo "$line" | sed -n "${count}p") - 1)
fi
sed -n "${startLine},${endLine}p" $group_file >$single_group
startLine=$(expr "$endLine" + 1)
#type
group_type="$(cfg_get "type:" "$single_group")"
#name
group_name="$(cfg_get "name:" "$single_group")"
#test_url
group_test_url="$(cfg_get "url:" "$single_group")"
#test_interval
group_test_interval="$(cfg_get "interval:" "$single_group")"
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Now Reading 【$group_type】-【$group_name】 Policy Group..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "正在读取【$group_type】-【$group_name】策略组配置..." >$REAL_LOG
fi
name=clash
uci_name_tmp=$(uci add $name groups)
uci_set="uci -q set $name.$uci_name_tmp."
uci_add="uci -q add_list $name.$uci_name_tmp."
${uci_set}name="$group_name"
${uci_set}old_name="$group_name"
${uci_set}old_name_cfg="$group_name"
${uci_set}type="$group_type"
${uci_set}test_url="$group_test_url"
${uci_set}test_interval="$group_test_interval"
#other_group
cat $single_group |while read line
do
if [ -z "$(echo "$line" |grep "^ \{0,\}-")" ]; then
continue
fi
group_name1=$(echo "$line" |grep -v "name:" 2>/dev/null |grep "^ \{0,\}-" 2>/dev/null |awk -F '^ \{0,\}-' '{print $2}' 2>/dev/null |sed 's/^ \{0,\}//' 2>/dev/null |sed 's/ \{0,\}$//' 2>/dev/null)
group_name2=$(echo "$line" |awk -F 'proxies: \\[' '{print $2}' 2>/dev/null |sed 's/].*//' 2>/dev/null |sed 's/^ \{0,\}//' 2>/dev/null |sed 's/ \{0,\}$//' 2>/dev/null |sed 's/ \{0,\}, \{0,\}/#,#/g' 2>/dev/null)
if [ -z "$group_name1" ] && [ -z "$group_name2" ]; then
continue
elif [ ! -z "$group_name1" ] && [ -z "$group_name2" ]; then
if [ ! -z "$(grep -F "$group_name1" $match_group_file)" ] && [ "$group_name1" != "$group_name" ]; then
${uci_add}other_group="$group_name1"
fi
elif [ -z "$group_name1" ] && [ ! -z "$group_name2" ]; then
group_num=$(( $(echo "$group_name2" | grep -o '#,#' | wc -l) + 1))
if [ "$group_num" -le 1 ]; then
if [ ! -z "$(grep -F "$group_name2" $match_group_file)" ] && [ "$group_name2" != "$group_name" ]; then
${uci_add}other_group="$group_name2"
fi
else
group_nums=1
while [[ $group_nums -le $group_num ]]
do
other_group_name=$(echo "$group_name2" |awk -v t="${group_nums}" -F '#,#' '{print $t}' 2>/dev/null)
if [ ! -z "$(grep -F "$other_group_name" $match_group_file 2>/dev/null)" ] && [ "$other_group_name" != "$group_name" ]; then
${uci_add}other_group="$other_group_name"
fi
group_nums=$(( $group_nums + 1))
done
fi
fi
done
file_count=$(( $file_count + 1))
done
uci commit clash
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Reading Policy Group Completed" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "读取策略组配置完成" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
rm -rf /tmp/group_*.yaml /tmp/yaml_group.yaml /tmp/Proxy_Group 2>/dev/null
awk '/^ {0,}Rule:/,/^ {0,}##END/{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/rule.yaml 2>&1
rm -rf /usr/shar/clash/custom_rule.yaml 2>/dev/null
mv /tmp/rule.yaml /usr/share/clash/custom_rule.yaml 2>/dev/null
rm -rf /tmp/rule.yaml 2>&1
fi
if [ $loadservers -eq 1 ];then
while [[ "$( grep -c "config servers" $CFG_FILE )" -ne 0 ]]
do
uci delete clash.@servers[0] && uci commit clash >/dev/null 2>&1
done
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
if [ -f /tmp/yaml_proxy.yaml ] && [ "$(ls -l /tmp/yaml_proxy.yaml | awk '{print int($5)}')" -eq 0 ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "No proxies found. Aborting Operation .." >$REAL_LOG
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "找不到代理。中止操作..." >$REAL_LOG
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
fi
exit 0
else
while [[ "$( grep -c "config servers" $CFG_FILE )" -ne 0 ]]
do
uci delete clash.@servers[0] && uci commit clash >/dev/null 2>&1
done
fi
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:")"
#protocol
protocol="$(cfg_get "protocol:")"
#protocolparam
protocolparam="$(cfg_get "protocolparam:")"
#obfsparam
obfsparam="$(cfg_get "obfsparam:")"
#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:")"
#psk:
psk="$(cfg_get "psk:")"
#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:")"
#tls_custom:
tls_custom="$(cfg_get "tls:")"
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Now Reading 【$server_type】-【$server_name】 Proxies..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "正在读取【$server_type】-【$server_name】代理配置..." >$REAL_LOG
fi
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"
elif [ "$server_type" = "ss" ]; then
${uci_set}cipher="$cipher"
elif [ "$server_type" = "ssr" ]; then
${uci_set}cipher_ssr="$cipher"
fi
${uci_set}udp="$udp"
${uci_set}protocol="$protocol"
${uci_set}protocolparam="$protocolparam"
if [ "$server_type" = "ss" ]; then
${uci_set}obfs="$obfs"
elif [ "$server_type" = "ssr" ]; then
${uci_set}obfs_ssr="$obfs"
fi
${uci_set}tls_custom="$tls_custom"
${uci_set}obfsparam="$obfsparam"
${uci_set}host="$obfs_host"
[ -z "$obfs" ] && ${uci_set}obfs="$mode"
if [ "$server_type" = "vmess" ]; then
[ -z "$mode" ] && [ ! -z "$network" ] && ${uci_set}obfs_vmess="websocket"
[ -z "$mode" ] && [ -z "$network" ] && ${uci_set}obfs_vmess="none"
fi
${uci_set}obfs_snell="$mode"
[ -z "$obfs" ] && ${uci_set}obfs="$mode"
[ -z "$obfs" ] && [ -z "$mode" ] && ${uci_set}obfs="none"
[ -z "$mode" ] && ${uci_set}obfs_snell="none"
[ -z "$obfs_host" ] && ${uci_set}host="$host"
if [ $tls ] && [ "$server_type" != "ss" ];then
${uci_set}tls="$tls"
fi
${uci_set}psk="$psk"
if [ $verify ] && [ "$server_type" != "ssr" ];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 2
uci commit clash
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Reading Server Completed" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "读取代理配置完成" >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
rm -rf /tmp/servers.yaml 2>/dev/null
rm -rf /tmp/yaml_proxy.yaml 2>/dev/null
fi
/usr/share/clash/proxy.sh 2>/dev/null

View File

@ -1,20 +1,18 @@
#!/bin/sh /etc/rc.common
. /lib/functions.sh
enable_create=$(uci get clash.config.cus_servers 2>/dev/null)
if [ "$enable_create" == "1" ];then
REAL_LOG="/usr/share/clash/clash_real.txt"
lang=$(uci get luci.main.lang 2>/dev/null)
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
fi
fi
status=$(ps|grep -c /usr/share/clash/proxy.sh)
[ "$status" -gt "3" ] && exit 0
create=$(uci get clash.config.create 2>/dev/null)
if [ "${create}" -eq 1 ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Strating to Create Custom Config.. " >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "开始创建自定义配置..." >$REAL_LOG
fi
sleep 1
CONFIG_YAML_RULE="/usr/share/clash/custom_rule.yaml"
SERVER_FILE="/tmp/servers.yaml"
CONFIG_YAML="/usr/share/clash/config/custom/config.yaml"
@ -25,6 +23,22 @@ CONFIG_FILE="/tmp/y_groups"
CFG_FILE="/etc/config/clash"
DNS_FILE="/usr/share/clash/dns.yaml"
servcount=$( grep -c "config servers" $CFG_FILE 2>/dev/null)
gcount=$( grep -c "config groups" $CFG_FILE 2>/dev/null)
if [ $servcount -eq 0 ] || [ $gcount -eq 0 ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "No servers or group. Aborting Operation .." >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "找不到代理或策略组。中止操作..." >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
exit 0
fi
sleep 2
servers_set()
{
local section="$1"
@ -40,7 +54,6 @@ servers_set()
config_get "obfs_vmess" "$section" "obfs_vmess" ""
config_get "host" "$section" "host" ""
config_get "custom" "$section" "custom" ""
config_get "custom_host" "$section" "custom_host" ""
config_get "tls" "$section" "tls" ""
config_get "tls_custom" "$section" "tls_custom" ""
config_get "skip_cert_verify" "$section" "skip_cert_verify" ""
@ -50,12 +63,42 @@ servers_set()
config_get "auth_name" "$section" "auth_name" ""
config_get "auth_pass" "$section" "auth_pass" ""
config_get "mux" "$section" "mux" ""
config_get "protocol" "$section" "protocol" ""
config_get "protocolparam" "$section" "protocolparam" ""
config_get "obfsparam" "$section" "obfsparam" ""
config_get "obfs_ssr" "$section" "obfs_ssr" ""
config_get "cipher_ssr" "$section" "cipher_ssr" ""
config_get "psk" "$section" "psk" ""
config_get "obfs_snell" "$section" "obfs_snell" ""
if [ -z "$type" ]; then
return
fi
if [ ! -z "$protocolparam" ];then
pro_param=", protocolparam: $protocolparam"
else
pro_param=", protocolparam: ''"
fi
if [ ! -z "$protocol" ] && [ "$type" = "ssr" ];then
protol=", protocol: $protocol"
else
protol=", protocol: origin"
fi
if [ ! -z "$obfs_ssr" ];then
ssr_obfs=", obfs: $obfs_ssr"
else
ssr_obfs=", obfs: plain"
fi
if [ ! -z "$obfsparam" ];then
obfs_param=", obfsparam: $obfsparam"
else
obfs_param=", obfsparam: ''"
fi
if [ -z "$server" ]; then
return
fi
@ -63,6 +106,9 @@ servers_set()
if [ ! -z "$mux" ]; then
muxx="mux: $mux"
fi
if [ "$obfs_snell" = "none" ]; then
obfs_snell=""
fi
if [ -z "$name" ]; then
name="Server"
@ -76,39 +122,36 @@ servers_set()
udpp=", udp: $udp"
fi
if [ "$obfs" != "none" ]; then
if [ "$obfs" != "none" ] && [ "$type" = "ss" ]; then
if [ "$obfs" = "websocket" ]; then
obfss="plugin: v2ray-plugin"
else
obfss="plugin: obfs"
fi
else
obfs=""
fi
if [ "$obfs_vmess" = "websocket" ]; then
if [ "$obfs_vmess" = "none" ] && [ "$type" = "vmess" ]; then
obfs_vmesss=""
elif [ "$obfs_vmess" != "none" ] && [ "$type" = "vmess" ]; then
obfs_vmesss=", network: ws"
else
obfs_vmesss=" "
fi
fi
if [ ! -z "$host" ]; then
host="host: $host"
fi
if [ ! -z "$custom" ] && [ "$type" = "vmess" ]; then
custom=", ws-headers: { Host: $custom }"
fi
if [ "$tls" ]; then
if [ ! "$tls" ] && [ "$type" = "vmess" ]; then
tlss=""
elif [ "$tls" ] && [ "$type" = "vmess" ]; then
tlss=", tls: $tls"
elif [ ! "$tls" ]; then
tlss=""
elif [ "$tls" = "true" ] && [ "$type" = "http" ]; then
elif [ "$tls" ] && [ "$type" = "http" ]; then
tls_hs=", tls: $tls"
elif [ "$tls" = "true" ] && [ "$type" = "socks5" ]; then
elif [ "$tls" ] && [ "$type" = "socks5" ]; then
tls_hs=", tls: $tls"
fi
if [ ! -z "$path" ]; then
if [ "$type" != "vmess" ]; then
@ -141,21 +184,20 @@ cat >> "$SERVER_FILE" <<-EOF
udp: $udp
EOF
fi
if [ ! -z "$obfss" ] && [ ! "$host" ]; then
if [ ! -z "$obfss" ]; then
cat >> "$SERVER_FILE" <<-EOF
$obfss
plugin-opts:
mode: $obfs
EOF
fi
if [ ! -z "$obfss" ] && [ "$host" ]; then
if [ "$host" ]; then
cat >> "$SERVER_FILE" <<-EOF
$obfss
plugin-opts:
mode: $obfs
$host
host: $host
EOF
fi
fi
if [ "$tls_custom" = "true" ] && [ "$type" = "ss" ]; then
cat >> "$SERVER_FILE" <<-EOF
tls: true
@ -167,13 +209,6 @@ cat >> "$SERVER_FILE" <<-EOF
EOF
fi
if [ ! -z "$custom_host" ]; then
cat >> "$SERVER_FILE" <<-EOF
host: $custom_host
EOF
fi
if [ ! -z "$path" ]; then
cat >> "$SERVER_FILE" <<-EOF
$paths
@ -201,6 +236,28 @@ EOF
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_hs }" >>$SERVER_FILE
fi
if [ "$type" = "ssr" ]; then
echo "- { name: \"$name\", type: $type, server: $server, port: $port, cipher: $cipher_ssr, password: "$password"$protol$pro_param$ssr_obfs$obfs_param}" >>$SERVER_FILE
fi
if [ "$type" = "snell" ]; then
cat >> "$SERVER_FILE" <<-EOF
- name: "$name"
type: $type
server: $server
port: $port
psk: $psk
EOF
if [ "$obfs_snell" != "none" ] && [ ! -z "$host" ]; then
cat >> "$SERVER_FILE" <<-EOF
obfs-opts:
mode: $obfs_snell
$host
EOF
fi
fi
}
config_load clash
@ -208,8 +265,8 @@ config_foreach servers_set "servers"
if [ "$(ls -l $SERVER_FILE|awk '{print $5}')" -ne 0 ]; then
sed -i "1i\ " $SERVER_FILE
sed -i "2i\Proxy:" $SERVER_FILE
sed -i "1i\ " $SERVER_FILE 2>/dev/null
sed -i "2i\Proxy:" $SERVER_FILE 2>/dev/null
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
@ -228,7 +285,7 @@ set_groups()
{
if [ "$1" = "$3" ]; then
echo " - \"${2}\"" >>$GROUP_FILE
echo " - \"${2}\"" >>$GROUP_FILE 2>/dev/null
fi
}
@ -236,7 +293,13 @@ set_groups()
set_other_groups()
{
echo " - ${1}" >>$GROUP_FILE
if [ "${1}" = "DIRECT" ]||[ "${1}" = "REJECT" ];then
echo " - ${1}" >>$GROUP_FILE 2>/dev/null
elif [ "${1}" = "ALL" ];then
cat $Proxy_Group >> $GROUP_FILE 2>/dev/null
else
echo " - \"${1}\"" >>$GROUP_FILE 2>/dev/null
fi
}
@ -258,15 +321,15 @@ yml_groups_set()
return
fi
echo "- name: $name" >>$GROUP_FILE
echo " type: $type" >>$GROUP_FILE
echo "- name: $name" >>$GROUP_FILE 2>/dev/null
echo " type: $type" >>$GROUP_FILE 2>/dev/null
if [ "$type" == "url-test" ] || [ "$type" == "load-balance" ] || [ "$name" == "Proxy" ] || [ "$name" == "🔑Proxy" ]; then
echo " proxies:" >>$GROUP_FILE
cat $Proxy_Group >> $GROUP_FILE 2>/dev/null
if [ "$type" == "url-test" ] || [ "$type" == "load-balance" ] || [ "$type" == "fallback" ] ; then
echo " proxies:" >>$GROUP_FILE 2>/dev/null
#cat $Proxy_Group >> $GROUP_FILE 2>/dev/null
else
echo " proxies:" >>$GROUP_FILE
fi
echo " proxies:" >>$GROUP_FILE 2>/dev/null
fi
if [ "$name" != "$old_name" ]; then
sed -i "s/,${old_name}$/,${name}#d/g" $CONFIG_FILE 2>/dev/null
@ -279,10 +342,10 @@ yml_groups_set()
config_foreach yml_servers_add "servers" "$name"
[ ! -z "$test_url" ] && {
echo " url: $test_url" >>$GROUP_FILE
echo " url: $test_url" >>$GROUP_FILE 2>/dev/null
}
[ ! -z "$test_interval" ] && {
echo " interval: \"$test_interval\"" >>$GROUP_FILE
echo " interval: \"$test_interval\"" >>$GROUP_FILE 2>/dev/null
}
}
@ -292,8 +355,8 @@ 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
sed -i "1i\ " $GROUP_FILE 2>/dev/null
sed -i "2i\Proxy Group:" $GROUP_FILE 2>/dev/null
fi
@ -314,23 +377,27 @@ cat >> "$TEMP_FILE" <<-EOF
#config-start-here
EOF
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
sed -i "1i\port: ${http_port}" $TEMP_FILE 2>/dev/null
sed -i "/port: ${http_port}/a\socks-port: ${socks_port}" $TEMP_FILE 2>/dev/null
sed -i "/socks-port: ${socks_port}/a\redir-port: ${redir_port}" $TEMP_FILE 2>/dev/null
sed -i "/redir-port: ${redir_port}/a\allow-lan: ${allow_lan}" $TEMP_FILE 2>/dev/null
if [ $allow_lan == "true" ]; then
sed -i "/allow-lan: ${allow_lan}/a\bind-address: \"${bind_addr}\"" $TEMP_FILE 2>/dev/null
sed -i "/bind-address: \"${bind_addr}\"/a\mode: Rule" $TEMP_FILE 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $TEMP_FILE 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $TEMP_FILE 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $TEMP_FILE 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $TEMP_FILE 2>/dev/null
sed -i "external-ui: \"/usr/share/clash/dashboard\"/a\ " $TEMP_FILE 2>/dev/null
sed -i " /a\ " $TEMP_FILE 2>/dev/null
else
sed -i "5i\#bind-address: " $TEMP_FILE
sed -i "/allow-lan: ${allow_lan}/a\mode: Rule" $TEMP_FILE 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $TEMP_FILE 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $TEMP_FILE 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $TEMP_FILE 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $TEMP_FILE 2>/dev/null
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
sed -i '/#config-start-here/ d' $TEMP_FILE 2>/dev/null
cat $DNS_FILE >> $TEMP_FILE 2>/dev/null
@ -343,16 +410,33 @@ if [ -f $CONFIG_YAML ];then
rm -rf $CONFIG_YAML
fi
sed -i "1i\ " $CONFIG_YAML_RULE
sed -i "2i\ " $CONFIG_YAML_RULE
cat $TEMP_FILE $CONFIG_YAML_RULE > $CONFIG_YAML 2>/dev/null
cat $TEMP_FILE $CONFIG_YAML_RULE > $CONFIG_YAML
sed -i "/Rule:/i\ " $CONFIG_YAML 2>/dev/null
rm -rf $TEMP_FILE $GROUP_FILE $Proxy_Group $CONFIG_FILE
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Completed Creating Custom Config.. " >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "创建自定义配置完成..." >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
if [ $config_type == "cus" ];then
if pidof clash >/dev/null; then
/etc/init.d/clash restart 2>/dev/null
fi
fi
rm -rf $SERVER_FILE
fi
rm -rf $SERVER_FILE
fi

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,32 @@ time3.google.com
time4.google.com
.music.163.com
.music.126.net
p1.music.126.net
p2.music.126.net
p3.music.126.net
p4.music.126.net
p5.music.126.net
p1c.music.126.net
p2c.music.126.net
p3c.music.126.net
p4c.music.126.net
p5c.music.126.net
interface.music.163.com
interface1.music.163.com
interface2.music.163.com
interface3.music.163.com
interface4.music.163.com
interface5.music.163.com
apm.music.163.com
apm3.music.163.com
man.netease.com
api.iplay.163.com
ac.dun.163yun.com
mr.da.netease.com
crash.163.com
imap.163.com
music.126.net
music.163.com
msftconnecttest.com
msftncsi.com
qq.com

View File

@ -0,0 +1,924 @@
#!/bin/sh /etc/rc.common
#awk '/config groups/,/##end/{print}' /etc/config/clashh 2>/dev/null >/usr/share/clash/v2ssr/config.bak 2>&1
CFG_FILE="/etc/config/clash"
while [[ "$( grep -c "config groups" $CFG_FILE )" -ne 0 ]]
do
uci delete clash.@groups[0] && uci commit clash >/dev/null 2>&1
done
while [[ "$( grep -c "config servers" $CFG_FILE )" -ne 0 ]]
do
uci delete clash.@servers[0] && uci commit clash >/dev/null 2>&1
done
cat /etc/config/clash /usr/share/clash/v2ssr/policygroup >/usr/share/clash/v2ssr/clash 2>/dev/null
mv /usr/share/clash/v2ssr/clash /etc/config/clash 2>/dev/null
# functions for parsing and generating json
_json_get_var() {
# dest=$1
# var=$2
eval "$1=\"\$${JSON_PREFIX}$2\""
}
_json_set_var() {
# var=$1
local ___val="$2"
eval "${JSON_PREFIX}$1=\"\$___val\""
}
__jshn_raw_append() {
# var=$1
local value="$2"
local sep="${3:- }"
eval "export -- \"$1=\${$1:+\${$1}\${value:+\$sep}}\$value\""
}
_jshn_append() {
# var=$1
local _a_value="$2"
eval "${JSON_PREFIX}$1=\"\${${JSON_PREFIX}$1} \$_a_value\""
}
_get_var() {
# var=$1
# value=$2
eval "$1=\"\$$2\""
}
_set_var() {
# var=$1
local __val="$2"
eval "$1=\"\$__val\""
}
_json_inc() {
# var=$1
# dest=$2
let "${JSON_PREFIX}$1 += 1" "$2 = ${JSON_PREFIX}$1"
}
_json_add_generic() {
# type=$1
# name=$2
# value=$3
# cur=$4
local var
if [ "${4%%[0-9]*}" = "J_A" ]; then
_json_inc "S_$4" var
else
var="${2//[^a-zA-Z0-9_]/_}"
[[ "$var" == "$2" ]] || export -- "${JSON_PREFIX}N_${4}_${var}=$2"
fi
export -- \
"${JSON_PREFIX}${4}_$var=$3" \
"${JSON_PREFIX}T_${4}_$var=$1"
_jshn_append "JSON_UNSET" "${4}_$var"
_jshn_append "K_$4" "$var"
}
_json_add_table() {
# name=$1
# type=$2
# itype=$3
local cur seq
_json_get_var cur JSON_CUR
_json_inc JSON_SEQ seq
local table="J_$3$seq"
_json_set_var "U_$table" "$cur"
export -- "${JSON_PREFIX}K_$table="
unset "${JSON_PREFIX}S_$table"
_json_set_var JSON_CUR "$table"
_jshn_append "JSON_UNSET" "$table"
_json_add_generic "$2" "$1" "$table" "$cur"
}
_json_close_table() {
local _s_cur
_json_get_var _s_cur JSON_CUR
_json_get_var "${JSON_PREFIX}JSON_CUR" "U_$_s_cur"
}
json_set_namespace() {
local _new="$1"
local _old="$2"
[ -n "$_old" ] && _set_var "$_old" "$JSON_PREFIX"
JSON_PREFIX="$_new"
}
json_cleanup() {
local unset tmp
_json_get_var unset JSON_UNSET
for tmp in $unset J_V; do
unset \
${JSON_PREFIX}U_$tmp \
${JSON_PREFIX}K_$tmp \
${JSON_PREFIX}S_$tmp \
${JSON_PREFIX}T_$tmp \
${JSON_PREFIX}N_$tmp \
${JSON_PREFIX}$tmp
done
unset \
${JSON_PREFIX}JSON_SEQ \
${JSON_PREFIX}JSON_CUR \
${JSON_PREFIX}JSON_UNSET
}
json_init() {
json_cleanup
export -n ${JSON_PREFIX}JSON_SEQ=0
export -- \
${JSON_PREFIX}JSON_CUR="J_V" \
${JSON_PREFIX}K_J_V=
}
json_add_object() {
_json_add_table "$1" object T
}
json_close_object() {
_json_close_table
}
json_add_array() {
_json_add_table "$1" array A
}
json_close_array() {
_json_close_table
}
json_add_string() {
local cur
_json_get_var cur JSON_CUR
_json_add_generic string "$1" "$2" "$cur"
}
json_add_int() {
local cur
_json_get_var cur JSON_CUR
_json_add_generic int "$1" "$2" "$cur"
}
json_add_boolean() {
local cur
_json_get_var cur JSON_CUR
_json_add_generic boolean "$1" "$2" "$cur"
}
json_add_double() {
local cur
_json_get_var cur JSON_CUR
_json_add_generic double "$1" "$2" "$cur"
}
json_add_null() {
local cur
_json_get_var cur JSON_CUR
_json_add_generic null "$1" "" "$cur"
}
# functions read access to json variables
json_load() {
eval "`jshn -r "$1"`"
}
json_load_file() {
eval "`jshn -R "$1"`"
}
json_dump() {
jshn "$@" ${JSON_PREFIX:+-p "$JSON_PREFIX"} -w
}
json_get_type() {
local __dest="$1"
local __cur
_json_get_var __cur JSON_CUR
local __var="${JSON_PREFIX}T_${__cur}_${2//[^a-zA-Z0-9_]/_}"
eval "export -- \"$__dest=\${$__var}\"; [ -n \"\${$__var+x}\" ]"
}
json_get_keys() {
local __dest="$1"
local _tbl_cur
if [ -n "$2" ]; then
json_get_var _tbl_cur "$2"
else
_json_get_var _tbl_cur JSON_CUR
fi
local __var="${JSON_PREFIX}K_${_tbl_cur}"
eval "export -- \"$__dest=\${$__var}\"; [ -n \"\${$__var+x}\" ]"
}
json_get_values() {
local _v_dest="$1"
local _v_keys _v_val _select=
local _json_no_warning=1
unset "$_v_dest"
[ -n "$2" ] && {
json_select "$2" || return 1
_select=1
}
json_get_keys _v_keys
set -- $_v_keys
while [ "$#" -gt 0 ]; do
json_get_var _v_val "$1"
__jshn_raw_append "$_v_dest" "$_v_val"
shift
done
[ -n "$_select" ] && json_select ..
return 0
}
json_get_var() {
local __dest="$1"
local __cur
_json_get_var __cur JSON_CUR
local __var="${JSON_PREFIX}${__cur}_${2//[^a-zA-Z0-9_]/_}"
eval "export -- \"$__dest=\${$__var:-$3}\"; [ -n \"\${$__var+x}\${3+x}\" ]"
}
json_get_vars() {
while [ "$#" -gt 0 ]; do
local _var="$1"; shift
if [ "$_var" != "${_var#*:}" ]; then
json_get_var "${_var%%:*}" "${_var%%:*}" "${_var#*:}"
else
json_get_var "$_var" "$_var"
fi
done
}
json_select() {
local target="$1"
local type
local cur
[ -z "$1" ] && {
_json_set_var JSON_CUR "J_V"
return 0
}
[[ "$1" == ".." ]] && {
_json_get_var cur JSON_CUR
_json_get_var cur "U_$cur"
_json_set_var JSON_CUR "$cur"
return 0
}
json_get_type type "$target"
case "$type" in
object|array)
json_get_var cur "$target"
_json_set_var JSON_CUR "$cur"
;;
*)
[ -n "$_json_no_warning" ] || \
echo "WARNING: Variable '$target' does not exist or is not an array/object"
return 1
;;
esac
}
json_is_a() {
local type
json_get_type type "$1"
[ "$type" = "$2" ]
}
json_for_each_item() {
[ "$#" -ge 2 ] || return 0
local function="$1"; shift
local target="$1"; shift
local type val
json_get_type type "$target"
case "$type" in
object|array)
local keys key
json_select "$target"
json_get_keys keys
for key in $keys; do
json_get_var val "$key"
eval "$function \"\$val\" \"\$key\" \"\$@\""
done
json_select ..
;;
*)
json_get_var val "$target"
eval "$function \"\$val\" \"\" \"\$@\""
;;
esac
}
REAL_LOG="/usr/share/clash/clash_real.txt"
lang=$(uci get luci.main.lang 2>/dev/null)
urlsafe_b64decode() {
local d="====" data=$(echo $1 | sed 's/_/\//g; s/-/+/g')
local mod4=$((${#data}%4))
[ $mod4 -gt 0 ] && data=${data}${d:mod4}
echo $data | base64 -d
}
Server_Update() {
local uci_set="uci -q set $name.$1."
${uci_set}name="$ssr_remarks"
${uci_set}type="$ssr_type"
${uci_set}server="$ssr_host"
${uci_set}port="$ssr_port"
uci -q get $name.@servers[$1].timeout >/dev/null || ${uci_set}timeout="60"
${uci_set}password="$ssr_passwd"
${uci_set}cipher_ssr="$ssr_method"
${uci_set}protocol="$ssr_protocol"
${uci_set}protocolparam="$ssr_protoparam"
${uci_set}obfs_ssr="$ssr_obfs"
${uci_set}obfsparam="$ssr_obfsparam"
if [ "$ssr_type" = "vmess" ]; then
#v2ray
${uci_set}alterId="$ssr_alter_id"
${uci_set}uuid="$ssr_vmess_id"
if [ "$ssr_security" = "none" ];then
${uci_set}securitys="auto"
else
${uci_set}securitys="$ssr_security"
fi
if [ "$ssr_transport" = "tcp" ];then
${uci_set}obfs_vmess="none"
else
${uci_set}obfs_vmess="websocket"
fi
${uci_set}custom_host="$ssr_ws_host"
${uci_set}path="$ssr_ws_path"
${uci_set}tls="$ssr_tls"
fi
}
echo "1" >/www/lock.htm
name=clash
subscribe_url=($(uci get $name.config.subscribe_url))
[ ${#subscribe_url[@]} -eq 0 ] && exit 1
for ((o=0;o<${#subscribe_url[@]};o++))
do
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Downloading Configuration..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "正在下载配置..." >$REAL_LOG
fi
sleep 2
subscribe_data=$(wget --user-agent="User-Agent: Mozilla" --no-check-certificate -T 3 -O- ${subscribe_url[o]})
curl_code=$?
if [ ! $curl_code -eq 0 ];then
subscribe_data=$(wget --no-check-certificate -T 3 -O- ${subscribe_url[o]})
curl_code=$?
fi
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Downloading Configuration Completed" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "下载配置完成" >$REAL_LOG
fi
sleep 2
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Strating to Create Custom Config.. " >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "开始创建自定义配置..." >$REAL_LOG
fi
sleep 2
if [ $curl_code -eq 0 ];then
ssr_url=($(echo $subscribe_data | base64 -d | sed 's/\r//g'))
subscribe_max=$(echo ${ssr_url[0]} | grep -i MAX= | awk -F = '{print $2}')
subscribe_max_x=()
if [ -n "$subscribe_max" ]; then
while [ ${#subscribe_max_x[@]} -ne $subscribe_max ]
do
if [ ${#ssr_url[@]} -ge 10 ]; then
if [ $((${RANDOM:0:2}%2)) -eq 0 ]; then
temp_x=${RANDOM:0:1}
else
temp_x=${RANDOM:0:2}
fi
else
temp_x=${RANDOM:0:1}
fi
[ $temp_x -lt ${#ssr_url[@]} -a -z "$(echo "${subscribe_max_x[*]}" | grep -w $temp_x)" ] && subscribe_max_x[${#subscribe_max_x[@]}]="$temp_x"
done
else
subscribe_max=${#ssr_url[@]}
fi
ssr_group=$(urlsafe_b64decode $(urlsafe_b64decode ${ssr_url[$((${#ssr_url[@]} - 1))]//ssr:\/\//} | sed 's/&/\n/g' | grep group= | awk -F = '{print $2}'))
if [ -z "$ssr_group" ]; then
ssr_group="default"
fi
if [ -n "$ssr_group" ]; then
subscribe_i=0
subscribe_n=0
subscribe_o=0
subscribe_x=""
temp_host_o=()
curr_ssr=$(uci show $name | grep @servers | grep -c server=)
for ((x=0;x<$curr_ssr;x++))
do
temp_alias=$(uci -q get $name.@servers[$x].grouphashkey | grep "$ssr_grouphashkey")
[ -n "$temp_alias" ] && temp_host_o[${#temp_host_o[@]}]=$(uci get $name.@servers[$x].hashkey)
done
for ((x=0;x<$subscribe_max;x++))
do
[ ${#subscribe_max_x[@]} -eq 0 ] && temp_x=$x || temp_x=${subscribe_max_x[x]}
result=$(echo ${ssr_url[temp_x]} | grep "ssr")
if [[ "$result" != "" ]]
then
temp_info=$(urlsafe_b64decode ${ssr_url[temp_x]//ssr:\/\//})
ssr_hashkey=$(echo "$temp_info" | md5sum | cut -d ' ' -f1)
info=${temp_info///?*/}
temp_info_array=(${info//:/ })
ssr_type="ssr"
ssr_host=${temp_info_array[0]}
ssr_port=${temp_info_array[1]}
ssr_protocol=${temp_info_array[2]}
ssr_method=${temp_info_array[3]}
ssr_obfs=${temp_info_array[4]}
ssr_passwd=$(urlsafe_b64decode ${temp_info_array[5]})
info=${temp_info:$((${#info} + 2))}
info=(${info//&/ })
ssr_protoparam=""
ssr_obfsparam=""
ssr_remarks="$temp_x"
for ((i=0;i<${#info[@]};i++))
do
temp_info=($(echo ${info[i]} | sed 's/=/ /g'))
case "${temp_info[0]}" in
protoparam)
ssr_protoparam=$(urlsafe_b64decode ${temp_info[1]})
;;
obfsparam)
ssr_obfsparam=$(urlsafe_b64decode ${temp_info[1]})
;;
remarks)
ssr_remarks=$(urlsafe_b64decode ${temp_info[1]})
;;
esac
done
else
temp_info=$(urlsafe_b64decode ${ssr_url[temp_x]//vmess:\/\//})
ssr_hashkey=$(echo "$temp_info" | md5sum | cut -d ' ' -f1)
ssr_type="vmess"
json_load "$temp_info"
json_get_var ssr_host add
json_get_var ssr_port port
json_get_var ssr_alter_id aid
json_get_var ssr_vmess_id id
json_get_var ssr_security type
json_get_var ssr_transport net
json_get_var ssr_remarks ps
json_get_var ssr_ws_host host
json_get_var ssr_ws_path path
json_get_var ssr_tls tls
if [ "$ssr_tls" == "tls" -o "$ssr_tls" == "1" ]; then
ssr_tls="true"
else
ssr_tls="false"
fi
fi
if [ -z "ssr_remarks" ]; then
ssr_remarks="$ssr_host:$ssr_port";
fi
uci_name_tmp=$(uci show $name | grep -w "$ssr_hashkey" | awk -F . '{print $2}')
if [ -z "$uci_name_tmp" ]; then
uci_name_tmp=$(uci add $name servers)
subscribe_n=$(($subscribe_n + 1))
fi
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Decoding 【$ssr_type】-【$ssr_remarks】 Proxy..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "正在解码 【$ssr_type】-【$ssr_remarks】 代理..." >$REAL_LOG
fi
Server_Update $uci_name_tmp
subscribe_x=$subscribe_x$ssr_hashkey" "
ssrtype=$(echo $ssr_type | tr '[a-z]' '[A-Z]')
done
for ((x=0;x<${#temp_host_o[@]};x++))
do
if [ -z "$(echo "$subscribe_x" | grep -w ${temp_host_o[x]})" ]; then
uci_name_tmp=$(uci show $name | grep ${temp_host_o[x]} | awk -F . '{print $2}')
uci delete $name.$uci_name_tmp
subscribe_o=$(($subscribe_o + 1))
fi
done
uci commit $name
fi
fi
done
echo "0" >/www/lock.htm
. /lib/functions.sh
config_type=$(uci get clash.config.config_type 2>/dev/null)
CONFIG_YAML_RULE="/usr/share/clash/v2ssr/v2ssr_custom_rule.yaml"
SERVER_FILE="/tmp/servers.yaml"
CONFIG_YAML="/usr/share/clash/config/sub/config.yaml"
TEMP_FILE="/tmp/dns_temp.yaml"
Proxy_Group="/tmp/Proxy_Group"
GROUP_FILE="/tmp/groups.yaml"
CONFIG_FILE="/tmp/y_groups"
DNS_FILE="/usr/share/clash/dns.yaml"
servcount=$( grep -c "config servers" $CFG_FILE 2>/dev/null)
gcount=$( grep -c "config groups" $CFG_FILE 2>/dev/null)
if [ $servcount -eq 0 ] || [ $gcount -eq 0 ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "No servers or group. Aborting Operation .." >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "找不到代理或策略组。中止操作..." >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
exit 0
fi
sleep 2
servers_set()
{
local section="$1"
config_get "type" "$section" "type" ""
config_get "name" "$section" "name" ""
config_get "server" "$section" "server" ""
config_get "port" "$section" "port" ""
config_get "cipher" "$section" "cipher" ""
config_get "password" "$section" "password" ""
config_get "securitys" "$section" "securitys" ""
config_get "udp" "$section" "udp" ""
config_get "obfs" "$section" "obfs" ""
config_get "obfs_vmess" "$section" "obfs_vmess" ""
config_get "host" "$section" "host" ""
config_get "custom" "$section" "custom" ""
config_get "tls" "$section" "tls" ""
config_get "tls_custom" "$section" "tls_custom" ""
config_get "skip_cert_verify" "$section" "skip_cert_verify" ""
config_get "path" "$section" "path" ""
config_get "alterId" "$section" "alterId" ""
config_get "uuid" "$section" "uuid" ""
config_get "auth_name" "$section" "auth_name" ""
config_get "auth_pass" "$section" "auth_pass" ""
config_get "mux" "$section" "mux" ""
config_get "protocol" "$section" "protocol" ""
config_get "protocolparam" "$section" "protocolparam" ""
config_get "obfsparam" "$section" "obfsparam" ""
config_get "obfs_ssr" "$section" "obfs_ssr" ""
config_get "cipher_ssr" "$section" "cipher_ssr" ""
config_get "psk" "$section" "psk" ""
config_get "obfs_snell" "$section" "obfs_snell" ""
if [ -z "$type" ]; then
return
fi
if [ ! -z "$protocolparam" ];then
pro_param=", protocolparam: $protocolparam"
else
pro_param=", protocolparam: ''"
fi
if [ ! -z "$protocol" ] && [ "$type" = "ssr" ];then
protol=", protocol: $protocol"
else
protol=", protocol: origin"
fi
if [ ! -z "$obfs_ssr" ];then
ssr_obfs=", obfs: $obfs_ssr"
else
ssr_obfs=", obfs: plain"
fi
if [ ! -z "$obfsparam" ];then
obfs_param=", obfsparam: $obfsparam"
else
obfs_param=", obfsparam: ''"
fi
if [ -z "$server" ]; then
return
fi
if [ ! -z "$mux" ]; then
muxx="mux: $mux"
fi
if [ "$obfs_snell" = "none" ]; then
obfs_snell=""
fi
if [ -z "$name" ]; then
name="Server"
fi
if [ -z "$port" ]; then
return
fi
if [ ! -z "$udp" ] && [ "$obfs" ] || [ "$obfs" = " " ]; then
udpp=", udp: $udp"
fi
if [ "$obfs" != "none" ] && [ "$type" = "ss" ]; then
if [ "$obfs" = "websocket" ]; then
obfss="plugin: v2ray-plugin"
else
obfss="plugin: obfs"
fi
fi
if [ "$obfs_vmess" = "none" ] && [ "$type" = "vmess" ]; then
obfs_vmesss=""
elif [ "$obfs_vmess" != "none" ] && [ "$type" = "vmess" ]; then
obfs_vmesss=", network: ws"
fi
if [ ! -z "$custom" ] && [ "$type" = "vmess" ]; then
custom=", ws-headers: { Host: $custom }"
fi
if [ ! "$tls" ] && [ "$type" = "vmess" ]; then
tlss=""
elif [ "$tls" ] && [ "$type" = "vmess" ]; then
tlss=", tls: $tls"
elif [ "$tls" ] && [ "$type" = "http" ]; then
tls_hs=", tls: $tls"
elif [ "$tls" ] && [ "$type" = "socks5" ]; then
tls_hs=", tls: $tls"
fi
if [ ! -z "$path" ]; then
if [ "$type" != "vmess" ]; then
paths="path: '$path'"
else
path=", ws-path: $path"
fi
fi
if [ "$skip_cert_verify" = "true" ] && [ "$type" != "ss" ]; then
skip_cert_verifys=", skip-cert-verify: $skip_cert_verify"
elif [ ! "$skip_cert_verify" ]; then
skip_cert_verifys=""
fi
if [ "$type" = "vmess" ]; then
echo "- { name: \"$name\", type: $type, server: $server, port: $port, uuid: $uuid, alterId: $alterId, cipher: $securitys$obfs_vmesss$path$custom$tlss$skip_cert_verifys }" >>$SERVER_FILE
fi
if [ "$type" = "ssr" ]; then
echo "- { name: \"$name\", type: $type, server: $server, port: $port, cipher: $cipher_ssr, password: "$password"$protol$pro_param$ssr_obfs$obfs_param}" >>$SERVER_FILE
fi
}
config_load clash
config_foreach servers_set "servers"
if [ "$(ls -l $SERVER_FILE|awk '{print $5}')" -ne 0 ]; then
sed -i "1i\ " $SERVER_FILE 2>/dev/null
sed -i "2i\Proxy:" $SERVER_FILE 2>/dev/null
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
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 2>/dev/null
fi
}
set_other_groups()
{
if [ "${1}" = "DIRECT" ]||[ "${1}" = "REJECT" ];then
echo " - ${1}" >>$GROUP_FILE 2>/dev/null
elif [ "${1}" = "ALL" ];then
cat $Proxy_Group >> $GROUP_FILE 2>/dev/nul
else
echo " - \"${1}\"" >>$GROUP_FILE 2>/dev/null
fi
}
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 2>/dev/null
echo " type: $type" >>$GROUP_FILE 2>/dev/null
if [ "$type" == "url-test" ] || [ "$type" == "load-balance" ] || [ "$type" == "fallback" ]; then
echo " proxies:" >>$GROUP_FILE 2>/dev/null
#cat $Proxy_Group >> $GROUP_FILE 2>/dev/null
else
echo " proxies:" >>$GROUP_FILE 2>/dev/null
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 2>/dev/null
}
[ ! -z "$test_interval" ] && {
echo " interval: \"$test_interval\"" >>$GROUP_FILE 2>/dev/null
}
}
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 2>/dev/null
sed -i "2i\Proxy Group:" $GROUP_FILE 2>/dev/null
fi
mode=$(uci get clash.config.mode 2>/dev/null)
da_password=$(uci get clash.config.dash_pass 2>/dev/null)
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)
subtype=$(uci get clash.config.subcri 2>/dev/null)
cat >> "$TEMP_FILE" <<-EOF
#config-start-here
EOF
sed -i "1i\port: ${http_port}" $TEMP_FILE 2>/dev/null
sed -i "/port: ${http_port}/a\socks-port: ${socks_port}" $TEMP_FILE 2>/dev/null
sed -i "/socks-port: ${socks_port}/a\redir-port: ${redir_port}" $TEMP_FILE 2>/dev/null
sed -i "/redir-port: ${redir_port}/a\allow-lan: ${allow_lan}" $TEMP_FILE 2>/dev/null
if [ $allow_lan == "true" ]; then
sed -i "/allow-lan: ${allow_lan}/a\bind-address: \"${bind_addr}\"" $TEMP_FILE 2>/dev/null
sed -i "/bind-address: \"${bind_addr}\"/a\mode: Rule" $TEMP_FILE 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $TEMP_FILE 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $TEMP_FILE 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $TEMP_FILE 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $TEMP_FILE 2>/dev/null
sed -i "external-ui: \"/usr/share/clash/dashboard\"/a\ " $TEMP_FILE 2>/dev/null
sed -i " /a\ " $TEMP_FILE 2>/dev/null
else
sed -i "/allow-lan: ${allow_lan}/a\mode: Rule" $TEMP_FILE 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $TEMP_FILE 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $TEMP_FILE 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $TEMP_FILE 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $TEMP_FILE 2>/dev/null
fi
sed -i '/#config-start-here/ d' $TEMP_FILE 2>/dev/null
cat $DNS_FILE >> $TEMP_FILE 2>/dev/null
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
cat $TEMP_FILE $CONFIG_YAML_RULE > $CONFIG_YAML 2>/dev/null
sed -i "/Rule:/i\ " $CONFIG_YAML 2>/dev/null
rm -rf $TEMP_FILE $GROUP_FILE $Proxy_Group $CONFIG_FILE
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Completed Creating Custom Config.. " >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "创建自定义配置完成..." >$REAL_LOG
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
mv /usr/share/clash/v2ssr/config.bak /etc/config/clash 2>/dev/null
sleep 1
if [ $config_type == "sub" ];then
if pidof clash >/dev/null; then
/etc/init.d/clash restart 2>/dev/null
fi
fi
fi
rm -rf $SERVER_FILE

View File

@ -0,0 +1,47 @@
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 'ALL'
config groups
option type 'select'
option name '🔑Proxy'
list other_group 'ALL'
list other_group '⚙LoadBalance'
list other_group '✈UrlTest'
config groups
option name '✈UrlTest'
option old_name '✈UrlTest'
option old_name_cfg '✈UrlTest'
option type 'url-test'
option test_url 'http://www.gstatic.com/generate_204'
option test_interval '600'
list other_group 'ALL'
config groups
option name '⚙LoadBalance'
option old_name '⚙LoadBalance'
option old_name_cfg '⚙LoadBalance'
option type 'load-balance'
option test_url 'http://www.gstatic.com/generate_204'
option test_interval '600'
list other_group 'ALL'

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

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

View File

@ -1,21 +0,0 @@
/*! modern-normalize | MIT License | https://github.com/sindresorhus/modern-normalize */html{box-sizing:border-box}*,:after,:before{box-sizing:inherit}:root{-moz-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}hr{height:0}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{padding:0}progress{vertical-align:initial}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}
._1EnK5MMInH{width:100%;height:100%;display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center}._39z9L5I2ao{--color1:#ddd;--size:40px;width:var(--size);height:var(--size);margin:10px;background-color:var(--color1);border-radius:100%;-webkit-animation:_1DSWK2a-pe 1s ease-in-out infinite;animation:_1DSWK2a-pe 1s ease-in-out infinite}@-webkit-keyframes _1DSWK2a-pe{0%{-webkit-transform:scale(0);transform:scale(0)}to{-webkit-transform:scale(1);transform:scale(1);opacity:0}}@keyframes _1DSWK2a-pe{0%{-webkit-transform:scale(0);transform:scale(0)}to{-webkit-transform:scale(1);transform:scale(1);opacity:0}}
._1rJPiLWN4s{position:fixed;top:0;bottom:0;left:0;right:0;overflow:hidden;padding:20px;background:var(--color-background);color:var(--color-text);text-align:center}._3h_IywJG1l{color:#2a477a;opacity:.6;display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center;padding:40px}.aXXDDfyTjE,._3h_IywJG1l{-webkit-box-align:center;align-items:center}.aXXDDfyTjE{display:-webkit-inline-box;display:inline-flex;color:var(--color-text-secondary)}.aXXDDfyTjE:active,.aXXDDfyTjE:hover{color:#387cec}.aXXDDfyTjE svg{margin-right:5px}
._30oJwXNik9{background:var(--color-bg-sidebar);position:relative}._1SsCcpJvxN{display:block}._2r8EkOI78X{display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;padding:25px 0 15px;color:#2a477a;-webkit-transition:color .3s ease-in-out;transition:color .3s ease-in-out}@media (max-width:768px){._2r8EkOI78X{display:none}}._2r8EkOI78X:hover{-webkit-animation:_2KRqAfqV8c .3s ease-in-out 0s infinite alternate;animation:_2KRqAfqV8c .3s ease-in-out 0s infinite alternate}._2r8EkOI78X img{width:80px;height:80px}@-webkit-keyframes _2KRqAfqV8c{0%{color:#2a477a}to{color:#1f52ac}}@keyframes _2KRqAfqV8c{0%{color:#2a477a}to{color:#1f52ac}}@media (max-width:768px){._2vUQ0Hs_C5{display:-webkit-box;display:flex;-webkit-box-pack:justify;justify-content:space-between;overflow:scroll}}._8mEn9Wlw1n{color:var(--color-text);text-decoration:none;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;padding:8px 20px}@media (max-width:768px){._8mEn9Wlw1n{-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column}}._8mEn9Wlw1n svg{color:var(--color-icon)}._1WyHmd6t6y{background:var(--color-sb-active-row-bg)}@media (max-width:768px){._1WyHmd6t6y{background:none;border-bottom:2px solid #387cec}}._2eMIYGbP9O{padding-left:14px}@media (max-width:768px){._2eMIYGbP9O{padding-left:0;padding-top:5px}}.nURY8qkFLS{--sz:50px;position:absolute;bottom:0;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);width:var(--sz);height:var(--sz);padding:20px 0;display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center}@media (max-width:768px){.nURY8qkFLS{display:none}}.nURY8qkFLS svg{display:block;color:var(--color-icon)}
.SNYKRrv_2I{height:76px;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center}.VG1cD2OYvg{padding:0 40px;text-align:left;margin:0}
._37kQcxVR4T{color:var(--color-text);display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center}._1U3kUwas7v,.-Hr5Z5iYfF{padding-top:10px;padding-bottom:10px;width:200px}._1U3kUwas7v div:first-child,.-Hr5Z5iYfF div:first-child{color:var(--color-text-secondary)}._1U3kUwas7v div:nth-child(2),.-Hr5Z5iYfF div:nth-child(2){padding:10px 0 0;font-size:2em}.-Hr5Z5iYfF{padding-right:20px}._1U3kUwas7v{padding-left:20px}
._2rN7aLQPCl{padding:10px 40px}
._1u5AP7XMF9{padding:0 40px 5px}._2zeyKJDdFH{position:relative;height:40px}._3DQ7SXxKRA{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);left:0;width:100%}._1f-XUgRxH1{-webkit-appearance:none;background-color:var(--color-input-bg);background-image:none;border-radius:20px;border:1px solid var(--color-input-border);box-sizing:border-box;color:#c1c1c1;display:inline-block;font-size:inherit;height:40px;outline:none;padding:0 15px 0 35px;-webkit-transition:border-color .2s cubic-bezier(.645,.045,.355,1);transition:border-color .2s cubic-bezier(.645,.045,.355,1);width:100%}._3PLtWxZwrd{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%);left:10px}
._2tpN_G7FeO{display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;flex-wrap:wrap;font-size:.9em;padding:10px}._3wuPHKqO5W{color:#eee;flex-shrink:0;text-align:center;width:66px;background:green;border-radius:5px;padding:3px 5px;margin:0 8px}.IwiVCclCSC{flex-shrink:0;color:#999;font-size:14px}._3I1beKAMFt{flex-shrink:0;display:-webkit-box;display:flex;font-family:Roboto Mono,Menlo,monospace;-webkit-box-align:center;align-items:center;padding:8px 0;width:100%;white-space:pre;overflow:auto}._2MDNI6JESq{margin:0;padding:0;color:var(--color-text)}._2MDNI6JESq li,._2MDNI6JESq li.even{background:var(--color-background)}._3KX1sKJ1QD{padding:10px 40px}._19_8g6kTIV{display:-webkit-box;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;color:#2d2d30}._19_8g6kTIV div:nth-child(2){color:var(--color-text-secondary);font-size:1.4em;opacity:.6}._3ljFcrWmBC{opacity:.3}
input.nJQwngxVo8[type=checkbox]{--white:#fff;--grey:#d3d3d3;--color-theme:#047aff;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;background-color:darken(var(--white),2%);border:1px solid var(--grey);border-radius:26px;box-shadow:inset 0 0 0 1px var(--grey);cursor:pointer;height:28px;position:relative;-webkit-transition:border .25s .15s,box-shadow .25s .3s,padding .25s;transition:border .25s .15s,box-shadow .25s .3s,padding .25s;width:44px;vertical-align:top}input.nJQwngxVo8[type=checkbox]:after{background-color:var(--white);border:1px solid var(--grey);border-radius:24px;box-shadow:inset 0 -3px 3px rgba(0,0,0,.025),0 1px 4px rgba(0,0,0,.15),0 4px 4px rgba(0,0,0,.1);content:"";display:block;height:26px;left:0;position:absolute;right:16px;top:0;-webkit-transition:border .25s .15s,left .25s .1s,right .15s .175s;transition:border .25s .15s,left .25s .1s,right .15s .175s}input.nJQwngxVo8[type=checkbox]:checked{border-color:var(--color-theme);box-shadow:inset 0 0 0 13px var(--color-theme);padding-left:18px;-webkit-transition:border .25s,box-shadow .25s,padding .25s .15s;transition:border .25s,box-shadow .25s,padding .25s .15s}input.nJQwngxVo8[type=checkbox]:checked:after{border-color:var(--color-theme);left:16px;right:0;-webkit-transition:border .25s,left .15s .25s,right .25s .175s;transition:border .25s,left .15s .25s,right .25s .175s}
._3evbv-Ui87{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:1px solid #525252;color:var(--color-text);background:var(--color-toggle-bg);display:-webkit-box;display:flex;position:relative}._3evbv-Ui87 input{position:absolute;left:0;opacity:0}._3evbv-Ui87 label{-webkit-box-flex:1;flex:1;z-index:2;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;padding:10px 0;cursor:pointer}._1ok8KIb1RH{z-index:1;position:absolute;display:block;left:0;height:100%;-webkit-transition:left .2s ease-out;transition:left .2s ease-out;background:var(--color-toggle-selected)}
._2S85tjFa1n{-webkit-appearance:none;background-color:var(--color-input-bg);background-image:none;border-radius:4px;border:1px solid var(--color-input-border);box-sizing:border-box;color:#c1c1c1;display:inline-block;font-size:inherit;height:40px;outline:none;padding:0 15px;-webkit-transition:border-color .2s cubic-bezier(.645,.045,.355,1);transition:border-color .2s cubic-bezier(.645,.045,.355,1);width:100%}._2S85tjFa1n:focus{border-color:var(--color-focus-blue)}input::-webkit-inner-spin-button,input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
._2A0HoxnDqc{-webkit-appearance:none;outline:none;color:var(--color-btn-fg);background:var(--color-btn-bg);border:1px solid #555;border-radius:100px;padding:6px 12px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}._2A0HoxnDqc:focus{border-color:var(--color-focus-blue)}._2A0HoxnDqc:hover{background:#387cec;border:1px solid #387cec;color:#fff}._2A0HoxnDqc:active{-webkit-transform:scale(.97);transform:scale(.97)}
._2id19fefQX{display:-webkit-box;display:flex;flex-wrap:wrap}._2QQQyNTKoG{-webkit-box-flex:0;flex-grow:0;margin-right:10px;margin-bottom:10px;cursor:pointer;border:2px solid transparent}.XJkW0wZSAx{border-color:#387cec}
._2OZZRrEL0J{padding:10px 40px 40px}._2OZZRrEL0J>div{width:360px}.lF_ZoyIdZN{padding:10px 40px 40px}.VduFBb2hWX{padding:0 40px}.VduFBb2hWX>div{border-top:1px dashed #373737}._2NQoBOQcGA{padding:16px 0}
.ctrHyq7uir{position:fixed;top:0;right:0;left:0;bottom:0;background:#444;z-index:1024}._17mHpKiOUD{outline:none;position:absolute;color:#ddd;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background:#444;padding:20px;border-radius:10px}
._1r-KsYFNaj{position:relative;padding:10px 0}._1r-KsYFNaj input{-webkit-appearance:none;background-color:initial;background-image:none;border:none;border-radius:0;border-bottom:1px solid var(--color-input-border);box-sizing:border-box;color:#c1c1c1;display:inline-block;font-size:inherit;height:40px;outline:none;padding:0 8px;-webkit-transition:border-color .2s cubic-bezier(.645,.045,.355,1);transition:border-color .2s cubic-bezier(.645,.045,.355,1);width:100%}._1r-KsYFNaj input:focus{border-color:var(--color-focus-blue)}._1r-KsYFNaj label{position:absolute;left:8px;bottom:22px;-webkit-transition:-webkit-transform .15s ease-in-out;transition:-webkit-transform .15s ease-in-out;transition:transform .15s ease-in-out;transition:transform .15s ease-in-out,-webkit-transform .15s ease-in-out;-webkit-transform-origin:0 0;transform-origin:0 0}._1r-KsYFNaj input:focus+label,._1r-KsYFNaj label.Hn6h5kxOg7{-webkit-transform:scale(.75) translateY(-25px);transform:scale(.75) translateY(-25px)}._1r-KsYFNaj input:focus+label{color:var(--color-focus-blue)}
._3hz7LVhvUv:focus{outline:none}._3HF-KB9mgO{display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center}._3HF-KB9mgO ._3HzgPICn91{color:#2d2d30;opacity:.4;-webkit-transition:opacity .4s;transition:opacity .4s}._3HF-KB9mgO ._3HzgPICn91:hover{opacity:.7}._1wpZuvoD5I{padding:30px 0 10px}.L7jTy-EFJ2{display:-webkit-box;display:flex}.L7jTy-EFJ2 div{-webkit-box-flex:1;flex:1 1 auto}.L7jTy-EFJ2 div:nth-child(2){-webkit-box-flex:0;flex-grow:0;flex-basis:120px;margin-left:10px}._2fehqRU9GV{padding:30px 0 10px;display:-webkit-box;display:flex;-webkit-box-pack:end;justify-content:flex-end;-webkit-box-align:center;align-items:center}
._3D3ZNp4oBz{background:none;position:fixed;top:0;bottom:0;left:0;right:0;-webkit-transform:none;transform:none;padding:0;border-radius:0}.tgH3yv-xGR{position:absolute;top:10%;left:50%;-webkit-transform:translate(-50%);transform:translate(-50%);max-width:376px;margin:0 auto}._3MMuzHtwZL{background:#222}
@font-face{font-family:Roboto Mono;font-style:normal;font-weight:400;src:local("Roboto Mono"),local("RobotoMono-Regular"),url(https://cdn.jsdelivr.net/npm/@hsjs/fonts@0.0.1/robotomono/v5/L0x5DF4xlVMF-BfR8bXMIjhLq3-cXbKD.woff2) format("woff2");unicode-range:u+00??,u+0131,u+0152-0153,u+02bb-02bc,u+02c6,u+02da,u+02dc,u+2000-206f,u+2074,u+20ac,u+2122,u+2191,u+2193,u+2212,u+2215,u+feff,u+fffd}.border-bottom,.border-left,.border-top{position:relative}.border-top:before{top:0}.border-bottom:after,.border-top:before{position:absolute;content:"";height:1px;width:100%;-webkit-transform:scaleY(.5) translateZ(0);transform:scaleY(.5) translateZ(0);left:0;right:0;background:#555}.border-bottom:after{bottom:0}.border-left:before{position:absolute;content:"";height:100%;width:1px;-webkit-transform:scaleX(.5) translateZ(0);transform:scaleX(.5) translateZ(0);top:0;bottom:0;background:#555;left:0}*,:after,:before{box-sizing:border-box}:root{--font-mono:"Roboto Mono",Menlo,monospace;--color-focus-blue:#1a73e8}body{font-family:Merriweather Sans,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,PingFang SC,Microsoft YaHei,;margin:0;padding:0}body,body.dark{--color-background:#202020;--color-text:#ddd;--color-text-secondary:#ccc;--color-bg-sidebar:#2d2d30;--color-sb-active-row-bg:#494b4e;--color-input-bg:#2d2d30;--color-input-border:#3f3f3f;--color-toggle-bg:#353535;--color-toggle-selected:#181818;--color-icon:#c7c7c7;--color-btn-bg:#232323;--color-btn-fg:#bebebe;--color-bg-proxy-selected:#303030}body.light{--color-background:#fbfbfb;--color-text:#222;--color-text-secondary:#646464;--color-bg-sidebar:#e7e7e7;--color-sb-active-row-bg:#d0d0d0;--color-input-bg:#fff;--color-input-border:silver;--color-toggle-bg:#fff;--color-toggle-selected:#d7d7d7;--color-icon:#5b5b5b;--color-btn-bg:#f4f4f4;--color-btn-fg:#101010;--color-bg-proxy-selected:#cfcfcf}
._35EMVy62Je{display:-webkit-box;display:flex;background:var(--color-background);color:var(--color-text);min-height:300px;height:100vh}@media (max-width:768px){._35EMVy62Je{-webkit-box-orient:vertical;-webkit-box-direction:normal;flex-direction:column}}.AwL8oIubvP{-webkit-box-flex:1;flex-grow:1;overflow:auto}

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,41 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="yacd.ico">
<link rel="icon" type="image/png" sizes="64x64" href="yacd-64.png">
<link rel="icon" type="image/png" sizes="128x128" href="yacd-128.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name="application-name" content="yacd">
<meta name="description" content="YAC Dashboard">
<meta name="theme-color" content="#202020">
<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">
<meta property="og:site_name" content="yacd">
<meta property="og:type" content="object">
<meta property="og:title" content="yacd">
<meta property="og:url" content="http://yacd.haishan.me">
<meta property="og:description" content="Yet Another Clash Dashboard">
<link href="app.26d9ccafb71b5570736d.css" rel="stylesheet">
<body>
<div id="app"></div>
<script src="runtime~app.271c0a96fd4712ee7d81.js" type="text/javascript"></script>
<script src="core-js~app.2bafdc22a68f45914da2.js" type="text/javascript"></script>
<script src="react~app.69171d2b5aa5144a2a86.js" type="text/javascript"></script>
<script src="app.326175ee257418d645a5.js" type="text/javascript"></script>
</body>
</html>

View File

@ -1,4 +0,0 @@
._2V-RqIAl7n{border-radius:20px;padding:3px 0;color:#eee}
.NpfXwxWAxo{position:relative;padding:10px;border-radius:10px;background-color:var(--color-bg-proxy-selected)}.NpfXwxWAxo._2zD7drviYH{background-color:var(--color-focus-blue);color:#ddd}._1rVl-Kdmss{font-family:var(--font-mono)}._3kdi5nima5{width:100%;overflow:hidden;text-overflow:ellipsis;margin-bottom:5px;font-size:1.1em}._12JM32OJa5{height:30px;display:-webkit-box;display:flex;-webkit-box-align:end;align-items:flex-end}
._3PCSxT0l14>h2{margin-top:0}._3PCSxT0l14>h2 span:nth-child(2){font-size:12px;color:#777;font-weight:400;margin:0 .3em}._1yYRIyvlRd{display:-webkit-box;display:flex;flex-wrap:wrap}._1OcDlvlM5R{max-width:280px;min-width:150px;margin:10px;-webkit-transition:-webkit-transform .2s ease-in-out;transition:-webkit-transform .2s ease-in-out;transition:transform .2s ease-in-out;transition:transform .2s ease-in-out,-webkit-transform .2s ease-in-out}._1OcDlvlM5R._3oAxPKtZFv{cursor:pointer}._1OcDlvlM5R._3oAxPKtZFv:hover{-webkit-transform:translateY(-2px);transform:translateY(-2px)}
.pWc1mov26e{padding-bottom:50px}._1myfcMimT9{padding:10px 40px}._1khaX45NQe{position:fixed;z-index:1;right:20px;bottom:20px}

View File

@ -1 +0,0 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{D46e:function(e,a,t){e.exports={header:"_3PCSxT0l14",list:"_1yYRIyvlRd",proxy:"_1OcDlvlM5R",proxySelectable:"_3oAxPKtZFv"}},FWZb:function(e,a,t){e.exports={proxy:"NpfXwxWAxo",now:"_2zD7drviYH",proxyType:"_1rVl-Kdmss",proxyName:"_3kdi5nima5",proxyLatencyWrap:"_12JM32OJa5"}},L5YO:function(e,a,t){e.exports={body:"pWc1mov26e",group:"_1myfcMimT9",fabgrp:"_1khaX45NQe"}},RbL9:function(e,a,t){e.exports={proxyLatency:"_2V-RqIAl7n"}},wyCT:function(e,a,t){"use strict";t.r(a);var n=t("o0o1"),r=t.n(n),c=t("HaE+"),o=t("q1tI"),l=t.n(o),s=t("u4Dv"),p=t("DKqX"),m=t("rePB"),i=t("17x9"),u=t.n(i),y=t("TSYQ"),b=t.n(y),x=t("RbL9"),d=t.n(x),f={good:"#67C23A",normal:"#E6A23C",bad:"#F56C6C",na:"#909399"};function v(e){var a=e.latency,t=a.number,n=a.error,r=Object(o.useMemo)(function(){return function(e,a){return""!==a?f.na:e<200?f.good:e<400?f.normal:f.bad}(t,n)},[t,n]);return l.a.createElement("span",{className:d.a.proxyLatency,style:{color:r}},""!==n?l.a.createElement("span",null,n):l.a.createElement("span",null,t," ms"))}v.propTypes={latency:u.a.shape({number:u.a.number,error:u.a.string})};var E=t("FWZb"),O=t.n(E),w=t("EQlU"),N=function(e){return{proxies:Object(w.d)(e),delay:Object(w.c)(e)}};function j(e){var a=e.now,t=e.name,n=Object(s.c)(N),r=n.proxies,c=n.delay[t],o=r[t];return l.a.createElement("div",{className:b()(O.a.proxy,Object(m.a)({},O.a.now,a))},l.a.createElement("div",{className:O.a.proxyName},t),l.a.createElement("div",{className:O.a.proxyType,style:{opacity:a?.6:.2}},o.type),l.a.createElement("div",{className:O.a.proxyLatencyWrap},c?l.a.createElement(v,{latency:c}):null))}j.propTypes={now:u.a.bool,name:u.a.string};var g=j,h=t("D46e"),_=t.n(h),T=function(e){return{proxies:Object(w.d)(e)}};function k(e){var a=e.name,t=Object(s.c)(T).proxies,n=Object(s.b)({switchProxy:w.g}),r=t[a],c=r.all;return l.a.createElement("div",{className:_.a.group},l.a.createElement("div",{className:_.a.header},l.a.createElement("h2",null,l.a.createElement("span",null,a),l.a.createElement("span",null,r.type))),l.a.createElement("div",{className:_.a.list},c.map(function(e){var t="Selector"===r.type,c=b()(_.a.proxy,Object(m.a)({},_.a.proxySelectable,t));return l.a.createElement("div",{className:c,key:e,onClick:function(){t&&n.switchProxy(a,e)}},l.a.createElement(g,{isSelectable:t,name:e,now:e===r.now}))})))}k.propTypes={name:u.a.string};var L=t("5Wrh"),C=t("L5YO"),D=t.n(C);t.d(a,"default",function(){return W});var P=function(e){return{proxies:Object(w.d)(e),groupNames:Object(w.e)(e)}},A={fetchProxies:w.b,requestDelayAll:w.f};function W(){var e=Object(s.b)(A),a=e.fetchProxies,t=e.requestDelayAll;Object(o.useEffect)(function(){Object(c.a)(r.a.mark(function e(){return r.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a();case 2:case"end":return e.stop()}},e)}))()},[a,t]);var n=Object(s.c)(P).groupNames;return l.a.createElement(l.a.Fragment,null,l.a.createElement(p.a,{title:"Proxies"}),l.a.createElement("div",{className:D.a.body},l.a.createElement("div",{className:D.a.fabgrp},l.a.createElement(L.a,{label:"Test Latency",onClick:t})),n.map(function(e){return l.a.createElement("div",{className:D.a.group,key:e},l.a.createElement(k,{name:e}))})))}}}]);

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 +0,0 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{BVyM:function(e,t,a){"use strict";a.r(t);var n=a("ODXe"),r=a("q1tI"),c=a.n(r),l=a("u4Dv"),i=a("5Wrh"),u=a("iR1w"),s=a("DKqX"),o=a("17x9"),m=a.n(o),f=a("xrux"),d=a.n(f),p={_default:"#59caf9",DIRECT:"#f5bc41",REJECT:"#cb3166"};function v(e){var t=e.type,a=e.payload,n=e.proxy,r=e.id,l=function(e){var t=e.proxy,a=p._default;return p[t]&&(a=p[t]),{color:a}}({proxy:n});return c.a.createElement("div",{className:d.a.rule},c.a.createElement("div",{className:d.a.left},r),c.a.createElement("div",null,c.a.createElement("div",{className:d.a.b},a),c.a.createElement("div",{className:d.a.a},c.a.createElement("div",{className:d.a.type},t),c.a.createElement("div",{style:l},n))))}v.propTypes={id:m.a.number,type:m.a.string,payload:m.a.string,proxy:m.a.string};var b=v,E=a("II4a"),h=a("Tvb5"),y={updateSearchText:h.f},x=Object(E.a)({mapStateToProps:function(e){return{searchText:Object(h.e)(e)}},actions:y}),O=a("Kv4h"),j=a("mlDh"),w=a.n(j);a.d(t,"default",function(){return _});var N=30,R=function(e){return{rules:Object(h.d)(e)}},g={fetchRules:h.b,fetchRulesOnce:h.c};function T(e,t){return t[e].id}var D=Object(r.memo)(function(e){var t=e.index,a=e.style,n=e.data[t];return c.a.createElement("div",{style:a},c.a.createElement(b,n))},u.b);function _(){var e=Object(l.b)(g),t=e.fetchRulesOnce,a=e.fetchRules,o=Object(l.c)(R).rules;Object(r.useEffect)(function(){t()},[t]);var m=Object(O.a)(),f=Object(n.a)(m,2),d=f[0],p=f[1];return c.a.createElement("div",null,c.a.createElement(s.a,{title:"Rules"}),c.a.createElement(x,null),c.a.createElement("div",{ref:d,style:{paddingBottom:N}},c.a.createElement(u.a,{height:p-N,width:"100%",itemCount:o.length,itemSize:80,itemData:o,itemKey:T},D)),c.a.createElement("div",{className:w.a.fabgrp},c.a.createElement(i.a,{label:"Refresh",onClick:a})))}},mlDh:function(e,t,a){e.exports={fabgrp:"_2Tux7NhweE"}},xrux:function(e,t,a){e.exports={rule:"_3eSLieOhVX",left:"_2n1pW09UvV",a:"t1XJIwvW7A",b:"_1fNf8kj0HA",type:"_3yJmN0tON0"}}}]);

View File

@ -1,2 +0,0 @@
._3eSLieOhVX{display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;padding:10px 40px}._2n1pW09UvV{width:40px;padding-right:15px;color:var(--color-text-secondary);opacity:.4}.t1XJIwvW7A{display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;font-size:12px;opacity:.8}._1fNf8kj0HA{padding:10px 0;font-family:Roboto Mono,Menlo,monospace;font-size:19px}._3yJmN0tON0{width:110px}
._2Tux7NhweE{position:fixed;right:20px;bottom:20px}

View File

@ -1 +0,0 @@
!function(e){function t(t){for(var n,o,i=t[0],l=t[1],f=t[2],s=t[3]||[],d=0,h=[];d<i.length;d++)o=i[d],Object.prototype.hasOwnProperty.call(a,o)&&a[o]&&h.push(a[o][0]),a[o]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(p&&p(t),c.push.apply(c,s);h.length;)h.shift()();return u.push.apply(u,f||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,o=1;o<r.length;o++){var f=r[o];0!==a[f]&&(n=!1)}n&&(u.splice(t--,1),e=l(l.s=r[0]))}return 0===u.length&&(c.forEach(function(e){if(void 0===a[e]){a[e]=null;var t=document.createElement("link");l.nc&&t.setAttribute("nonce",l.nc),t.rel="prefetch",t.as="script",t.href=i(e),document.head.appendChild(t)}}),c.length=0),e}var n={},o={5:0},a={5:0},u=[],c=[];function i(e){return l.p+""+({2:"proxies",4:"rules",6:"vendors~chartjs"}[e]||e)+"."+{2:"e224f2407be3c35c1eb8",4:"5a42cf2d599e6ae44097",6:"1bf4142c0531e8a79fdd",7:"6347f82f57f293361a76"}[e]+".js"}function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.e=function(e){var t=[];o[e]?t.push(o[e]):0!==o[e]&&{2:1,4:1}[e]&&t.push(o[e]=new Promise(function(t,r){for(var n=({2:"proxies",4:"rules",6:"vendors~chartjs"}[e]||e)+"."+{2:"b42d1d5155bdec5e6c11",4:"fd22590d9542ad5fc200",6:"063030943ce194cc3bd3",7:"bf6de3d705889f2069d2"}[e]+".css",a=l.p+n,u=document.getElementsByTagName("link"),c=0;c<u.length;c++){var i=(s=u[c]).getAttribute("data-href")||s.getAttribute("href");if("stylesheet"===s.rel&&(i===n||i===a))return t()}var f=document.getElementsByTagName("style");for(c=0;c<f.length;c++){var s;if((i=(s=f[c]).getAttribute("data-href"))===n||i===a)return t()}var d=document.createElement("link");d.rel="stylesheet",d.type="text/css",d.onload=t,d.onerror=function(t){var n=t&&t.target&&t.target.src||a,u=new Error("Loading CSS chunk "+e+" failed.\n("+n+")");u.code="CSS_CHUNK_LOAD_FAILED",u.request=n,delete o[e],d.parentNode.removeChild(d),r(u)},d.href=a,document.getElementsByTagName("head")[0].appendChild(d)}).then(function(){o[e]=0}));var r=a[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise(function(t,n){r=a[e]=[t,n]});t.push(r[2]=n);var u,c=document.createElement("script");c.charset="utf-8",c.timeout=120,l.nc&&c.setAttribute("nonce",l.nc),c.src=i(e);var f=new Error;u=function(t){c.onerror=c.onload=null,clearTimeout(s);var r=a[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;f.message="Loading chunk "+e+" failed.\n("+n+": "+o+")",f.name="ChunkLoadError",f.type=n,f.request=o,r[1](f)}a[e]=void 0}};var s=setTimeout(function(){u({type:"timeout",target:c})},12e4);c.onerror=c.onload=u,document.head.appendChild(c)}return Promise.all(t)},l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="",l.oe=function(e){throw console.error(e),e};var f=window.webpackJsonp=window.webpackJsonp||[],s=f.push.bind(f);f.push=t,f=f.slice();for(var d=0;d<f.length;d++)t(f[d]);var p=s;r()}([]);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -3,25 +3,32 @@ 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"
lang=$(uci get luci.main.lang 2>/dev/null)
config_type=$(uci get clash.config.config_type 2>/dev/null)
REAL_LOG="/usr/share/clash/clash_real.txt"
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
if [ -f $CONFIG_YAML_SUB ] && [ "$(ls -l $CONFIG_YAML_SUB|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_SUB $CONFIG_YAML 2>/dev/null
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
if [ -f $CONFIG_YAML_UPL ] && [ "$(ls -l $CONFIG_YAML_UPL|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_UPL $CONFIG_YAML 2>/dev/null
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
if [ -f $CONFIG_YAML_CUS ] && [ "$(ls -l $CONFIG_YAML_CUS|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_CUS $CONFIG_YAML 2>/dev/null
fi
fi
if [ -f $CONFIG_YAML ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Checking DNS Settings.. " >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "DNS设置检查..." >$REAL_LOG
fi
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
@ -41,66 +48,92 @@ fi
log_level=$(uci get clash.config.level 2>/dev/null)
subtype=$(uci get clash.config.subcri 2>/dev/null)
if [ $mode -eq 1 ]; then
sed -i "/Proxy:/i\#clash-openwrt" $CONFIG_YAML
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML
sed -i "/#=============/a\ " $CONFIG_YAML
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML
if [ $mode -eq 1 ]; then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Setting Up Ports and Password.. " >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "设置端口,DNS和密码..." >$REAL_LOG
fi
sed -i "/Proxy:/i\#clash-openwrt" $CONFIG_YAML 2>/dev/null
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML 2>/dev/null
sed -i "/#=============/a\ " $CONFIG_YAML 2>/dev/null
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML 2>/dev/null
mv /etc/clash/config.yaml /etc/clash/dns.yaml
cat /usr/share/clash/dns.yaml /etc/clash/dns.yaml > $CONFIG_YAML
cat /usr/share/clash/dns.yaml /etc/clash/dns.yaml > $CONFIG_YAML 2>/dev/null
rm -rf /etc/clash/dns.yaml
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: ${allow_lan}" $CONFIG_YAML
if [ $allow_lan == "true" ]; then
sed -i "5i\bind-address: '${bind_addr}'" $CONFIG_YAML
sed -i "1i\port: ${http_port}" $CONFIG_YAML 2>/dev/null
sed -i "/port: ${http_port}/a\socks-port: ${socks_port}" $CONFIG_YAML 2>/dev/null
sed -i "/socks-port: ${socks_port}/a\redir-port: ${redir_port}" $CONFIG_YAML 2>/dev/null
sed -i "/redir-port: ${redir_port}/a\allow-lan: ${allow_lan}" $CONFIG_YAML 2>/dev/null
if [ $allow_lan == "true" ]; then
sed -i "/allow-lan: ${allow_lan}/a\bind-address: \"${bind_addr}\"" $CONFIG_YAML 2>/dev/null
sed -i "/bind-address: \"${bind_addr}\"/a\mode: Rule" $CONFIG_YAML 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $CONFIG_YAML 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $CONFIG_YAML 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $CONFIG_YAML 2>/dev/null
sed -i "external-ui: \"/usr/share/clash/dashboard\"/a\ " $CONFIG_YAML 2>/dev/null
sed -i " /a\ " $CONFIG_YAML 2>/dev/null
else
sed -i "5i\#bind-address: " $CONFIG_YAML
sed -i "/allow-lan: ${allow_lan}/a\mode: Rule" $CONFIG_YAML 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $CONFIG_YAML 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $CONFIG_YAML 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $CONFIG_YAML 2>/dev/null
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
sed -i '/#=============/ d' $CONFIG_YAML 2>/dev/null
if [ ! -z "$(grep "^experimental:" $CONFIG_YAML)" ]; then
sed -i "/experimental:/i\ " $CONFIG_YAML 2>/dev/null
else
sed -i "/dns:/i\ " $CONFIG_YAML 2>/dev/null
fi
else
if [ $subtype == "v2rayn2clash" ];then
sed -i "/Proxy:/i\#clash-openwrt" $CONFIG_YAML
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML
sed -i "/#=============/a\ " $CONFIG_YAML
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML
mv $CONFIG_YAML /etc/clash/dns.yaml
cat /usr/share/clash/dns.yaml /etc/clash/dns.yaml > $CONFIG_YAML
rm -rf /etc/clash/dns.yaml
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Setting Up Ports and Password.. " >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "设置端口,DNS和密码..." >$REAL_LOG
fi
if [ ! -z "$(grep "^experimental:" /etc/clash/config.yaml)" ]; then
sed -i "/experimental:/i\ " $CONFIG_YAML 2>/dev/null
sed -i "/ /a\#clash-openwrt" $CONFIG_YAML 2>/dev/null
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML 2>/dev/null
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML 2>/dev/null
else
sed -i "/dns:/i\#clash-openwrt" $CONFIG_YAML
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML
sed -i "/dns:/i\ " $CONFIG_YAML 2>/dev/null
sed -i "/ /a\#clash-openwrt" $CONFIG_YAML 2>/dev/null
sed -i "/#clash-openwrt/a\#=============" $CONFIG_YAML 2>/dev/null
sed -i '1,/#clash-openwrt/d' $CONFIG_YAML 2>/dev/null
fi
sed -i "1i\port: ${http_port}" $CONFIG_YAML
sed -i "2i\socks-port: ${socks_port}" $CONFIG_YAML
sed -i "3i\redir-port: ${redir_port}" $CONFIG_YAML
sed -i "4i\allow-lan: ${allow_lan}" $CONFIG_YAML
if [ $allow_lan == "true" ]; then
sed -i "5i\bind-address: '${bind_addr}'" $CONFIG_YAML
sed -i "1i\port: ${http_port}" $CONFIG_YAML 2>/dev/null
sed -i "/port: ${http_port}/a\socks-port: ${socks_port}" $CONFIG_YAML 2>/dev/null
sed -i "/socks-port: ${socks_port}/a\redir-port: ${redir_port}" $CONFIG_YAML 2>/dev/null
sed -i "/redir-port: ${redir_port}/a\allow-lan: ${allow_lan}" $CONFIG_YAML 2>/dev/null
if [ $allow_lan == "true" ]; then
sed -i "/allow-lan: ${allow_lan}/a\bind-address: \"${bind_addr}\"" $CONFIG_YAML 2>/dev/null
sed -i "/bind-address: \"${bind_addr}\"/a\mode: Rule" $CONFIG_YAML 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $CONFIG_YAML 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $CONFIG_YAML 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $CONFIG_YAML 2>/dev/null
else
sed -i "5i\#bind-address: " $CONFIG_YAML
sed -i "/allow-lan: ${allow_lan}/a\mode: Rule" $CONFIG_YAML 2>/dev/null
sed -i "/mode: Rule/a\log-level: ${log_level}" $CONFIG_YAML 2>/dev/null
sed -i "/log-level: ${log_level}/a\external-controller: 0.0.0.0:${dash_port}" $CONFIG_YAML 2>/dev/null
sed -i "/external-controller: 0.0.0.0:${dash_port}/a\secret: \"${da_password}\"" $CONFIG_YAML 2>/dev/null
sed -i "/secret: \"${da_password}\"/a\external-ui: \"/usr/share/clash/dashboard\"" $CONFIG_YAML 2>/dev/null
fi
sed -i '/#=============/ d' $CONFIG_YAML 2>/dev/null
if [ ! -z "$(grep "^experimental:" $CONFIG_YAML)" ]; then
sed -i "/experimental:/i\ " $CONFIG_YAML 2>/dev/null
else
sed -i "/dns:/i\ " $CONFIG_YAML 2>/dev/null
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
fi