Merge pull request #6 from coolsnowwolf/master

luci-app-familycloud: fix menu display without IPSEC
This commit is contained in:
CN_SZTL 2019-05-31 22:02:13 +08:00 committed by GitHub
commit 20a90e53cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 4 deletions

View File

@ -11,7 +11,7 @@ LUCI_DEPENDS:=
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-accesscontrol
PKG_VERSION:=1
PKG_RELEASE:=9
PKG_RELEASE:=11
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -6,7 +6,13 @@ function index()
end
entry({"admin","services","mia"},cbi("mia"),_("Internet Access Schedule Control"),30).dependent=true
entry({"admin","services","mia","status"},call("act_status")).leaf=true
end
function act_status()
local e={}
e.running=luci.sys.call("iptables -L INPUT |grep MIA >/dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -1,5 +1,6 @@
a=Map("mia",translate("Internet Access Schedule Control"),translate("Access Schedule Control Settins"))
a:section(SimpleSection).template = "mia/mia_status"
t=a:section(TypedSection,"basic")
t.anonymous=true
@ -7,6 +8,10 @@ t.anonymous=true
e=t:option(Flag,"enable",translate("Enabled"))
e.rmempty=false
e=t:option(Flag,"strict",translate("Strict Mode"))
e.rmempty=false
e.description = translate("Strict Mode will degrade CPU performance, but it can achieve better results")
t=a:section(TypedSection,"macbind",translate("Client Rules"))
t.template="cbi/tblsection"
t.anonymous=true

View File

@ -0,0 +1,22 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[services]], [[mia]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('mia_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green><%:Internet Access Schedule Control%> <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red><%:Internet Access Schedule Control%> <%:NOT RUNNING%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="mia_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -7,6 +7,12 @@ msgstr "设置客户端禁止访问互联网的时间"
msgid "General switch"
msgstr "开启/关闭"
msgid "Strict Mode"
msgstr "严格模式"
msgid "Strict Mode will degrade CPU performance, but it can achieve better results"
msgstr "严格模式会损耗部分CPU资源但可以按照时间规则立即拦截数据包效果更好"
msgid "Client Rules"
msgstr "客户端规则"

View File

@ -73,9 +73,12 @@ start(){
iptables -I INPUT -p tcp --dport 53 -m comment --comment "Rule For Control" -j MIA
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control"
iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control"
strict=$(uci get mia.@basic[0].strict)
[ $strict -eq 1 ] && iptables -t filter -I FORWARD -m comment --comment "Rule For Control" -j MIA
add_rule
}
stop(){
iptables -t filter -D FORWARD -m comment --comment "Rule For Control" -j MIA 2>/dev/null
iptables -D INPUT -p udp --dport 53 -m comment --comment "Rule For Control" -j MIA 2>/dev/null
iptables -D INPUT -p tcp --dport 53 -m comment --comment "Rule For Control" -j MIA 2>/dev/null
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control" 2>/dev/null

View File

@ -10,7 +10,7 @@ LUCI_DEPENDS:=+coreutils +coreutils-nohup +libreadline +libcurl +libopenssl +bas
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-familycloud
PKG_VERSION:=1
PKG_RELEASE:=3
PKG_RELEASE:=5
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -2,7 +2,7 @@
module("luci.controller.familycloud", package.seeall)
function index()
if not nixio.fs.access("/etc/config/ipsec") then
if not nixio.fs.access("/etc/config/familycloud") then
return
end