Skip to content

Commit

Permalink
1.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
frainzy1477 committed Jun 30, 2020
1 parent eaae598 commit fb6d84f
Show file tree
Hide file tree
Showing 32 changed files with 870 additions and 559 deletions.
34 changes: 22 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-clash
PKG_VERSION:=1.7.3.3
PKG_VERSION:=1.7.4
PKG_MAINTAINER:=frainzy1477


Expand Down Expand Up @@ -68,9 +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
mv /usr/share/clash/dns.yaml /usr/share/clashbackup/dns.bak 2>/dev/null
mv /usr/share/clash/tundns.yaml /usr/share/clashbackup/tundns.bak 2>/dev/null
mv /usr/share/clash/custom_rule.yaml /usr/share/clashbackup/custom_rule.bak 2>/dev/null
mv /usr/share/clash/rule.yaml /usr/share/clashbackup/rule.bak 2>/dev/null
fi

exit 0
Expand All @@ -85,9 +83,7 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
mv /usr/share/clashbackup/config.bak1 /usr/share/clash/config/sub/config.yaml 2>/dev/null
mv /usr/share/clashbackup/config.bak2 /usr/share/clash/config/upload/config.yaml 2>/dev/null
mv /usr/share/clashbackup/config.bak3 /usr/share/clash/config/custom/config.yaml 2>/dev/null
mv /usr/share/clashbackup/dns.bak /usr/share/clash/dns.yaml 2>/dev/null
mv /usr/share/clashbackup/tundns.bak /usr/share/clash/tundns.yaml 2>/dev/null
mv /usr/share/clashbackup/custom_rule.bak /usr/share/clash/custom_rule.yaml 2>/dev/null
mv /usr/share/clashbackup/rule.bak /usr/share/clash/rule.yaml 2>/dev/null
/etc/init.d/clash disable 2>/dev/null
fi

Expand All @@ -98,6 +94,15 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash/config

$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash/dns
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash/client
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash/filter
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash/game
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash/geoip
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash/logs
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/clash/update

