1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
d03efa9c
|
Scott Ullrich
|
<?php
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
services_dyndns.php
|
5 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
6 |
d03efa9c
|
Scott Ullrich
|
|
7 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
|
|
All rights reserved.
|
9 |
d03efa9c
|
Scott Ullrich
|
|
10 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
d03efa9c
|
Scott Ullrich
|
|
13 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
d03efa9c
|
Scott Ullrich
|
|
16 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
d03efa9c
|
Scott Ullrich
|
|
20 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
require("guiconfig.inc");
|
33 |
|
|
|
34 |
07bd3f83
|
Scott Ullrich
|
if (!is_array($config['dnsupdate'])) {
|
35 |
|
|
$config['dnsupdate'] = array();
|
36 |
|
|
}
|
37 |
|
|
|
38 |
5b237745
|
Scott Ullrich
|
$pconfig['username'] = $config['dyndns']['username'];
|
39 |
|
|
$pconfig['password'] = $config['dyndns']['password'];
|
40 |
|
|
$pconfig['host'] = $config['dyndns']['host'];
|
41 |
|
|
$pconfig['mx'] = $config['dyndns']['mx'];
|
42 |
|
|
$pconfig['type'] = $config['dyndns']['type'];
|
43 |
|
|
$pconfig['enable'] = isset($config['dyndns']['enable']);
|
44 |
|
|
$pconfig['wildcard'] = isset($config['dyndns']['wildcard']);
|
45 |
|
|
|
46 |
07bd3f83
|
Scott Ullrich
|
$pconfig['dnsupdate_enable'] = isset($config['dnsupdate']['enable']);
|
47 |
|
|
$pconfig['dnsupdate_host'] = $config['dnsupdate']['host'];
|
48 |
|
|
$pconfig['dnsupdate_ttl'] = $config['dnsupdate']['ttl'];
|
49 |
|
|
if (!$pconfig['dnsupdate_ttl'])
|
50 |
|
|
$pconfig['dnsupdate_ttl'] = 60;
|
51 |
|
|
$pconfig['dnsupdate_keydata'] = $config['dnsupdate']['keydata'];
|
52 |
|
|
$pconfig['dnsupdate_keyname'] = $config['dnsupdate']['keyname'];
|
53 |
|
|
$pconfig['dnsupdate_keytype'] = $config['dnsupdate']['keytype'];
|
54 |
|
|
if (!$pconfig['dnsupdate_keytype'])
|
55 |
|
|
$pconfig['dnsupdate_keytype'] = "zone";
|
56 |
|
|
$pconfig['dnsupdate_usetcp'] = isset($config['dnsupdate']['usetcp']);
|
57 |
|
|
|
58 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
59 |
|
|
|
60 |
|
|
unset($input_errors);
|
61 |
|
|
$pconfig = $_POST;
|
62 |
|
|
|
63 |
|
|
/* input validation */
|
64 |
07bd3f83
|
Scott Ullrich
|
$reqdfields = array();
|
65 |
|
|
$reqdfieldsn = array();
|
66 |
5b237745
|
Scott Ullrich
|
if ($_POST['enable']) {
|
67 |
07bd3f83
|
Scott Ullrich
|
$reqdfields = array_merge($reqdfields, explode(" ", "host username password type"));
|
68 |
|
|
$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,Username,Password,Service type"));
|
69 |
5b237745
|
Scott Ullrich
|
}
|
70 |
07bd3f83
|
Scott Ullrich
|
if ($_POST['dnsupdate_enable']) {
|
71 |
|
|
$reqdfields = array_merge($reqdfields, explode(" ", "dnsupdate_host dnsupdate_ttl dnsupdate_keyname dnsupdate_keydata"));
|
72 |
|
|
$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,TTL,Key name,Key"));
|
73 |
|
|
}
|
74 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
75 |
d03efa9c
|
Scott Ullrich
|
|
76 |
5b237745
|
Scott Ullrich
|
if (($_POST['host'] && !is_domain($_POST['host']))) {
|
77 |
|
|
$input_errors[] = "The host name contains invalid characters.";
|
78 |
|
|
}
|
79 |
|
|
if (($_POST['mx'] && !is_domain($_POST['mx']))) {
|
80 |
|
|
$input_errors[] = "The MX contains invalid characters.";
|
81 |
|
|
}
|
82 |
|
|
if (($_POST['username'] && !is_dyndns_username($_POST['username']))) {
|
83 |
|
|
$input_errors[] = "The username contains invalid characters.";
|
84 |
|
|
}
|
85 |
d03efa9c
|
Scott Ullrich
|
|
86 |
07bd3f83
|
Scott Ullrich
|
if (($_POST['dnsupdate_host'] && !is_domain($_POST['dnsupdate_host']))) {
|
87 |
|
|
$input_errors[] = "The DNS update host name contains invalid characters.";
|
88 |
|
|
}
|
89 |
|
|
if (($_POST['dnsupdate_ttl'] && !is_numericint($_POST['dnsupdate_ttl']))) {
|
90 |
|
|
$input_errors[] = "The DNS update TTL must be an integer.";
|
91 |
|
|
}
|
92 |
|
|
if (($_POST['dnsupdate_keyname'] && !is_domain($_POST['dnsupdate_keyname']))) {
|
93 |
|
|
$input_errors[] = "The DNS update key name contains invalid characters.";
|
94 |
|
|
}
|
95 |
5b237745
|
Scott Ullrich
|
|
96 |
|
|
if (!$input_errors) {
|
97 |
d03efa9c
|
Scott Ullrich
|
$config['dyndns']['type'] = $_POST['type'];
|
98 |
5b237745
|
Scott Ullrich
|
$config['dyndns']['username'] = $_POST['username'];
|
99 |
|
|
$config['dyndns']['password'] = $_POST['password'];
|
100 |
|
|
$config['dyndns']['host'] = $_POST['host'];
|
101 |
|
|
$config['dyndns']['mx'] = $_POST['mx'];
|
102 |
|
|
$config['dyndns']['wildcard'] = $_POST['wildcard'] ? true : false;
|
103 |
|
|
$config['dyndns']['enable'] = $_POST['enable'] ? true : false;
|
104 |
d03efa9c
|
Scott Ullrich
|
|
105 |
07bd3f83
|
Scott Ullrich
|
$config['dnsupdate']['enable'] = $_POST['dnsupdate_enable'] ? true : false;
|
106 |
|
|
$config['dnsupdate']['host'] = $_POST['dnsupdate_host'];
|
107 |
|
|
$config['dnsupdate']['ttl'] = $_POST['dnsupdate_ttl'];
|
108 |
|
|
$config['dnsupdate']['keyname'] = $_POST['dnsupdate_keyname'];
|
109 |
|
|
$config['dnsupdate']['keytype'] = $_POST['dnsupdate_keytype'];
|
110 |
|
|
$config['dnsupdate']['keydata'] = $_POST['dnsupdate_keydata'];
|
111 |
|
|
$config['dnsupdate']['usetcp'] = $_POST['dnsupdate_usetcp'] ? true : false;
|
112 |
d03efa9c
|
Scott Ullrich
|
|
113 |
5b237745
|
Scott Ullrich
|
write_config();
|
114 |
d03efa9c
|
Scott Ullrich
|
|
115 |
5b237745
|
Scott Ullrich
|
$retval = 0;
|
116 |
|
|
if (!file_exists($d_sysrebootreqd_path)) {
|
117 |
|
|
/* nuke the cache file */
|
118 |
|
|
config_lock();
|
119 |
|
|
services_dyndns_reset();
|
120 |
|
|
$retval = services_dyndns_configure();
|
121 |
07bd3f83
|
Scott Ullrich
|
$retval |= services_dnsupdate_process();
|
122 |
5b237745
|
Scott Ullrich
|
config_unlock();
|
123 |
|
|
}
|
124 |
|
|
$savemsg = get_std_save_message($retval);
|
125 |
|
|
}
|
126 |
|
|
}
|
127 |
|
|
?>
|
128 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
129 |
|
|
<html>
|
130 |
|
|
<head>
|
131 |
|
|
<title><?=gentitle("Services: Dynamic DNS client");?></title>
|
132 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
133 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
134 |
|
|
<script language="JavaScript">
|
135 |
|
|
<!--
|
136 |
|
|
function enable_change(enable_change) {
|
137 |
07bd3f83
|
Scott Ullrich
|
var endis;
|
138 |
d03efa9c
|
Scott Ullrich
|
|
139 |
07bd3f83
|
Scott Ullrich
|
endis = !(document.iform.enable.checked || enable_change);
|
140 |
|
|
document.iform.host.disabled = endis;
|
141 |
|
|
document.iform.mx.disabled = endis;
|
142 |
|
|
document.iform.type.disabled = endis;
|
143 |
|
|
document.iform.wildcard.disabled = endis;
|
144 |
|
|
document.iform.username.disabled = endis;
|
145 |
|
|
document.iform.password.disabled = endis;
|
146 |
d03efa9c
|
Scott Ullrich
|
|
147 |
07bd3f83
|
Scott Ullrich
|
endis = !(document.iform.dnsupdate_enable.checked || enable_change);
|
148 |
|
|
document.iform.dnsupdate_host.disabled = endis;
|
149 |
|
|
document.iform.dnsupdate_ttl.disabled = endis;
|
150 |
|
|
document.iform.dnsupdate_keyname.disabled = endis;
|
151 |
|
|
document.iform.dnsupdate_keytype[0].disabled = endis;
|
152 |
|
|
document.iform.dnsupdate_keytype[1].disabled = endis;
|
153 |
|
|
document.iform.dnsupdate_keytype[2].disabled = endis;
|
154 |
|
|
document.iform.dnsupdate_keydata.disabled = endis;
|
155 |
|
|
document.iform.dnsupdate_usetcp.disabled = endis;
|
156 |
5b237745
|
Scott Ullrich
|
}
|
157 |
|
|
//-->
|
158 |
|
|
</script>
|
159 |
|
|
</head>
|
160 |
|
|
|
161 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
162 |
|
|
<?php include("fbegin.inc"); ?>
|
163 |
|
|
<p class="pgtitle">Services: Dynamic DNS client</p>
|
164 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
165 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
166 |
|
|
<form action="services_dyndns.php" method="post" name="iform" id="iform">
|
167 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
168 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
169 |
07bd3f83
|
Scott Ullrich
|
<td colspan="2" valign="top" class="optsect_t">
|
170 |
|
|
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
171 |
|
|
<tr><td class="optsect_s"><strong>Dynamic DNS client</strong></td>
|
172 |
|
|
<td align="right" class="optsect_s"><input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)"> <strong>Enable</strong></td></tr>
|
173 |
|
|
</table></td>
|
174 |
|
|
</tr>
|
175 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
176 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Service type</td>
|
177 |
|
|
<td width="78%" class="vtable">
|
178 |
|
|
<select name="type" class="formfld" id="type">
|
179 |
|
|
<?php $types = explode(",", "DynDNS,DHS,ODS,DyNS,HN.ORG,ZoneEdit,GNUDip,DynDNS (static),DynDNS (custom),easyDNS,EZ-IP,TZO");
|
180 |
|
|
$vals = explode(" ", "dyndns dhs ods dyns hn zoneedit gnudip dyndns-static dyndns-custom easydns ezip tzo");
|
181 |
|
|
$j = 0; for ($j = 0; $j < count($vals); $j++): ?>
|
182 |
d03efa9c
|
Scott Ullrich
|
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected";?>>
|
183 |
5b237745
|
Scott Ullrich
|
<?=htmlspecialchars($types[$j]);?>
|
184 |
|
|
</option>
|
185 |
|
|
<?php endfor; ?>
|
186 |
|
|
</select></td>
|
187 |
|
|
</tr>
|
188 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
189 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Hostname</td>
|
190 |
d03efa9c
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
191 |
|
|
<input name="host" type="text" class="formfld" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>">
|
192 |
5b237745
|
Scott Ullrich
|
</td>
|
193 |
|
|
</tr>
|
194 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
195 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncell">MX</td>
|
196 |
d03efa9c
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
197 |
|
|
<input name="mx" type="text" class="formfld" id="mx" size="30" value="<?=htmlspecialchars($pconfig['mx']);?>">
|
198 |
5b237745
|
Scott Ullrich
|
<br>
|
199 |
d03efa9c
|
Scott Ullrich
|
Set this option only if you need a special MX record. Not
|
200 |
5b237745
|
Scott Ullrich
|
all services support this.</td>
|
201 |
|
|
</tr>
|
202 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
203 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Wildcards</td>
|
204 |
d03efa9c
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
205 |
07bd3f83
|
Scott Ullrich
|
<input name="wildcard" type="checkbox" id="wildcard" value="yes" <?php if ($pconfig['wildcard']) echo "checked"; ?>>
|
206 |
5b237745
|
Scott Ullrich
|
Enable Wildcard</td>
|
207 |
|
|
</tr>
|
208 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
209 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Username</td>
|
210 |
d03efa9c
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
211 |
|
|
<input name="username" type="text" class="formfld" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
|
212 |
5b237745
|
Scott Ullrich
|
</td>
|
213 |
|
|
</tr>
|
214 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
215 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Password</td>
|
216 |
d03efa9c
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
217 |
|
|
<input name="password" type="password" class="formfld" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
|
218 |
5b237745
|
Scott Ullrich
|
</td>
|
219 |
|
|
</tr>
|
220 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
221 |
|
|
<td colspan="2" class="list" height="12"> </td>
|
222 |
07bd3f83
|
Scott Ullrich
|
</tr>
|
223 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
224 |
07bd3f83
|
Scott Ullrich
|
<td colspan="2" valign="top" class="optsect_t">
|
225 |
|
|
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
226 |
|
|
<tr><td class="optsect_s"><strong>RFC 2163 Dynamic DNS updates</strong></td>
|
227 |
|
|
<td align="right" class="optsect_s"><input name="dnsupdate_enable" type="checkbox" value="yes" <?php if ($pconfig['dnsupdate_enable']) echo "checked"; ?> onClick="enable_change(false)"> <strong>Enable</strong></td></tr>
|
228 |
|
|
</table></td>
|
229 |
|
|
</tr>
|
230 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
231 |
07bd3f83
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Hostname</td>
|
232 |
d03efa9c
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
233 |
|
|
<input name="dnsupdate_host" type="text" class="formfld" id="dnsupdate_host" size="30" value="<?=htmlspecialchars($pconfig['dnsupdate_host']);?>">
|
234 |
07bd3f83
|
Scott Ullrich
|
</td>
|
235 |
|
|
</tr>
|
236 |
|
|
<tr>
|
237 |
|
|
<td valign="top" class="vncellreq">TTL</td>
|
238 |
|
|
<td class="vtable">
|
239 |
d03efa9c
|
Scott Ullrich
|
<input name="dnsupdate_ttl" type="text" class="formfld" id="dnsupdate_ttl" size="6" value="<?=htmlspecialchars($pconfig['dnsupdate_ttl']);?>">
|
240 |
07bd3f83
|
Scott Ullrich
|
seconds</td>
|
241 |
|
|
</tr>
|
242 |
|
|
<tr>
|
243 |
|
|
<td valign="top" class="vncellreq">Key name</td>
|
244 |
|
|
<td class="vtable">
|
245 |
|
|
<input name="dnsupdate_keyname" type="text" class="formfld" id="dnsupdate_keyname" size="30" value="<?=htmlspecialchars($pconfig['dnsupdate_keyname']);?>">
|
246 |
d03efa9c
|
Scott Ullrich
|
<br>
|
247 |
07bd3f83
|
Scott Ullrich
|
This must match the setting on the DNS server.</td>
|
248 |
|
|
</tr>
|
249 |
|
|
<tr>
|
250 |
|
|
<td valign="top" class="vncellreq">Key type </td>
|
251 |
|
|
<td class="vtable">
|
252 |
|
|
<input name="dnsupdate_keytype" type="radio" value="zone" <?php if ($pconfig['dnsupdate_keytype'] == "zone") echo "checked"; ?>> Zone
|
253 |
|
|
<input name="dnsupdate_keytype" type="radio" value="host" <?php if ($pconfig['dnsupdate_keytype'] == "host") echo "checked"; ?>> Host
|
254 |
|
|
<input name="dnsupdate_keytype" type="radio" value="user" <?php if ($pconfig['dnsupdate_keytype'] == "user") echo "checked"; ?>> User
|
255 |
|
|
</tr>
|
256 |
|
|
<tr>
|
257 |
|
|
<td valign="top" class="vncellreq">Key</td>
|
258 |
|
|
<td class="vtable">
|
259 |
|
|
<input name="dnsupdate_keydata" type="text" class="formfld" id="dnsupdate_keydata" size="70" value="<?=htmlspecialchars($pconfig['dnsupdate_keydata']);?>">
|
260 |
d03efa9c
|
Scott Ullrich
|
<br>
|
261 |
07bd3f83
|
Scott Ullrich
|
Paste an HMAC-MD5 key here.</td>
|
262 |
|
|
</tr>
|
263 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
264 |
07bd3f83
|
Scott Ullrich
|
<td width="22%" valign="top" class="vncellreq">Protocol</td>
|
265 |
d03efa9c
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
266 |
07bd3f83
|
Scott Ullrich
|
<input name="dnsupdate_usetcp" type="checkbox" id="dnsupdate_usetcp" value="yes" <?php if ($pconfig['dnsupdate_usetcp']) echo "checked"; ?>>
|
267 |
|
|
<strong>Use TCP instead of UDP</strong></td>
|
268 |
|
|
</tr>
|
269 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
270 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
271 |
d03efa9c
|
Scott Ullrich
|
<td width="78%">
|
272 |
|
|
<input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
|
273 |
5b237745
|
Scott Ullrich
|
</td>
|
274 |
|
|
</tr>
|
275 |
d03efa9c
|
Scott Ullrich
|
<tr>
|
276 |
5b237745
|
Scott Ullrich
|
<td width="22%" valign="top"> </td>
|
277 |
|
|
<td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
|
278 |
d03efa9c
|
Scott Ullrich
|
</strong></span>You must configure a DNS server in <a href="system.php">System:
|
279 |
|
|
General setup</a> or allow the DNS server list to be overridden
|
280 |
07bd3f83
|
Scott Ullrich
|
by DHCP/PPP on WAN for dynamic DNS updates to work.</span></td>
|
281 |
5b237745
|
Scott Ullrich
|
</tr>
|
282 |
|
|
</table>
|
283 |
|
|
</form>
|
284 |
|
|
<script language="JavaScript">
|
285 |
|
|
<!--
|
286 |
|
|
enable_change(false);
|
287 |
|
|
//-->
|
288 |
|
|
</script>
|
289 |
|
|
<?php include("fend.inc"); ?>
|
290 |
|
|
</body>
|
291 |
|
|
</html>
|