cbi_addsnat.htm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <%
  2. local fw = require "luci.model.firewall".init()
  3. local nw = require "luci.model.network".init()
  4. local wz = fw:get_zone("wan")
  5. local lz = fw:get_zone("lan")
  6. %>
  7. <div class="cbi-section-create cbi-tblsection-create">
  8. <% if wz and lz then %>
  9. <br />
  10. <table class="cbi-section-table" style="width:700px; margin-left:5px">
  11. <tr class="cbi-section-table-titles">
  12. <th class="cbi-section-table-cell left" colspan="6"><%:New source NAT%>:</th>
  13. </tr>
  14. <tr class="cbi-section-table-descr">
  15. <th class="cbi-section-table-cell"><%:Name%></th>
  16. <th class="cbi-section-table-cell"><%:Source zone%></th>
  17. <th class="cbi-section-table-cell"><%:Destination zone%></th>
  18. <th class="cbi-section-table-cell"><%:To source IP%></th>
  19. <th class="cbi-section-table-cell"><%:To source port%></th>
  20. <th class="cbi-section-table-cell"></th>
  21. </tr>
  22. <tr class="cbi-section-table-row">
  23. <td class="cbi-section-table-cell">
  24. <input type="text" class="cbi-input-text" id="_newsnat.name" name="_newsnat.name" placeholder="<%:New SNAT rule%>" />
  25. </td>
  26. <td class="cbi-section-table-cell" style="width:110px">
  27. <select class="cbi-input-text" id="_newsnat.src" name="_newsnat.src">
  28. <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
  29. <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
  30. <%- end %>
  31. </select>
  32. </td>
  33. <td class="cbi-section-table-cell" style="width:110px">
  34. <select class="cbi-input-text" id="_newsnat.dest" name="_newsnat.dest">
  35. <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
  36. <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
  37. <%- end %>
  38. </select>
  39. </td>
  40. <td class="cbi-section-table-cell" style="width:110px">
  41. <input type="text" class="cbi-input-text" id="_newsnat.dip" name="_newsnat.dip" />
  42. </td>
  43. <td class="cbi-section-table-cell" style="width:110px">
  44. <input type="text" class="cbi-input-text" id="_newsnat.dport" name="_newsnat.dport" placeholder="<%:Do not rewrite%>" />
  45. </td>
  46. <td class="cbi-section-table-cell">
  47. <input type="submit" class="cbi-button cbi-button-link" name="_newsnat.submit" value="<%:Add and edit...%>" />
  48. </td>
  49. </tr>
  50. </table>
  51. <script type="text/javascript">//<![CDATA[
  52. cbi_validate_field('_newsnat.dport', true, 'portrange');
  53. cbi_validate_field('_newsnat.dip', true, 'ip4addr');
  54. cbi_combobox_init('_newsnat.dip', {
  55. <% local c, k, v = 0; for k, v in ipairs(nw:get_interfaces()) do -%>
  56. <%- local a; for k, a in ipairs(v:ipaddrs()) do c = c + 1 -%>
  57. <% if c > 1 then %>,<% end %>'<%=a:host():string()%>': '<%=a:host():string()%> (<%=v:shortname()%>)'
  58. <%- end %>
  59. <%- end %> }, '<%: -- Please choose -- %>', '<%: -- custom -- %>');
  60. //]]></script>
  61. <% else %>
  62. <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
  63. <% end %>
  64. </div>