diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2011-01-29 22:50:13 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2011-01-29 22:50:13 +0000 |
commit | 80c2b4cf4602b04fe2e22d7fa3d36e426af13abc (patch) | |
tree | 100b9966df2670a2c07e9ca2cad1667621088b0f | |
parent | c3c22f792b4e2576713c9609f804c42975e09dbc (diff) |
modules/admin-full: add ip6tables status output (#193)
-rw-r--r-- | modules/admin-full/luasrc/controller/admin/status.lua | 11 | ||||
-rw-r--r-- | modules/admin-full/luasrc/view/admin_status/iptables.htm | 39 |
2 files changed, 41 insertions, 9 deletions
diff --git a/modules/admin-full/luasrc/controller/admin/status.lua b/modules/admin-full/luasrc/controller/admin/status.lua index 7684e64c0e..a408bb44f4 100644 --- a/modules/admin-full/luasrc/controller/admin/status.lua +++ b/modules/admin-full/luasrc/controller/admin/status.lua @@ -2,6 +2,7 @@ LuCI - Lua Configuration Interface 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"); 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", "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", "routes"}, template("admin_status/routes"), i18n("Routes"), 4) entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("System Log"), 5) @@ -46,8 +47,12 @@ function action_dmesg() end function action_iptables() - if luci.http.formvalue("zero") == "1" then - luci.util.exec("iptables -Z") + if luci.http.formvalue("zero") then + if luci.http.formvalue("zero") == "6" then + luci.util.exec("ip6tables -Z") + else + luci.util.exec("iptables -Z") + end luci.http.redirect( luci.dispatcher.build_url("admin", "status", "iptables") ) diff --git a/modules/admin-full/luasrc/view/admin_status/iptables.htm b/modules/admin-full/luasrc/view/admin_status/iptables.htm index a81797dee8..957604e8af 100644 --- a/modules/admin-full/luasrc/view/admin_status/iptables.htm +++ b/modules/admin-full/luasrc/view/admin_status/iptables.htm @@ -1,7 +1,7 @@ <%# LuCI - Lua Configuration Interface 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"); you may not use this file except in compliance with the License. @@ -17,8 +17,17 @@ $Id$ require "luci.sys.iptparser" 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 rowcnt = 1 @@ -45,23 +54,41 @@ $Id$ return i end + local tables = { "Filter", "NAT", "Mangle", "Raw" } + if mode == 6 then + tables = { "Filter", "Mangle", "Raw" } + end -%> <%+header%> +<style type="text/css"> + span:target { + color: blue; + text-decoration: underline; + } +</style> + <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%>"> <div class="cbi-map"> <fieldset class="cbi-section"> <h3><%:Actions%></h3> <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> </ul> <br /><br /> - <% for _, tbl in ipairs({"Filter", "NAT", "Mangle"}) do chaincnt = 0 %> + <% for _, tbl in ipairs(tables) do chaincnt = 0 %> <h3><%:Table%>: <%=tbl%></h3> <table class="cbi-section-table" style="font-size:90%"> <% for _, chain in ipairs(ipt:chains(tbl)) do @@ -71,13 +98,13 @@ $Id$ %> <tr class="cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>"> <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> (<%- if chaininfo.policy then -%> <%:Policy%>: <em><%=chaininfo.policy%></em>, <%:Packets%>: <%=chaininfo.packets%>, <%:Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%> <%- else -%> <%:References%>: <%=chaininfo.references-%> - <%- end -%>) + <%- end -%>)</span> </th> </tr> <tr class="cbi-section-table-descr"> |