$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/clash
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(INSTALL_DIR) $(1)/etc/init.d
Expand All @@ -118,7 +123,7 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/etc/clash/dtun
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/usr/share/clashbackup
$(INSTALL_DIR) $(1)/usr/share/clash/provider
$(INSTALL_DIR) $(1)/usr/share/clash/create
$(INSTALL_DIR) $(1)/etc/clash/provider
$(INSTALL_DIR) $(1)/etc/clash/proxyprovider
$(INSTALL_DIR) $(1)/etc/clash/ruleprovider
Expand All @@ -131,15 +136,13 @@ define Package/$(PKG_NAME)/install
$(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/Country.mmdb $(1)/etc/clash
$(INSTALL_BIN) ./root/usr/share/clash/provider/* $(1)/usr/share/clash/provider
$(INSTALL_BIN) ./root/usr/share/clash/create/* $(1)/usr/share/clash/create
$(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/rpcd/acl.d/luci-app-clash.json $(1)/usr/share/rpcd/acl.d
$(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.yaml $(1)/usr/share/clash
$(INSTALL_BIN) ./root/usr/share/clash/custom_rule.yaml $(1)/usr/share/clash
$(INSTALL_BIN) ./root/usr/share/clash/rule.yaml $(1)/usr/share/clash

$(INSTALL_BIN) ./root/usr/share/clash/luci_version $(1)/usr/share/clash
$(INSTALL_BIN) ./root/usr/share/clash/server.list $(1)/usr/share/clash
Expand All @@ -158,6 +161,13 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DATA) ./luasrc/controller/*.lua $(1)/usr/lib/lua/luci/controller
$(INSTALL_DATA) ./luasrc/model/cbi/clash/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash
$(INSTALL_DATA) ./luasrc/model/cbi/clash/config/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/config
$(INSTALL_DATA) ./luasrc/model/cbi/clash/client/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/client
$(INSTALL_DATA) ./luasrc/model/cbi/clash/dns/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/dns
$(INSTALL_DATA) ./luasrc/model/cbi/clash/filter/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/filter
$(INSTALL_DATA) ./luasrc/model/cbi/clash/game/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/game
$(INSTALL_DATA) ./luasrc/model/cbi/clash/geoip/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/geoip
$(INSTALL_DATA) ./luasrc/model/cbi/clash/logs/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/logs
$(INSTALL_DATA) ./luasrc/model/cbi/clash/update/*.lua $(1)/usr/lib/lua/luci/model/cbi/clash/update
$(INSTALL_DATA) ./luasrc/view/clash/* $(1)/usr/lib/lua/luci/view/clash
$(INSTALL_DATA) ./po/zh-cn/clash.zh-cn.lmo $(1)/usr/lib/lua/luci/i18n
endef
Expand Down
30 changes: 17 additions & 13 deletions luasrc/controller/clash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ function index()
page.acl_depends = {"luci-app-clash"}

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", "client"},cbi("clash/client/client"),_("Client"), 20).leaf = true

entry({"admin", "services", "clash", "config"}, firstchild(),_("Config"), 25)
entry({"admin", "services", "clash", "config", "import"},cbi("clash/import"),_("Import Config"), 25).leaf = true
entry({"admin", "services", "clash", "config", "config"},cbi("clash/config"),_("Select Config"), 30).leaf = true
entry({"admin", "services", "clash", "config", "import"},cbi("clash/config/import"),_("Import Config"), 25).leaf = true
entry({"admin", "services", "clash", "config", "config"},cbi("clash/config/config"),_("Select Config"), 30).leaf = true

entry({"admin", "services", "clash", "config", "create"},cbi("clash/config/create"),_("Create Config"), 35).leaf = true
entry({"admin", "services", "clash", "proxyprovider"},cbi("clash/config/proxy_provider"), nil).leaf = true
Expand All @@ -32,17 +32,21 @@ function index()


entry({"admin", "services", "clash", "settings"}, firstchild(),_("Settings"), 40)
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", "settings", "port"},cbi("clash/dns/port"),_("Proxy Ports"), 60).leaf = true
entry({"admin", "services", "clash", "settings", "geoip"},cbi("clash/geoip/geoip"),_("Update GeoIP"), 80).leaf = true
entry({"admin", "services", "clash", "settings", "list"},cbi("clash/filter/list"),_("Filter List"), 90).leaf = true
entry({"admin", "services", "clash", "settings", "grules"},cbi("clash/game/game-settings"),_("Game Rules"), 91).dependent = false
entry({"admin", "services", "clash", "g-rules"},cbi("clash/game/game-rule"), nil).leaf = true
entry({"admin", "services", "clash", "settings", "other"},cbi("clash/other"),_("Other Settings"), 92).leaf = true
entry({"admin", "services", "clash", "ip-rules"},cbi("clash/ip-rules"), nil).leaf = true
entry({"admin", "services", "clash", "ip-rules"},cbi("clash/config/ip-rules"), nil).leaf = true
entry({"admin", "services", "clash", "settings", "dns"},firstchild(),_("DNS Settings"), 65)
entry({"admin", "services", "clash", "settings", "dns", "dns"},cbi("clash/dns/dns"),_("Clash DNS"), 70).leaf = true
entry({"admin", "services", "clash", "settings", "dns", "advance"},cbi("clash/dns/advance"),_("Advance DNS"), 75).leaf = true

entry({"admin", "services", "clash", "update"},cbi("clash/update"),_("Update"), 45).leaf = true
entry({"admin", "services", "clash", "log"},cbi("clash/log"),_("Log"), 50).leaf = true


entry({"admin", "services", "clash", "update"},cbi("clash/update/update"),_("Update"), 45).leaf = true
entry({"admin", "services", "clash", "log"},cbi("clash/logs/log"),_("Log"), 50).leaf = true


entry({"admin","services","clash","check_status"},call("check_status")).leaf=true
Expand Down Expand Up @@ -70,7 +74,7 @@ local fss = require "luci.clash"

local function download_rule_provider()
local filename = luci.http.formvalue("filename")
local status = luci.sys.call(string.format('/usr/share/clash/provider/clash_rule_provider.sh "%s" >/dev/null 2>&1',filename))
local status = luci.sys.call(string.format('/usr/share/clash/create/clash_rule_provider.sh "%s" >/dev/null 2>&1',filename))
return status
end

Expand Down
File renamed without changes.
File renamed without changes.
72 changes: 41 additions & 31 deletions luasrc/model/cbi/clash/config/create.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local clash = "clash"
local NXFS = require "nixio.fs"
local SYS = require "luci.sys"
local HTTP = require "luci.http"
Expand All @@ -6,7 +7,6 @@ local UTIL = require "luci.util"
local fs = require "luci.clash"
local uci = require "luci.model.uci".cursor()
local s, o, krk, z, r
local clash = "clash"
local http = luci.http

font_blue = [[<font color="blue">]]
Expand All @@ -17,7 +17,7 @@ bold_off = [[</strong>]]
krk = Map(clash)
s = krk:section(TypedSection, "clash", translate("Create Config"))
s.anonymous = true
krk.pageaction = false
--krk.pageaction = false

o = s:option(Flag, "provider_config", translate("Enable Create"))
o.default = 1
Expand Down Expand Up @@ -66,7 +66,7 @@ end


local t = {
{Creat_Config, Apply, Delete_Groups, Delete_ProxyPro, Delete_RulePro,Delete_Rules}
{Creat_Config, Delete_Groups, Delete_ProxyPro, Delete_RulePro,Delete_Rules}
}

b = krk:section(Table, t)
Expand All @@ -77,25 +77,16 @@ o.inputtitle = translate("Create Config")
o.inputstyle = "apply"
o.write = function()
krk.uci:commit("clash")
luci.sys.call("bash /usr/share/clash/provider/provider.sh >/dev/null 2>&1 &")
luci.sys.call("bash /usr/share/clash/create/create.sh >/dev/null 2>&1 &")
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", "config", "create"))
end

o = b:option(Button,"Delete Severs")
o.inputtitle = translate("Delete Severs")
o.inputstyle = "reset"
o.write = function()
krk.uci:delete_all("clash", "servers", function(s) return true end)
krk.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "config", "create"))
end

o = b:option(Button,"Delete_ProxyPro")
Expand All @@ -104,7 +95,6 @@ o.inputstyle = "reset"
o.write = function()
krk.uci:delete_all("clash", "proxyprovider", function(s) return true end)
krk.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "config", "create"))
end

o = b:option(Button,"Delete_RulePro")
Expand All @@ -113,7 +103,6 @@ o.inputstyle = "reset"
o.write = function()
krk.uci:delete_all("clash", "ruleprovider", function(s) return true end)
krk.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "config", "create"))
end


Expand All @@ -123,7 +112,6 @@ o.inputstyle = "reset"
o.write = function()
krk.uci:delete_all("clash", "rules", function(s) return true end)
krk.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "config", "create"))
end

o = b:option(Button,"Delete_Groups")
Expand Down Expand Up @@ -151,6 +139,12 @@ function s.create(...)
end
end

o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end

o = s:option(DummyValue, "type", translate("Type"))
function o.cfgvalue(...)
Expand Down Expand Up @@ -193,6 +187,13 @@ function x.create(...)
end
end

o = x:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end

o = x:option(DummyValue, "type", translate("Group Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
Expand Down Expand Up @@ -221,6 +222,12 @@ function z.create(...)
end
end

o = z:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end

o = z:option(DummyValue, "name", translate("Provider Name"))
function o.cfgvalue(...)
Expand All @@ -234,9 +241,6 @@ end






-- [[ Rule-Provider Manage ]]--
r = krk:section(TypedSection, "ruleprovider", translate("Rule Provider"))
r.description = font_blue..bold_on..translate(" https://lancellc.gitbook.io/clash/clash-config-file/rule-provider")..bold_off..font_off..' '
Expand All @@ -253,6 +257,13 @@ function r.create(...)
end
end

o = r:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end


o = r:option(DummyValue, "name", translate("Provider Name"))
function o.cfgvalue(...)
Expand Down Expand Up @@ -286,6 +297,13 @@ function q.create(...)
end
end

o = q:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end

o = q:option(DummyValue, "type", translate("Rule Type"))
function o.cfgvalue(...)
return Value.cfgvalue(...) or translate("None")
Expand All @@ -307,7 +325,7 @@ m = Map("clash")
y = m:section(TypedSection, "clash" , translate("Script"))
y.anonymous = true
y.addremove=false
m.pageaction = false


local script="/usr/share/clash/provider/script.yaml"
sev = y:option(TextValue, "scriptt")
Expand All @@ -321,20 +339,12 @@ sev.write = function(self, section, value)
NXFS.writefile(script, value:gsub("\r\n", "\n"))
end

o = y:option(Button,"Apply")
o.inputtitle = translate("Save & Apply")
o.inputstyle = "apply"
o.write = function()
m.uci:commit("clash")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "clash", "config", "providers"))
end


l = Map("clash")
v = l:section(TypedSection, "clash" , translate("Other Rules"))
v.anonymous = true
v.addremove=false
l.pageaction = false


o = v:option(Value, "rule_url")
o.title = translate("Custom Rule Url")
Expand All @@ -351,7 +361,7 @@ o.write = function()
luci.sys.call("bash /usr/share/clash/rule.sh >>/usr/share/clash/clash.txt >/dev/null 2>&1 &")
end

local rule = "/usr/share/clash/custom_rule.yaml"
local rule = "/usr/share/clash/rule.yaml"
sev = v:option(TextValue, "rule")
sev.description = translate("NB: Attention to Proxy Group and Rule when making changes to this section")
sev.rows = 20
Expand All @@ -366,7 +376,7 @@ end
o = v:option(Button,"del_rule")
o.inputtitle = translate("Delete Rule")
o.write = function()
SYS.call("rm -rf /usr/share/clash/custom_rule.yaml >/dev/null 2>&1 &")
SYS.call("rm -rf /usr/share/clash/rule.yaml >/dev/null 2>&1 &")
end

krk:append(Template("clash/list"))
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fb6d84f

Please sign in to comment.