2 LuCI - Lua Configuration Interface
3 Copyright
2009 Steven Barth
<steven@midlink.org
>
4 Copyright
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"><%:a_s_ipt_status Firewall Status%
></a></h2>
54 <form method=
"post" action=
"<%=REQUEST_URI%>">
56 <fieldset class=
"cbi-section">
57 <fieldset class=
"cbi-section-node">
58 <h3><%:a_s_ipt_actions Actions%
></h3>
60 <li><a href=
"<%=REQUEST_URI%>?zero=1"><%:a_s_ipt_reset Reset Counters%
></a></li>
61 <li><a href=
"<%=REQUEST_URI%>?restart=1"><%:a_s_ipt_restart Restart Firewall%
></a></li>
66 <fieldset class=
"cbi-section-node">
67 <% for _, tbl in ipairs({
"Filter",
"NAT",
"Mangle"}) do chaincnt =
0 %
>
68 <h3><%:a_s_ipt_table Table%
>: <%=tbl%
></h3>
69 <table class=
"cbi-section-table" style=
"font-size:90%">
70 <% for _, chain in ipairs(ipt:chains(tbl)) do
72 chaincnt = chaincnt +
1
73 chaininfo = ipt:chain(tbl, chain)
75 <tr class=
"cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>">
76 <th class=
"cbi-section-table-cell" style=
"text-align:left" colspan=
"11">
77 <br /><a name=
"rule_<%=tbl:lower()%>_<%=chain%>"></a>
78 <%:a_s_ipt_chain Chain%
> <em><%=chain%
></em>
79 (<%- if chaininfo.policy then -%
>
80 <%: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)-%
>
82 <%:a_s_ipt_references References%
>: <%=chaininfo.references-%
>
86 <tr class=
"cbi-section-table-descr">
87 <th class=
"cbi-section-table-cell"><%:a_s_ipt_rulenum Rule #%
></th>
88 <th class=
"cbi-section-table-cell"><%:a_s_ipt_packets Pkts.%
></th>
89 <th class=
"cbi-section-table-cell"><%:a_s_ipt_bytes Traffic%
></th>
90 <th class=
"cbi-section-table-cell"><%:a_s_ipt_target Target%
></th>
91 <th class=
"cbi-section-table-cell"><%:a_s_ipt_proto Prot.%
></th>
92 <th class=
"cbi-section-table-cell"><%:a_s_ipt_flags Flags%
></th>
93 <th class=
"cbi-section-table-cell"><%:a_s_ipt_inputif In%
></th>
94 <th class=
"cbi-section-table-cell"><%:a_s_ipt_outputif Out%
></th>
95 <th class=
"cbi-section-table-cell"><%:a_s_ipt_source Source%
></th>
96 <th class=
"cbi-section-table-cell"><%:a_s_ipt_destination Destination%
></th>
97 <th class=
"cbi-section-table-cell"><%:a_s_ipt_options Options%
></th>
100 <% for _, rule in ipairs(ipt:find({table=tbl, chain=chain})) do %
>
101 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
102 <td><%=rule.index%
></td>
103 <td><%=rule.packets%
></td>
104 <td><%=wba.byte_format(rule.bytes)%
></td>
105 <td><%=link_target(tbl, rule.target)%
></td>
106 <td><%=rule.protocol%
></td>
107 <td><%=rule.flags%
></td>
108 <td><%=link_iface(rule.inputif)%
></td>
109 <td><%=link_iface(rule.outputif)%
></td>
110 <td><%=rule.source%
></td>
111 <td><%=rule.destination%
></td>
112 <td><small><%=#rule.options
> 0 and table.concat(rule.options,
" ") or
"-"%
></small></td>
116 <% if rowcnt ==
1 then %
>
117 <tr class=
"cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>">
118 <td colspan=
"11"><em><%:a_s_ipt_norules No rules in this chain%
></em></td>
123 <% if chaincnt ==
0 then %
>
124 <tr class=
"cbi-section-table-titles cbi-rowstyle-<%=rowstyle()%>">
125 <td colspan=
"11"><em><%:a_s_ipt_nochains No chains in this table%
></em></td>
137 <% if ret ==
0 then luci.sys.reboot() end %
>