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