2 local fw = require "luci.model.firewall".init()
6 for _, z in ipairs(fw:get_zones()) do
7 if z:name() ~= "wan" then
10 if z:name() ~= "lan" then
15 local keys, vals = { }, { }
16 luci.sys.net.ipv4_hints(function(ip, name)
18 vals[#vals+1] = '%s (%s)' %{ ip, name }
21 <div class="cbi-section-create cbi-tblsection-create">
23 <table class="cbi-section-table" style="width:810px; margin-left:5px">
24 <tr class="cbi-section-table-titles">
25 <th class="cbi-section-table-cell" colspan="8"><%:New port forward%>:</th>
27 <tr class="cbi-section-table-descr">
28 <th class="cbi-section-table-cell"><%:Name%></th>
29 <th class="cbi-section-table-cell"><%:Protocol%></th>
30 <th class="cbi-section-table-cell"><%:External zone%></th>
31 <th class="cbi-section-table-cell"><%:External port%></th>
32 <th class="cbi-section-table-cell"><%:Internal zone%></th>
33 <th class="cbi-section-table-cell"><%:Internal IP address%></th>
34 <th class="cbi-section-table-cell"><%:Internal port%></th>
35 <th class="cbi-section-table-cell"></th>
37 <tr class="cbi-section-table-row">
38 <td class="cbi-section-table-cell">
39 <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New port forward%>" />
41 <td class="cbi-section-table-cell" style="width:110px">
42 <select class="cbi-input-select" id="_newfwd.proto" name="_newfwd.proto">
43 <option value="tcp udp">TCP+UDP</option>
44 <option value="tcp">TCP</option>
45 <option value="udp">UDP</option>
46 <option value="other"><%:Other...%></option>
49 <td class="cbi-section-table-cell" style="width:55px">
50 <select class="cbi-input-select" id="_newfwd.extzone" name="_newfwd.extzone">
51 <% for _, z in ipairs(ezl) do -%><option value="<%=z:name()%>"><%=z:name()%></option><%- end %>
54 <td class="cbi-section-table-cell" style="width:110px">
55 <input type="text" class="cbi-input-text" id="_newfwd.extport" name="_newfwd.extport" data-type="portrange" data-optional="true" />
57 <td class="cbi-section-table-cell" style="width:55px">
58 <select class="cbi-input-select" id="_newfwd.intzone" name="_newfwd.intzone">
59 <% for _, z in ipairs(izl) do -%><option value="<%=z:name()%>"><%=z:name()%></option><%- end %>
62 <td class="cbi-section-table-cell" style="width:110px">
63 <input type="text" class="cbi-input-text" id="_newfwd.intaddr" name="_newfwd.intaddr" data-type="host" data-optional="true"<%=
64 ifattr(#keys > 0, "data-choices", {keys, vals})
67 <td class="cbi-section-table-cell" style="width:110px">
68 <input type="text" class="cbi-input-text" id="_newfwd.intport" name="_newfwd.intport" data-type="portrange" data-optional="true" />
70 <td class="cbi-section-table-cell">
71 <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
76 <script type="text/javascript">//<![CDATA[
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;