提交 8bef369d 编写于 作者: L LEAN-ESX

luci-app-accesscontrol: add strict mode support

上级 c3a80af0
......@@ -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
......
......@@ -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
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
......
<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>
......@@ -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 "客户端规则"
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册