9b17d52e7f45093198936811cc3b03e411fd54fa
[project/luci.git] / applications / luci-firewall / luasrc / view / firewall / cbi_addforward.htm
1 <div class="cbi-section-create cbi-tblsection-create">
2         <br />
3         <table class="cbi-section-table" style="width:700px; margin-left:5px">
4                 <tr class="cbi-section-table-titles">
5                         <th class="cbi-section-table-cell" colspan="6"><%:New port forward%>:</th>
6                 </tr>
7                 <tr class="cbi-section-table-descr">
8                         <th class="cbi-section-table-cell"><%:Name%></th>
9                         <th class="cbi-section-table-cell"><%:Protocol%></th>
10                         <th class="cbi-section-table-cell"><%:External port%></th>
11                         <th class="cbi-section-table-cell"><%:Internal IP address%></th>
12                         <th class="cbi-section-table-cell"><%:Internal port%></th>
13                         <th class="cbi-section-table-cell"></th>
14                 </tr>
15                 <tr class="cbi-section-table-row">
16                         <td class="cbi-section-table-cell">
17                                 <input type="text" class="cbi-input-text" id="_newfwd.name" name="_newfwd.name" placeholder="<%:New port forward%>" />
18                         </td>
19                         <td class="cbi-section-table-cell" style="width:110px">
20                                 <select class="cbi-input-select" id="_newfwd.proto" name="_newfwd.proto">
21                                         <option value="tcp udp">TCP+UDP</option>
22                                         <option value="tcp">TCP</option>
23                                         <option value="udp">UDP</option>
24                                         <option value="other"><%:Other...%></option>
25                                 </select>
26                         </td>
27                         <td class="cbi-section-table-cell" style="width:110px">
28                                 <input type="text" class="cbi-input-text" id="_newfwd.extport" name="_newfwd.extport" />
29                         </td>
30                         <td class="cbi-section-table-cell" style="width:110px">
31                                 <input type="text" class="cbi-input-text" id="_newfwd.intaddr" name="_newfwd.intaddr" />
32                         </td>
33                         <td class="cbi-section-table-cell" style="width:110px">
34                                 <input type="text" class="cbi-input-text" id="_newfwd.intport" name="_newfwd.intport" />
35                         </td>
36                         <td class="cbi-section-table-cell">
37                                 <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" value="<%:Add%>" />
38                         </td>
39                 </tr>
40         </table>
41
42         <script type="text/javascript">//<![CDATA[
43                 cbi_validate_field('_newfwd.extport', true, 'portrange');
44                 cbi_validate_field('_newfwd.intaddr', true, 'host');
45                 cbi_validate_field('_newfwd.intport', true, 'portrange');
46
47                 cbi_combobox_init('_newfwd.intaddr', {
48                         <% first = true; luci.sys.net.ipv4_hints(function(ip, name) %>
49                                 <%- if first then first = false else %>,<% end -%>'<%=ip%>': '<%=ip%> (<%=name%>)'
50                         <%- end) %> }, '', '<%: -- custom -- %>');
51
52                 cbi_bind(document.getElementById('_newfwd.extport'), 'blur',
53                         function() {
54                                 var n = document.getElementById('_newfwd.name');
55                                 var p = document.getElementById('_newfwd.proto');
56                                 var i = document.getElementById('_newfwd.intport');
57                                 var hints = {
58                                 /*  port    name     0=both, 1=tcp, 2=udp, 3=other */
59                                         21:   [ 'FTP',   1 ],
60                                         22:   [ 'SSH',   1 ],
61                                         53:   [ 'DNS',   0 ],
62                                         80:   [ 'HTTP',  1 ],
63                                         443:  [ 'HTTPS', 1 ],
64                                         3389: [ 'RDP',   1 ],
65                                         5900: [ 'VNC',   1 ],
66                                 };
67
68                                 if (!this.className.match(/invalid/))
69                                 {
70                                         if (!i.value) i.value = this.value;
71
72                                         var hint = hints[this.value || 0] || hints[i.value || 0];
73                                         if (hint)
74                                         {
75                                                 p.selectedIndex = hint[1];
76
77                                                 if (!n.value)
78                                                         n.value = hint[0];
79                                         }
80                                         else if (!n.value)
81                                         {
82                                                 n.value = 'Forward' + this.value;
83                                         }
84                                 }
85                         });
86
87
88                 cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');
89         //]]></script>
90 </div>