luci.sys = require "luci.sys"
luci.ip = require "luci.ip"
-local tonumber, ipairs = tonumber, ipairs
+local tonumber, ipairs, table = tonumber, ipairs, table
--- LuCI iptables parser and query library
-- @cstyle instance
local rule_parts = luci.util.split( rule, "%s+", nil, true )
local rule_details = { }
+ -- cope with rules that have no target assigned
+ if rule:match("^%d+%s+%d+%s+%d+%s%s") then
+ table.insert(rule_parts, 4, nil)
+ end
+
rule_details["table"] = tbl
rule_details["chain"] = self._chain
rule_details["index"] = tonumber(rule_parts[1])
<td><%=rule.index%></td>
<td><%=rule.packets%></td>
<td><%=wba.byte_format(rule.bytes)%></td>
- <td><%=link_target(tbl, rule.target)%></td>
+ <td><%=rule.target and link_target(tbl, rule.target) or "-"%></td>
<td><%=rule.protocol%></td>
<td><%=rule.flags%></td>
<td><%=link_iface(rule.inputif)%></td>