2 local fw = require "luci.model.firewall".init()
6 for _, z in ipairs(fw:get_zones()) do
7 if z:name() ~= "wan" then
9 elseif z:name() ~= "lan" then
14 <div class="cbi-section-create cbi-tblsection-create">
16 <table class="cbi-section-table" style="width:810px; margin-left:5px">
17 <tr class="cbi-section-table-titles">
18 <th class="cbi-section-table-cell" colspan="8"><%:New port forward%>:</th>
20 <tr class="cbi-section-table-descr">
21 <th class="cbi-section-table-cell"><%:Name%></th>
22 <th class="cbi-section-table-cell"><%:Protocol%></th>
23 <th class="cbi-section-table-cell"><%:External zone%></th>
24 <th class="cbi-section-table-cell"><%:External port%></th>
25 <th class="cbi-section-table-cell"><%:Internal zone%></th>
26 <th class="cbi-section-table-cell"><%:Internal IP address%></th>
27 <th class="cbi-section-table-cell"><%:Internal 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="_newfwd.name" name="_newfwd.name" placeholder="<%:New port forward%>" />
34 <td class="cbi-section-table-cell" style="width:110px">
35 <select class="cbi-input-select" id="_newfwd.proto" name="_newfwd.proto">
36 <option value="tcp udp">TCP+UDP</option>
37 <option value="tcp">TCP</option>
38 <option value="udp">UDP</option>
39 <option value="other"><%:Other...%></option>
42 <td class="cbi-section-table-cell" style="width:55px">
43 <select class="cbi-input-select" id="_newfwd.extzone" name="_newfwd.extzone">
44 <% for _, z in ipairs(ezl) do -%><option value="<%=z:name()%>"><%=z:name()%></option><%- end %>
47 <td class="cbi-section-table-cell" style="width:110px">
48 <input type="text" class="cbi-input-text" id="_newfwd.extport" name="_newfwd.extport" />
50 <td class="cbi-section-table-cell" style="width:55px">
51 <select class="cbi-input-select" id="_newfwd.intzone" name="_newfwd.intzone">
52 <% for _, z in ipairs(izl) do -%><option value="<%=z:name()%>"><%=z:name()%></option><%- end %>
55 <td class="cbi-section-table-cell" style="width:110px">
56 <input type="text" class="cbi-input-text" id="_newfwd.intaddr" name="_newfwd.intaddr" />
58 <td class="cbi-section-table-cell" style="width:110px">
59 <input type="text" class="cbi-input-text" id="_newfwd.intport" name="_newfwd.intport" />
61 <td class="cbi-section-table-cell">
62 <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
67 <script type="text/javascript">//<![CDATA[
68 cbi_validate_field('_newfwd.extport', true, 'portrange');
69 cbi_validate_field('_newfwd.intaddr', true, 'host');
70 cbi_validate_field('_newfwd.intport', true, 'portrange');
72 cbi_combobox_init('_newfwd.intaddr', {
73 <% first = true; luci.sys.net.ipv4_hints(function(ip, name) %>
74 <%- if first then first = false else %>,<% end -%>'<%=ip%>': '<%=ip%> (<%=name%>)'
75 <%- end) %> }, '', '<%: -- custom -- %>');
77 cbi_bind(document.getElementById('_newfwd.extport'), 'blur',
79 var n = document.getElementById('_newfwd.name');
80 var p = document.getElementById('_newfwd.proto');
81 var i = document.getElementById('_newfwd.intport');
83 /* port name 0=both, 1=tcp, 2=udp, 3=other */
93 if (!this.className.match(/invalid/))
95 if (!i.value) i.value = this.value;
97 var hint = hints[this.value || 0] || hints[i.value || 0];
100 p.selectedIndex = hint[1];
107 n.value = 'Forward' + this.value;
113 cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');