1 |
f1f60c92
|
Ermal Luçi
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
ce77a9c4
|
Phil Davis
|
services_rfc2136_edit.php
|
5 |
|
|
|
6 |
1d7ba683
|
ayvis
|
Copyright (C) 2008 Ermal Luçi
|
7 |
ce77a9c4
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
8 |
f1f60c92
|
Ermal Luçi
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
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 |
|
|
|
20 |
|
|
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 |
1d333258
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_MODULE: dnsupdate
|
33 |
|
|
*/
|
34 |
f1f60c92
|
Ermal Luçi
|
|
35 |
|
|
require("guiconfig.inc");
|
36 |
|
|
|
37 |
6626eb26
|
Ermal Luçi
|
if (!is_array($config['dnsupdates']['dnsupdate'])) {
|
38 |
f1f60c92
|
Ermal Luçi
|
$config['dnsupdates']['dnsupdate'] = array();
|
39 |
6626eb26
|
Ermal Luçi
|
}
|
40 |
f1f60c92
|
Ermal Luçi
|
|
41 |
|
|
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
|
42 |
|
|
|
43 |
e41ec584
|
Renato Botelho
|
if (is_numericint($_GET['id']))
|
44 |
|
|
$id = $_GET['id'];
|
45 |
|
|
if (isset($_POST['id']) && is_numericint($_POST['id']))
|
46 |
6626eb26
|
Ermal Luçi
|
$id = $_POST['id'];
|
47 |
|
|
|
48 |
|
|
if (isset($id) && isset($a_rfc2136[$id])) {
|
49 |
|
|
$pconfig['enable'] = isset($a_rfc2136[$id]['enable']);
|
50 |
|
|
$pconfig['host'] = $a_rfc2136[$id]['host'];
|
51 |
|
|
$pconfig['ttl'] = $a_rfc2136[$id]['ttl'];
|
52 |
|
|
if (!$pconfig['ttl'])
|
53 |
|
|
$pconfig['ttl'] = 60;
|
54 |
|
|
$pconfig['keydata'] = $a_rfc2136[$id]['keydata'];
|
55 |
|
|
$pconfig['keyname'] = $a_rfc2136[$id]['keyname'];
|
56 |
|
|
$pconfig['keytype'] = $a_rfc2136[$id]['keytype'];
|
57 |
|
|
if (!$pconfig['keytype'])
|
58 |
|
|
$pconfig['keytype'] = "zone";
|
59 |
|
|
$pconfig['server'] = $a_rfc2136[$id]['server'];
|
60 |
|
|
$pconfig['interface'] = $a_rfc2136[$id]['interface'];
|
61 |
|
|
$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
|
62 |
6d8dd98b
|
jim-p
|
$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);
|
63 |
ea08d2b2
|
Robert Nelson
|
$pconfig['recordtype'] = $a_rfc2136[$id]['recordtype'];
|
64 |
|
|
if (!$pconfig['recordtype'])
|
65 |
|
|
$pconfig['recordtype'] = "both";
|
66 |
6626eb26
|
Ermal Luçi
|
$pconfig['descr'] = $a_rfc2136[$id]['descr'];
|
67 |
|
|
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
if ($_POST) {
|
71 |
|
|
|
72 |
|
|
unset($input_errors);
|
73 |
|
|
$pconfig = $_POST;
|
74 |
|
|
|
75 |
|
|
/* input validation */
|
76 |
|
|
$reqdfields = array();
|
77 |
|
|
$reqdfieldsn = array();
|
78 |
|
|
$reqdfields = array_merge($reqdfields, explode(" ", "host ttl keyname keydata"));
|
79 |
c37eeb93
|
Carlos Eduardo Ramos
|
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Hostname"), gettext("TTL"), gettext("Key name"), gettext("Key")));
|
80 |
6626eb26
|
Ermal Luçi
|
|
81 |
1e9b4611
|
Renato Botelho
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
82 |
6626eb26
|
Ermal Luçi
|
|
83 |
|
|
if (($_POST['host'] && !is_domain($_POST['host'])))
|
84 |
bd758833
|
Rafael Lucas
|
$input_errors[] = gettext("The DNS update host name contains invalid characters.");
|
85 |
6626eb26
|
Ermal Luçi
|
if (($_POST['ttl'] && !is_numericint($_POST['ttl'])))
|
86 |
bd758833
|
Rafael Lucas
|
$input_errors[] = gettext("The DNS update TTL must be an integer.");
|
87 |
6626eb26
|
Ermal Luçi
|
if (($_POST['keyname'] && !is_domain($_POST['keyname'])))
|
88 |
bd758833
|
Rafael Lucas
|
$input_errors[] = gettext("The DNS update key name contains invalid characters.");
|
89 |
f1f60c92
|
Ermal Luçi
|
|
90 |
6626eb26
|
Ermal Luçi
|
if (!$input_errors) {
|
91 |
|
|
$rfc2136 = array();
|
92 |
d2ff48a0
|
Ermal
|
$rfc2136['enable'] = $_POST['enable'] ? true : false;
|
93 |
6626eb26
|
Ermal Luçi
|
$rfc2136['host'] = $_POST['host'];
|
94 |
|
|
$rfc2136['ttl'] = $_POST['ttl'];
|
95 |
|
|
$rfc2136['keyname'] = $_POST['keyname'];
|
96 |
|
|
$rfc2136['keytype'] = $_POST['keytype'];
|
97 |
|
|
$rfc2136['keydata'] = $_POST['keydata'];
|
98 |
|
|
$rfc2136['server'] = $_POST['server'];
|
99 |
|
|
$rfc2136['usetcp'] = $_POST['usetcp'] ? true : false;
|
100 |
6d8dd98b
|
jim-p
|
$rfc2136['usepublicip'] = $_POST['usepublicip'] ? true : false;
|
101 |
ea08d2b2
|
Robert Nelson
|
$rfc2136['recordtype'] = $_POST['recordtype'];
|
102 |
6626eb26
|
Ermal Luçi
|
$rfc2136['interface'] = $_POST['interface'];
|
103 |
|
|
$rfc2136['descr'] = $_POST['descr'];
|
104 |
f1f60c92
|
Ermal Luçi
|
|
105 |
6626eb26
|
Ermal Luçi
|
if (isset($id) && $a_rfc2136[$id])
|
106 |
|
|
$a_rfc2136[$id] = $rfc2136;
|
107 |
|
|
else
|
108 |
|
|
$a_rfc2136[] = $rfc2136;
|
109 |
|
|
|
110 |
bd758833
|
Rafael Lucas
|
write_config(gettext("New/Edited RFC2136 dnsupdate entry was posted."));
|
111 |
6626eb26
|
Ermal Luçi
|
|
112 |
7c9da7be
|
jim-p
|
if ($_POST['Submit'] == gettext("Save & Force Update"))
|
113 |
|
|
$retval = services_dnsupdate_process("", $rfc2136['host'], true);
|
114 |
|
|
else
|
115 |
|
|
$retval = services_dnsupdate_process();
|
116 |
6626eb26
|
Ermal Luçi
|
|
117 |
|
|
header("Location: services_rfc2136.php");
|
118 |
f1f60c92
|
Ermal Luçi
|
exit;
|
119 |
6626eb26
|
Ermal Luçi
|
}
|
120 |
f1f60c92
|
Ermal Luçi
|
}
|
121 |
|
|
|
122 |
bd758833
|
Rafael Lucas
|
$pgtitle = array(gettext("Services"),gettext("RFC 2136 client"), gettext("Edit"));
|
123 |
f1f60c92
|
Ermal Luçi
|
include("head.inc");
|
124 |
|
|
|
125 |
|
|
?>
|
126 |
|
|
|
127 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
128 |
|
|
<?php include("fbegin.inc"); ?>
|
129 |
|
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
130 |
6626eb26
|
Ermal Luçi
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
131 |
|
|
<form action="services_rfc2136_edit.php" method="post" name="iform" id="iform">
|
132 |
d3c90ddd
|
Colin Fleming
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="rfs2136 edit">
|
133 |
6626eb26
|
Ermal Luçi
|
<tr>
|
134 |
|
|
<td colspan="2" valign="top" class="optsect_t">
|
135 |
d3c90ddd
|
Colin Fleming
|
<table border="0" cellspacing="0" cellpadding="0" width="100%" summary="title">
|
136 |
bd758833
|
Rafael Lucas
|
<tr><td class="optsect_s"><strong><?=gettext("RFC 2136 client");?></strong></td></tr>
|
137 |
6626eb26
|
Ermal Luçi
|
</table>
|
138 |
|
|
</td>
|
139 |
|
|
</tr>
|
140 |
f1f60c92
|
Ermal Luçi
|
<tr>
|
141 |
bd758833
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Enable");?></td>
|
142 |
6626eb26
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
143 |
d3c90ddd
|
Colin Fleming
|
<input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> />
|
144 |
f1f60c92
|
Ermal Luçi
|
</td>
|
145 |
6626eb26
|
Ermal Luçi
|
</tr>
|
146 |
|
|
<tr>
|
147 |
bd758833
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface to monitor");?></td>
|
148 |
6626eb26
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
149 |
|
|
<select name="interface" class="formselect" id="interface">
|
150 |
|
|
<?php $iflist = get_configured_interface_with_descr();
|
151 |
|
|
foreach ($iflist as $if => $ifdesc):?>
|
152 |
d3c90ddd
|
Colin Fleming
|
<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected=\"selected\"";?>><?=$ifdesc;?></option>
|
153 |
6626eb26
|
Ermal Luçi
|
<?php endforeach; ?>
|
154 |
|
|
</select>
|
155 |
|
|
</td>
|
156 |
|
|
</tr>
|
157 |
|
|
<tr>
|
158 |
bd758833
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname");?></td>
|
159 |
6626eb26
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
160 |
d3c90ddd
|
Colin Fleming
|
<input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>" />
|
161 |
1d7ba683
|
ayvis
|
<br /><span>Fully qualified hostname of the host to be updated</span>
|
162 |
f1f60c92
|
Ermal Luçi
|
</td>
|
163 |
|
|
</tr>
|
164 |
|
|
<tr>
|
165 |
3b0b4ea7
|
Carlos Eduardo Ramos
|
<td valign="top" class="vncellreq"><?=gettext("TTL"); ?></td>
|
166 |
6626eb26
|
Ermal Luçi
|
<td class="vtable">
|
167 |
d3c90ddd
|
Colin Fleming
|
<input name="ttl" type="text" class="formfld unknown" id="ttl" size="6" value="<?=htmlspecialchars($pconfig['ttl']);?>" />
|
168 |
bd758833
|
Rafael Lucas
|
<?=gettext("seconds");?></td>
|
169 |
6626eb26
|
Ermal Luçi
|
</tr>
|
170 |
|
|
<tr>
|
171 |
bd758833
|
Rafael Lucas
|
<td valign="top" class="vncellreq"><?=gettext("Key name");?></td>
|
172 |
6626eb26
|
Ermal Luçi
|
<td class="vtable">
|
173 |
d3c90ddd
|
Colin Fleming
|
<input name="keyname" type="text" class="formfld unknown" id="keyname" size="30" value="<?=htmlspecialchars($pconfig['keyname']);?>" />
|
174 |
1d7ba683
|
ayvis
|
<br />
|
175 |
bd758833
|
Rafael Lucas
|
<?=gettext("This must match the setting on the DNS server.");?></td>
|
176 |
6626eb26
|
Ermal Luçi
|
</tr>
|
177 |
|
|
<tr>
|
178 |
3b0b4ea7
|
Carlos Eduardo Ramos
|
<td valign="top" class="vncellreq"><?=gettext("Key type");?> </td>
|
179 |
6626eb26
|
Ermal Luçi
|
<td class="vtable">
|
180 |
d3c90ddd
|
Colin Fleming
|
<input name="keytype" type="radio" value="zone" <?php if ($pconfig['keytype'] == "zone") echo "checked=\"checked\""; ?> /> <?=gettext("Zone");?>
|
181 |
|
|
<input name="keytype" type="radio" value="host" <?php if ($pconfig['keytype'] == "host") echo "checked=\"checked\""; ?> /> <?=gettext("Host");?>
|
182 |
|
|
<input name="keytype" type="radio" value="user" <?php if ($pconfig['keytype'] == "user") echo "checked=\"checked\""; ?> /><?=gettext(" User");?>
|
183 |
|
|
</td>
|
184 |
|
|
</tr>
|
185 |
6626eb26
|
Ermal Luçi
|
<tr>
|
186 |
bd758833
|
Rafael Lucas
|
<td valign="top" class="vncellreq"><?=gettext("Key");?></td>
|
187 |
6626eb26
|
Ermal Luçi
|
<td class="vtable">
|
188 |
d3c90ddd
|
Colin Fleming
|
<input name="keydata" type="text" class="formfld unknown" id="keydata" size="70" value="<?=htmlspecialchars($pconfig['keydata']);?>" />
|
189 |
1d7ba683
|
ayvis
|
<br />
|
190 |
bd758833
|
Rafael Lucas
|
<?=gettext("Paste an HMAC-MD5 key here.");?></td>
|
191 |
f1f60c92
|
Ermal Luçi
|
</tr>
|
192 |
6626eb26
|
Ermal Luçi
|
<tr>
|
193 |
bd758833
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Server");?></td>
|
194 |
6626eb26
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
195 |
e185c584
|
Phil Davis
|
<input name="server" type="text" class="formfld unknown" id="server" size="30" value="<?=htmlspecialchars($pconfig['server'])?>" />
|
196 |
6626eb26
|
Ermal Luçi
|
</td>
|
197 |
|
|
</tr>
|
198 |
|
|
<tr>
|
199 |
bd758833
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
|
200 |
6626eb26
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
201 |
d3c90ddd
|
Colin Fleming
|
<input name="usetcp" type="checkbox" id="usetcp" value="<?=gettext("yes");?>" <?php if ($pconfig['usetcp']) echo "checked=\"checked\""; ?> />
|
202 |
bd758833
|
Rafael Lucas
|
<strong><?=gettext("Use TCP instead of UDP");?></strong></td>
|
203 |
6626eb26
|
Ermal Luçi
|
</tr>
|
204 |
6d8dd98b
|
jim-p
|
<tr>
|
205 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Use Public IP");?></td>
|
206 |
|
|
<td width="78%" class="vtable">
|
207 |
d3c90ddd
|
Colin Fleming
|
<input name="usepublicip" type="checkbox" id="usepublicip" value="<?=gettext("yes");?>" <?php if ($pconfig['usepublicip']) echo "checked=\"checked\""; ?> />
|
208 |
6d8dd98b
|
jim-p
|
<strong><?=gettext("If the interface IP is private, attempt to fetch and use the public IP instead.");?></strong>
|
209 |
|
|
</td>
|
210 |
|
|
</tr>
|
211 |
52cbfd45
|
Robert Nelson
|
<tr>
|
212 |
ea08d2b2
|
Robert Nelson
|
<td valign="top" class="vncellreq"><?=gettext("Record Type");?> </td>
|
213 |
52cbfd45
|
Robert Nelson
|
<td class="vtable">
|
214 |
ea08d2b2
|
Robert Nelson
|
<input name="recordtype" type="radio" value="A" <?php if ($pconfig['recordtype'] == "A") echo "checked=\"checked\""; ?> /> <?=gettext("A (IPv4)");?>
|
215 |
|
|
<input name="recordtype" type="radio" value="AAAA" <?php if ($pconfig['recordtype'] == "AAAA") echo "checked=\"checked\""; ?> /> <?=gettext("AAAA (IPv6)");?>
|
216 |
|
|
<input name="recordtype" type="radio" value="both" <?php if ($pconfig['recordtype'] == "both") echo "checked=\"checked\""; ?> /> <?=gettext("Both");?>
|
217 |
52cbfd45
|
Robert Nelson
|
</td>
|
218 |
|
|
</tr>
|
219 |
6626eb26
|
Ermal Luçi
|
<tr>
|
220 |
bd758833
|
Rafael Lucas
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Description");?></td>
|
221 |
6626eb26
|
Ermal Luçi
|
<td width="78%" class="vtable">
|
222 |
d3c90ddd
|
Colin Fleming
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>" />
|
223 |
6626eb26
|
Ermal Luçi
|
</td>
|
224 |
|
|
</tr>
|
225 |
|
|
<tr>
|
226 |
|
|
<td width="22%" valign="top"> </td>
|
227 |
|
|
<td width="78%">
|
228 |
d3c90ddd
|
Colin Fleming
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
|
229 |
|
|
<a href="services_rfc2136.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>" /></a>
|
230 |
|
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save & Force Update");?>" onclick="enable_change(true)" />
|
231 |
6626eb26
|
Ermal Luçi
|
<?php if (isset($id) && $a_rfc2136[$id]): ?>
|
232 |
d3c90ddd
|
Colin Fleming
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
233 |
6626eb26
|
Ermal Luçi
|
<?php endif; ?>
|
234 |
|
|
</td>
|
235 |
|
|
</tr>
|
236 |
|
|
<tr>
|
237 |
|
|
<td width="22%" valign="top"> </td>
|
238 |
1d7ba683
|
ayvis
|
<td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br />
|
239 |
3b0b4ea7
|
Carlos Eduardo Ramos
|
</strong></span><?php printf(gettext("You must configure a DNS server in %sSystem: " .
|
240 |
|
|
"General setup %sor allow the DNS server list to be overridden " .
|
241 |
|
|
"by DHCP/PPP on WAN for dynamic DNS updates to work."),'<a href="system.php">', '</a>');?></span></td>
|
242 |
6626eb26
|
Ermal Luçi
|
</tr>
|
243 |
f1f60c92
|
Ermal Luçi
|
</table>
|
244 |
|
|
</form>
|
245 |
|
|
<?php include("fend.inc"); ?>
|
246 |
|
|
</body>
|
247 |
|
|
</html>
|