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")
7 local keys, vals, a, k, v = {}, {}
8 for k, v in ipairs(nw:get_interfaces()) do
9 for k, a in ipairs(v:ipaddrs()) do
10 keys[#keys+1] = a:host():string()
11 vals[#vals+1] = '%s (%s)' %{ a:host(), v:shortname() }
16 <div class="cbi-section-create cbi-tblsection-create">
17 <% if wz and lz then %>
19 <table class="cbi-section-table" style="width:700px; margin-left:5px">
20 <tr class="cbi-section-table-titles">
21 <th class="cbi-section-table-cell left" colspan="6"><%:New source NAT%>:</th>
23 <tr class="cbi-section-table-descr">
24 <th class="cbi-section-table-cell"><%:Name%></th>
25 <th class="cbi-section-table-cell"><%:Source zone%></th>
26 <th class="cbi-section-table-cell"><%:Destination zone%></th>
27 <th class="cbi-section-table-cell"><%:To source IP%></th>
28 <th class="cbi-section-table-cell"><%:To source port%></th>
29 <th class="cbi-section-table-cell"></th>
31 <tr class="cbi-section-table-row">
32 <td class="cbi-section-table-cell">
33 <input type="text" class="cbi-input-text" id="_newsnat.name" name="_newsnat.name" placeholder="<%:New SNAT rule%>" />
35 <td class="cbi-section-table-cell" style="width:110px">
36 <select class="cbi-input-text" id="_newsnat.src" name="_newsnat.src">
37 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
38 <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
42 <td class="cbi-section-table-cell" style="width:110px">
43 <select class="cbi-input-text" id="_newsnat.dest" name="_newsnat.dest">
44 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
45 <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
49 <td class="cbi-section-table-cell" style="width:110px">
50 <input type="text" class="cbi-input-text" id="_newsnat.dip" name="_newsnat.dip" placeholder="<%:Do not rewrite%>" data-type="ip4addr" data-optional="true"<%=
51 ifattr(#keys > 0, "data-choices", { keys, vals })
54 <td class="cbi-section-table-cell" style="width:110px">
55 <input type="text" class="cbi-input-text" id="_newsnat.dport" name="_newsnat.dport" placeholder="<%:Do not rewrite%>" data-type="portrange" data-optional="true" />
57 <td class="cbi-section-table-cell">
58 <input type="submit" class="cbi-button cbi-button-link" name="_newsnat.submit" value="<%:Add and edit...%>" />
63 <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />