1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
12 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
13 <meta name='robots' content='noindex,nofollow'
>
14 <title>[<%
ident(); %>] Forwarding: UPnP / NAT-PMP
</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'
>
16 <link rel='stylesheet' type='text/css' href='color.css'
>
17 <script type='text/javascript' src='tomato.js'
></script>
21 <style type='text/css'
>
22 #upnp-grid .co1
, #upnp-grid
.co2
{
36 <script type='text/javascript' src='debug.js'
></script>
38 <script type='text/javascript'
>
41 !!TB - additional miniupnp settings
43 // <% nvram("upnp_enable,upnp_mnp,upnp_clean,upnp_secure,upnp_clean_interval,upnp_clean_threshold"); %>
47 nvram
.upnp_enable
= fixInt(nvram
.upnp_enable
, 0, 3, 0);
50 function submitDelete(proto
, eport
)
52 form
.submitHidden('upnp.cgi', {
55 _redirect
: 'forward-upnp.asp' });
58 function deleteData(data
)
60 if (!confirm('Delete ' + data
[3] + ' ' + data
[0] + ' -> ' + data
[2] + ':' + data
[1] + ' ?')) return;
61 submitDelete(data
[3], data
[0]);
64 var ug
= new TomatoGrid();
66 ug
.onClick = function(cell
) {
67 deleteData(cell
.parentNode
.getRowData());
70 ug
.rpDel = function(e
) {
71 deleteData(PR(e
).getRowData());
75 ug
.setup = function() {
76 this.init('upnp-grid', 'sort delete');
77 this.headerSet(['External', 'Internal', 'Internal Address', 'Protocol', 'Description']);
81 ug
.populate = function() {
82 var i
, j
, r
, row
, data
;
84 if (nvram
.upnp_enable
!= 0) {
85 var data
= mupnp_data
.split('\n');
86 for (i
= 0; i
< data
.length
; ++i
) {
87 r
= data
[i
].match(/^(UDP|TCP)\s+(\d+)\s+(.+?)\s+(\d+)\s+\[(.*)\](.*)$/);
88 if (r
== null) continue;
89 row
= this.insertData(-1, [r
[2], r
[4], r
[3], r
[1], r
[5]]);
92 for (j
= 0; j
< 5; ++j
) {
93 elem
.addClass(row
.cells
[j
], 'disabled');
96 for (j
= 0; j
< 5; ++j
) {
97 row
.cells
[j
].title
= 'Click to delete';
102 E('upnp-delete-all').disabled
= (ug
.getDataCount() == 0);
107 if (!confirm('Delete all entries?')) return;
108 submitDelete('*', '0');
111 function toggleFiltersVisibility(){
112 if(E('upnpsettings').style
.display
=='')
113 E('upnpsettings').style
.display
='none';
115 E('upnpsettings').style
.display
='';
118 function verifyFields(focused
, quiet
)
121 !!TB - additional miniupnp settings
123 var enable
= E('_f_enable_upnp').checked
|| E('_f_enable_natpmp').checked
;
124 var bc
= E('_f_upnp_clean').checked
;
126 E('_f_upnp_clean').disabled
= (enable
== 0);
127 E('_f_upnp_secure').disabled
= (enable
== 0);
128 E('_f_upnp_mnp').disabled
= (E('_f_enable_upnp').checked
== 0);
129 E('_upnp_clean_interval').disabled
= (enable
== 0) || (bc
== 0);
130 E('_upnp_clean_threshold').disabled
= (enable
== 0) || (bc
== 0);
131 elem
.display(PR(E('_upnp_clean_interval')), (enable
!= 0) && (bc
!= 0));
132 elem
.display(PR(E('_upnp_clean_threshold')), (enable
!= 0) && (bc
!= 0));
134 if ((enable
!= 0) && (bc
!= 0)) {
135 if (!v_range('_upnp_clean_interval', quiet
, 60, 65535)) return 0;
136 if (!v_range('_upnp_clean_threshold', quiet
, 0, 9999)) return 0;
139 ferror
.clear(E('_upnp_clean_interval'));
140 ferror
.clear(E('_upnp_clean_threshold'));
151 if (!verifyFields(null, 0)) return;
154 fom
.upnp_enable
.value
= 0;
155 if (fom
.f_enable_upnp
.checked
) fom
.upnp_enable
.value
= 1;
156 if (fom
.f_enable_natpmp
.checked
) fom
.upnp_enable
.value
|= 2;
159 !!TB - additional miniupnp settings
161 fom
.upnp_mnp
.value
= E('_f_upnp_mnp').checked
? 1 : 0;
162 fom
.upnp_clean
.value
= E('_f_upnp_clean').checked
? 1 : 0;
163 fom
.upnp_secure
.value
= E('_f_upnp_secure').checked
? 1 : 0;
176 function submit_complete()
183 <body onload='init()'
>
184 <form id='_fom' method='post' action='tomato.cgi'
>
185 <table id='container' cellspacing=
0>
186 <tr><td colspan=
2 id='header'
>
187 <div class='title'
>Tomato
</div>
188 <div class='version'
>Version <%
version(); %></div>
190 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
192 <div id='ident'
><%
ident(); %></div>
196 <input type='hidden' name='_nextpage' value='forward-upnp.asp'
>
197 <input type='hidden' name='_service' value='upnp-restart'
>
199 <input type='hidden' name='upnp_enable'
>
201 !!TB - additional miniupnp settings
203 <input type='hidden' name='upnp_mnp'
>
204 <input type='hidden' name='upnp_clean'
>
205 <input type='hidden' name='upnp_secure'
>
207 <div class='section-title'
>Forwarded Ports
</div>
208 <div class='section'
>
209 <table id='upnp-grid' class='tomato-grid'
></table>
210 <div style='width:
100%; text-align: right'
><input type='button' value='Delete All' onclick='deleteAll()' id='upnp-delete-all'
> <input type='button' value='Refresh' onclick='javascript:reloadPage();'
></div>
213 <div class='section-title'
>Settings
<small><i><a href='javascript:toggleFiltersVisibility();'
>(Toggle Visibility)
</a></i></small></div>
214 <div class='section' id='upnpsettings' style='display:none'
>
215 <script type='text/javascript'
>
216 createFieldTable('', [
217 { title
: 'Enable UPnP', name
: 'f_enable_upnp', type
: 'checkbox', value
: (nvram
.upnp_enable
& 1) },
218 { title
: 'Enable NAT-PMP', name
: 'f_enable_natpmp', type
: 'checkbox', value
: (nvram
.upnp_enable
& 2) },
220 !!TB - additional miniupnp settings
222 { title
: 'Inactive Rules Cleaning', name
: 'f_upnp_clean', type
: 'checkbox', value
: (nvram
.upnp_clean
== '1') },
223 { title
: 'Cleaning Interval', indent
: 2, name
: 'upnp_clean_interval', type
: 'text', maxlen
: 5, size
: 7,
224 suffix
: ' <small>seconds</small>', value
: nvram
.upnp_clean_interval
},
225 { title
: 'Cleaning Threshold', indent
: 2, name
: 'upnp_clean_threshold', type
: 'text', maxlen
: 4, size
: 7,
226 suffix
: ' <small>redirections</small>', value
: nvram
.upnp_clean_threshold
},
227 { title
: 'Secure Mode', name
: 'f_upnp_secure', type
: 'checkbox',
228 suffix
: ' <small>(when enabled, UPnP clients are allowed to add mappings only to their IP)</small>',
229 value
: (nvram
.upnp_secure
== '1') },
231 { title
: 'Show In My Network Places', name
: 'f_upnp_mnp', type
: 'checkbox', value
: (nvram
.upnp_mnp
== '1') }
240 <tr><td id='footer' colspan=
2>
241 <span id='footer-msg'
></span>
242 <input type='button' value='Save' id='save-button' onclick='save()'
>
243 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'
>
248 !!TB - added verifyFields
250 <script type='text/javascript'
>ug
.setup();verifyFields(null, 1);</script>