luci-app-clash: sync with upstream source

This commit is contained in:
CN_SZTL 2020-01-24 15:03:54 +08:00
parent ba39ed7b0c
commit eeaaa1ae10
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
46 changed files with 4008 additions and 628 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-clash
PKG_VERSION:=1.4.8
PKG_VERSION:=1.4.9
PKG_MAINTAINER:=frainzy1477
@ -10,7 +10,7 @@ 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-base64 +coreutils +coreutils-nohup +bash +ipset +libustream-openssl +libopenssl +openssl-util
PKGARCH:=all
@ -68,6 +68,7 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
mv /usr/share/clash/config/sub/config.yaml /usr/share/clashbackup/config.bak1 2>/dev/null
mv /usr/share/clash/config/upload/config.yaml /usr/share/clashbackup/config.bak2 2>/dev/null
mv /usr/share/clash/config/custom/config.yaml /usr/share/clashbackup/config.bak3 2>/dev/null
fi
exit 0
@ -100,61 +101,49 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/usr/share/
$(INSTALL_DIR) $(1)/usr/share/clash
$(INSTALL_DIR) $(1)/usr/share/clash/rules
$(INSTALL_DIR) $(1)/usr/share/clash/rules/g_rules
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard/img
$(INSTALL_DIR) $(1)/usr/share/clash/dashboard/js
$(INSTALL_DIR) $(1)/etc/clash/clashtun
$(INSTALL_DIR) $(1)/usr/share/clashbackup
$(INSTALL_DIR) $(1)/etc/clash/provider
$(INSTALL_DIR) $(1)/usr/share/clash/config
$(INSTALL_DIR) $(1)/usr/share/clash/config/sub
$(INSTALL_DIR) $(1)/usr/share/clash/config/upload
$(INSTALL_DIR) $(1)/usr/share/clash/config/custom
$(INSTALL_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/
$(INSTALL_BIN) ./root/usr/share/clash/config/sub/config.yaml $(1)/usr/share/clash/config/sub/
$(INSTALL_BIN) ./root/etc/init.d/clash $(1)/etc/init.d/clash
$(INSTALL_CONF) ./root/etc/config/clash $(1)/etc/config/clash
$(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/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/*.sh $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/dns.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/tundns_1.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/rules/g_rules/Steam.rules $(1)/usr/share/clash/rules/g_rules
$(INSTALL_BIN) ./root//usr/share/clash/rules/rules.list $(1)/usr/share/clash/rules
$(INSTALL_BIN) ./root/usr/share/clash/tundns_2.yaml $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/tundns_3.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/geoip.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/clash_real.txt $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/logstatus_check $(1)/usr/share/clash/
$(INSTALL_BIN) ./root/usr/share/clash/clash.txt $(1)/tmp/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/index.html $(1)/usr/share/clash/dashboard/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/main.0bddb85299f970595cb5.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.0bddb85299f970595cb5.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_BIN) ./root/usr/share/clash/dashboard/js/bundle.0bddb85299f970595cb5.min.js $(1)/usr/share/clash/dashboard/js/
$(INSTALL_DATA) ./luasrc/clash.lua $(1)/usr/lib/lua/luci/
$(INSTALL_DATA) ./luasrc/controller/*.lua $(1)/usr/lib/lua/luci/controller/
$(INSTALL_DATA) ./luasrc/model/cbi/clash/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/

View File

@ -14,19 +14,23 @@ 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", "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", "servers-config"},cbi("clash/servers-config"), nil).leaf = true
entry({"admin", "services", "clash", "provider-config"},cbi("clash/provider-config"), nil).leaf = true
entry({"admin", "services", "clash", "groups"},cbi("clash/groups"), nil).leaf = true
entry({"admin", "services", "clash", "groups"},cbi("clash/groups"), nil).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", "geoip"},cbi("clash/geoip"),_("Update GeoIP"), 80).leaf = true
entry({"admin", "services", "clash", "settings", "list"},cbi("clash/list"),_("Custom List"), 90).leaf = true
entry({"admin", "services", "clash", "settings", "grules"},cbi("clash/game-settings"),_("Game Rules"), 91).dependent = false
entry({"admin", "services", "clash", "g-rules"},cbi("clash/game-rule"), nil).leaf = true
--entry({"admin", "services", "clash", "g-groups"},cbi("clash/game-groups"), nil).leaf = true
entry({"admin", "services", "clash", "config"},firstchild(),_("Config"), 100)
entry({"admin", "services", "clash", "config"},firstchild(),_("Config"), 30)
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
@ -49,11 +53,81 @@ function index()
entry({"admin", "services", "clash", "check_geoip"}, call("check_geoip_log")).leaf=true
entry({"admin", "services", "clash", "corelog"},call("down_check")).leaf=true
entry({"admin", "services", "clash", "logstatus"},call("logstatus_check")).leaf=true
entry({"admin", "services", "clash", "conf"},call("action_conf")).leaf=true
entry({"admin", "services", "clash", "update_config"},call("action_update")).leaf=true
entry({"admin", "services", "clash", "game_rule"},call("action_update_rule")).leaf=true
end
local fss = require "luci.clash"
local function download_rule()
local filename = luci.http.formvalue("filename")
local rule_file_dir="/usr/share/clash/rules/g_rules/" .. filename
luci.sys.call(string.format('sh /usr/share/clash/clash_game_rule.sh "%s" >/dev/null 2>&1',filename))
if not fss.isfile(rule_file_dir) then
return "0"
else
return "1"
end
end
function action_update_rule()
luci.http.prepare_content("application/json")
luci.http.write_json({
game_rule = download_rule()
})
end
function action_update()
luci.sys.exec("kill $(pgrep /usr/share/clash/update.sh) ; (bash /usr/share/clash/update.sh >/tmp/clash.txt 2>&1) &")
end
local function in_use()
return luci.sys.exec("uci get clash.config.config_type")
end
local function subconf()
if nixio.fs.access(string.sub(luci.sys.exec("uci get clash.config.config_path_sub"), 1, -2)) then
return fss.basename(string.sub(luci.sys.exec("uci get clash.config.config_path_sub"), 1, -2))
else
return ""
end
end
local function upconf()
if nixio.fs.access(string.sub(luci.sys.exec("uci get clash.config.config_path_up"), 1, -2)) then
return fss.basename(string.sub(luci.sys.exec("uci get clash.config.config_path_up"), 1, -2))
else
return ""
end
end
local function cusconf()
if nixio.fs.access(string.sub(luci.sys.exec("uci get clash.config.config_path_cus"), 1, -2)) then
return fss.basename(string.sub(luci.sys.exec("uci get clash.config.config_path_cus"), 1, -2))
else
return ""
end
end
function action_conf()
luci.http.prepare_content("application/json")
luci.http.write_json({
subconf = subconf(),
upconf = upconf(),
cusconf = cusconf(),
})
end
local function dash_port()
return luci.sys.exec("uci get clash.config.dash_port 2>/dev/null")
end
@ -85,6 +159,10 @@ local function check_clashr_core()
return luci.sys.exec("sh /usr/share/clash/check_clashr_core_version.sh")
end
local function check_clashtun_core()
return luci.sys.exec("sh /usr/share/clash/check_clashtun_core_version.sh")
end
local function current_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/luci_version")
end
@ -101,6 +179,10 @@ local function new_clashr_core_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/new_clashr_core_version")
end
local function new_clashtun_core_version()
return luci.sys.exec("sed -n 1p /usr/share/clash/new_clashtun_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
@ -194,9 +276,10 @@ function check_status()
clash_core = clash_core(),
clashr_core = clashr_core(),
clashtun_core = clashtun_core(),
new_core_version = new_core_version()
new_core_version = new_core_version(),
new_clashtun_core_version =new_clashtun_core_version(),
check_clashtun_core = check_clashtun_core()
})
end
function action_status()
@ -211,7 +294,9 @@ function action_status()
clashr_core = clashr_core(),
dash_pass = dash_pass(),
clashtun_core = clashtun_core(),
e_mode = e_mode()
e_mode = e_mode(),
in_use = in_use()
})
end

View File

@ -37,8 +37,6 @@ o.description = translate("Select core, clashr support ssr while clash does not.
o = s:option(ListValue, "tun_mode", translate("Tun Mode"))
o.default = "1"
o:value("0", translate("Disable"))
o:value("1", translate("Fake-IP(Dreamacro Tun)"))
o:value("2", translate("Fake-IP(comzyh Tun)"))
o:value("3", translate("Redir-Host(comzyh Tun)"))
o.description = translate("Select Tun Mode")
@ -46,11 +44,17 @@ o:depends("core",3)
o = s:option(ListValue, "config_type", translate("Config Type"))
o.default = "sub"
o:value("sub", translate("Subscription Config"))
o:value("upl", translate("Uploaded Config"))
o:value("cus", translate("Custom Config"))
o:value("1", translate("Subscription Config"))
o:value("2", translate("Uploaded Config"))
o:value("3", translate("Custom Config"))
o.description = translate("Select Configuration type")
o = s:option(ListValue, "g_rules", translate("Game Rules"))
o.default = "0"
o:value("0", translate("Disable"))
o:value("1", translate("Enable"))
o.description = translate("Set rules under Setting=>Game Rules, will take effect when client start")
o = s:option(Button, "Apply")
o.title = translate("Save & Apply")
o.inputtitle = translate("Save & Apply")
@ -60,7 +64,7 @@ o.write = function()
end
o = s:option(Button,"action")
o.title = translate("Action")
o.title = translate("Operation")
o.template = "clash/start_stop"

View File

@ -62,6 +62,16 @@ cc = s:option(Flag, "create", translate("Enable Create"))
cc.default = 1
cc.description = translate("Enable to create configuration")
o = s:option(Value, "create_tag")
o.title = translate("Config Name")
o.rmempty = true
o.description = translate("Give a name for your config")
cc = s:option(Flag, "same_tag", translate("Force Same Name"))
cc.default = 1
cc.description = translate("Enable to overwrite config file")
o = s:option(ListValue, "loadfrom", translate("Load From"))
o:value("sub", translate("Subscription Config"))
o:value("upl", translate("Upload Config"))
@ -80,7 +90,7 @@ o.description = translate("Enable to read policy group")
local t = {
{Load_Config, Creat_Config, Delete_Severs, Delete_Groups}
{Load_Config, Creat_Config, Apply, Delete_Severs, Delete_Groups}
}
b = krk:section(Table, t)
@ -103,6 +113,13 @@ o.write = function()
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash"))
end
o = b:option(Button,"Apply")
o.inputtitle = translate("Save & Apply")
o.inputstyle = "apply"
o.write = function()
krk.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "create"))
end
o = b:option(Button,"Delete_Severs")
o.inputtitle = translate("Delete Severs")

View File

@ -8,6 +8,8 @@ local uci = require("luci.model.uci").cursor()
local fs = require "luci.clash"
local http = luci.http
c = Map("clash")
c.template="clash/cusconf"
m = Map("clash")
@ -17,7 +19,7 @@ s.anonymous = true
s.addremove=false
local conf = "/usr/share/clash/config/custom/config.yaml"
local conf = string.sub(luci.sys.exec("uci get clash.config.config_path_cus"), 1, -2)
sev = s:option(TextValue, "conf")
--sev.readonly=true
sev.rows = 20
@ -37,22 +39,67 @@ o.write = function()
end
o = s:option(Button,"configrm")
o.inputtitle = translate("Delete Config")
o.write = function()
SYS.call("rm -rf /usr/share/clash/config/custom/config.yaml 2>&1 &")
local e,a={}
for t,o in ipairs(fs.glob("/usr/share/clash/config/custom/*"))do
a=fs.stat(o)
if a then
e[t]={}
e[t].name=fs.basename(o)
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
e[t].size=tostring(a.size)
e[t].remove=0
e[t].enable=false
end
end
o = s:option(Button, "Download")
o.inputtitle = translate("Download Config")
o.inputstyle = "apply"
o.write = function ()
f=Form("config_list")
f.reset=false
f.submit=false
tb=f:section(Table,e)
nm=tb:option(DummyValue,"name",translate("File Name"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
sz=tb:option(DummyValue,"size",translate("Size"))
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e==".yaml"
end
btnis=tb:option(Button,"switch",translate("Use Config"))
btnis.template="clash/other_button"
btnis.render=function(o,t,a)
if not e[t]then return false end
if IsYamlFile(e[t].name)then
a.display=""
else
a.display="none"
end
o.inputstyle="apply"
Button.render(o,t,a)
end
btnis.write=function(a,t)
luci.sys.exec(string.format('uci set clash.config.config_path_cus="/usr/share/clash/config/custom/%s"',e[t].name ))
luci.sys.exec('uci commit clash')
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "clash", "config", "cusconfig"))
end
btndl = tb:option(Button,"download",translate("Download"))
btndl.template="clash/other_button"
btndl.render=function(e,t,a)
e.inputstyle="remove"
Button.render(e,t,a)
end
btndl.write = function (a,t)
local sPath, sFile, fd, block
sPath = "/usr/share/clash/config/custom/config.yaml"
sPath = "/usr/share/clash/config/custom/"..e[t].name
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".tar.gz"
fd = io.popen('yaml -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".yaml"
else
fd = nixio.open(sPath, "r")
end
@ -73,4 +120,20 @@ o.write = function ()
HTTP.close()
end
return m
btnrm=tb:option(Button,"remove",translate("Remove"))
btnrm.render=function(e,t,a)
e.inputstyle="remove"
Button.render(e,t,a)
end
btnrm.write=function(a,t)
local a=fs.unlink("/usr/share/clash/config/custom/"..fs.basename(e[t].name))
luci.sys.exec(string.format('uci set clash.config.config_cus_remove="%s"',e[t].name))
luci.sys.exec('uci commit clash')
luci.sys.exec('/usr/share/clash/cuslist.sh 2>&1 &')
if a then table.remove(e,t)end
return a
end
return c,f,m

View File

@ -43,7 +43,6 @@ y.description = translate("Allow ipv6 traffic through clash")
o = s:option(ListValue, "tun_mode", translate("Tun Mode DNS"))
o.default = "0"
o:value("0", translate("Disable"))
o:value("1", translate("Fake-IP(Dreamacro Tun)"))
o:value("2", translate("Fake-IP(comzyh Tun)"))
o:value("3", translate("Redir-Host(comzyh Tun)"))
o.description = translate("Select Tun Mode, Enable Tun custom DNS and make sure you are using tun supported core")
@ -73,20 +72,6 @@ o.description = translate("NB: press ENTER to create a blank line at the end of
o:depends("mode", 1)
local dns1 = "/usr/share/clash/tundns_1.yaml"
o = s:option(TextValue, "dns1",translate("Modify Tun DNS"))
o.template = "clash/tvalue"
o.rows = 26
o.wrap = "off"
o.cfgvalue = function(self, section)
return NXFS.readfile(dns1) or ""
end
o.write = function(self, section, value)
NXFS.writefile(dns1, value:gsub("\r\n", "\n"))
end
o.description = translate("NB: press ENTER to create a blank line at the end of input.")
o:depends("tun_mode", 1)
local dns2 = "/usr/share/clash/tundns_2.yaml"
o = s:option(TextValue, "dns2",translate("Modify Tun DNS"))

View File

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

View File

@ -0,0 +1,64 @@
local m, s, o
local clash = "clash"
local uci = luci.model.uci.cursor()
--local fs = require "nixio.fs"
local sys = require "luci.sys"
local sid = arg[1]
local fs = require "luci.clash"
m = Map(clash, translate("Edit Game Rule & Group"))
--m.pageaction = false
m.redirect = luci.dispatcher.build_url("admin/services/clash/settings/grules")
if m.uci:get(clash, sid) ~= "game" then
luci.http.redirect(m.redirect)
return
end
function IsRuleFile(e)
e=e or""
local e=string.lower(string.sub(e,-6,-1))
return e==".rules"
end
-- [[ Groups Setting ]]--
s = m:section(NamedSection, sid, "game")
s.anonymous = true
s.addremove = false
o = s:option(Value, "tag")
o.title = translate("Rule Tag")
o.rmempty = false
o.description = translate("Give a special name for your rules")
---- Proxy Group
o = s:option(ListValue, "group", translate("Select Proxy Group"))
uci:foreach("clash", "conf_groups",
function(s)
if s.name ~= "" and s.name ~= nil then
o:value(s.name)
end
end)
o:value("DIRECT")
o:value("REJECT")
o.rmempty = true
o.description = translate("Select a policy group to add rule")
---- rule name
o = s:option(DynamicList, "rule_name", translate("Game Rule's Name"))
local e,a={}
for t,f in ipairs(fs.glob("/usr/share/clash/rules/g_rules/*"))do
a=fs.stat(f)
if a then
e[t]={}
e[t].filename=fs.basename(f)
if IsRuleFile(e[t].filename) then
e[t].name=luci.sys.exec(string.format("grep -F '%s' /usr/share/clash/rules/rules.list | awk -F ',' '{print $2}'",e[t].filename))
o:value(e[t].filename)
end
end
end
o.rmempty = true
return m

View File

@ -0,0 +1,161 @@
local k, m, s, o, f
local clash = "clash"
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()
m = Map(clash)
m.pageaction = false
SYS.call("awk -F ',' '{print $1}' /usr/share/clash/rules/rules.list > /tmp/rules_name 2>/dev/null")
file = io.open("/tmp/rules_name", "r");
r = m:section(TypedSection, "conf_groups", translate("Policy Groups"))
r.anonymous = true
r.addremove = false
r.sortable = false
r.template = "cbi/tblsection"
--r.extedit = luci.dispatcher.build_url("admin/services/clash/g-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
-- [[ Edit Game Rule ]] --
r = m:section(TypedSection, "game", translate("Game Rules & Groups"))
r.anonymous = true
r.addremove = true
r.sortable = false
r.template = "cbi/tblsection"
r.extedit = luci.dispatcher.build_url("admin/services/clash/g-rules/%s")
function r.create(...)
local sid = TypedSection.create(...)
if sid then
luci.http.redirect(r.extedit % sid)
return
end
end
o = r:option(DummyValue, "tag", translate("Game Rule Tag"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
o = r:option(DummyValue, "group", translate("Policy Groups"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
end
---- Rules List
local e={},a,o,t
a=nixio.fs.access("/tmp/rules_name")
if a then
for o in file:lines() do
table.insert(e,o)
end
for t,o in ipairs(e) do
e[t]={}
e[t].num=string.format(t)
e[t].name=o
e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /usr/share/clash/rules/rules.list |awk -F ',' '{print $3}' 2>/dev/null",e[t].name)),1,-2)
if e[t].filename == "" then
e[t].filename=string.sub(luci.sys.exec(string.format("grep -F '%s,' /usr/share/clash/rules/rules.list |awk -F ',' '{print $2}' 2>/dev/null",e[t].name)),1,-2)
end
RULE_FILE="/usr/share/clash/rules/g_rules/".. e[t].filename
if fs.mtime(RULE_FILE) then
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(RULE_FILE))
else
e[t].mtime="/"
end
if fs.isfile(RULE_FILE) then
e[t].exist=translate("Exist")
else
e[t].exist=translate("Not Exist")
end
e[t].remove=0
end
end
file:close()
f=Form("filelist", translate("Game Rules List"))
tb=f:section(Table,e)
nu=tb:option(DummyValue,"num",translate("Order Number"))
st=tb:option(DummyValue,"exist",translate("State"))
--nm=tb:option(DummyValue,"name",translate("Rule Name"))
fm=tb:option(DummyValue,"filename",translate("File Name"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
btnis=tb:option(DummyValue,"filename",translate("Download Rule"))
btnis.template="clash/game_rule"
btnrm=tb:option(Button,"remove",translate("Remove"))
btnrm.render=function(e,t,a)
e.inputstyle="reset"
Button.render(e,t,a)
end
btnrm.write=function(a,t)
local a=fs.unlink("/usr/share/clash/rules/g_rules/"..e[t].filename)
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "clash", "settings", "grules"))
end
local t = {
{Load,Apply}
}
k = Form("apply")
k.reset = false
k.submit = false
s = k:section(Table, t)
o = s:option(Button, "Load")
o.inputtitle = translate("Load Groups")
o.inputstyle = "apply"
o.write = function()
m.uci:commit("clash")
luci.sys.call("bash /usr/share/clash/load_groups.sh >/dev/null 2>&1 &")
luci.sys.call("sleep 3")
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "clash", "settings", "grules"))
end
o = s:option(Button, "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"))
else
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "clash", "settings", "grules"))
end
end
return m, k, f

View File

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

@ -7,18 +7,85 @@ local UTIL = require "luci.util"
local uci = require("luci.model.uci").cursor()
local fs = require "luci.clash"
local http = luci.http
local clash = "clash"
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. Only update config in use")
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, "config_name")
o.title = translate("Config Name")
o.description = translate("Give a name for your config")
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(Value, "subscribe_url")
o.title = translate("Subcription Url")
o.description = translate("V2/SSR Subscription Address, Only input your subscription address without any api conversion url")
o.rmempty = true
o:depends("subcri", 'v2ssr2clash')
o = s:option(Button,"update")
o.title = translate("Download Config")
o.inputtitle = translate("Download 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("Download Config")
o.inputtitle = translate("Download 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')
c = Map("clash")
c.template="clash/subconf"
m = Map("clash")
s = m:section(TypedSection, "clash")
m.pageaction = false
s.anonymous = true
s.addremove=false
local conf = "/usr/share/clash/config/sub/config.yaml"
local conf = string.sub(luci.sys.exec("uci get clash.config.config_path_sub"), 1, -2)
sev = s:option(TextValue, "conf")
--sev.readonly=true
sev.rows = 20
sev.wrap = "off"
sev.cfgvalue = function(self, section)
@ -35,25 +102,70 @@ o.write = function()
m.uci:commit("clash")
end
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e==".yaml"
end
o = s:option(Button,"configrm")
o.inputtitle = translate("Delete Config")
o.write = function()
SYS.call("rm -rf /usr/share/clash/config/sub/config.yaml 2>&1 &")
local e,a={}
for t,o in ipairs(fs.glob("/usr/share/clash/config/sub/*"))do
a=fs.stat(o)
if a then
e[t]={}
e[t].name=fs.basename(o)
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
e[t].size=tostring(a.size)
e[t].remove=0
e[t].enable=false
end
end
f=Form("config_list")
f.reset=false
f.submit=false
tb=f:section(Table,e)
nm=tb:option(DummyValue,"name",translate("File Name"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
sz=tb:option(DummyValue,"size",translate("Size"))
btnis=tb:option(Button,"switch",translate("Use Config"))
btnis.template="clash/other_button"
btnis.render=function(o,t,a)
if not e[t]then return false end
if IsYamlFile(e[t].name)then
a.display=""
else
a.display="none"
end
o.inputstyle="apply"
Button.render(o,t,a)
end
btnis.write=function(a,t)
luci.sys.exec(string.format('uci set clash.config.config_path_sub="/usr/share/clash/config/sub/%s"',e[t].name ))
luci.sys.exec(string.format('uci set clash.config.config_update_name="%s"',e[t].name ))
luci.sys.exec('uci commit clash')
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "clash", "config", "subconfig"))
end
o = s:option(Button, "Download")
o.inputtitle = translate("Download Config")
o.inputstyle = "apply"
o.write = function ()
btndl = tb:option(Button,"download",translate("Download"))
btndl.template="clash/other_button"
btndl.render=function(e,t,a)
e.inputstyle="remove"
Button.render(e,t,a)
end
btndl.write = function (a,t)
local sPath, sFile, fd, block
sPath = "/usr/share/clash/config/sub/config.yaml"
sPath = "/usr/share/clash/config/sub/"..e[t].name
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('tar -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".tar.gz"
fd = io.popen('yaml -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".yaml"
else
fd = nixio.open(sPath, "r")
end
@ -74,4 +186,21 @@ o.write = function ()
HTTP.close()
end
return m
btnrm=tb:option(Button,"remove",translate("Remove"))
btnrm.render=function(e,t,a)
e.inputstyle="remove"
Button.render(e,t,a)
end
btnrm.write=function(a,t)
local a=fs.unlink("/usr/share/clash/config/sub/"..fs.basename(e[t].name))
luci.sys.exec(string.format('uci set clash.config.config_name_remove="%s"',e[t].name))
luci.sys.exec('uci commit clash')
luci.sys.exec('bash /usr/share/clash/rmlist.sh 2>&1 &')
if a then table.remove(e,t)end
return a
end
return kr,c,f,m

View File

@ -1,12 +1,66 @@
local http = luci.http
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
local DISP = require "luci.dispatcher"
local UTIL = require "luci.util"
local uci = require("luci.model.uci").cursor()
local fs = require "luci.clash"
local http = luci.http
local uci = require("luci.model.uci").cursor()
local clash = "clash"
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 .yaml.It recommended to rename each upload file name to avoid overwrite")
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
c = Map("clash")
c.template="clash/upconf"
m = Map("clash")
@ -16,7 +70,7 @@ s.anonymous = true
s.addremove=false
local conf = "/usr/share/clash/config/upload/config.yaml"
local conf = string.sub(luci.sys.exec("uci get clash.config.config_path_up"), 1, -2)
sev = s:option(TextValue, "conf")
--sev.readonly=true
sev.rows = 20
@ -28,12 +82,6 @@ sev.write = function(self, section, value)
NXFS.writefile(conf, value:gsub("\r\n", "\n"))
end
o = s:option(Button,"configrm")
o.inputtitle = translate("Delete Config")
o.write = function()
SYS.call("rm -rf /usr/share/clash/config/upload/config.yaml >/dev/null 2>&1 &")
end
o=s:option(Button,"apply")
o.inputtitle = translate("Save & Apply")
o.inputstyle = "reload"
@ -42,6 +90,100 @@ o.write = function()
end
return m
local e,a={}
for t,o in ipairs(fs.glob("/usr/share/clash/config/upload/*.yaml"))do
a=fs.stat(o)
if a then
e[t]={}
e[t].name=fs.basename(o)
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",a.mtime)
e[t].size=tostring(a.size)
e[t].remove=0
e[t].enable=false
end
end
f=Form("config_list")
f.reset=false
f.submit=false
tb=f:section(Table,e)
nm=tb:option(DummyValue,"name",translate("File Name"))
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
sz=tb:option(DummyValue,"size",translate("Size"))
function IsYamlFile(e)
e=e or""
local e=string.lower(string.sub(e,-5,-1))
return e==".yaml"
end
btnis=tb:option(Button,"switch",translate("Use Config"))
btnis.template="clash/other_button"
btnis.render=function(o,t,a)
if not e[t]then return false end
if IsYamlFile(e[t].name)then
a.display=""
else
a.display="none"
end
o.inputstyle="apply"
Button.render(o,t,a)
end
btnis.write=function(a,t)
luci.sys.exec(string.format('uci set clash.config.config_path_up="/usr/share/clash/config/upload/%s"',e[t].name ))
luci.sys.exec('uci commit clash')
HTTP.redirect(luci.dispatcher.build_url("admin", "services", "clash", "config", "upconfig"))
end
btndl = tb:option(Button,"download",translate("Download"))
btndl.template="clash/other_button"
btndl.render=function(e,t,a)
e.inputstyle="remove"
Button.render(e,t,a)
end
btndl.write = function (a,t)
local sPath, sFile, fd, block
sPath = "/usr/share/clash/config/upload/"..e[t].name
sFile = NXFS.basename(sPath)
if fs.isdirectory(sPath) then
fd = io.popen('yaml -C "%s" -cz .' % {sPath}, "r")
sFile = sFile .. ".yaml"
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
btnrm=tb:option(Button,"remove",translate("Remove"))
btnrm.render=function(e,t,a)
e.inputstyle="remove"
Button.render(e,t,a)
end
btnrm.write=function(a,t)
local a=fs.unlink("/usr/share/clash/config/upload/"..fs.basename(e[t].name))
luci.sys.exec(string.format('uci set clash.config.config_up_remove="%s"',e[t].name))
luci.sys.exec('uci commit clash')
luci.sys.exec('bash /usr/share/clash/uplist.sh 2>&1 &')
if a then table.remove(e,t)end
return a
end
return k,c,f,m

View File

@ -17,67 +17,13 @@ m:section(SimpleSection).template = "clash/update"
m.pageaction = false
k = Map("clash")
s=k:section(TypedSection, "clash", translate("Upload Clash(Tun)"))
s.anonymous = true
s.addremove=false
o = s:option(FileUpload, "")
o.description = translate("NB: Upload Clash Supported Tun (clash)")
.."<br />"
..translate("https://github.com/comzyh/clash/releases")
.."<br />"
..translate("https://github.com/Dreamacro/clash/releases/tag/TUN")
o.title = translate(" ")
o.template = "clash/clash_upload"
um = s:option(DummyValue, "", nil)
um.template = "clash/clash_dvalue"
local dir, fd
dir = "/etc/clash/clashtun/"
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/clashtun/"'
SYS.call("chmod 755 /etc/clash/clashtun/clash")
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
s = k:section(TypedSection, "clash", translate("Download Clash/Clashr"))
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:value("3", translate("ClashTun"))
o.description = translate("Select core, clashr support ssr while clash does not.")

View File

@ -0,0 +1,11 @@
<fieldset class="cbi-section">
<p width="100%" align="center"><font color="blue"><b><%:CONFIG IN USE%>:</b> <b id="_cusconfig"></b></font></p>
</fieldset>
<script type="text/javascript">//<![CDATA[
var cusconfig = document.getElementById('_cusconfig');
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "conf")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
cusconfig.innerHTML = status.cusconf ? '<b><font color="green">'+status.cusconf+'</font> </b>' : '<b><font color="red"><%:Not Selected%></font></b>';
}
});
//]]></script>

View File

@ -0,0 +1,38 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function act_download_rule(btn,filename)
{
btn.disabled = true;
btn.value = '<%:Downloading...%> ';
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash","game_rule")%>',
{
filename: filename
},
function(x,status)
{
if ( x && x.status == 200 ) {
if(status.game_rule=="0")
{
btn.value = '<%:Error%>';
}
else
{
btn.value = '<%:Successful%>';
window.location.reload();
}
}
else {
btn.value = '<%:Timeout%>';
}
}
);
btn.disabled = false;
return false;
}
//]]></script>
<input type="button" class="cbi-button cbi-input-reload" value="<%:Update Rule%>" onclick="return act_download_rule(this,'<%=self:cfgvalue(section)%>')" />
<%+cbi/valuefooter%>

View File

@ -0,0 +1,7 @@
<%+cbi/valueheader%>
<% if self:cfgvalue(section) ~= false then %>
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="display: <%= display %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.inputtitle or self.title)%> />
<% else %>
-
<% end %>
<%+cbi/valuefooter%>

View File

@ -10,6 +10,7 @@
<table width="100%" cellspacing="10">
<tr><td width="50%"><span><%:Clash Client%></span></td><td id="_clash"><em><%:Collecting data...%></em></td> </tr>
<tr><td width="50%"><span><%:Clash Mode%></span></td><td id="_emode"><em><%:Collecting data...%></em></td> </tr>
<tr><td width="50%"><span><%:Clash Config%></span></td><td id="_useconf"><em><%:Collecting data...%></em></td> </tr>
<tr><td width="50%"><span><%:Clash Dashboard%></span></td><td id="_web"><em> <%:Collecting data...%> </em></td> </tr>
</table>
</fieldset>
@ -150,14 +151,25 @@ var HTTP = {
var secret = document.getElementById('_secret');
var emode = document.getElementById('_emode');
var logo = document.getElementById('_logo');
var use = document.getElementById('_useconf');
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
if(status.in_use==1){
use.innerHTML = status.in_use ? '<b><font color="green"><%:SUBSCRIBE%></font> </b>' : '<b><font color="red"><%:NOT SELECTED%></font></b>';
}
if(status.in_use==2){
use.innerHTML = status.in_use ? '<b><font color="green"><%:UPLOAD%></font> </b>' : '<em><b><font color="red"><%:NOT SELECTED%></font></b></em>';
}
if(status.in_use==3){
use.innerHTML = status.in_use ? '<b><font color="green"><%:CUSTOM%></font> </b>' : '<em><b><font color="red"><%:NOT SELECTED%></font></b></em>';
}
web.innerHTML = status.web ? '<a type="button" class="btn" style="background-color:black;padding: 5px;" href="http://'+window.location.hostname+':'+status.dash_port+'/ui" target="_blank"/><b><font color="green"><%:OPEN DASHBOARD%></font></b></a>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
clash.innerHTML = status.clash ? '<b><font color="green"><%:RUNNING%></font> </b>' : '<b><font color="red"><%:NOT RUNNING%></font></b>';
ip.innerHTML = status.localip ? '<b><font color="green">'+status.localip+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
port.innerHTML = status.dash_port ? '<b><font color="green">'+status.dash_port+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
secret.innerHTML = status.dash_pass ? '<b><font color="green">'+status.dash_pass+'</font> </b>' : '<em><b><font color="red"><%:NOT SET%></font></b></em>';
emode.innerHTML = status.e_mode ? '<b><font color="green" style="text-transform: uppercase;">'+status.e_mode+'</font> </b>' : '<b><font color="red"><%:NOT SET%></font></b>';
IP.getIpifyIP();
IP.getIpipnetIP();

View File

@ -0,0 +1,19 @@
<fieldset class="cbi-section">
<p width="100%" align="center"><font color="blue"><b><%:CONFIG IN USE%>:</b> <b id="_subconfig"></b></font></p>
</fieldset>
<script type="text/javascript">//<![CDATA[
var subconfig = document.getElementById('_subconfig');
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "conf")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
subconfig.innerHTML = status.subconf ? '<b><font color="green">'+status.subconf+'</font> <input type="button" class="cbi-button cbi-button-apply" value="<%:Update%>" style=" display:inline;" onclick=" return download_conf()" /></b>' : '<b><font color="red"><%:Not Selected%></font></b>';
}
});
function download_conf(){
XHR.get('<%=url([[admin]], [[services]], [[clash]], [[update_config]])%>',null,function(x, data){}
);
window.setTimeout("location.href='/cgi-bin/luci/admin/services/clash/'", 500);
return
}
//]]></script>

View File

@ -0,0 +1,11 @@
<fieldset class="cbi-section">
<p width="100%" align="center"><font color="blue"><b><%:CONFIG IN USE%>:</b> <b id="_upconfig"></b></font></p>
</fieldset>
<script type="text/javascript">//<![CDATA[
var upconfig = document.getElementById('_upconfig');
XHR.poll(1, '<%=luci.dispatcher.build_url("admin", "services", "clash", "conf")%>', null, function(x, status) {
if ( x && x.status == 200 ) {
upconfig.innerHTML = status.upconf ? '<b><font color="green">'+status.upconf+'</font> </b>' : '<b><font color="red"><%:Not Selected%></font></b>';
}
});
//]]></script>

View File

@ -71,7 +71,7 @@
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>';
coretun_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Link1%>" onclick="return clashtun_core_check1(this)"/> <input type="button" class="cbi-button cbi-button-reload" value="<%:Link2%>" onclick="return clashtun_core_check2(this)"/></center>' : '<em></em>';
coretun_butt.innerHTML = status.current_version ? '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return clashtun_core_check(this)"/></center>' : '<em></em>';
@ -148,6 +148,34 @@ function clashr_core_check(btn)
});
}
function clashtun_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_clashtun_core_version > status.clashtun_core)
{
coretun_butt.innerHTML ='<center><b><font color="green"><%:New Version :%>'+status.new_clashtun_core_version+'</font> </b></center>';
}
else if(status.new_clashtun_core_version==0)
{
coretun_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-reset" value="<%:Error Occured |Return%>" onclick="return clashtun_core_return(this)"/></center>';
}
else if(status.clashtun_core >= status.new_clashtun_core_version)
{
coretun_butt.innerHTML ='<center><input type="button" class="cbi-button cbi-button-reset" value="<%:No Update | Return%>" onclick="return clashtun_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) {
@ -160,29 +188,6 @@ XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_statu
});
}
function clashtun_core_check1(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Link1%>';
url='https://github.com/Dreamacro/clash/releases/tag/TUN';
window.open(url);
btn.disabled = false;
return false;
});
}
function clashtun_core_check2(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "check_status")%>', null, function(x, status) {
btn.disabled = true;
btn.value = '<%:Link2%>';
url='https://github.com/comzyh/clash/releases';
window.open(url);
btn.disabled = false;
return false;
});
}
function check_return(btn)
{
@ -215,7 +220,15 @@ function clashr_core_return(btn)
}
function clashtun_core_return(btn)
{
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "clash", "status")%>', status.clashtun_core, function(x, status) {
btn.disabled = true;
btn.value = '<%:Return Check%>';
coretun_butt.innerHTML = '<center><input type="button" class="cbi-button cbi-button-reload" value="<%:Check%>" onclick="return clashtun_core_check(this)"/></center>';
});
}
//]]></script>

View File

@ -143,7 +143,7 @@ msgid "Overview"
msgstr "概览"
msgid "Download"
msgstr "下载新版本"
msgstr "下载"
msgid "Checking..."
msgstr "正在检查..."
@ -766,3 +766,129 @@ msgstr "未选择文件"
msgid "Chose File"
msgstr "选择文件"
msgid "Update Time"
msgstr "更新时间"
msgid "File Name"
msgstr "文件名"
msgid "Use Config"
msgstr "使用配置"
msgid "Size"
msgstr "文件大小"
msgid "Remove"
msgstr "移除"
msgid "Download Config"
msgstr "下载配置"
msgid "Config Name"
msgstr "配置名"
msgid "Give a name for your config"
msgstr "为配置命名"
msgid "CONFIG IN USE"
msgstr "使用中的配置"
msgid "Daily Server subscription update time. Only update config in use"
msgstr "每日服务器订阅更新时间。仅更新正在使用的配置"
msgid "NB: Only upload file with name .yaml.It recommended to rename each upload file name to avoid overwrite"
msgstr "注意:仅上载名为.yaml的文件。建议重命名每个上载文件名以避免覆盖"
msgid "Not Selected"
msgstr "未选择"
msgid "Force Same Name"
msgstr "强制使用同名"
msgid "Enable to overwrite config file"
msgstr "启用覆盖配置文件"
msgid "Clash Config"
msgstr "Clash配置"
msgid "SUBSCRIBE"
msgstr "订阅配置"
msgid "UPLOAD"
msgstr "上传配置"
msgid "CUSTOM"
msgstr "自定义配置"
msgid "Operation"
msgstr "操作"
msgid "NOT SELECTED"
msgstr "未选择"
msgid "Game Rule's Name"
msgstr "选择游戏规则"
msgid "Select Proxy Group"
msgstr "选择策略组"
msgid "Game Rules List"
msgstr "游戏规则列表"
msgid "Rule Name"
msgstr "规则名称"
msgid "Download Rule"
msgstr "下载规则"
msgid "Exist"
msgstr "已下载"
msgid "Not Exist"
msgstr "未下载"
msgid "Order Number"
msgstr "序号"
msgid "Game Rules & Groups"
msgstr "游戏规则策略组"
msgid "Timeout"
msgstr "下载超时"
msgid "Error"
msgstr "下载失败"
msgid "Successful"
msgstr "下载成功"
msgid "Game Rules"
msgstr "游戏规则"
msgid "Update Rule"
msgstr "点击更新规则"
msgid "Game Rule Tag"
msgstr "游戏规则评论"
msgid "Rule Tag"
msgstr "游戏评论"
msgid "Edit Game Rule & Group"
msgstr "编辑游戏规则策略组"
msgid "Give a special name for your rules"
msgstr "规则名字"
msgid "Select a policy group to add rule"
msgstr "选择要添加规则的策略组"
msgid "Set rules under Setting=>Game Rules, will take effect when client start"
msgstr "在设置=>游戏规则下设置规则,将在客户端启动时生效"
msgid "Enable"
msgstr "启用"
msgid "Downloading..."
msgstr "正在下载规则..."

View File

@ -19,12 +19,12 @@ config clash 'config'
option cus_list '1'
option custom_dns '114.114.114.114'
option cusrule '0'
option config_type 'sub'
option loadfrom 'sub'
option loadservers '1'
option loadgroups '1'
option fake_ip_range '198.18.0.0/16'
option dnscache '0'
option config_type '1'
config groups
option old_name '❌AdBlock'

View File

@ -11,9 +11,10 @@ CRON_FILE="/etc/crontabs/root"
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_OLD="/etc/clash/config.yml"
CONFIG_YAML_SUB="/usr/share/clash/config/sub/config.yaml"
CONFIG_YAML_UPL="/usr/share/clash/config/upload/config.yaml"
CONFIG_YAML_CUS="/usr/share/clash/config/custom/config.yaml"
CONFIG_YAML_SUB=$(uci get clash.config.config_path_sub 2>/dev/null)
CONFIG_YAML_UPL=$(uci get clash.config.config_path_up 2>/dev/null)
CONFIG_YAML_CUS=$(uci get clash.config.config_path_cus 2>/dev/null)
CUSLIST="/tmp/dnsmasq.d/custom_list.conf"
CUSLITT="/tmp/dnsmasq.clash"
CUSLISTV="/var/dnsmasq.d/custom_list.conf"
@ -41,8 +42,7 @@ config_type=$(uci get clash.config.config_type 2>/dev/null)
[ -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
[ -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
[ -z "$(grep -w "/usr/share/clash/update.sh" $CRON_FILE)" ] && echo "0 $(uci get clash.config.auto_update_time 2>/dev/null) * * * /usr/share/clash/update.sh" >> $CRON_FILE
fi
auto_geoip=$(uci get clash.config.auto_update_geoip 2>/dev/null)
if [ "${auto_geoip}" -eq 1 ]; then
@ -83,18 +83,53 @@ elif [ "${lang}" == "zh_cn" ];then
echo "正在检查配置文件。。。" >$REAL_LOG
fi
sleep 1
if [ $config_type == "sub" ];then
if [ $config_type == "1" ];then
if [ "$(uci get clash.config.config_path_sub)" == "" ] && [ -z "$(uci get clash.config.config_path_sub)" ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Select Config and Restart Client" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "选择配置,重新启动客户端" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
fi
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
elif [ $config_type == "2" ];then
if [ "$(uci get clash.config.config_path_up)" == "" ] && [ -z "$(uci get clash.config.config_path_up)" ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Select Config and Restart Client" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "选择配置,重新启动客户端" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
fi
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
elif [ $config_type == "3" ];then
if [ "$(uci get clash.config.config_path_cus)" == "" ] && [ -z "$(uci get clash.config.config_path_cus)" ];then
if [ "${lang}" == "en" ] || [ $lang == "auto" ];then
echo "Select Config and Restart Client" >$REAL_LOG
elif [ "${lang}" == "zh_cn" ];then
echo "选择配置,重新启动客户端" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
fi
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
#===========================================================================================================================
@ -108,6 +143,11 @@ yml_change() {
#===========================================================================================================================
}
game_rules() {
#===========================================================================================================================
sh /usr/share/clash/game.sh 2>/dev/null
#===========================================================================================================================
}
yml_dns_change(){
@ -228,6 +268,13 @@ rules(){
PROXY_ROUTE_TABLE="0x162"
PROXY_BYPASS_USER="root"
TUN_DEVICE=$(egrep '^ {0,}device-url:' /etc/clash/config.yaml |grep device-url: |awk -F '//' '{print $2}')
if [ -z $TUN_DEVICE ];then
TUN_DEVICE_NAME="clash0"
else
TUN_DEVICE_NAME=$TUN_DEVICE
fi
ipset create localnetwork hash:net
ipset add localnetwork 127.0.0.0/8
ipset add localnetwork 10.0.0.0/8
@ -237,10 +284,10 @@ rules(){
ipset add localnetwork 240.0.0.0/4
ipset add localnetwork 172.16.0.0/12
ip tuntap add user root mode tun clash0
ip link set clash0 up
ip address replace 198.18.0.0/16 dev clash0
ip route replace default dev clash0 table "$PROXY_ROUTE_TABLE"
ip tuntap add user root mode tun $TUN_DEVICE_NAME
ip link set $TUN_DEVICE_NAME up
ip address replace 198.18.0.0/16 dev $TUN_DEVICE_NAME
ip route replace default dev $TUN_DEVICE_NAME table "$PROXY_ROUTE_TABLE"
ip rule add fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE"
iptables -t mangle -N clash
@ -393,7 +440,7 @@ else
if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')" -ne 0 ] ; 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 ] || [ "${checktype}" -gt 0 ] && [ "${core}" -eq 3 ]; then
@ -406,27 +453,6 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
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
@ -463,7 +489,9 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
fi
game_rules >/dev/null 2>&1
if [ "${core}" -eq 1 ];then
nohup $CLASH -d "$CLASH_CONFIG" > /tmp/clash.txt 2>&1 &
@ -500,11 +528,11 @@ if [ -f $CONFIG_YAML ] && [ "$(ls -l $CONFIG_YAML|awk '{print int($5/1024)}')"
echo "设置 Clash iptables" >$REAL_LOG
fi
if [ "$(uci get firewall.@defaults[0].forward)" != "ACCEPT" ]; then
if [ "$(uci get firewall.@defaults[0].forward)" != "ACCEPT" ]; then
uci set firewall.@defaults[0].forward=ACCEPT >/dev/null 2>&1
uci commit firewall >/dev/null 2>&1
/etc/init.d/firewall restart >/dev/null 2>&1
fi
fi
rules >/dev/null 2>&1
@ -592,11 +620,17 @@ remove_mark(){
PROXY_FWMARK="0x162" 2>/dev/null
PROXY_ROUTE_TABLE="0x162" 2>/dev/null
TUN_DEVICE=$(egrep '^ {0,}device-url:' /etc/clash/config.yaml |grep device-url: |awk -F '//' '{print $2}')
if [ -z $TUN_DEVICE ];then
TUN_DEVICE_NAME="clash0"
else
TUN_DEVICE_NAME=$TUN_DEVICE
fi
ip link set dev clash0 down 2>/dev/null
ip tuntap del clash0 mode tun 2>/dev/null
ip link set dev $TUN_DEVICE_NAME down 2>/dev/null
ip tuntap del $TUN_DEVICE_NAME mode tun 2>/dev/null
ip route del default dev clash0 table "$PROXY_ROUTE_TABLE" 2>/dev/null
ip route del default dev $TUN_DEVICE_NAME table "$PROXY_ROUTE_TABLE" 2>/dev/null
ip rule del fwmark "$PROXY_FWMARK" table "$PROXY_ROUTE_TABLE" 2>/dev/null
iptables -t mangle -D OUTPUT -j clash 2>/dev/null

View File

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

View File

@ -1,48 +1,66 @@
#!/bin/sh /etc/rc.common
#!/bin/bash /etc/rc.common
. /lib/functions.sh
subscribe_url=$(uci get clash.config.subscribe_url_clash 2>/dev/null)
subtype=$(uci get clash.config.subcri 2>/dev/null)
config_type=$(uci get clash.config.config_type 2>/dev/null)
REAL_LOG="/usr/share/clash/clash_real.txt"
config_name=$(uci get clash.config.config_name 2>/dev/null)
subtype=$(uci get clash.config.subcri 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_name}.yaml"
if [ $config_name == "" ] || [ -z $config_name ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Tag Your Config" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "标记您的配置" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
fi
check_name=$(grep -F "${config_name}.yaml" "/usr/share/clashbackup/confit_list.conf")
if [ ! -z $check_name ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Config with same name exist, please rename and download again" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "已存在同名配置,请重命名名配置重新下载" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
else
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Downloading Configuration..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "正在下载配置..." >$REAL_LOG
fi
sleep 1
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
fi
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
fi
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
wget --no-check-certificate --user-agent="Clash/OpenWRT" $subscribe_url -O 2>&1 >1 $CONFIG_YAML
if [ "$?" -eq "0" ]; then
echo "${config_name}.yaml#$subscribe_url#$subtype" >>/usr/share/clashbackup/confit_list.conf
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
fi

View File

@ -0,0 +1,78 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
RULE_FILE_NAME="$1"
RULE_FILE_ENNAME=$(grep -F $RULE_FILE_NAME /usr/share/clash/rules/rules.list |awk -F ',' '{print $3}' 2>/dev/null)
if [ ! -z "$RULE_FILE_ENNAME" ]; then
DOWNLOAD_PATH=$(grep -F $RULE_FILE_NAME /usr/share/clash/rules/rules.list |awk -F ',' '{print $2}' 2>/dev/null)
else
DOWNLOAD_PATH=$RULE_FILE_NAME
fi
RULE_FILE_DIR="/usr/share/clash/rules/g_rules/$RULE_FILE_NAME"
TMP_RULE_DIR="/tmp/$RULE_FILE_NAME"
LOG_FILE="/tmp/clash.txt"
REAL_LOG="/usr/share/clash/clash_real.txt"
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Updating 【$RULE_FILE_NAME】 Rule..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "开始下载【$RULE_FILE_NAME】规则..." >$REAL_LOG
fi
wget -c4 --no-check-certificate --timeout=30 https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -O 2>&1 >1 "$TMP_RULE_DIR"
if [ "$?" -eq "0" ] && [ "$(ls -l $TMP_RULE_DIR |awk '{print $5}')" -ne 0 ]; then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "$RULE_FILE_NAME】 Downloaded successfully. Checking whether the rule version is updated.." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "$RULE_FILE_NAME】规则下载成功,检查规则版本是否更新..." >$REAL_LOG
fi
cmp -s $TMP_RULE_DIR $RULE_FILE_DIR
if [ "$?" -ne "0" ]; then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Rule version has been updated. Start to replace the old rule version.." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "规则版本有更新,开始替换旧规则版本..." >$REAL_LOG
fi
mv $TMP_RULE_DIR $RULE_FILE_DIR >/dev/null 2>&1
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Delete download cache" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "删除下载缓存..." >$REAL_LOG
fi
rm -rf $TMP_RULE_DIR >/dev/null 2>&1
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Rule File【$RULE_FILE_NAME】 Download Successful" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "$RULE_FILE_NAME】规则更新成功!" >$REAL_LOG
fi
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
else
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Updated Rule File【$RULE_FILE_NAME】 No Change, Do Nothing" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "$RULE_FILE_NAME】规则版本没有更新,停止继续操作..." >$REAL_LOG
fi
rm -rf $TMP_RULE_DIR >/dev/null 2>&1
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi
else
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Rule File【$RULE_FILE_NAME】 Download Error" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "$RULE_FILE_NAME】规则下载失败,请检查网络或稍后再试!" >$REAL_LOG
fi
rm -rf $TMP_RULE_DIR >/dev/null 2>&1
sleep 2
echo "Clash for OpenWRT" >$REAL_LOG
fi

View File

@ -14,6 +14,29 @@ if [ -f /usr/share/clash/core_down_complete ];then
rm -rf /usr/share/clash/core_down_complete 2>/dev/null
fi
if [ $CORETYPE -eq 3 ];then
if [ -f /usr/share/clash/download_tun_version ];then
rm -rf /usr/share/clash/download_tun_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_clashtun_core_version=`wget -qO- "https://github.com/frainzy1477/clashtun/tags"| grep "/frainzy1477/clashtun/releases/tag/"| head -n 1| awk -F "/tag/v" '{print $2}'| sed 's/\">//'`
if [ $new_clashtun_core_version ]; then
echo $new_clashtun_core_version > /usr/share/clash/download_tun_version 2>&1 & >/dev/null
elif [ $new_clashtun_core_version =="" ]; then
echo 0 > /usr/share/clash/download_tun_version 2>&1 & >/dev/null
fi
sleep 8
if [ -f /usr/share/clash/download_tun_version ];then
CLASHTUN=$(sed -n 1p /usr/share/clash/download_tun_version 2>/dev/null)
fi
fi
if [ $CORETYPE -eq 2 ];then
if [ -f /usr/share/clash/download_corer_version ];then
rm -rf /usr/share/clash/download_corer_version
@ -68,6 +91,12 @@ fi
VERR=$(sed -n 1p /usr/share/clash/corer_version 2>/dev/null)
else
VERR=0
fi
if [ -f /usr/share/clash/tun_version ];then
VERS=$(sed -n 1p /usr/share/clash/tun_version 2>/dev/null)
else
VERS=0
fi
sleep 2
@ -85,6 +114,8 @@ update(){
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
elif [ $CORETYPE -eq 3 ];then
wget --no-check-certificate https://github.com/frainzy1477/clashtun/releases/download/v"$CLASHTUN"/clash-"$MODELTYPE".tar.gz -O 2>&1 >1 /tmp/clash.gz
fi
if [ "$?" -eq "0" ] && [ "$(ls -l /tmp/clash.gz |awk '{print int($5)}')" -ne 0 ]; then
@ -127,7 +158,20 @@ update(){
echo " ${LOGTIME} - Clashr内核更新成功" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - Clashr Core Update Successful" >>$LOG_FILE
fi
fi
elif [ $CORETYPE -eq 3 ];then
rm -rf /etc/clash/clashtun/clash >/dev/null 2>&1
mv /tmp/clash /etc/clash/clashtun/clash >/dev/null 2>&1
rm -rf /usr/share/clash/tun_version >/dev/null 2>&1
mv /usr/share/clash/download_tun_version /usr/share/clash/tun_version >/dev/null 2>&1
if [ $lang == "zh_cn" ];then
echo " ${LOGTIME} - ClashTun内核更新成功" >$LOG_FILE
elif [ $lang == "en" ] || [ $lang == "auto" ];then
echo " ${LOGTIME} - ClashTun Core Update Successful" >>$LOG_FILE
fi
fi
sleep 2
@ -155,6 +199,8 @@ update(){
if [ $CORETYPE -eq 1 ] && [ $VER != $CLASHVER ]; then
update
elif [ $CORETYPE -eq 2 ] && [ $VERR != $CLASHRVER ]; then
update
elif [ $CORETYPE -eq 2 ] && [ $VERS != $CLASHTUN ]; then
update
else
if [ $lang == "zh_cn" ];then

View File

@ -0,0 +1,11 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
name=$(uci get clash.config.config_cus_remove 2>/dev/null)
check_match_name=$(grep -F "$name" "/usr/share/clashbackup/create_list.conf")
line_no=$(grep -n "$check_match_name" /usr/share/clashbackup/create_list.conf |awk -F ':' '{print $1}')
if [ ! -z $check_match_name ];then
sed -i "${line_no}d" /usr/share/clashbackup/create_list.conf
rm -rf /usr/share/clash/config/custom/${name}
sed -i '/^$/d' /usr/share/clashbackup/create_list.conf
fi

View File

@ -1,4 +1,11 @@
Rule:
- DOMAIN-SUFFIX,netflix.com,🎬Netflix
- DOMAIN-SUFFIX,netflix.net,🎬Netflix
- DOMAIN-SUFFIX,nflxext.com,🎬Netflix
- DOMAIN-SUFFIX,nflximg.com,🎬Netflix
- DOMAIN-SUFFIX,nflximg.net,🎬Netflix
- DOMAIN-SUFFIX,nflxso.net,🎬Netflix
- DOMAIN-SUFFIX,nflxvideo.net,🎬Netflix
# (GlobalTV)
# > ABC
- DOMAIN-SUFFIX,edgedatg.com,📺GlobalTV
@ -80,14 +87,6 @@ Rule:
- DOMAIN-SUFFIX,mytvsuper.com,📺GlobalTV
- DOMAIN-SUFFIX,tvb.com,📺GlobalTV
# > Netflix
- DOMAIN-SUFFIX,netflix.com,📺GlobalTV
- DOMAIN-SUFFIX,netflix.net,📺GlobalTV
- DOMAIN-SUFFIX,nflxext.com,📺GlobalTV
- DOMAIN-SUFFIX,nflximg.com,📺GlobalTV
- DOMAIN-SUFFIX,nflximg.net,📺GlobalTV
- DOMAIN-SUFFIX,nflxso.net,📺GlobalTV
- DOMAIN-SUFFIX,nflxvideo.net,📺GlobalTV
# > Pandora
- DOMAIN-SUFFIX,pandora.com,📺GlobalTV
@ -132,9 +131,9 @@ Rule:
- DOMAIN-SUFFIX,api.mob.app.letv.com,🖥AsianTV
# > NeteaseMusic
- DOMAIN-SUFFIX,163yun.com,DIRECT
- DOMAIN-SUFFIX,music.126.net,DIRECT
- DOMAIN-SUFFIX,music.163.com,DIRECT
- DOMAIN-SUFFIX,163yun.com,🖥AsianTV
- DOMAIN-SUFFIX,music.126.net,🖥AsianTV
- DOMAIN-SUFFIX,music.163.com,🖥AsianTV
# > Tencent Video
- DOMAIN-SUFFIX,vv.video.qq.com,🖥AsianTV
@ -144,7 +143,7 @@ Rule:
- DOMAIN,analytics.google.com,🔑Proxy
- DOMAIN,analyticsinsights-pa.googleapis.com,🔑Proxy
- DOMAIN,analyticsreporting.googleapis.com,🔑Proxy
- DOMAIN-SUFFIX,vd.l.qq.com,DIRECT
- DOMAIN-SUFFIX,vd.l.qq.com,🖥AsianTV
# > General
- DOMAIN-KEYWORD,adservice,❌AdBlock
- DOMAIN-KEYWORD,analytics,❌AdBlock
@ -766,189 +765,191 @@ Rule:
# China Area Network
# > App Store Download || iBooks Sample
- DOMAIN-SUFFIX,itunes.apple.com,🔑Proxy
- DOMAIN-SUFFIX,itunes.apple.com,🖥AsianTV
# > Apple Music
- DOMAIN,aod.itunes.apple.com,🔑Proxy
- DOMAIN,audio.itunes.apple.com,🔑Proxy
- DOMAIN,audio-ssl.itunes.apple.com,🔑Proxy
- DOMAIN,streamingaudio.itunes.apple.com,🔑Proxy
- DOMAIN,aod.itunes.apple.com,🖥AsianTV
- DOMAIN,audio.itunes.apple.com,🖥AsianTV
- DOMAIN,audio-ssl.itunes.apple.com,🖥AsianTV
- DOMAIN,streamingaudio.itunes.apple.com,🖥AsianTV
# > Apple TV
- DOMAIN,ocvideo.apple.com,🔑Proxy
- DOMAIN,ocvideo.apple.com,🖥AsianTV
# > Apple News and Apple Map TOMTOM Version
- DOMAIN,gspe1-ssl.ls.apple.com,🔑Proxy
- DOMAIN,gspe1-ssl.ls.apple.com,🖥AsianTV
#PROCESS-NAME,News,🔑Proxy
#USER-AGENT,AppleNews*,🔑Proxy
# > Apple
- DOMAIN-SUFFIX,aaplimg.com,🔑Proxy
- DOMAIN-SUFFIX,apple.co,DIRECT
- DOMAIN-SUFFIX,apple.com,DIRECT
- DOMAIN-SUFFIX,appstore.com,DIRECT
- DOMAIN-SUFFIX,cdn-apple.com,🔑Proxy
- DOMAIN-SUFFIX,crashlytics.com,DIRECT
- DOMAIN-SUFFIX,icloud.com,DIRECT
- DOMAIN-SUFFIX,icloud-content.com,🔑Proxy
- DOMAIN-SUFFIX,me.com,DIRECT
- DOMAIN-SUFFIX,mzstatic.com,DIRECT
- DOMAIN-SUFFIX,aaplimg.com,🖥AsianTV
- DOMAIN-SUFFIX,apple.co,🖥AsianTV
- DOMAIN-SUFFIX,apple.com,🖥AsianTV
- DOMAIN-SUFFIX,appstore.com,🖥AsianTV
- DOMAIN-SUFFIX,cdn-apple.com,🖥AsianTV
- DOMAIN-SUFFIX,crashlytics.com,🖥AsianTV
- DOMAIN-SUFFIX,icloud.com,🖥AsianTV
- DOMAIN-SUFFIX,icloud-content.com,🖥AsianTV
- DOMAIN-SUFFIX,me.com,🖥AsianTV
- DOMAIN-SUFFIX,mzstatic.com,🖥AsianTV
# > Microsoft
- DOMAIN-SUFFIX,microsoft.com,DIRECT
- DOMAIN-SUFFIX,windows.net,DIRECT
- DOMAIN-SUFFIX,sfx.ms,DIRECT
- DOMAIN-SUFFIX,sharepoint.com,DIRECT
- DOMAIN-KEYWORD,officecdn,DIRECT
- DOMAIN-SUFFIX,microsoft.com,🖥AsianTV
- DOMAIN-SUFFIX,windows.net,🖥AsianTV
- DOMAIN-SUFFIX,sfx.ms,🖥AsianTV
- DOMAIN-SUFFIX,sharepoint.com,🖥AsianTV
- DOMAIN-KEYWORD,officecdn,🖥AsianTV
# > Blizzard
- DOMAIN-SUFFIX,blizzard.com,DIRECT
- DOMAIN-SUFFIX,battle.net,DIRECT
- DOMAIN,blzddist1-a.akamaihd.net,DIRECT
- DOMAIN-SUFFIX,blizzard.com,🖥AsianTV
- DOMAIN-SUFFIX,battle.net,🖥AsianTV
- DOMAIN,blzddist1-a.akamaihd.net,🖥AsianTV
# > Steam
- DOMAIN-SUFFIX,steampowered.com,DIRECT
- DOMAIN-SUFFIX,steam-chat.com,DIRECT
- DOMAIN-KEYWORD,steamcdn,DIRECT
- DOMAIN-KEYWORD,steamstore,DIRECT
- DOMAIN-KEYWORD,steamuserimages,DIRECT
- DOMAIN-KEYWORD,steambroadcast,DIRECT
- DOMAIN-SUFFIX,steampowered.com,🖥AsianTV
- DOMAIN-SUFFIX,steam-chat.com,🖥AsianTV
- DOMAIN-KEYWORD,steamcdn,🖥AsianTV
- DOMAIN-KEYWORD,steamstore,🖥AsianTV
- DOMAIN-KEYWORD,steamuserimages,🖥AsianTV
- DOMAIN-KEYWORD,steambroadcast,🖥AsianTV
# > Tencent
#USER-AGENT,MicroMessenger%20Client,DIRECT
#USER-AGENT,WeChat*,DIRECT
- DOMAIN-SUFFIX,qq.com,DIRECT
- DOMAIN-SUFFIX,qpic.cn,DIRECT
- DOMAIN-SUFFIX,tencent.com,DIRECT
#USER-AGENT,MicroMessenger%20Client,🖥AsianTV
#USER-AGENT,WeChat*,🖥AsianTV
- DOMAIN-SUFFIX,qq.com,🖥AsianTV
- DOMAIN-SUFFIX,qpic.cn,🖥AsianTV
- DOMAIN-SUFFIX,tencent.com,🖥AsianTV
# > Alibaba
- DOMAIN-SUFFIX,alibaba.com,DIRECT
- DOMAIN-SUFFIX,alicdn.com,DIRECT
- DOMAIN-SUFFIX,amap.com,DIRECT
- DOMAIN-SUFFIX,dingtalk.com,DIRECT
- DOMAIN-SUFFIX,taobao.com,DIRECT
- DOMAIN-SUFFIX,tmall.com,DIRECT
- DOMAIN-SUFFIX,ykimg.com,DIRECT
- DOMAIN-SUFFIX,youku.com,DIRECT
- DOMAIN-SUFFIX,xiami.com,DIRECT
- DOMAIN-SUFFIX,xiami.net,DIRECT
- DOMAIN-SUFFIX,alibaba.com,🖥AsianTV
- DOMAIN-SUFFIX,alicdn.com,🖥AsianTV
- DOMAIN-SUFFIX,amap.com,🖥AsianTV
- DOMAIN-SUFFIX,dingtalk.com,🖥AsianTV
- DOMAIN-SUFFIX,taobao.com,🖥AsianTV
- DOMAIN-SUFFIX,tmall.com,🖥AsianTV
- DOMAIN-SUFFIX,ykimg.com,🖥AsianTV
- DOMAIN-SUFFIX,youku.com,🖥AsianTV
- DOMAIN-SUFFIX,xiami.com,🖥AsianTV
- DOMAIN-SUFFIX,xiami.net,🖥AsianTV
# > NetEase
- DOMAIN-SUFFIX,163.com,DIRECT
- DOMAIN-SUFFIX,126.net,DIRECT
- DOMAIN-SUFFIX,163yun.com,DIRECT
- DOMAIN-SUFFIX,163.com,🖥AsianTV
- DOMAIN-SUFFIX,126.net,🖥AsianTV
- DOMAIN-SUFFIX,163yun.com,🖥AsianTV
# > Sohu
- DOMAIN-SUFFIX,sohu.com.cn,DIRECT
- DOMAIN-SUFFIX,itc.cn,DIRECT
- DOMAIN-SUFFIX,sohu.com,DIRECT
- DOMAIN-SUFFIX,v-56.com,DIRECT
- DOMAIN-SUFFIX,sohu.com.cn,🖥AsianTV
- DOMAIN-SUFFIX,itc.cn,🖥AsianTV
- DOMAIN-SUFFIX,sohu.com,🖥AsianTV
- DOMAIN-SUFFIX,v-56.com,🖥AsianTV
# > Sina
- DOMAIN-SUFFIX,weibo.com,DIRECT
- DOMAIN-SUFFIX,weibo.cn,DIRECT
- DOMAIN-SUFFIX,weibo.com,🖥AsianTV
- DOMAIN-SUFFIX,weibo.cn,🖥AsianTV
# > JD
- DOMAIN-SUFFIX,jd.com,DIRECT
- DOMAIN-SUFFIX,jd.hk,DIRECT
- DOMAIN-SUFFIX,360buyimg.com,DIRECT
- DOMAIN-SUFFIX,jd.com,🖥AsianTV
- DOMAIN-SUFFIX,jd.hk,🖥AsianTV
- DOMAIN-SUFFIX,360buyimg.com,🖥AsianTV
# > MI
- DOMAIN-SUFFIX,duokan.com,DIRECT
- DOMAIN-SUFFIX,mi-img.com,DIRECT
- DOMAIN-SUFFIX,mifile.cn,DIRECT
- DOMAIN-SUFFIX,xiaomi.com,DIRECT
- DOMAIN-SUFFIX,duokan.com,🖥AsianTV
- DOMAIN-SUFFIX,mi-img.com,🖥AsianTV
- DOMAIN-SUFFIX,mifile.cn,🖥AsianTV
- DOMAIN-SUFFIX,xiaomi.com,🖥AsianTV
# > bilibili
- DOMAIN-SUFFIX,acgvideo.com,DIRECT
- DOMAIN-SUFFIX,bilibili.com,DIRECT
- DOMAIN-SUFFIX,hdslb.com,DIRECT
- DOMAIN-SUFFIX,acgvideo.com,🖥AsianTV
- DOMAIN-SUFFIX,bilibili.com,🖥AsianTV
- DOMAIN-SUFFIX,hdslb.com,🖥AsianTV
# > iQiyi
- DOMAIN-SUFFIX,iqiyi.com,DIRECT
- DOMAIN-SUFFIX,iqiyipic.com,DIRECT
- DOMAIN-SUFFIX,71.am.com,DIRECT
- DOMAIN-SUFFIX,iqiyi.com,🖥AsianTV
- DOMAIN-SUFFIX,iqiyipic.com,🖥AsianTV
- DOMAIN-SUFFIX,71.am.com,🖥AsianTV
# > HunanTV
- DOMAIN-SUFFIX,hitv.com,DIRECT
- DOMAIN-SUFFIX,mgtv.com,DIRECT
- DOMAIN-SUFFIX,hitv.com,🖥AsianTV
- DOMAIN-SUFFIX,mgtv.com,🖥AsianTV
# > Meitu
- DOMAIN-SUFFIX,meitu.com,DIRECT
- DOMAIN-SUFFIX,meitudata.com,DIRECT
- DOMAIN-SUFFIX,meipai.com,DIRECT
- DOMAIN-SUFFIX,meitu.com,🖥AsianTV
- DOMAIN-SUFFIX,meitudata.com,🖥AsianTV
- DOMAIN-SUFFIX,meipai.com,🖥AsianTV
# > YYeTs
- DOMAIN-SUFFIX,zmzapi.com,DIRECT
- DOMAIN-SUFFIX,zimuzu.tv,DIRECT
- DOMAIN-SUFFIX,zmzfile.com,DIRECT
- DOMAIN-SUFFIX,zmzapi.net,DIRECT
- DOMAIN-SUFFIX,zmzapi.com,🖥AsianTV
- DOMAIN-SUFFIX,zimuzu.tv,🖥AsianTV
- DOMAIN-SUFFIX,zmzfile.com,🖥AsianTV
- DOMAIN-SUFFIX,zmzapi.net,🖥AsianTV
# > 蛋蛋赞
- DOMAIN-SUFFIX,baduziyuan.com,DIRECT
- DOMAIN-SUFFIX,com-hs-hkdy.com,DIRECT
- DOMAIN-SUFFIX,czybjz.com,DIRECT
- DOMAIN-SUFFIX,dandanzan.com,DIRECT
- DOMAIN-SUFFIX,fjhps.com,DIRECT
- DOMAIN-SUFFIX,kuyunbo.club,DIRECT
- DOMAIN-SUFFIX,baduziyuan.com,🖥AsianTV
- DOMAIN-SUFFIX,com-hs-hkdy.com,🖥AsianTV
- DOMAIN-SUFFIX,czybjz.com,🖥AsianTV
- DOMAIN-SUFFIX,dandanzan.com,🖥AsianTV
- DOMAIN-SUFFIX,fjhps.com,🖥AsianTV
- DOMAIN-SUFFIX,kuyunbo.club,🖥AsianTV
# > Baidu
- DOMAIN-SUFFIX,baidu.com,DIRECT
- DOMAIN-SUFFIX,baidubcr.com,DIRECT
- DOMAIN-SUFFIX,bdstatic.com,DIRECT
- DOMAIN-SUFFIX,baidu.com,🖥AsianTV
- DOMAIN-SUFFIX,baidubcr.com,🖥AsianTV
- DOMAIN-SUFFIX,bdstatic.com,🖥AsianTV
# > ChinaNet
- DOMAIN-SUFFIX,189.cn,DIRECT
- DOMAIN-SUFFIX,21cn.com,DIRECT
- DOMAIN-SUFFIX,189.cn,🖥AsianTV
- DOMAIN-SUFFIX,21cn.com,🖥AsianTV
# > ByteDance
- DOMAIN-SUFFIX,bytecdn.cn,DIRECT
- DOMAIN-SUFFIX,pstatp.com,DIRECT
- DOMAIN-SUFFIX,snssdk.com,DIRECT
- DOMAIN-SUFFIX,toutiao.com,DIRECT
- DOMAIN-SUFFIX,bytecdn.cn,🖥AsianTV
- DOMAIN-SUFFIX,pstatp.com,🖥AsianTV
- DOMAIN-SUFFIX,snssdk.com,🖥AsianTV
- DOMAIN-SUFFIX,toutiao.com,🖥AsianTV
# > Content Delivery Network
# > Akamai
- DOMAIN-SUFFIX,akadns.net,DIRECT
# - DOMAIN-SUFFIX,akamai.net,DIRECT
# - DOMAIN-SUFFIX,akamaiedge.net,DIRECT
# - DOMAIN-SUFFIX,akamaihd.net,DIRECT
# - DOMAIN-SUFFIX,akamaistream.net,DIRECT
# - DOMAIN-SUFFIX,akamaized.net,DIRECT
- DOMAIN-SUFFIX,akadns.net,🖥AsianTV
# - DOMAIN-SUFFIX,akamai.net,🖥AsianTV
# - DOMAIN-SUFFIX,akamaiedge.net,🖥AsianTV
# - DOMAIN-SUFFIX,akamaihd.net,🖥AsianTV
# - DOMAIN-SUFFIX,akamaistream.net,🖥AsianTV
# - DOMAIN-SUFFIX,akamaized.net,🖥AsianTV
# > ChinaNetCenter
- DOMAIN-SUFFIX,chinanetcenter.com,DIRECT
- DOMAIN-SUFFIX,wangsu.com,DIRECT
- DOMAIN-SUFFIX,chinanetcenter.com,🖥AsianTV
- DOMAIN-SUFFIX,wangsu.com,🖥AsianTV
# > CloudFlare
- DOMAIN-SUFFIX,cloudflare.com,DIRECT
- DOMAIN-SUFFIX,cloudflare.com,🔑Proxy
- DOMAIN-KEYWORD,cloudflare,🔑Proxy
# > IP Query
- DOMAIN-SUFFIX,ipip.net,DIRECT
- DOMAIN-SUFFIX,ip.cn,DIRECT
- DOMAIN-SUFFIX,ip.la,DIRECT
- DOMAIN-SUFFIX,ip-cdn.com,DIRECT
- DOMAIN-SUFFIX,ipv6-test.com,DIRECT
- DOMAIN-SUFFIX,test-ipv6.com,DIRECT
- DOMAIN-SUFFIX,whatismyip.com,DIRECT
- DOMAIN,ip.bjango.com,DIRECT
- DOMAIN-SUFFIX,ipip.net,🖥AsianTV
- DOMAIN-SUFFIX,ip.cn,🖥AsianTV
- DOMAIN-SUFFIX,ip.la,🖥AsianTV
- DOMAIN-SUFFIX,ip-cdn.com,🖥AsianTV
- DOMAIN-SUFFIX,ipv6-test.com,🖥AsianTV
- DOMAIN-SUFFIX,test-ipv6.com,🖥AsianTV
- DOMAIN-SUFFIX,whatismyip.com,🖥AsianTV
- DOMAIN,ip.bjango.com,🖥AsianTV
# > Other
- DOMAIN-SUFFIX,40017.cn,DIRECT
- DOMAIN-SUFFIX,cailianpress.com,DIRECT
- DOMAIN-SUFFIX,chdbits.co,DIRECT
- DOMAIN-SUFFIX,chushou.tv,DIRECT
- DOMAIN-SUFFIX,cmbchina.com,DIRECT
- DOMAIN-SUFFIX,cmbimg.com,DIRECT
- DOMAIN-SUFFIX,cmct.tv,DIRECT
- DOMAIN-SUFFIX,cmvideo.cn,DIRECT
- DOMAIN-SUFFIX,cnlang.org,DIRECT
- DOMAIN-SUFFIX,doubanio.com,DIRECT
- DOMAIN-SUFFIX,douyu.com,DIRECT
- DOMAIN-SUFFIX,douyucdn.cn,DIRECT
- DOMAIN-SUFFIX,dxycdn.com,DIRECT
- DOMAIN-SUFFIX,hicloud.com,DIRECT
- DOMAIN-SUFFIX,hdchina.org,DIRECT
- DOMAIN-SUFFIX,hdcmct.org,DIRECT
- DOMAIN-SUFFIX,ithome.com,DIRECT
- DOMAIN-SUFFIX,kkmh.com,DIRECT
- DOMAIN-SUFFIX,ksosoft.com,DIRECT
- DOMAIN-SUFFIX,maoyun.tv,DIRECT
- DOMAIN-SUFFIX,meituan.net,DIRECT
- DOMAIN-SUFFIX,mobike.com,DIRECT
- DOMAIN-SUFFIX,mubu.com,DIRECT
- DOMAIN-SUFFIX,myzaker.com,DIRECT
- DOMAIN-SUFFIX,ourbits.club,DIRECT
- DOMAIN-SUFFIX,passthepopcorn.me,DIRECT
- DOMAIN-SUFFIX,paypal.com,DIRECT
- DOMAIN-SUFFIX,paypalobjects.com,DIRECT
- DOMAIN-SUFFIX,privatehd.to,DIRECT
- DOMAIN-SUFFIX,redacted.ch,DIRECT
- DOMAIN-SUFFIX,ruguoapp.com,DIRECT
- DOMAIN-SUFFIX,smzdm.com,DIRECT
- DOMAIN-SUFFIX,sogou.com,DIRECT
- DOMAIN-SUFFIX,teamviewer.com,DIRECT
- DOMAIN-SUFFIX,totheglory.im,DIRECT
- DOMAIN-SUFFIX,tp.m-team.cc,DIRECT
- DOMAIN-SUFFIX,udacity.com,DIRECT
- DOMAIN-SUFFIX,xmcdn.com,DIRECT
- DOMAIN-SUFFIX,yangkeduo.com,DIRECT
- DOMAIN-SUFFIX,zhihu.com,DIRECT
- DOMAIN-SUFFIX,zhimg.com,DIRECT
#USER-AGENT,NeteaseMusic*,DIRECT
#USER-AGENT,%E7%BD%91%E6%98%93%E4%BA%91%E9%9F%B3%E4%B9%90*,DIRECT
- DOMAIN-SUFFIX,40017.cn,🖥AsianTV
- DOMAIN-SUFFIX,cailianpress.com,🖥AsianTV
- DOMAIN-SUFFIX,chdbits.co,🖥AsianTV
- DOMAIN-SUFFIX,chushou.tv,🖥AsianTV
- DOMAIN-SUFFIX,cmbchina.com,🖥AsianTV
- DOMAIN-SUFFIX,cmbimg.com,🖥AsianTV
- DOMAIN-SUFFIX,cmct.tv,🖥AsianTV
- DOMAIN-SUFFIX,cmvideo.cn,🖥AsianTV
- DOMAIN-SUFFIX,cnlang.org,🖥AsianTV
- DOMAIN-SUFFIX,doubanio.com,🖥AsianTV
- DOMAIN-SUFFIX,douyu.com,🖥AsianTV
- DOMAIN-SUFFIX,douyucdn.cn,🖥AsianTV
- DOMAIN-SUFFIX,dxycdn.com,🖥AsianTV
- DOMAIN-SUFFIX,hicloud.com,🖥AsianTV
- DOMAIN-SUFFIX,hdchina.org,🖥AsianTV
- DOMAIN-SUFFIX,hdcmct.org,🖥AsianTV
- DOMAIN-SUFFIX,ithome.com,🖥AsianTV
- DOMAIN-SUFFIX,kkmh.com,🖥AsianTV
- DOMAIN-SUFFIX,ksosoft.com,🖥AsianTV
- DOMAIN-SUFFIX,maoyun.tv,🖥AsianTV
- DOMAIN-SUFFIX,meituan.net,🖥AsianTV
- DOMAIN-SUFFIX,mobike.com,🖥AsianTV
- DOMAIN-SUFFIX,mubu.com,🖥AsianTV
- DOMAIN-SUFFIX,myzaker.com,🖥AsianTV
- DOMAIN-SUFFIX,ourbits.club,🖥AsianTV
- DOMAIN-SUFFIX,passthepopcorn.me,🖥AsianTV
- DOMAIN-SUFFIX,paypal.com,🔑Proxy
- DOMAIN-KEYWORD,paypal,🔑Proxy
- DOMAIN-SUFFIX,paypalobjects.com,🔑Proxy
- DOMAIN-SUFFIX,privatehd.to,🖥AsianTV
- DOMAIN-SUFFIX,redacted.ch,🖥AsianTV
- DOMAIN-SUFFIX,ruguoapp.com,🖥AsianTV
- DOMAIN-SUFFIX,smzdm.com,🖥AsianTV
- DOMAIN-SUFFIX,sogou.com,🖥AsianTV
- DOMAIN-SUFFIX,teamviewer.com,🖥AsianTV
- DOMAIN-SUFFIX,totheglory.im,🖥AsianTV
- DOMAIN-SUFFIX,tp.m-team.cc,🖥AsianTV
- DOMAIN-SUFFIX,udacity.com,🖥AsianTV
- DOMAIN-SUFFIX,xmcdn.com,🖥AsianTV
- DOMAIN-SUFFIX,yangkeduo.com,🖥AsianTV
- DOMAIN-SUFFIX,zhihu.com,🖥AsianTV
- DOMAIN-SUFFIX,zhimg.com,🖥AsianTV
#USER-AGENT,NeteaseMusic*,🖥AsianTV
#USER-AGENT,%E7%BD%91%E6%98%93%E4%BA%91%E9%9F%B3%E4%B9%90*,🖥AsianTV
# (DNS Cache Pollution Protection)
# > Google
@ -1108,8 +1109,6 @@ 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
@ -1256,20 +1255,33 @@ Rule:
# (The Most Popular Sites)
# > Apple
# > Apple URL Shortener
- DOMAIN-SUFFIX,appsto.re,🔑Proxy
- DOMAIN-SUFFIX,appsto.re,🖥AsianTV
# > TestFlight
- DOMAIN,beta.itunes.apple.com,🔑Proxy
- DOMAIN,beta.itunes.apple.com,🖥AsianTV
# > iBooks Store download
- DOMAIN,books.itunes.apple.com,🔑Proxy
- DOMAIN,books.itunes.apple.com,🖥AsianTV
# > iTunes Store Moveis Trailers
- DOMAIN,hls.itunes.apple.com,🔑Proxy
- DOMAIN,hls.itunes.apple.com,🖥AsianTV
# App Store Preview
- DOMAIN,itunes.apple.com,🔑Proxy
- DOMAIN,itunes.apple.com,🖥AsianTV
# > Spotlight
- DOMAIN,api-glb-sea.smoot.apple.com,🔑Proxy
- DOMAIN,api-glb-sea.smoot.apple.com,🖥AsianTV
# > Dictionary
- DOMAIN,lookup-api.apple.com,🔑Proxy
- DOMAIN,lookup-api.apple.com,🖥AsianTV
#PROCESS-NAME,LookupViewService,🔑Proxy
- DOMAIN,guzzoni.apple.com,🖥AsianTV
- DOMAIN-SUFFIX,aaplimg.com,🖥AsianTV
- DOMAIN-SUFFIX,apple.co,🖥AsianTV
- DOMAIN-SUFFIX,apple.com,🖥AsianTV
- DOMAIN-SUFFIX,apple-cloudkit.com,🖥AsianTV
- DOMAIN-SUFFIX,cdn-apple.com,🖥AsianTV
- DOMAIN-SUFFIX,icloud.com,🖥AsianTV
- DOMAIN-SUFFIX,icloud-content.com,🖥AsianTV
- DOMAIN-SUFFIX,itunes.apple.com,🖥AsianTV
- DOMAIN-SUFFIX,itunes.com,🖥AsianTV
- DOMAIN-SUFFIX,lookup-api.apple.com,🖥AsianTV
- DOMAIN-SUFFIX,me.com,🖥AsianTV
- DOMAIN-SUFFIX,mzstatic.com,🖥AsianTV
# > Google
- DOMAIN-SUFFIX,abc.xyz,🔑Proxy
- DOMAIN-SUFFIX,android.com,🔑Proxy
@ -1377,16 +1389,16 @@ Rule:
- DOMAIN-SUFFIX,dler.cloud,🔑Proxy
# Local Area Network
- DOMAIN-KEYWORD,announce,DIRECT
- DOMAIN-KEYWORD,torrent,DIRECT
- DOMAIN-KEYWORD,tracker,DIRECT
- DOMAIN-SUFFIX,smtp,DIRECT
- DOMAIN-SUFFIX,local,DIRECT
- IP-CIDR,192.168.0.0/16,DIRECT
- IP-CIDR,10.0.0.0/8,DIRECT
- IP-CIDR,172.16.0.0/12,DIRECT
- IP-CIDR,127.0.0.0/8,DIRECT
- IP-CIDR,100.64.0.0/10,DIRECT
- DOMAIN-KEYWORD,announce,🖥AsianTV
- DOMAIN-KEYWORD,torrent,🖥AsianTV
- DOMAIN-KEYWORD,tracker,🖥AsianTV
- DOMAIN-SUFFIX,smtp,🖥AsianTV
- DOMAIN-SUFFIX,local,🖥AsianTV
- IP-CIDR,192.168.0.0/16,🖥AsianTV
- IP-CIDR,10.0.0.0/8,🖥AsianTV
- IP-CIDR,172.16.0.0/12,🖥AsianTV
- IP-CIDR,127.0.0.0/8,🖥AsianTV
- IP-CIDR,100.64.0.0/10,🖥AsianTV
# (🖥AsianTV)
# > Bilibili
@ -1508,9 +1520,26 @@ 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
# > CloudFlare
- IP-CIDR,173.245.48.0/20,🔑Proxy
- IP-CIDR,103.21.244.0/22,🔑Proxy
- IP-CIDR,103.22.200.0/22,🔑Proxy
- IP-CIDR,103.31.4.0/22,🔑Proxy
- IP-CIDR,141.101.64.0/18,🔑Proxy
- IP-CIDR,108.162.192.0/18,🔑Proxy
- IP-CIDR,190.93.240.0/20,🔑Proxy
- IP-CIDR,188.114.96.0/20,🔑Proxy
- IP-CIDR,197.234.240.0/22,🔑Proxy
- IP-CIDR,198.41.128.0/17,🔑Proxy
- IP-CIDR,162.158.0.0/15,🔑Proxy
- IP-CIDR,104.16.0.0/12,🔑Proxy
- IP-CIDR,172.64.0.0/13,🔑Proxy
- IP-CIDR,131.0.72.0/22,🔑Proxy
#- DST-PORT,80,🖥AsianTV
#- DST-PORT,443,🖥AsianTV
# GeoIP China
- GEOIP,CN,🖥AsianTV
- GEOIP,CN,DIRECT
- MATCH,🔑Proxy

View File

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

View File

@ -0,0 +1,69 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
GROUP_FILE="/tmp/yaml_group.yaml"
GAME_RULE_FILE="/tmp/yaml_game_rule_group.yaml"
CLASH_CONFIG="/etc/clash/config.yaml"
game_rules=$(uci get clash.config.g_rules 2>/dev/null)
if [ "${game_rules}" -eq 1 ];then
get_rule_file()
{
if [ -z "$1" ]; then
return
fi
GAME_RULE_FILE_NAME=$(grep -F $1 /usr/share/clash/rules/rules.list |awk -F ',' '{print $3}' 2>/dev/null)
if [ -z "$GAME_RULE_FILE_NAME" ]; then
GAME_RULE_FILE_NAME=$(grep -F $1 /usr/share/clash/rules/rules.list |awk -F ',' '{print $2}' 2>/dev/null)
fi
GAME_RULE_PATH="/usr/share/clash/rules/g_rules/$GAME_RULE_FILE_NAME"
sed '/^#/d' $GAME_RULE_PATH 2>/dev/null |sed '/^ *$/d' |awk '{print "- IP-CIDR,"$0}' |awk -v tag="$2" '{print $0","'tag'""}' >> $GAME_RULE_FILE 2>/dev/null
set_rule_file=1
}
yml_game_rule_get()
{
local section="$1"
config_get "group" "$section" "group" ""
if [ -f $GAME_RULE_FILE ];then
rm -rf $GAME_RULE_FILE 2>/dev/null
fi
if [ -z "$group" ]; then
return
fi
config_list_foreach "$section" "rule_name" get_rule_file "$group"
}
config_load "clash"
config_foreach yml_game_rule_get "game"
if [ -f $GAME_RULE_FILE ];then
sed -i -e "\$a#*******GAME-RULE-END**********#" $GAME_RULE_FILE 2>/dev/null
sed -i '#*******GAME-RULE-START**********#/,/#*******GAME-RULE-END**********#/d' "$CLASH_CONFIG" 2>/dev/null
if [ ! -z "$(grep "^ \{0,\}- GEOIP" "/etc/clash/config.yaml")" ]; then
sed -i '1,/^ \{0,\}- GEOIP,/{/^ \{0,\}- GEOIP,/s/^ \{0,\}- GEOIP,/#*******GAME-RULE-START**********#\n&/}' "$CLASH_CONFIG" 2>/dev/null
elif [ ! -z "$(grep "^ \{0,\}- MATCH," "$RULE_FILE")" ]; then
sed -i '1,/^ \{0,\}- MATCH,/{/^ \{0,\}- MATCH,/s/^ \{0,\}- MATCH,/#*******GAME-RULE-START**********#\n&/}' "$CLASH_CONFIG" 2>/dev/null
else
echo "#*******GAME RULE START**********#" >> "$CLASH_CONFIG" 2>/dev/null
fi
sed -i '/GAME-RULE-START/r/tmp/yaml_game_rule_group.yaml' "$CLASH_CONFIG" 2>/dev/null
fi
else
sed -i '#*******GAME-RULE-START**********#/,/#*******GAME-RULE-END**********#/d' "$CLASH_CONFIG" 2>/dev/null
fi

View File

@ -9,9 +9,9 @@ load_from=$(uci get clash.config.loadfrom 2>/dev/null)
run_load(){
if [ "$load_from" == "sub" ];then
load="/usr/share/clash/config/sub/config.yaml"
load=$(uci get clash.config.config_path_sub 2>/dev/null)
elif [ "$load_from" == "upl" ];then
load="/usr/share/clash/config/upload/config.yaml"
load=$(uci get clash.config.config_path_up 2>/dev/null)
fi

View File

@ -0,0 +1,185 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
lang=$(uci get luci.main.lang 2>/dev/null)
load="/etc/clash/config.yaml"
config_type=$(uci get clash.config.config_type 2>/dev/null)
CONFIG_YAML_SUB=$(uci get clash.config.config_path_sub 2>/dev/null)
CONFIG_YAML_UPL=$(uci get clash.config.config_path_up 2>/dev/null)
CONFIG_YAML_CUS=$(uci get clash.config.config_path_cus 2>/dev/null)
if [ ! -f $load ] || [ "$(ls -l $load|awk '{print int($5)}')" -eq 0 ];then
if [ $config_type == "1" ];then
if [ -f $CONFIG_YAML_SUB ] && [ "$(ls -l $CONFIG_YAML_SUB|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_SUB $load 2>/dev/null
fi
elif [ $config_type == "2" ];then
if [ -f $CONFIG_YAML_UPL ] && [ "$(ls -l $CONFIG_YAML_UPL|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_UPL $load 2>/dev/null
fi
elif [ $config_type == "3" ];then
if [ -f $CONFIG_YAML_CUS ] && [ "$(ls -l $CONFIG_YAML_CUS|awk '{print int($5)}')" -ne 0 ];then
cp $CONFIG_YAML_CUS $load 2>/dev/null
fi
fi
fi
if [ ! -f $load ] || [ "$(ls -l $load|awk '{print int($5)}')" -eq 0 ]; then
exit 0
fi
CFG_FILE="/etc/config/clash"
REAL_LOG="/usr/share/clash/clash_real.txt"
rm -rf /tmp/Proxy_Group /tmp/group_*.yaml /tmp/yaml_group.yaml 2>/dev/null
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
[ ! -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-provider':" "$load")" ] || [ ! -z "$(grep '^ \{0,\}"proxy-provider":' "$load")" ] && {
sed -i "/^ \{0,\}\'proxy-provider\:'/c\proxy-provider:" "$load"
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$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"
}
group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$load" 2>/dev/null)
provider_len=$(sed -n '/^ \{0,\}proxy-provider:/=' "$load" 2>/dev/null)
if [ "$provider_len" -ge "$group_len" ]; then
awk '/Proxy:/,/proxy-provider:/{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
sed -i "s/proxy-provider://g" /tmp/Proxy_Group 2>&1
else
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
fi
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
group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$load" 2>/dev/null)
provider_len=$(sed -n '/^ \{0,\}proxy-provider:/=' "$load" 2>/dev/null)
if [ "$provider_len" -ge "$group_len" ]; then
awk '/Proxy Group:/,/proxy-provider:/{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
sed -i "s/proxy-provider://g" /tmp/yaml_group.yaml 2>&1
else
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
fi
#######READ GROUPS START
if [ -f /tmp/yaml_group.yaml ];then
while [[ "$( grep -c "config conf_groups" $CFG_FILE )" -ne 0 ]]
do
uci delete clash.@conf_groups[0] && uci commit clash >/dev/null 2>&1
done
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
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 conf_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}type="$group_type"
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/Proxy_Group /tmp/group_*.yaml /tmp/yaml_group.yaml 2>/dev/null
fi
#######READ GROUPS END

View File

@ -1,19 +1,50 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
create_config(){
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)
create=$(uci get clash.config.create 2>/dev/null)
load_from=$(uci get clash.config.loadfrom 2>/dev/null)
load_from=$(uci get clash.config.loadfrom 2>/dev/null)
config_name=$(uci get clash.config.create_tag 2>/dev/null)
CONFIG_YAML="/usr/share/clash/config/custom/${config_name}.yaml"
check_name=$(grep -F "${config_name}.yaml" "/usr/share/clashbackup/create_list.conf")
same_tag=$(uci get clash.config.same_tag 2>/dev/null)
if [ "$load_from" == "sub" ];then
load="/usr/share/clash/config/sub/config.yaml"
if [ $config_name == "" ] || [ -z $config_name ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Tag Your Config" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "标记您的配置" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
fi
if [ ! -z $check_name ] && [ "${same_tag}" -eq 0 ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Config with same name exist, please rename tag and create again" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "已存在同名配置,请重命名标记,重新创建配置" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
else
if [ "$load_from" == "sub" ];then
load=$(uci get clash.config.config_path_sub 2>/dev/null)
elif [ "$load_from" == "upl" ];then
load="/usr/share/clash/config/upload/config.yaml"
load=$(uci get clash.config.config_path_up 2>/dev/null)
fi
if [ "${create}" -eq 1 ];then
@ -28,7 +59,6 @@ if [ "${create}" -eq 1 ];then
CONFIG_YAML_RULE="/usr/share/clash/custom_rule.yaml"
SERVER_FILE="/tmp/servers.yaml"
CONFIG_YAML="/usr/share/clash/config/custom/config.yaml"
TEMP_FILE="/tmp/dns_temp.yaml"
Proxy_Group="/tmp/Proxy_Group"
GROUP_FILE="/tmp/groups.yaml"
@ -593,6 +623,12 @@ cat $TEMP_FILE $CONFIG_YAML_RULE > $CONFIG_YAML 2>/dev/null
sed -i "/Rule:/i\ " $CONFIG_YAML 2>/dev/null
if [ -z $check_name ] && [ "${same_tag}" -eq 1 ];then
echo "${config_name}.yaml" >>/usr/share/clashbackup/create_list.conf
elif [ -z $check_name ] && [ "${same_tag}" -eq 0 ];then
echo "${config_name}.yaml" >>/usr/share/clashbackup/create_list.conf
fi
rm -rf $TEMP_FILE $GROUP_FILE $Proxy_Group $CONFIG_FILE $PROVIDER_FILE
if [ $lang == "en" ] || [ $lang == "auto" ];then
@ -604,19 +640,9 @@ rm -rf $TEMP_FILE $GROUP_FILE $Proxy_Group $CONFIG_FILE $PROVIDER_FILE
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
fi
}
create_config >/dev/null 2>&1

View File

@ -0,0 +1,13 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
name=$(uci get clash.config.config_name_remove 2>/dev/null)
check_match_name=$(grep -F "$name" "/usr/share/clashbackup/confit_list.conf")
line_no=$(grep -n "$check_match_name" /usr/share/clashbackup/confit_list.conf |awk -F ':' '{print $1}')
if [ ! -z $check_match_name ];then
sed -i "${line_no}d" /usr/share/clashbackup/confit_list.conf
rm -rf /usr/share/clash/config/sub/${name}
sed -i '/^$/d' /usr/share/clashbackup/confit_list.conf
rm -rf /usr/share/clash/config/sub/${name}
fi

View File

@ -0,0 +1,949 @@
#Steam,Steam-社区(Beta),0,0,1,0,0,0,By-FQrabbit
2.16.4.0/24
2.16.10.0/24
2.16.17.0/24
2.16.21.0/24
2.16.39.0/24
2.16.59.0/24
2.16.82.0/24
2.16.95.0/24
2.16.104.0/23
2.16.111.0/24
2.17.55.0/24
2.17.98.0/24
2.17.191.0/24
2.18.119.0/24
2.18.152.0/24
2.18.199.0/24
2.19.131.0/24
2.19.147.0/24
2.19.225.0/24
2.20.57.0/24
2.20.166.0/24
2.20.177.0/24
2.20.200.0/24
2.20.214.0/24
2.21.31.0/24
2.21.46.0/24
2.21.75.0/24
2.21.131.0/24
2.21.145.0/24
2.21.150.0/24
2.21.195.0/24
2.21.205.0/24
2.21.248.0/24
2.22.13.0/24
2.22.15.0/24
2.22.36.0/24
2.22.69.0/24
2.22.73.0/24
2.22.74.0/23
2.22.146.0/24
2.23.151.0/24
2.23.181.0/24
8.7.198.0/24
14.21.78.0/24
23.0.7.0/24
23.0.21.0/24
23.0.83.0/24
23.0.146.0/24
23.0.168.0/24
23.0.178.0/24
23.0.232.0/24
23.0.252.0/24
23.1.15.0/24
23.1.26.0/24
23.1.45.0/24
23.1.227.0/24
23.2.8.0/24
23.2.11.0/24
23.2.16.0/24
23.2.18.0/24
23.2.29.0/24
23.2.42.0/24
23.2.59.0/24
23.2.92.0/24
23.2.204.0/24
23.2.206.0/24
23.3.244.0/24
23.4.168.0/24
23.4.251.0/24
23.5.114.0/24
23.5.117.0/24
23.5.156.0/24
23.5.170.0/24
23.5.241.0/24
23.5.242.0/24
23.7.39.0/24
23.7.80.0/24
23.7.128.0/24
23.7.199.0/24
23.7.246.0/24
23.8.12.0/24
23.8.117.0/24
23.8.229.0/24
23.9.9.0/24
23.9.154.0/24
23.10.0.0/16
23.11.202.0/24
23.11.204.0/24
23.11.225.0/24
23.11.236.0/24
23.12.34.0/24
23.12.109.0/24
23.12.227.0/24
23.12.229.0/24
23.13.147.0/24
23.14.6.0/24
23.14.10.0/24
23.14.68.0/24
23.14.77.0/24
23.14.85.0/24
23.14.222.0/24
23.14.229.0/24
23.15.4.0/24
23.15.81.0/24
23.15.91.0/24
23.15.94.0/24
23.15.98.0/23
23.15.184.0/24
23.15.187.0/24
23.15.224.0/24
23.32.17.0/24
23.32.86.0/24
23.32.113.0/24
23.32.131.0/24
23.32.163.0/24
23.32.215.0/24
23.32.216.0/24
23.32.248.0/24
23.32.254.0/24
23.33.75.0/24
23.33.88.0/24
23.33.112.0/24
23.33.168.0/24
23.33.255.0/24
23.34.60.0/24
23.34.65.0/24
23.34.75.0/24
23.35.225.0/24
23.35.230.0/24
23.36.26.0/24
23.36.105.0/24
23.36.141.0/24
23.36.148.0/24
23.36.165.0/24
23.36.216.0/24
23.36.220.0/24
23.36.230.0/23
23.37.53.0/24
23.37.58.0/24
23.37.67.0/24
23.37.147.0/24
23.37.148.0/24
23.37.237.0/24
23.37.239.0/24
23.37.242.0/23
23.37.249.0/24
23.37.250.0/24
23.38.3.0/24
23.38.77.0/24
23.38.109.0/24
23.38.153.0/24
23.38.155.0/24
23.38.166.0/24
23.39.136.0/24
23.40.1.0/24
23.40.4.0/24
23.40.31.0/24
23.40.247.0/24
23.41.5.0/24
23.41.59.0/24
23.41.102.0/24
23.41.132.0/24
23.41.149.0/24
23.41.165.0/24
23.41.243.0/24
23.42.6.0/24
23.42.69.0/24
23.42.83.0/24
23.42.165.0/24
23.42.212.0/24
23.42.232.0/24
23.42.248.0/24
23.43.0.0/16
23.44.193.0/24
23.45.96.0/24
23.45.201.0/24
23.46.18.0/24
23.46.24.0/24
23.46.104.0/24
23.46.241.0/24
23.47.0.0/16
23.48.4.0/24
23.48.219.0/24
23.49.4.0/24
23.49.119.0/24
23.49.135.0/24
23.49.148.0/24
23.49.224.0/24
23.50.18.0/24
23.50.37.0/24
23.50.43.0/24
23.50.69.0/24
23.50.168.0/24
23.51.39.0/24
23.51.122.0/24
23.51.131.0/24
23.51.134.0/23
23.51.154.0/24
23.51.240.0/24
23.51.246.0/24
23.52.37.0/24
23.52.51.0/24
23.52.74.0/24
23.52.82.0/24
23.52.86.0/24
23.53.33.0/24
23.53.73.0/24
23.53.195.0/24
23.54.176.0/24
23.54.179.0/24
23.54.199.0/24
23.54.247.0/24
23.54.248.0/24
23.54.250.0/24
23.55.48.0/24
23.55.53.0/24
23.55.60.0/24
23.55.139.0/24
23.55.235.0/24
23.56.115.0/24
23.56.208.0/24
23.57.32.0/24
23.57.64.0/23
23.57.230.0/24
23.57.251.0/24
23.58.0.0/24
23.58.27.0/24
23.58.36.0/24
23.58.41.0/24
23.58.75.0/24
23.58.80.0/24
23.58.154.0/24
23.59.57.0/24
23.59.96.0/24
23.59.117.0/24
23.60.41.0/24
23.60.48.0/24
23.60.123.0/24
23.60.131.0/24
23.61.10.0/24
23.61.74.0/24
23.61.161.0/24
23.62.53.0/24
23.62.102.0/24
23.62.109.0/24
23.62.145.0/24
23.62.152.0/24
23.63.11.0/24
23.63.22.0/24
23.63.32.0/24
23.63.219.0/24
23.63.228.0/24
23.64.22.0/24
23.64.34.0/24
23.64.37.0/24
23.64.38.0/24
23.64.127.0/24
23.64.158.0/24
23.64.178.0/24
23.65.80.0/24
23.65.190.0/24
23.65.225.0/24
23.66.0.0/16
23.67.65.0/24
23.67.67.0/24
23.67.69.0/24
23.67.72.0/24
23.67.76.0/24
23.67.130.0/24
23.67.161.0/24
23.67.200.0/24
23.67.204.0/24
23.67.217.0/24
23.72.20.0/24
23.72.36.0/24
23.72.58.0/24
23.72.80.0/24
23.72.92.0/24
23.72.138.0/24
23.72.156.0/24
23.72.226.0/24
23.72.250.0/24
23.73.29.0/24
23.73.77.0/24
23.73.85.0/24
23.73.137.0/24
23.73.139.0/24
23.73.144.0/24
23.73.153.0/24
23.73.168.0/24
23.73.170.0/24
23.73.199.0/24
23.73.206.0/24
23.74.15.0/24
23.74.17.0/24
23.74.57.0/24
23.74.60.0/24
23.74.138.0/24
23.74.162.0/24
23.74.170.0/24
23.74.237.0/24
23.75.12.0/24
23.75.14.0/24
23.75.30.0/24
23.75.186.0/24
23.75.210.0/24
23.75.212.0/24
23.75.216.0/23
23.76.253.0/24
23.77.32.0/24
23.77.202.0/24
23.77.208.0/24
23.77.214.0/24
23.78.23.0/24
23.78.39.0/24
23.78.54.0/24
23.78.86.0/24
23.78.117.0/24
23.78.168.0/24
23.79.15.0/24
23.79.19.0/24
23.79.68.0/24
23.192.26.0/24
23.192.38.0/24
23.192.114.0/24
23.192.116.0/24
23.192.126.0/24
23.192.168.0/24
23.192.245.0/24
23.193.64.0/24
23.193.162.0/24
23.193.168.0/24
23.193.171.0/24
23.193.175.0/24
23.194.66.0/24
23.194.88.0/24
23.194.212.0/24
23.194.216.0/24
23.196.4.0/24
23.196.56.0/24
23.196.199.0/24
23.196.214.0/24
23.196.244.0/24
23.197.49.0/24
23.198.97.0/24
23.198.108.0/24
23.198.121.0/24
23.198.213.0/24
23.198.214.0/24
23.199.7.0/24
23.199.10.0/24
23.199.67.0/24
23.199.134.0/24
23.199.138.0/24
23.199.149.0/24
23.199.152.0/24
23.199.154.0/24
23.199.207.0/24
23.199.232.0/24
23.199.234.0/24
23.199.242.0/24
23.199.248.0/24
23.200.18.0/24
23.200.26.0/24
23.200.94.0/24
23.200.103.0/24
23.200.140.0/24
23.201.23.0/24
23.201.41.0/24
23.201.103.0/24
23.201.254.0/24
23.202.39.0/24
23.202.69.0/24
23.202.70.0/24
23.202.83.0/24
23.202.117.0/24
23.202.124.0/24
23.202.128.0/24
23.202.139.0/24
23.202.143.0/24
23.203.26.0/23
23.203.50.0/24
23.203.52.0/24
23.203.62.0/24
23.203.84.0/24
23.203.132.0/24
23.203.255.0/24
23.204.36.0/24
23.204.104.0/23
23.204.148.0/24
23.204.239.0/24
23.205.26.0/24
23.205.35.0/24
23.205.132.0/24
23.205.140.0/24
23.205.226.0/24
23.206.10.0/24
23.206.13.0/24
23.206.35.0/24
23.206.51.0/24
23.206.66.0/24
23.206.90.0/24
23.206.95.0/24
23.206.112.0/24
23.206.126.0/24
23.206.169.0/24
23.206.192.0/24
23.206.197.0/24
23.206.198.0/24
23.206.211.0/24
23.206.239.0/24
23.206.246.0/24
23.207.179.0/24
23.208.28.0/24
23.208.34.0/24
23.208.36.0/24
23.208.102.0/24
23.208.123.0/24
23.208.136.0/24
23.208.138.0/24
23.208.215.0/24
23.208.228.0/24
23.208.235.0/24
23.209.75.0/24
23.209.184.0/24
23.210.0.0/24
23.210.3.0/24
23.210.203.0/24
23.211.16.0/24
23.211.40.0/24
23.211.56.0/24
23.211.106.0/24
23.211.140.0/24
23.211.150.0/24
23.211.152.0/24
23.212.53.0/24
23.212.110.0/24
23.212.141.0/24
23.212.171.0/24
23.213.53.0/24
23.213.55.0/24
23.213.138.0/24
23.213.158.0/24
23.213.176.0/24
23.214.27.0/24
23.214.43.0/24
23.214.51.0/24
23.214.66.0/24
23.214.74.0/24
23.214.102.0/23
23.214.116.0/24
23.214.165.0/24
23.214.172.0/24
23.215.0.0/24
23.215.52.0/24
23.215.57.0/24
23.215.105.0/24
23.215.130.0/24
23.216.8.0/24
23.216.202.0/24
23.217.43.0/24
23.217.106.0/24
23.217.143.0/24
23.217.226.0/24
23.218.40.0/24
23.218.144.0/24
23.218.158.0/24
23.218.215.0/24
23.219.212.0/24
23.220.38.0/24
23.220.46.0/24
23.220.181.0/24
23.220.195.0/24
23.220.206.0/24
23.221.3.0/24
23.221.17.0/24
23.221.45.0/24
23.221.46.0/24
23.221.66.0/24
23.221.154.0/24
23.222.27.0/24
23.222.61.0/24
23.222.132.0/24
23.222.161.0/24
23.222.172.0/24
23.222.195.0/24
23.223.65.0/24
23.223.75.0/24
23.223.99.0/24
31.13.0.0/16
37.10.124.0/24
45.121.186.0/24
46.82.0.0/16
59.24.0.0/16
60.254.131.0/24
60.254.171.0/24
61.213.168.0/24
63.146.69.0/24
63.219.254.0/24
63.243.244.0/24
64.13.0.0/16
65.158.114.0/24
66.220.0.0/16
67.15.0.0/16
67.131.44.0/24
67.228.0.0/16
69.16.175.0/24
69.63.0.0/16
69.171.0.0/16
69.192.12.0/24
69.192.44.0/24
72.165.61.0/24
72.246.62.0/24
72.246.91.0/24
72.246.106.0/24
72.246.167.0/24
72.246.169.0/24
72.246.174.0/24
72.246.189.0/24
72.246.190.0/24
72.246.224.0/24
72.247.90.0/24
72.247.192.0/23
72.247.198.0/24
74.86.0.0/16
74.201.99.0/24
75.126.0.0/16
78.16.49.0/24
84.53.134.0/24
85.190.158.0/24
88.191.0.0/16
88.221.34.0/24
88.221.37.0/24
88.221.71.0/24
88.221.99.0/24
88.221.172.0/24
88.221.175.0/24
88.221.195.0/24
88.221.198.0/23
92.122.5.0/24
92.122.254.0/24
92.123.123.0/24
92.123.176.0/24
92.123.208.0/24
95.100.3.0/24
95.100.60.0/24
95.100.97.0/24
95.100.142.0/24
95.101.30.0/24
95.101.51.0/24
95.101.166.0/24
95.101.199.0/24
95.101.241.0/24
95.101.247.0/24
96.6.89.0/24
96.6.161.0/24
96.7.0.0/16
96.16.160.0/24
96.16.184.0/24
96.16.186.0/24
96.16.221.0/24
96.17.38.0/24
96.17.109.0/24
96.17.210.0/24
103.28.54.0/24
103.74.6.0/24
104.65.15.0/24
104.66.5.0/24
104.66.7.0/24
104.66.36.0/24
104.66.44.0/24
104.66.140.0/24
104.67.26.0/24
104.67.37.0/24
104.67.57.0/24
104.67.152.0/24
104.68.176.0/24
104.68.183.0/24
104.68.189.0/24
104.69.0.0/16
104.70.69.0/24
104.70.154.0/24
104.70.200.0/24
104.70.204.0/24
104.70.207.0/24
104.71.138.0/24
104.71.152.0/24
104.71.213.0/24
104.72.60.0/24
104.72.63.0/24
104.72.154.0/24
104.72.156.0/24
104.73.12.0/24
104.74.0.0/16
104.75.37.0/24
104.75.57.0/24
104.75.65.0/24
104.75.228.0/24
104.76.18.0/24
104.76.58.0/24
104.76.65.0/24
104.76.88.0/24
104.76.111.0/24
104.76.114.0/24
104.76.133.0/24
104.77.22.0/24
104.78.0.0/16
104.79.88.0/24
104.79.128.0/24
104.79.153.0/24
104.80.3.0/24
104.80.29.0/24
104.80.37.0/24
104.80.53.0/24
104.80.59.0/24
104.80.64.0/24
104.80.66.0/24
104.80.88.0/24
104.81.11.0/24
104.81.23.0/24
104.81.120.0/24
104.81.126.0/24
104.81.137.0/24
104.81.141.0/24
104.81.244.0/23
104.82.83.0/24
104.82.89.0/24
104.82.180.0/23
104.82.245.0/24
104.82.247.0/24
104.83.70.0/24
104.83.83.0/24
104.83.89.0/24
104.83.100.0/24
104.83.102.0/24
104.84.154.0/24
104.84.169.0/24
104.84.187.0/24
104.85.41.0/24
104.85.50.0/24
104.85.52.0/23
104.85.172.0/24
104.85.174.0/24
104.86.44.0/23
104.86.110.0/24
104.86.250.0/24
104.87.39.0/24
104.87.102.0/24
104.87.227.0/24
104.87.228.0/24
104.88.0.0/16
104.89.8.0/24
104.89.18.0/24
104.89.38.0/23
104.89.40.0/24
104.89.143.0/24
104.90.20.0/24
104.90.24.0/24
104.90.44.0/24
104.90.49.0/24
104.90.96.0/24
104.90.100.0/24
104.90.104.0/24
104.90.140.0/24
104.90.143.0/24
104.90.180.0/24
104.91.170.0/24
104.91.217.0/24
104.91.233.0/24
104.92.6.0/24
104.92.80.0/24
104.92.90.0/24
104.92.102.0/24
104.92.123.0/24
104.92.136.0/24
104.92.153.0/24
104.93.0.0/16
104.94.2.0/24
104.94.8.0/24
104.94.18.0/24
104.94.110.0/24
104.94.173.0/24
104.94.204.0/24
104.95.20.0/24
104.95.24.0/24
104.95.59.0/24
104.95.98.0/24
104.95.110.0/24
104.95.119.0/24
104.95.197.0/24
104.95.227.0/24
104.96.0.0/16
104.97.66.0/24
104.97.113.0/24
104.97.226.0/24
104.97.228.0/24
104.98.0.0/15
104.100.51.0/24
104.100.52.0/24
104.100.187.0/24
104.101.203.0/24
104.102.10.0/24
104.102.56.0/24
104.103.52.0/24
104.103.58.0/24
104.103.70.0/24
104.103.106.0/24
104.103.157.0/24
104.104.162.0/24
104.104.187.0/24
104.105.7.0/24
104.105.10.0/24
104.105.28.0/24
104.105.58.0/24
104.105.148.0/24
104.105.153.0/24
104.106.200.0/24
104.106.236.0/24
104.107.7.0/24
104.107.52.0/23
104.107.108.0/24
104.107.168.0/23
104.107.248.0/24
104.108.46.0/24
104.108.52.0/24
104.108.69.0/24
104.109.55.0/24
104.109.66.0/24
104.109.82.0/24
104.109.130.0/24
104.109.139.0/24
104.109.142.0/24
104.109.160.0/24
104.109.208.0/24
104.109.235.0/24
104.110.104.0/24
104.111.200.0/24
104.111.247.0/24
104.112.150.0/24
104.112.238.0/24
104.113.52.0/24
104.113.62.0/24
104.113.115.0/24
104.115.83.0/24
104.115.92.0/24
104.115.97.0/24
104.115.118.0/24
104.115.125.0/24
104.115.175.0/24
104.115.209.0/24
104.115.227.0/24
104.115.233.0/24
104.115.253.0/24
104.116.0.0/24
104.116.18.0/24
104.116.70.0/24
104.116.130.0/24
104.116.145.0/24
104.116.217.0/24
104.116.243.0/24
104.116.246.0/24
104.116.251.0/24
104.117.0.0/24
104.117.65.0/24
104.117.95.0/24
104.117.105.0/24
104.117.140.0/24
104.118.6.0/24
104.118.28.0/24
104.118.96.0/24
104.118.103.0/24
104.118.112.0/24
104.119.40.0/24
104.119.181.0/24
104.120.78.0/24
104.120.86.0/24
104.120.92.0/24
104.120.143.0/24
104.120.178.0/24
104.120.219.0/24
104.121.21.0/24
104.121.70.0/24
104.121.122.0/24
104.121.226.0/24
104.121.232.0/24
104.121.249.0/24
104.122.2.0/24
104.122.10.0/24
104.122.102.0/24
104.122.198.0/24
104.122.203.0/24
104.122.220.0/24
104.122.255.0/24
104.123.122.0/24
104.124.27.0/24
104.124.49.0/24
104.124.119.0/24
104.124.134.0/24
104.124.139.0/24
104.124.182.0/24
104.124.211.0/24
104.124.228.0/24
104.125.0.0/16
104.126.21.0/24
104.126.83.0/24
104.127.43.0/24
104.127.62.0/24
104.127.119.0/24
104.127.221.0/24
106.15.109.0/24
110.45.200.0/24
115.223.23.0/24
117.103.182.0/24
118.155.230.0/24
118.214.82.0/24
118.214.249.0/24
118.215.92.0/24
118.215.97.0/24
118.215.176.0/24
121.156.60.0/24
122.252.43.0/24
125.56.227.0/24
125.252.235.0/24
128.241.91.0/24
139.175.87.0/24
141.0.168.0/24
146.66.152.0/24
152.199.38.0/24
153.254.86.0/24
155.133.227.0/24
155.133.229.0/24
155.133.230.0/24
155.133.238.0/24
155.133.242.0/24
155.133.254.0/24
162.254.193.0/24
162.254.195.0/24
162.254.196.0/23
165.254.12.0/24
165.254.105.0/24
165.254.134.0/24
172.16.0.0/16
172.19.83.0/24
172.224.1.0/24
172.224.11.0/24
172.226.72.0/24
172.226.220.0/24
172.227.13.0/24
172.227.150.0/24
172.227.171.0/24
172.228.232.0/24
172.229.58.0/24
172.230.102.0/24
172.230.106.0/24
172.230.108.0/24
172.230.172.0/24
172.231.9.0/24
173.197.192.0/24
173.205.6.0/24
173.222.1.0/24
173.222.43.0/24
173.222.193.0/24
173.222.225.0/24
173.222.237.0/24
173.223.81.0/24
173.223.87.0/24
173.223.164.0/24
173.252.0.0/16
174.36.0.0/15
175.99.100.0/24
175.99.115.0/24
175.139.142.0/24
182.162.106.0/24
184.24.26.0/24
184.24.104.0/24
184.24.110.0/24
184.24.155.0/24
184.24.195.0/24
184.24.223.0/24
184.25.19.0/24
184.25.56.0/24
184.25.61.0/24
184.25.91.0/24
184.25.146.0/24
184.25.158.0/24
184.25.205.0/24
184.25.221.0/24
184.25.243.0/24
184.25.248.0/24
184.25.252.0/23
184.26.22.0/24
184.26.84.0/24
184.26.114.0/24
184.26.120.0/24
184.26.140.0/23
184.26.221.0/24
184.27.0.0/16
184.28.0.0/16
184.29.37.0/24
184.29.59.0/24
184.29.108.0/24
184.29.150.0/24
184.30.6.0/24
184.30.19.0/24
184.30.20.0/24
184.30.226.0/24
184.31.201.0/24
184.50.2.0/24
184.50.87.0/24
184.50.163.0/24
184.51.0.0/24
184.51.15.0/24
184.51.17.0/24
184.51.56.0/24
184.51.141.0/24
184.84.56.0/24
184.84.168.0/24
184.85.67.0/24
184.85.120.0/24
184.85.244.0/24
184.86.0.0/16
184.87.14.0/24
184.87.121.0/24
184.87.197.0/24
185.25.180.0/24
185.27.16.0/24
185.88.181.0/24
192.81.222.0/24
198.172.88.0/24
199.16.0.0/16
199.59.0.0/16
199.239.182.0/24
203.69.81.0/24
205.186.152.0/24
208.43.0.0/16
208.64.201.0/24
208.78.164.0/24
208.101.0.0/16
209.170.97.0/24
210.61.248.0/24
210.201.31.0/24
216.3.133.0/24
216.156.211.0/24
223.119.157.0/24
223.119.206.0/24
223.119.217.0/24
224.0.0.0/4
243.185.187.0/24

View File

@ -0,0 +1,140 @@
300英雄,300hero-cn.rules
永恒之塔-台服,Aion-TW.rules
美国卡车模拟国际服,American-Truck-Simulator.rules
圣歌,Anthem.rules
Apex-uu,Apex-uu.rules
Apex英雄,Apex.rules
方舟:生存进化,ARK--Survival-Evolved.rules
刺客信条:奥德赛,Assassin's-Creed-Odyssey.rules,Assassins-Creed-Odyssey.rules
刺客信条:起源,Assassin's-Creed-Origins.rules,Assassins-Creed-Origins.rules
Atlas-全区,Atlas.rules
战地1,Battlefield-1.rules
战地4,BattleField-4.rules
战地5,Battlefield-.rules,Battlefield-5.rules
黑色沙漠-steam,BlackDesert-steam.rules
黑色幸存者,BlackSurvivor.rules
剑灵台服,Blade%26Soul%20TW.rules
剑灵-日服,Blade-%26-Soul-jp.rules
剑灵-国服全部区服UU规则,Blood-%26-Soul-CN-TestServer-NantianGuo-Alpha.rules
剑灵-国服-南天国(测试版),Blood-%26-Soul-CN.rules
无主之地3,Borderlands3-asia.rules
使命召唤4现代战争重置版,Call-Of-Duty-4-Modern-Warfare.rules
使命召唤15亚服,Call-Of-Duty15-Asia.rules
英雄连2,Company-Of-Heroes-2.rules
反恐精英:全球攻势,CS-GO.rules
反恐精英:全球攻势-港服(tx),CSGO-HKtx.rules
反恐精英:全球攻势-日服(tx),CSGO-JPtx.rules
反恐精英:全球攻势-美服(tx),CSGO-UStx.rules
黑暗之魂3,Dark-Souls-3.rules
不屈不挠,Dauntless.rules
DayZ-steam,DayZ.rules
黎明杀机,Dead-by-Daylight.rules
命运2-全服(tx),Destiny2-Alltx.rules
命运2-全服(uu),Destiny2-Alluu.rules
天命2-亚服/命运2-亚服,Destiny2-Asia.rules
天命2-欧服/命运2-欧服,Destiny2-EU.rules
命运2-steam,Destiny2-steam.rules
天命2-美服/命运2-美服,Destiny2-US.rules
暗黑破坏神3-亚服,Diablo3-Asia.rules
暗黑破坏神3-美服,Diablo3-US.rules
脏弹-Steam,Dirty-Bomb.rules
Discord,Discord-All.rules
饥荒-steam,Don't-Starve-steam.rules,Dont-Starve-steam.rules
刀塔霸业,Dota-Underlords.rules
DOTA2-日服,Dota2-jp.rules
逃离塔科夫,Escape-from-Tarkov.rules
欧卡2所有分区-UU,Euro-Truck-Simulator-2.rules
Eve-online欧服,Eve-online.rules
FIFA19,FiFa19-INT.rules
FIFA20,FIFA20.rules
最终幻想14国服,FINAL-FANTASY-XIV-cn.rules
最终幻想14,Final-Fantasy-XIV.rules
荣耀战魂,For-Honour.rules
堡垒之夜-亚服,Fortnite-AS.rules
堡垒之夜-国服,Fortnite-cn.rules
极限竞速地平线4,Forza-Horizon-4.rules
极限竞速7,Forza-Motorsport-7.rules
基佬大乱斗Gang-Beasts,Gang-Beasts.rules
GTA5,GTA-5.rules
激战2,Guild-Wars-2.rules
巫师昆特牌国际服,Gwent_The-Witcher-Card-game.rules
杀手2外服,HITMAN2.rules
荒野行动PC版-国服,HuangYeXingDong-cn.rules
叛乱:沙漠风暴,Insurgency-Sandstorm.rules
Jump大乱斗,Jump-Force.rules
跑跑卡丁车(韩服),KartRider.rules
Kurtzpel,Kurtzpel.rules
求生之路2-Test,L4D2-Test.rules
英雄联盟-日服,League-of-Legends-jp.rules
英雄联盟-韩服,League-of-Legends-kr.rules
英雄联盟PBE,League-of-Legends-PBE.rules
英雄联盟-台服,League-of-Legends-tw+Garena(2018-12-19).rules
英雄联盟-台服+Garena平台(2018-12-19更新),League-of-Legends-tw.rules
英雄联盟-美服,League-of-Legends-us.rules
失落的方舟韩服,Lost-Ark.rules
失落的方舟俄服,Lostark-RU.rules
冒险岛,Maplestory-us.rules
怪兽世界猎人steam版,Monster-Hunter-World.rules
奇迹传奇MU2,MU2.rules
NBA-2K19,NBA-2K19.rules
NBA2K20,NBA2K20.rules
仁王,NIOH.rules
橘子客户端-UU,Origin.rules
Osu!,Osu!.rules
守望先锋-亚服,Overwatch-Asia.rules
守望先锋-美服,Overwatch-US.rules
流亡黯道-国际服,Path%20Of%20Exile.rules
流放之路,PathOfexile.rules
梦幻之星2-日服(tx),PHANTASY%20STAR%20ONLINE2-JPtx.rules
行星边际2,PlanetSide-2.rules
绝地求生大逃杀,PlayerUnknown's-Battlegrounds-update.rules,PlayerUnknowns-Battlegrounds-update.rules
实况足球-2018,Pro-Evolution-Soccer-2018.rules
实况足球-2019,Pro-Evolution-Soccer-2019.rules
绝地求生亚服-东南亚服,PUBG-Asia%26-Southeast-Asia.rules
绝地求生国际服,PUBG-INT.rules
绝地求生韩服,PUBG-kakao.rules
绝地求生低配版-Garena,PUBGLite-Garena.rules
绝地求生轻量版-WEB客户端,PUBGLITE-WEB.rules
R2竞技场服,R2Arena.rules
R2俄服官服,R2RU.rules
R2美服,R2US.rules
仙境传说OL台湾,RagnarokOnlineTW.rules
荒野大镖客2,Red-dead-redemption2.rules
无限法则,Ring-of-Elysium-asia.rules
Roblox,Roblox.rules
影之诗,Shadowverse.rules
灵魂行者-台服,Soul-Worker.rules
星际公民,Star-Citizen.rules
星球大战2前线,Star-Wars-BattlefrontII.rules
StarCraft-亚服,StarCraft-2-asia.rules
星际争霸2-国服,StarCraftⅡ-cn.rules,StarCraft2-cn.rules
Steam-社区(Beta),Steam.rules
极限巅峰,Steep.rules
街头霸王5,Street-Fighter-V.rules
神谕之战,TERA.rules
飙酷车神,The-Crew.rules
飙酷车神2,The-Crew2.rules
上古卷轴OL,The-Elder-Scrolls-Online.rules
天涯明月刀-台服,TianYaMingYueDao-tw.rules
泰坦陨落2,TiTanFall2.rules
新枫之谷,TMS.rules
幽灵行动:荒野,Tom-Clancy's-Ghost-Recon-Wildlands.rules,Tom-Clancys-Ghost-Recon-Wildlands.rules
彩虹六号-围攻-全部,Tom-Clancy's-Rainbow-Six-Siege-all.rules,Tom-Clancys-Rainbow-Six-Siege-all.rules
彩虹六号-围攻-EAS,Tom-Clancy's-Rainbow-Six-Siege-EAS.rules,Tom-Clancys-Rainbow-Six-Siege-EAS.rules
全境封锁,Tom-clancy's-The-Division-2.rules,Tom-clancys-The-Division-2.rules
全境封锁2,Tom-clancy's-The-Division.rules,Tom-clancys-The-Division.rules
未转变者Unturned,Unturned.rules
战争前线,War-thunder-steam.rules
战争雷霆-steam,Warface.rules
看门狗,Watch-Dogs.rules
看门狗2,Watch-Dogs2.rules
求生意志OL,Will-To-Live-Online.rules
坦克世界-亚服,World-of-Tanks-Asia.rules
坦克世界-国服,World-of-Tanks-cn.rules
魔兽世界台服,World-of-warcraft-tw.rules
战舰世界-亚服,World-of-Warships-US.rules
战舰世界-美服,World-of-Warships.rules
僵尸世界大战,Worldwar-Z.rules
魔兽世界-欧服,WoW-EU.rules
游戏王决斗链接,YO-GI-HO%20delulinks.rules
游侠对战平台,YouXiaDuiZhanPingTai.rules

View File

@ -1,22 +0,0 @@
experimental:
ignore-resolve-fail: true
tun:
enable: true
dns:
enable: true
listen: 0.0.0.0:5300
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
nameserver:
- 114.114.114.114
- 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

View File

@ -0,0 +1,965 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
config_name=$(uci get clash.config.config_update_name 2>/dev/null)
CONFIG_YAML="/usr/share/clash/config/sub/${config_name}"
url=$(grep -F "${config_name}" "/usr/share/clashbackup/confit_list.conf" | awk -F '#' '{print $2}')
lang=$(uci get luci.main.lang 2>/dev/null)
REAL_LOG="/usr/share/clash/clash_real.txt"
type=$(grep -F "${config_name}" "/usr/share/clashbackup/confit_list.conf" | awk -F '#' '{print $3}')
if [ $type == "clash" ] && [ ! -z $url ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Updating Configuration..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "开始更新配置" >$REAL_LOG
fi
wget --no-check-certificate --user-agent="Clash/OpenWRT" $url -O 2>&1 >1 $CONFIG_YAML
if [ "$?" -eq "0" ]; then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Updating Configuration Completed" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "更新配置完成" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
if pidof clash >/dev/null; then
/etc/init.d/clash restart 2>/dev/null
fi
fi
elif [ $type == "v2ssr2clash" ] && [ ! -z $url ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Updating Configuration..." >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "开始更新配置" >$REAL_LOG
fi
#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=$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_name}"
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
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
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Updating 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
mv /usr/share/clash/v2ssr/config.bak /etc/config/clash 2>/dev/null
sleep 1
if pidof clash >/dev/null; then
/etc/init.d/clash restart 2>/dev/null
fi
fi
rm -rf $SERVER_FILE
fi

View File

@ -0,0 +1,7 @@
#!/bin/bash /etc/rc.common
. /lib/functions.sh
name=$(uci get clash.config.config_up_remove 2>/dev/null)
if [ ! -z $name ];then
rm -rf /usr/share/clash/config/upload/${name}
fi

View File

@ -1,6 +1,25 @@
#!/bin/sh /etc/rc.common
#!/bin/bash /etc/rc.common
config_name=$(uci get clash.config.config_name 2>/dev/null)
REAL_LOG="/usr/share/clash/clash_real.txt"
lang=$(uci get luci.main.lang 2>/dev/null)
check_name=$(grep -F "${config_name}.yaml" "/usr/share/clashbackup/confit_list.conf")
if [ ! -z $check_name ];then
if [ $lang == "en" ] || [ $lang == "auto" ];then
echo "Config with same name exist, please rename and download again" >$REAL_LOG
elif [ $lang == "zh_cn" ];then
echo "已存在同名配置,请重命名名配置重新下载" >$REAL_LOG
fi
sleep 5
echo "Clash for OpenWRT" >$REAL_LOG
exit 0
else
#awk '/config groups/,/##end/{print}' /etc/config/clashh 2>/dev/null >/usr/share/clash/v2ssr/config.bak 2>&1
@ -576,7 +595,7 @@ 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"
CONFIG_YAML="/usr/share/clash/config/sub/${config_name}.yaml"
TEMP_FILE="/tmp/dns_temp.yaml"
Proxy_Group="/tmp/Proxy_Group"
GROUP_FILE="/tmp/groups.yaml"
@ -887,14 +906,12 @@ 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
echo "${config_name}.yaml#$subscribe_url#$subtype" >>/usr/share/clashbackup/confit_list.conf
rm -rf $TEMP_FILE $GROUP_FILE $Proxy_Group $CONFIG_FILE
@ -921,4 +938,5 @@ fi
fi
rm -rf $SERVER_FILE
fi

View File

@ -1,8 +1,8 @@
#!/bin/sh
CONFIG_YAML="/etc/clash/config.yaml"
CONFIG_YAML_SUB="/usr/share/clash/config/sub/config.yaml"
CONFIG_YAML_UPL="/usr/share/clash/config/upload/config.yaml"
CONFIG_YAML_CUS="/usr/share/clash/config/custom/config.yaml"
CONFIG_YAML_SUB=$(uci get clash.config.config_path_sub 2>/dev/null)
CONFIG_YAML_UPL=$(uci get clash.config.config_path_up 2>/dev/null)
CONFIG_YAML_CUS=$(uci get clash.config.config_path_cus 2>/dev/null)
lang=$(uci get luci.main.lang 2>/dev/null)
config_type=$(uci get clash.config.config_type 2>/dev/null)
tun_mode=$(uci get clash.config.tun_mode 2>/dev/null)
@ -12,15 +12,15 @@ subscribe_urll=$(uci get $name.config.subscribe_url 2>/dev/null)
REAL_LOG="/usr/share/clash/clash_real.txt"
if [ $config_type == "sub" ];then
if [ $config_type == "1" ];then
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
elif [ $config_type == "2" ];then
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
elif [ $config_type == "3" ];then
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