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(); %>] Basic: DDNS
</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 <script type='text/javascript' src='debug.js'
></script>
23 <script type='text/javascript'
>
25 // <% nvram("ddnsx0,ddnsx1,ddnsx_ip,wan_dns,wan_get_dns,dns_addget,ddnsx_refresh,ddnsx_save"); %>
34 j = hostname (optional)
41 z = can't use client-given IP address
42 s = save state checkbox
48 ['3322', '3322', 'http://www.3322.org/', 'uhwmb'],
49 ['3322-static', '3322 - Static', 'http://www.3322.org/', 'uhwmb'],
50 ['dnsexit', 'DNS Exit', 'http://www.dnsexit.com/', 'uh'],
51 ['dnsomatic', 'DNS-O-Matic', 'http://www.dnsomatic.com/', 'u'],
52 ['dyndns', 'DynDNS - Dynamic', 'http://www.dyndns.com/', 'uhwmbs'],
53 ['dyndns-static', 'DynDNS - Static', 'http://www.dyndns.com/', 'uhwmbs'],
54 ['dyndns-custom', 'DynDNS - Custom', 'http://www.dyndns.com/', 'uhwmbs'],
55 ['sdyndns', 'DynDNS (https) - Dynamic', 'http://www.dyndns.com/', 'uhwmbs'],
56 ['sdyndns-static', 'DynDNS (https) - Static', 'http://www.dyndns.com/', 'uhwmbs'],
57 ['sdyndns-custom', 'DynDNS (https) - Custom', 'http://www.dyndns.com/', 'uhwmbs'],
58 ['dyns', 'DyNS', 'http://www.dyns.cx/', 'uh'],
59 ['easydns', 'easyDNS', 'http://www.easydns.com/', 'uhwm'],
60 ['seasydns', 'easyDNS (https)', 'http://www.easydns.com/', 'uhwm'],
61 ['editdns', 'EditDNS', 'http://www.editdns.net/', 'tpz'],
62 ['everydns', 'EveryDNS', 'http://www.everydns.net/', 'uj', null, null, 'Domain <small>(optional)</small>'],
63 ['enom', 'eNom', 'http://www.enom.com/', 'ut', 'Domain'],
64 ['afraid', 'FreeDNS (afraid.org)', 'http://freedns.afraid.org/', 'az'],
65 ['ieserver', 'ieServer.net', 'http://www.ieserver.net/', 'uhz', 'Username / Hostname', null, 'Domain'],
66 ['namecheap', 'namecheap', 'http://www.namecheap.com/', 'ut', 'Domain'],
67 ['noip', 'No-IP.com', 'http://www.no-ip.com/', 'uh', 'Email Address', null, 'Hostname / Group'],
68 ['opendns', 'OpenDNS', 'http://www.opendns.com/', 'uhoz', null, null, 'Network <small>(optional)</small>'],
69 ['tzo', 'TZO', 'http://www.tzo.com/', 'uh', 'Email Address', 'Password'],
70 ['zoneedit', 'ZoneEdit', 'http://www.zoneedit.com/', 'uh'],
71 ['custom', 'Custom URL', '', 'c']];
73 var opendns
= ['208.67.222.222', '208.67.220.220'];
80 s
= s
.replace(/\n+/g, ' ');
81 if (r
= s
.match(/^(.*?): (.*)/)) {
82 r
[2] = r
[2].replace(/#RETRY (\d+) (\d+)/,
83 function(s
, min
, num
) {
84 return '<br><small>(' + ((num
>= 1) ? (num
+ '/3: ') : '') + 'Automatically retrying in ' + min
+ ' minutes)</small>';
87 return '<small>' + (new Date(r
[1])).toLocaleString() + ':</small><br>' + r
[2];
89 else if (s
.length
== 0) {
100 for (i
= s
.length
- 1; i
>= 0; --i
) {
107 function verifyFields(focused
, quiet
)
115 b
= E('_f_ddnsx_ip').value
== 'custom';
116 elem
.display(PR('_f_custom_ip'), b
);
117 if ((b
) && (!v_ip('_f_custom_ip', quiet
))) return 0;
119 if (!v_range('_ddnsx_refresh', quiet
, 0, 90)) return 0;
122 for (i
= 0; i
< 2; ++i
) {
123 data
= services
[E('_f_service' + i
).selectedIndex
] || services
[0];
124 enabled
= (data
[0] != '');
128 elem
.display(PR('url' + i
), (enabled
) && (data
[0] != 'custom'));
129 elem
.display('row_z' + i
, op
.z
);
131 elem
.display(PR('_f_hosttop' + i
), op
.t
);
132 elem
.display(PR('_f_user' + i
), op
.u
);
133 elem
.display(PR('_f_pass' + i
), op
.u
|| op
.p
);
134 elem
.display(PR('_f_host' + i
), op
.h
|| op
.j
);
135 elem
.display(PR('_f_cust' + i
), 'custmsg' + i
, op
.c
);
137 elem
.display(PR('_f_wild' + i
), op
.w
);
138 elem
.display(PR('_f_mx' + i
), op
.m
);
139 elem
.display(PR('_f_bmx' + i
), op
.b
);
140 elem
.display(PR('_f_opendns' + i
), op
.o
);
141 elem
.display(PR('_f_afraid' + i
), op
.a
);
142 elem
.display(PR('_f_ddnsx_save' + i
), op
.s
);
144 elem
.display(PR('_f_force' + i
), 'last-response' + i
, enabled
);
145 elem
.display('last-update' + i
, enabled
&& !op
.z
);
148 PR('_f_user' + i
).cells
[0].innerHTML
= data
[4] || 'Username';
149 PR('_f_pass' + i
).cells
[0].innerHTML
= data
[5] || 'Password';
150 PR('_f_host' + i
).cells
[0].innerHTML
= data
[6] || 'Hostname';
154 e
.innerHTML
= data
[2];
157 e
= E('_f_cust' + i
);
158 e
.value
= e
.value
.trim();
162 if (e
.value
.search(/http(s?):\/\/./) != 0) {
163 ferror
.set(e
, 'Expecting a URL -- http://... or https://...', quiet
)
171 e
= E('_f_afraid' + i
);
172 e
.value
= e
.value
.trim();
173 if (e
.value
.match(/freedns\.afraid\.org\/dynamic\/update\.php\?([a-zA-Z0-9]+)/)) {
176 if (e
.value
.search(/^[A-Za-z0-9]+/) == -1) {
177 ferror
.set(e
, 'Invalid hash or URL', quiet
)
185 if (((op
.u
) && (!v_length('_f_user' + i
, quiet
, 1))) ||
186 (!v_length('_f_pass' + i
, quiet
, 1)) ||
187 ((op
.h
) && (!op
.o
) && (!v_length('_f_host' + i
, quiet
, 1))) ||
188 ((op
.t
) && (!v_length('_f_hosttop' + i
, quiet
, 1)))) {
195 // shouldn't do this twice, but...
196 if (E('_f_opendns0') == focused
) E('_f_opendns1').checked
= E('_f_opendns0').checked
;
197 if (E('_f_opendns1') == focused
) E('_f_opendns0').checked
= E('_f_opendns1').checked
;
199 if (E('_f_ddnsx_save0') == focused
) E('_f_ddnsx_save1').checked
= E('_f_ddnsx_save0').checked
;
200 if (E('_f_ddnsx_save1') == focused
) E('_f_ddnsx_save0').checked
= E('_f_ddnsx_save1').checked
;
213 if (!verifyFields(null, 0)) return;
216 fom
.ddnsx_save
.value
= (nvram
.ddnsx_save
== 1) ? 1 : 0;
218 fom
.ddnsx_ip
.value
= (E('_f_ddnsx_ip').value
== 'custom') ? E('_f_custom_ip').value
: E('_f_ddnsx_ip').value
;
221 for (i
= 0; i
< 2; ++i
) {
223 data
= services
[E('_f_service' + i
).selectedIndex
] || services
[0];
229 u = username/password
237 z = can't use client-given IP address
238 s = save state checkbox
249 custom url/afraid hash<
254 if ((op
.u
) || (op
.p
)) s
.push(E('_f_user' + i
).value
+ ':' + E('_f_pass' + i
).value
);
258 s
.push(E('_f_hosttop' + i
).value
);
260 else if ((op
.h
) || (op
.j
)) {
261 s
.push(E('_f_host' + i
).value
);
267 if (op
.w
) s
.push(E('_f_wild' + i
).checked
? 1 : 0);
269 if (op
.m
) s
.push(E('_f_mx' + i
).value
)
271 if (op
.b
) s
.push(E('_f_bmx' + i
).checked
? 1 : 0);
275 s
.push(E('_f_cust' + i
).value
);
278 s
.push(E('_f_afraid' + i
).value
);
285 fom
.ddnsx_save
.value
= E('_f_ddnsx_save' + i
).checked
? 1 : 0;
288 if (data
[0] == 'opendns') setopendns
= E('_f_opendns' + i
).checked
;
291 fom
['ddnsx' + i
].value
= s
;
292 fom
['ddnsx' + i
+ '_cache'].disabled
= (!E('_f_force' + i
).checked
) && (s
== nvram
['ddnsx' + i
]);
295 if (setopendns
!= -1) {
297 if (opendnsInUse
!= opendns
.length
) {
298 fom
.wan_dns
.value
= opendns
.join(' ');
299 fom
.wan_dns
.disabled
= 0;
300 fom
._service
.value
+= ',dns-restart';
304 // not set if partial, do not remove if partial
305 if (opendnsInUse
== opendns
.length
) {
306 a
= nvram
.wan_dns
.split(/\s+/);
308 for (i
= a
.length
- 1; i
>= 0; --i
) {
309 for (j
= opendns
.length
- 1; j
>= 0; --j
) {
310 if (a
[i
] == opendns
[j
]) {
316 fom
.wan_dns
.value
= a
.join(' ');
317 fom
.wan_dns
.disabled
= 0;
318 fom
._service
.value
+= ',dns-restart';
328 if ('<% psup("ddns-update"); %>' != 0) {
329 var e
= E('footer-msg');
330 e
.innerHTML
= 'DDNS update is running. Please refresh after a few seconds.';
331 e
.style
.visibility
= 'visible';
337 <body onload='init()'
>
338 <form id='_fom' method='post' action='tomato.cgi'
>
339 <table id='container' cellspacing=
0>
340 <tr><td colspan=
2 id='header'
>
341 <div class='title'
>Tomato
</div>
342 <div class='version'
>Version <%
version(); %></div>
344 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
346 <div id='ident'
><%
ident(); %></div>
350 <input type='hidden' name='_nextpage' value='basic-ddns.asp'
>
351 <input type='hidden' name='_service' value='ddns-restart'
>
352 <input type='hidden' name='_nextwait' value='
8'
>
354 <input type='hidden' name='ddnsx0' value=''
>
355 <input type='hidden' name='ddnsx1' value=''
>
356 <input type='hidden' name='ddnsx0_cache' value='' disabled
>
357 <input type='hidden' name='ddnsx1_cache' value='' disabled
>
358 <input type='hidden' name='wan_dns' value='' disabled
>
359 <input type='hidden' name='ddnsx_ip' value=''
>
360 <input type='hidden' name='ddnsx_save' value=''
>
363 <div class='section-title'
>Dynamic DNS
</div>
364 <div class='section'
>
365 <script type='text/javascript'
>
367 a
= (s
!= '') && (s
.indexOf('@') != 0) && (s
!= '0.0.0.0') && (s
!= '1.1.1.1') && (s
!= '10.1.1.1');
368 createFieldTable('', [
369 { title
: 'IP address', name
: 'f_ddnsx_ip', type
: 'select',
371 ['', 'Use WAN IP Address ' + ddnsx_ip
+ ' (recommended)'],
372 ['@', 'Use External IP Address Checker (every 10 minutes)'],
373 ['0.0.0.0', 'Offline (0.0.0.0)'],
374 ['1.1.1.1', 'Offline (1.1.1.1)'],
375 ['10.1.1.1', 'Offline (10.1.1.1)'],
376 ['custom', 'Custom IP Address...']
378 value
: a
? 'custom' : nvram
.ddnsx_ip
},
379 { title
: 'Custom IP address', indent
: 2, name
: 'f_custom_ip', type
: 'text', maxlen
: 15, size
: 20,
380 value
: a
? nvram
.ddnsx_ip
: '', hidden
: !a
},
381 { title
: 'Auto refresh every', name
: 'ddnsx_refresh', type
: 'text', maxlen
: 8, size
: 8, suffix
: ' days <small>(0 = disable)</small>', value
: fixInt(nvram
.ddnsx_refresh
, 0, 90, 28) }
387 <script type='text/javascript'
>
388 a
= nvram
.wan_dns
.split(/\s+/);
389 for (i
= 0; i
< a
.length
; ++i
) {
390 for (j
= 0; j
< opendns
.length
; ++j
) {
391 if (a
[i
] == opendns
[j
]) ++opendnsInUse
;
395 if (nvram
.dns_addget
== 1) {
396 dns
= nvram
.wan_dns
+ ' ' + nvram
.wan_get_dns
;
398 else if (nvram
.wan_dns
!= '') {
402 dns
= nvram
.wan_get_dns
;
404 dns
= dns
.split(/\s+/);
405 for (i
= 0; i
< dns
.length
; ++i
) {
406 for (j
= 0; j
< opendns
.length
; ++j
) {
407 if (dns
[i
] == opendns
[j
]) {
408 dns
[i
] = '<i>' + dns
[i
] + '</i>';
413 dns
= dns
.join(', ');
415 for (i
= 0; i
< 2; ++i
) {
416 v
= nvram
['ddnsx' + i
].split('<');
417 if (v
.length
!= 7) v
= ['', '', '', 0, '', 0, ''];
420 if (u
.length
!= 2) u
= ['', ''];
423 W('<div class="section-title">Dynamic DNS ' + (i
+ 1) + '</div><div class="section">');
424 createFieldTable('', [
425 { title
: 'Service', name
: 'f_service' + i
, type
: 'select', options
: services
, value
: v
[0] },
426 { title
: 'URL', indent
: 2, text
: '<a href="" id="url' + i
+ '" target="tomato-ext-ddns"></a>', hidden
: 1 },
427 { title
: ' ', text
: '<small>* This service determines the IP address using its own method.</small>', hidden
: 1, rid
: 'row_z' + i
},
428 { title
: 'Hostname', name
: 'f_hosttop' + i
, type
: 'text', maxlen
: 96, size
: 35, value
: v
[2], hidden
: 1 },
429 { title
: 'Username', name
: 'f_user' + i
, type
: 'text', maxlen
: 64, size
: 35, value
: u
[0], hidden
: 1 },
430 { title
: 'Password', name
: 'f_pass' + i
, type
: 'password', maxlen
: 64, size
: 35, peekaboo
: 1, value
: u
[1], hidden
: 1 },
431 { title
: 'Hostname', name
: 'f_host' + i
, type
: 'text', maxlen
: 255, size
: 80, value
: v
[2], hidden
: 1 },
432 { title
: 'URL', name
: 'f_cust' + i
, type
: 'text', maxlen
: 255, size
: 80, value
: v
[6], hidden
: 1 },
433 { title
: ' ', text
: '(Use @IP for the current IP address)', rid
: ('custmsg' + i
), hidden
: 1 },
434 { title
: 'Wildcard', indent
: 2, name
: 'f_wild' + i
, type
: 'checkbox', value
: v
[3] != '0', hidden
: 1 },
435 { title
: 'MX', name
: 'f_mx' + i
, type
: 'text', maxlen
: 32, size
: 35, value
: v
[4], hidden
: 1 },
436 { title
: 'Backup MX', indent
: 2, name
: 'f_bmx' + i
, type
: 'checkbox', value
: v
[5] != '0', hidden
: 1 },
437 { title
: 'Use as DNS', name
: 'f_opendns' + i
, type
: 'checkbox', value
: (opendnsInUse
== opendns
.length
),
438 suffix
: '<br><small>(Current DNS: ' + dns
+ ')</small>', hidden
: 1 },
439 { title
: 'Token / URL', name
: 'f_afraid' + i
, type
: 'text', maxlen
: 255, size
: 80, value
: v
[6], hidden
: 1 },
440 { title
: 'Save state when IP changes (nvram commit)', name
: 'f_ddnsx_save' + i
, type
: 'checkbox', value
: nvram
.ddnsx_save
== '1', hidden
: 1 },
441 { title
: 'Force next update', name
: 'f_force' + i
, type
: 'checkbox', value
: 0, hidden
: 1 },
443 { title
: 'Last IP Address', custom
: msgLoc(ddnsx_last
[i
]), rid
: 'last-update' + i
, hidden
: 1 },
444 { title
: 'Last Result', custom
: msgLoc(ddnsx_msg
[i
]), rid
: 'last-response' + i
, hidden
: h
}
454 <tr><td id='footer' colspan=
2>
455 <span id='footer-msg'
></span>
456 <input type='button' value='Save' id='save-button' onclick='save()'
>
457 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'
>
460 <script type='text/javascript'
>verifyFields(null, 1);</script>