2 local fw = require "luci.model.firewall".init()
3 local nw = require "luci.model.network".init()
4 local zones = fw:get_zones()
6 local keys, vals, a, k, v = {}, {}
7 for k, v in ipairs(nw:get_interfaces()) do
8 for k, a in ipairs(v:ipaddrs()) do
9 keys[#keys+1] = a:host():string()
10 vals[#vals+1] = '%s (%s)' %{ a:host(), v:shortname() }
15 <div class="cbi-section-create cbi-tblsection-create">
16 <% if #zones > 1 then %>
18 <table class="cbi-section-table" style="width:700px; margin-left:5px">
19 <tr class="cbi-section-table-titles">
20 <th class="cbi-section-table-cell left" colspan="6"><%:New source NAT%>:</th>
22 <tr class="cbi-section-table-descr">
23 <th class="cbi-section-table-cell"><%:Name%></th>
24 <th class="cbi-section-table-cell"><%:Source zone%></th>
25 <th class="cbi-section-table-cell"><%:Destination zone%></th>
26 <th class="cbi-section-table-cell"><%:To source IP%></th>
27 <th class="cbi-section-table-cell"><%:To source port%></th>
28 <th class="cbi-section-table-cell"></th>
30 <tr class="cbi-section-table-row">
31 <td class="cbi-section-table-cell">
32 <input type="text" class="cbi-input-text" id="_newsnat.name" name="_newsnat.name" placeholder="<%:New SNAT rule%>" />
34 <td class="cbi-section-table-cell" style="width:110px">
35 <select class="cbi-input-text" id="_newsnat.src" name="_newsnat.src">
36 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
37 <option<%=ifattr(v:name() == "lan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
41 <td class="cbi-section-table-cell" style="width:110px">
42 <select class="cbi-input-text" id="_newsnat.dest" name="_newsnat.dest">
43 <% local k, v; for k, v in ipairs(fw:get_zones()) do -%>
44 <option<%=ifattr(v:name() == "wan", "selected", "selected")%> value="<%=v:name()%>"><%=v:name()%></option>
48 <td class="cbi-section-table-cell" style="width:110px">
49 <input type="text" class="cbi-input-text" id="_newsnat.dip" name="_newsnat.dip" placeholder="<%:Do not rewrite%>" data-type="ip4addr" data-optional="true"<%=
50 ifattr(#keys > 0, "data-choices", { keys, vals })
53 <td class="cbi-section-table-cell" style="width:110px">
54 <input type="text" class="cbi-input-text" id="_newsnat.dport" name="_newsnat.dport" placeholder="<%:Do not rewrite%>" data-type="portrange" data-optional="true" />
56 <td class="cbi-section-table-cell">
57 <input type="submit" class="cbi-button cbi-button-link" name="_newsnat.submit" value="<%:Add and edit...%>" />
62 <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />