modules/admin-full: add ip6tables status output (#193)
This commit is contained in:
parent
c3c22f792b
commit
80c2b4cf46
2 changed files with 41 additions and 9 deletions
|
@ -2,6 +2,7 @@
|
||||||
LuCI - Lua Configuration Interface
|
LuCI - Lua Configuration Interface
|
||||||
|
|
||||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||||
|
Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -19,7 +20,7 @@ function index()
|
||||||
|
|
||||||
entry({"admin", "status"}, template("admin_status/index"), i18n("Status"), 20).index = true
|
entry({"admin", "status"}, template("admin_status/index"), i18n("Status"), 20).index = true
|
||||||
entry({"admin", "status", "interfaces"}, template("admin_status/interfaces"), i18n("Interfaces"), 1)
|
entry({"admin", "status", "interfaces"}, template("admin_status/interfaces"), i18n("Interfaces"), 1)
|
||||||
entry({"admin", "status", "iptables"}, call("action_iptables"), i18n("Firewall"), 2)
|
entry({"admin", "status", "iptables"}, call("action_iptables"), i18n("Firewall"), 2).leaf = true
|
||||||
entry({"admin", "status", "conntrack"}, template("admin_status/conntrack"), i18n("Active Connections"), 3)
|
entry({"admin", "status", "conntrack"}, template("admin_status/conntrack"), i18n("Active Connections"), 3)
|
||||||
entry({"admin", "status", "routes"}, template("admin_status/routes"), i18n("Routes"), 4)
|
entry({"admin", "status", "routes"}, template("admin_status/routes"), i18n("Routes"), 4)
|
||||||
entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("System Log"), 5)
|
entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("System Log"), 5)
|
||||||
|
@ -46,8 +47,12 @@ function action_dmesg()
|
||||||
end
|
end
|
||||||
|
|
||||||
function action_iptables()
|
function action_iptables()
|
||||||
if luci.http.formvalue("zero") == "1" then
|
if luci.http.formvalue("zero") then
|
||||||
luci.util.exec("iptables -Z")
|
if luci.http.formvalue("zero") == "6" then
|
||||||
|
luci.util.exec("ip6tables -Z")
|
||||||
|
else
|
||||||
|
luci.util.exec("iptables -Z")
|
||||||
|
end
|
||||||
luci.http.redirect(
|
luci.http.redirect(
|
||||||
luci.dispatcher.build_url("admin", "status", "iptables")
|
luci.dispatcher.build_url("admin", "status", "iptables")
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<%#
|
<%#
|
||||||
LuCI - Lua Configuration Interface
|
LuCI - Lua Configuration Interface
|
||||||
Copyright 2008-2009 Steven Barth <steven@midlink.org>
|
Copyright 2008-2009 Steven Barth <steven@midlink.org>
|
||||||
Copyright 2008-2009 Jo-Philipp Wich <xm@leipzig.freifunk.net>
|
Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -17,8 +17,17 @@ $Id$
|
||||||
|
|
||||||
require "luci.sys.iptparser"
|
require "luci.sys.iptparser"
|
||||||
require "luci.tools.webadmin"
|
require "luci.tools.webadmin"
|
||||||
|
require "luci.fs"
|
||||||
|
|
||||||
local ipt = luci.sys.iptparser.IptParser()
|
local has_ip6tables = luci.fs.access("/usr/sbin/ip6tables")
|
||||||
|
local mode = 4
|
||||||
|
|
||||||
|
if has_ip6tables then
|
||||||
|
mode = luci.dispatcher.context.requestpath
|
||||||
|
mode = tonumber(mode[#mode] ~= "iptables" and mode[#mode]) or 4
|
||||||
|
end
|
||||||
|
|
||||||
|
local ipt = luci.sys.iptparser.IptParser(mode)
|
||||||
local wba = luci.tools.webadmin
|
local wba = luci.tools.webadmin
|
||||||
|
|
||||||
local rowcnt = 1
|
local rowcnt = 1
|
||||||
|
@ -45,23 +54,41 @@ $Id$
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local tables = { "Filter", "NAT", "Mangle", "Raw" }
|
||||||
|
if mode == 6 then
|
||||||
|
tables = { "Filter", "Mangle", "Raw" }
|
||||||
|
end
|
||||||
-%>
|
-%>
|
||||||
|
|
||||||
<%+header%>
|
<%+header%>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
span:target {
|
||||||
|
color: blue;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<h2><a id="content" name="content"><%:Firewall Status%></a></h2>
|
<h2><a id="content" name="content"><%:Firewall Status%></a></h2>
|
||||||
|
|
||||||
|
<% if has_ip6tables then %>
|
||||||
|
<ul class="cbi-tabmenu">
|
||||||
|
<li class="cbi-tab<%= mode ~= 4 and "-disabled" %>"><a href="<%=luci.dispatcher.build_url("admin/status/iptables/4")%>"><%:IPv4 Firewall%></a></li>
|
||||||
|
<li class="cbi-tab<%= mode ~= 6 and "-disabled" %>"><a href="<%=luci.dispatcher.build_url("admin/status/iptables/6")%>"><%:IPv6 Firewall%></a></li>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<form method="post" action="<%=REQUEST_URI%>">
|
<form method="post" action="<%=REQUEST_URI%>">
|
||||||
<div class="cbi-map">
|
<div class="cbi-map">
|
||||||
<fieldset class="cbi-section">
|
<fieldset class="cbi-section">
|
||||||
<h3><%:Actions%></h3>
|
<h3><%:Actions%></h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="<%=REQUEST_URI%>?zero=1"><%:Reset Counters%></a></li>
|
<li><a href="<%=REQUEST_URI%>?zero=<%=mode%>"><%:Reset Counters%></a></li>
|
||||||
<li><a href="<%=REQUEST_URI%>?restart=1"><%:Restart Firewall%></a></li>
|
<li><a href="<%=REQUEST_URI%>?restart=1"><%:Restart Firewall%></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
<% for _, tbl in ipairs({"Filter", "NAT", "Mangle"}) do chaincnt = 0 %>
|
<% for _, tbl in ipairs(tables) do chaincnt = 0 %>
|
||||||
<h3><%:Table%>: <%=tbl%></h3>
|
<h3><%:Table%>: <%=tbl%></h3>
|
||||||
<table class="cbi-section-table" style="font-size:90%">
|
<table class="cbi-section-table" style="font-size:90%">
|
||||||
<% for _, chain in ipairs(ipt:chains(tbl)) do
|
<% for _, chain in ipairs(ipt:chains(tbl)) do
|
||||||
|
@ -71,13 +98,13 @@ $Id$
|
||||||
%>
|
%>
|
||||||
<tr class="cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>">
|
<tr class="cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>">
|
||||||
<th class="cbi-section-table-cell" style="text-align:left" colspan="11">
|
<th class="cbi-section-table-cell" style="text-align:left" colspan="11">
|
||||||
<br /><a name="rule_<%=tbl:lower()%>_<%=chain%>"></a>
|
<br /><span id="rule_<%=tbl:lower()%>_<%=chain%>">
|
||||||
<%:Chain%> <em><%=chain%></em>
|
<%:Chain%> <em><%=chain%></em>
|
||||||
(<%- if chaininfo.policy then -%>
|
(<%- if chaininfo.policy then -%>
|
||||||
<%:Policy%>: <em><%=chaininfo.policy%></em>, <%:Packets%>: <%=chaininfo.packets%>, <%:Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%>
|
<%:Policy%>: <em><%=chaininfo.policy%></em>, <%:Packets%>: <%=chaininfo.packets%>, <%:Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%>
|
||||||
<%- else -%>
|
<%- else -%>
|
||||||
<%:References%>: <%=chaininfo.references-%>
|
<%:References%>: <%=chaininfo.references-%>
|
||||||
<%- end -%>)
|
<%- end -%>)</span>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="cbi-section-table-descr">
|
<tr class="cbi-section-table-descr">
|
||||||
|
|
Loading…
Reference in a new issue