From: Jo-Philipp Wich Date: Sat, 29 Jan 2011 22:50:13 +0000 (+0000) Subject: modules/admin-full: add ip6tables status output (#193) X-Git-Tag: 0.11.0~2302 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=80c2b4cf4602b04fe2e22d7fa3d36e426af13abc modules/admin-full: add ip6tables status output (#193) --- diff --git a/modules/admin-full/luasrc/controller/admin/status.lua b/modules/admin-full/luasrc/controller/admin/status.lua index 7684e64c0..a408bb44f 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 +Copyright 2011 Jo-Philipp Wich 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 a81797dee..957604e8a 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 -Copyright 2008-2009 Jo-Philipp Wich +Copyright 2008-2011 Jo-Philipp Wich 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%> + +

<%:Firewall Status%>

+<% if has_ip6tables then %> + +<% end %> +

<%:Actions%>



- <% for _, tbl in ipairs({"Filter", "NAT", "Mangle"}) do chaincnt = 0 %> + <% for _, tbl in ipairs(tables) do chaincnt = 0 %>

<%:Table%>: <%=tbl%>

<% for _, chain in ipairs(ipt:chains(tbl)) do @@ -71,13 +98,13 @@ $Id$ %>
-
+
<%:Chain%> <%=chain%> (<%- if chaininfo.policy then -%> <%:Policy%>: <%=chaininfo.policy%>, <%:Packets%>: <%=chaininfo.packets%>, <%:Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%> <%- else -%> <%:References%>: <%=chaininfo.references-%> - <%- end -%>) + <%- end -%>)