firewall_zoneforwards.htm 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <%+cbi/valueheader%>
  2. <%-
  3. local utl = require "luci.util"
  4. local fwm = require "luci.model.firewall".init()
  5. local nwm = require "luci.model.network".init()
  6. local zone, fwd, fz
  7. local value = self:formvalue(section)
  8. if not value or value == "-" then
  9. value = self:cfgvalue(section) or self.default
  10. end
  11. local def = fwm:get_defaults()
  12. local zone = fwm:get_zone(value)
  13. local empty = true
  14. local function render_zone(zone)
  15. -%>
  16. <label class="zonebadge" style="background-color:<%=zone:get_color()%>">
  17. <strong><%=zone:name()%></strong>
  18. <div class="cbi-tooltip">
  19. <%-
  20. local zempty = true
  21. for _, net in ipairs(zone:get_networks()) do
  22. net = nwm:get_network(net)
  23. if net then
  24. zempty = false
  25. -%>
  26. <span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:&#160;
  27. <%
  28. local nempty = true
  29. for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
  30. nempty = false
  31. %>
  32. <img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
  33. <% end %>
  34. <% if nempty then %><em><%:(empty)%></em><% end %>
  35. </span>
  36. <%- end end -%>
  37. <% if zempty then %><span class="ifacebadge"><em><%:(empty)%></em></span><% end %>
  38. </div>
  39. </label>
  40. <%-
  41. end
  42. -%>
  43. <% if zone then %>
  44. <div class="zone-forwards">
  45. <div class="zone-src">
  46. <%=render_zone(zone)%>
  47. </div>
  48. <span>&#8658;</span>
  49. <div class="zone-dest">
  50. <%
  51. for _, fwd in ipairs(zone:get_forwardings_by("src")) do
  52. fz = fwd:dest_zone()
  53. if fz then
  54. empty = false
  55. render_zone(fz)
  56. end
  57. end
  58. if empty then
  59. %>
  60. <label class="zonebadge zonebadge-empty">
  61. <strong><%=def:forward():upper()%></strong>
  62. </label>
  63. <% end %>
  64. </div>
  65. </div>
  66. <% end %>
  67. <%+cbi/valuefooter%>