diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-02-08 03:56:50 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-02-08 03:56:50 +0000 |
commit | f52ec227175c9db1bfee95f8a59c7c56d01911d4 (patch) | |
tree | 7ba7e2d346b2cea378267fee607001d4eb841a9d /modules/admin-full/luasrc/view | |
parent | e3c8b9a10b383138ba1a5ed7bea51fd3694f596d (diff) |
modules/admin-full: implement iptables status page
i18n/english: resync xml, add strings for iptables page
libs/sys/iptparser: implement chain() and is_custom_target()
Diffstat (limited to 'modules/admin-full/luasrc/view')
-rw-r--r-- | modules/admin-full/luasrc/view/admin_status/iptables.htm | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/modules/admin-full/luasrc/view/admin_status/iptables.htm b/modules/admin-full/luasrc/view/admin_status/iptables.htm new file mode 100644 index 0000000000..da0a994d97 --- /dev/null +++ b/modules/admin-full/luasrc/view/admin_status/iptables.htm @@ -0,0 +1,137 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2009 Steven Barth <steven@midlink.org> +Copyright 2009 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ + +-%> + +<%- + + require "luci.sys.iptparser" + require "luci.tools.webadmin" + + local ipt = luci.sys.iptparser.IptParser() + local wba = luci.tools.webadmin + + local rowcnt = 1 + function rowstyle() + rowcnt = rowcnt + 1 + return (rowcnt % 2) + 1 + end + + function link_target(t,c) + if ipt:is_custom_target(c) then + return '<a href="#rule_%s_%s">%s</a>' %{ t:lower(), c, c } + end + return c + end + + function link_iface(i) + local net = wba.iface_get_network(i) + if net and i ~= "lo" then + return '<a href="%s">%s</a>' %{ + luci.dispatcher.build_url("admin", "network", "network", net), i + } + + end + return i + end + +-%> + +<%+header%> + +<h2><a id="content" name="content"><%:a_s_ipt_status Firewall Status%></a></h2> + +<form method="post" action="<%=REQUEST_URI%>"> + <div class="cbi-map"> + <fieldset class="cbi-section"> + <fieldset class="cbi-section-node"> + <h3><%:a_s_ipt_actions Actions%></h3> + <ul> + <li><a href="<%=REQUEST_URI%>?zero=1"><%:a_s_ipt_reset Reset Counters%></a></li> + <li><a href="<%=REQUEST_URI%>?restart=1"><%:a_s_ipt_restart Restart Firewall%></a></li> + </ul> + </fieldset> + <br /> + + <fieldset class="cbi-section-node"> + <% for _, tbl in ipairs({"Filter", "NAT", "Mangle"}) do chaincnt = 0 %> + <h3><%:a_s_ipt_table Table%>: <%=tbl%></h3> + <table class="cbi-section-table" style="font-size:90%"> + <% for _, chain in ipairs(ipt:chains(tbl)) do + rowcnt = 0 + chaincnt = chaincnt + 1 + chaininfo = ipt:chain(tbl, chain) + %> + <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> + <%:a_s_ipt_chain Chain%> <em><%=chain%></em> + (<%- if chaininfo.policy then -%> + <%:a_s_ipt_policy Policy%>: <em><%=chaininfo.policy%></em>, <%:a_s_ipt_packets Packets%>: <%=chaininfo.packets%>, <%:a_s_ipt_bytes Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%> + <%- else -%> + <%:a_s_ipt_references References%>: <%=chaininfo.references-%> + <%- end -%>) + </th> + </tr> + <tr class="cbi-section-table-descr"> + <th class="cbi-section-table-cell"><%:a_s_ipt_rulenum Rule #%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_packets Pkts.%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_bytes Traffic%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_target Target%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_proto Prot.%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_flags Flags%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_inputif In%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_outputif Out%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_source Source%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_destination Destination%></th> + <th class="cbi-section-table-cell"><%:a_s_ipt_options Options%></th> + </tr> + + <% for _, rule in ipairs(ipt:find({table=tbl, chain=chain})) do %> + <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>"> + <td><%=rule.index%></td> + <td><%=rule.packets%></td> + <td><%=wba.byte_format(rule.bytes)%></td> + <td><%=link_target(tbl, rule.target)%></td> + <td><%=rule.protocol%></td> + <td><%=rule.flags%></td> + <td><%=link_iface(rule.inputif)%></td> + <td><%=link_iface(rule.outputif)%></td> + <td><%=rule.source%></td> + <td><%=rule.destination%></td> + <td><small><%=#rule.options > 0 and table.concat(rule.options, " ") or "-"%></small></td> + </tr> + <% end %> + + <% if rowcnt == 1 then %> + <tr class="cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>"> + <td colspan="11"><em><%:a_s_ipt_norules No rules in this chain%></em></td> + </tr> + <% end %> + <% end %> + + <% if chaincnt == 0 then %> + <tr class="cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>"> + <td colspan="11"><em><%:a_s_ipt_nochains No chains in this table%></em></td> + </tr> + <% end %> + </table> + <br /><br /> + <% end %> + </fieldset> + </fieldset> + </div> +</form> + +<%+footer%> +<% if ret == 0 then luci.sys.reboot() end %> |