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: Basic
</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>
20 <style type='text/css'
>
46 <script type='text/javascript' src='debug.js'
></script>
48 <script type='text/javascript'
>
50 // <% nvram("portforward"); %>
51 var lipp
= '<% lipp(); %>.';
53 var fog
= new TomatoGrid();
55 fog
.sortCompare = function(a
, b
) {
56 var col
= this.sortColumn
;
57 var da
= a
.getRowData();
58 var db
= b
.getRowData();
64 r
= cmpIP(da
[col
], db
[col
]);
68 r
= cmpInt(da
[col
], db
[col
]);
71 r
= cmpText(da
[col
], db
[col
]);
75 return this.sortAscending
? r
: -r
;
78 fog
.dataToView = function(data
) {
79 return [(data
[0] != '0') ? 'On' : '', ['TCP', 'UDP', 'Both'][data
[1] - 1], (data
[2].match(/(.+)-(.+)/)) ? (RegExp
.$1 + ' -<br>' + RegExp
.$2) : data
[2], data
[3], data
[4], data
[5], data
[6]];
82 fog
.fieldValuesToData = function(row
) {
83 var f
= fields
.getAll(row
);
84 return [f
[0].checked
? 1 : 0, f
[1].value
, f
[2].value
, f
[3].value
, f
[4].value
, f
[5].value
, f
[6].value
];
87 fog
.verifyFields = function(row
, quiet
) {
88 var f
= fields
.getAll(row
);
91 f
[2].value
= f
[2].value
.trim();
93 if ((f
[2].value
.length
) && (!v_iptip(f
[2], 0))) return 0;
95 if (!v_iptport(f
[3], quiet
)) return 0;
97 if (f
[3].value
.search(/[-:,]/) != -1) {
102 f
[4].disabled
= false;
103 f
[4].value
= f
[4].value
.trim();
104 if (f
[4].value
!= '') {
105 if (!v_port(f
[4], quiet
)) return 0;
110 if (f
[5].value
.indexOf('.') == -1) f
[5].value
= lipp
+ f
[5].value
;
111 if (!v_ip(f
[5], quiet
, 1)) return 0;
113 f
[6].value
= f
[6].value
.replace(/>/g
, '_');
117 fog
.resetNewEditor = function() {
118 var f
= fields
.getAll(this.newEditor
);
120 f
[1].selectedIndex
= 0;
126 ferror
.clearAll(fields
.getAll(this.newEditor
));
129 fog
.setup = function() {
130 this.init('fo-grid', 'sort', 50, [
131 { type
: 'checkbox' },
132 { type
: 'select', options
: [[1, 'TCP'],[2, 'UDP'],[3,'Both']] },
133 { type
: 'text', maxlen
: 32 },
134 { type
: 'text', maxlen
: 16 },
135 { type
: 'text', maxlen
: 5 },
136 { type
: 'text', maxlen
: 15 },
137 { type
: 'text', maxlen
: 32 }]);
138 this.headerSet(['On', 'Proto', 'Src Address', 'Ext Ports', 'Int Port', 'Int Address', 'Description']);
139 var nv
= nvram
.portforward
.split('>');
140 for (var i
= 0; i
< nv
.length
; ++i
) {
144 if (r
= nv
[i
].match(/^(\d)<(\d)<([\d\-\:,]+)<(\d*)<(.*)<(.*)$/)) {
147 r
[3] = r
[3].replace(/:/g
, '-');
148 if (!fixIP(r
[5], 1)) r
[5] = lipp
+ r
[5];
149 fog
.insertData(-1, [r
[1], r
[2], '', r
[3], r
[4], r
[5], r
[6]]);
152 else if (r
= nv
[i
].match(/^(\d)<(\d)<(.*)<(.+?)<(\d*)<(.*)<(.*)$/)) {
155 r
[4] = r
[4].replace(/:/g
, '-');
156 if (!fixIP(r
[6], 1)) r
[6] = lipp
+ r
[6];
157 fog
.insertData(-1, r
.slice(1, 8));
164 function srcSort(a
, b
)
166 if (a
[2].length
) return -1;
167 if (b
[2].length
) return 1;
173 if (fog
.isEditing()) return;
175 var data
= fog
.getAllData().sort(srcSort
);
177 for (var i
= 0; i
< data
.length
; ++i
) {
178 data
[i
][3] = data
[i
][3].replace(/-/g
, ':');
179 s
+= data
[i
].join('<') + '>';
182 fom
.portforward
.value
= s
;
183 form
.submit(fom
, 1, 'tomato.cgi');
189 fog
.resetNewEditor();
193 <body onload='init()'
>
194 <form id='_fom' method='post' action='javascript:{}'
>
195 <table id='container' cellspacing=
0>
196 <tr><td colspan=
2 id='header'
>
197 <div class='title'
>Tomato
</div>
198 <div class='version'
>Version <%
version(); %></div>
200 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
202 <div id='ident'
><%
ident(); %></div>
206 <input type='hidden' name='_nextpage' value='forward-basic.asp'
>
207 <input type='hidden' name='_service' value='firewall-restart'
>
209 <input type='hidden' name='portforward'
>
211 <div class='section-title'
>Port Forwarding
</div>
212 <div class='section'
>
213 <table class='tomato-grid' cellspacing=
1 id='fo-grid'
></table>
214 <script type='text/javascript'
>fog
.setup();</script>
219 <li><b>Src Address
</b> <i>(optional)
</i> - Forward only if from this address. Ex:
"1.2.3.4",
"1.2.3.4 - 2.3.4.5",
"1.2.3.0/24".
220 <li><b>Ext Ports
</b> - The ports to be forwarded, as seen from the WAN. Ex:
"2345",
"200,300",
"200-300,400".
221 <li><b>Int Port
</b> <i>(optional)
</i> - The destination port inside the LAN. If blank, the destination port
222 is the same as
<i>Ext Ports
</i>. Only one port per entry is supported when forwarding to a different internal
224 <li><b>Int Address
</b> - The destination address inside the LAN.
231 <tr><td id='footer' colspan=
2>
232 <span id='footer-msg'
></span>
233 <input type='button' value='Save' id='save-button' onclick='save()'
>
234 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'
>