luci-base: gracefully handle broken firewall forwarding sections

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2017-09-07 15:29:45 +02:00
parent 462779c384
commit 98aacba3ac
2 changed files with 7 additions and 4 deletions

View file

@ -498,11 +498,13 @@ function forwarding.dest(self)
end
function forwarding.src_zone(self)
return zone(self:src())
local z = zone(self:src())
return z.sid and z
end
function forwarding.dest_zone(self)
return zone(self:dest())
local z = zone(self:dest())
return z.sid and z
end

View file

@ -43,11 +43,12 @@
&#160;&#8658;&#160;
<% for _, fwd in ipairs(zone:get_forwardings_by("src")) do
fz = fwd:dest_zone()
empty = false %>
if fz then
empty = false %>
<label class="zonebadge" style="background-color:<%=fz:get_color()%>">
<strong><%=fz:name()%></strong>
</label>&#160;
<% end %>
<% end end %>
<% if empty then %>
<label class="zonebadge zonebadge-empty">
<strong><%=zone:forward():upper()%></strong>