2 LuCI - Lua Configuration Interface
3 Copyright
2008-
2009 Steven Barth
<steven@midlink.org
>
4 Copyright
2008-
2009 Jo-Philipp Wich
<xm@leipzig.freifunk.net
>
6 Licensed under the Apache License, Version
2.0 (the
"License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-
2.0
18 require
"luci.sys.iptparser"
19 require
"luci.tools.webadmin"
21 local ipt = luci.sys.iptparser.IptParser()
22 local wba = luci.tools.webadmin
27 return (rowcnt %
2) +
1
30 function link_target(t,c)
31 if ipt:is_custom_target(c) then
32 return '
<a href=
"#rule_%s_%s">%s
</a>' %{ t:lower(), c, c }
37 function link_iface(i)
38 local net = wba.iface_get_network(i)
39 if net and i ~=
"lo" then
40 return '
<a href=
"%s">%s
</a>' %{
41 luci.dispatcher.build_url(
"admin",
"network",
"network", net), i
52 <h2><a id=
"content" name=
"content"><%:Firewall Status%
></a></h2>
54 <form method=
"post" action=
"<%=REQUEST_URI%>">
56 <fieldset class=
"cbi-section">
59 <li><a href=
"<%=REQUEST_URI%>?zero=1"><%:Reset Counters%
></a></li>
60 <li><a href=
"<%=REQUEST_URI%>?restart=1"><%:Restart Firewall%
></a></li>
64 <% for _, tbl in ipairs({
"Filter",
"NAT",
"Mangle"}) do chaincnt =
0 %
>
65 <h3><%:Table%
>: <%=tbl%
></h3>
66 <table class=
"cbi-section-table" style=
"font-size:90%">
67 <% for _, chain in ipairs(ipt:chains(tbl)) do
69 chaincnt = chaincnt +
1
70 chaininfo = ipt:chain(tbl, chain)
72 <tr class=
"cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>">
73 <th class=
"cbi-section-table-cell" style=
"text-align:left" colspan=
"11">
74 <br /><a name=
"rule_<%=tbl:lower()%>_<%=chain%>"></a>
75 <%:Chain%
> <em><%=chain%
></em>
76 (<%- if chaininfo.policy then -%
>
77 <%:Policy%
>:
<em><%=chaininfo.policy%
></em>, <%:Packets%
>: <%=chaininfo.packets%
>, <%:Traffic%
>: <%=wba.byte_format(chaininfo.bytes)-%
>
79 <%:References%
>: <%=chaininfo.references-%
>
83 <tr class=
"cbi-section-table-descr">
84 <th class=
"cbi-section-table-cell"><%:Rule #%
></th>
85 <th class=
"cbi-section-table-cell"><%:Pkts.%
></th>
86 <th class=
"cbi-section-table-cell"><%:Traffic%
></th>
87 <th class=
"cbi-section-table-cell"><%:Target%
></th>
88 <th class=
"cbi-section-table-cell"><%:Prot.%
></th>
89 <th class=
"cbi-section-table-cell"><%:Flags%
></th>
90 <th class=
"cbi-section-table-cell"><%:In%
></th>
91 <th class=
"cbi-section-table-cell"><%:Out%
></th>
92 <th class=
"cbi-section-table-cell"><%:Source%
></th>
93 <th class=
"cbi-section-table-cell"><%:Destination%
></th>
94 <th class=
"cbi-section-table-cell" style=
"width:30%"><%:Options%
></th>
97 <% for _, rule in ipairs(ipt:find({table=tbl, chain=chain})) do %
>
98 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
99 <td><%=rule.index%
></td>
100 <td><%=rule.packets%
></td>
101 <td><%=wba.byte_format(rule.bytes)%
></td>
102 <td><%=rule.target and link_target(tbl, rule.target) or
"-"%
></td>
103 <td><%=rule.protocol%
></td>
104 <td><%=rule.flags%
></td>
105 <td><%=link_iface(rule.inputif)%
></td>
106 <td><%=link_iface(rule.outputif)%
></td>
107 <td><%=rule.source%
></td>
108 <td><%=rule.destination%
></td>
109 <td style=
"width:30%"><small><%=#rule.options
> 0 and luci.util.pcdata(table.concat(rule.options,
" ")) or
"-"%
></small></td>
113 <% if rowcnt ==
1 then %
>
114 <tr class=
"cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>">
115 <td colspan=
"11"><em><%:No rules in this chain%
></em></td>
120 <% if chaincnt ==
0 then %
>
121 <tr class=
"cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>">
122 <td colspan=
"11"><em><%:No chains in this table%
></em></td>