|
1 |
<?php
|
|
2 |
/*
|
|
3 |
services_unbound.php
|
|
4 |
*/
|
|
5 |
/* ====================================================================
|
|
6 |
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
|
7 |
* Copyright (c) 2014 Warren Baker (warren@pfsense.org)
|
|
8 |
*
|
|
9 |
* Redistribution and use in source and binary forms, with or without modification,
|
|
10 |
* are permitted provided that the following conditions are met:
|
|
11 |
*
|
|
12 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
13 |
* this list of conditions and the following disclaimer.
|
|
14 |
*
|
|
15 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
16 |
* notice, this list of conditions and the following disclaimer in
|
|
17 |
* the documentation and/or other materials provided with the
|
|
18 |
* distribution.
|
|
19 |
*
|
|
20 |
* 3. All advertising materials mentioning features or use of this software
|
|
21 |
* must display the following acknowledgment:
|
|
22 |
* "This product includes software developed by the pfSense Project
|
|
23 |
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
|
24 |
*
|
|
25 |
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
|
26 |
* endorse or promote products derived from this software without
|
|
27 |
* prior written permission. For written permission, please contact
|
|
28 |
* coreteam@pfsense.org.
|
|
29 |
*
|
|
30 |
* 5. Products derived from this software may not be called "pfSense"
|
|
31 |
* nor may "pfSense" appear in their names without prior written
|
|
32 |
* permission of the Electric Sheep Fencing, LLC.
|
|
33 |
*
|
|
34 |
* 6. Redistributions of any form whatsoever must retain the following
|
|
35 |
* acknowledgment:
|
|
36 |
*
|
|
37 |
* "This product includes software developed by the pfSense Project
|
|
38 |
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
|
39 |
*
|
|
40 |
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
|
41 |
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
42 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
43 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
|
44 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
45 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
46 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
47 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
48 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
49 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
50 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
51 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
52 |
*
|
|
53 |
* ====================================================================
|
|
54 |
*
|
|
55 |
*/
|
|
56 |
|
|
57 |
##|+PRIV
|
|
58 |
##|*IDENT=page-services-dnsresolver-overrides
|
|
59 |
##|*NAME=Services: DNS Resolver Overrides
|
|
60 |
##|*DESCR=Allow access to the 'Services: DNS Resolver' Overrides page.
|
|
61 |
##|*MATCH=services_unbound_overrides.php*
|
|
62 |
##|-PRIV
|
|
63 |
|
|
64 |
require_once("guiconfig.inc");
|
|
65 |
require_once("unbound.inc");
|
|
66 |
require_once("system.inc");
|
|
67 |
|
|
68 |
if (!is_array($config['unbound'])) {
|
|
69 |
$config['unbound'] = array();
|
|
70 |
}
|
|
71 |
|
|
72 |
$a_unboundcfg =& $config['unbound'];
|
|
73 |
|
|
74 |
if (!is_array($a_unboundcfg['hosts'])) {
|
|
75 |
$a_unboundcfg['hosts'] = array();
|
|
76 |
}
|
|
77 |
|
|
78 |
$a_hosts =& $a_unboundcfg['hosts'];
|
|
79 |
|
|
80 |
if (!is_array($a_unboundcfg['domainoverrides'])) {
|
|
81 |
$a_unboundcfg['domainoverrides'] = array();
|
|
82 |
}
|
|
83 |
|
|
84 |
$a_domainOverrides = &$a_unboundcfg['domainoverrides'];
|
|
85 |
|
|
86 |
if ($_POST) {
|
|
87 |
if ($_POST['apply']) {
|
|
88 |
$retval = services_unbound_configure();
|
|
89 |
$savemsg = get_std_save_message($retval);
|
|
90 |
if ($retval == 0) {
|
|
91 |
clear_subsystem_dirty('unbound');
|
|
92 |
}
|
|
93 |
/* Update resolv.conf in case the interface bindings exclude localhost. */
|
|
94 |
system_resolvconf_generate();
|
|
95 |
/* Start or restart dhcpleases when it's necessary */
|
|
96 |
system_dhcpleases_configure();
|
|
97 |
}
|
|
98 |
}
|
|
99 |
|
|
100 |
if ($_GET['act'] == "del") {
|
|
101 |
if ($_GET['type'] == 'host') {
|
|
102 |
if ($a_hosts[$_GET['id']]) {
|
|
103 |
unset($a_hosts[$_GET['id']]);
|
|
104 |
write_config();
|
|
105 |
mark_subsystem_dirty('unbound');
|
|
106 |
header("Location: services_unbound_overrides.php");
|
|
107 |
exit;
|
|
108 |
}
|
|
109 |
} elseif ($_GET['type'] == 'doverride') {
|
|
110 |
if ($a_domainOverrides[$_GET['id']]) {
|
|
111 |
unset($a_domainOverrides[$_GET['id']]);
|
|
112 |
write_config();
|
|
113 |
mark_subsystem_dirty('unbound');
|
|
114 |
header("Location: services_unbound_overrides.php");
|
|
115 |
exit;
|
|
116 |
}
|
|
117 |
}
|
|
118 |
}
|
|
119 |
|
|
120 |
$pgtitle = array(gettext("Services"), gettext("DNS Resolver"), gettext("Overrides"));
|
|
121 |
$shortcut_section = "resolver";
|
|
122 |
|
|
123 |
include_once("head.inc");
|
|
124 |
|
|
125 |
if ($input_errors) {
|
|
126 |
print_input_errors($input_errors);
|
|
127 |
}
|
|
128 |
|
|
129 |
if ($savemsg) {
|
|
130 |
print_info_box($savemsg, 'success');
|
|
131 |
}
|
|
132 |
|
|
133 |
if (is_subsystem_dirty('unbound')) {
|
|
134 |
print_apply_box(gettext("The DNS resolver configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
|
|
135 |
}
|
|
136 |
|
|
137 |
|
|
138 |
?>
|
|
139 |
|
|
140 |
<div class="panel panel-default">
|
|
141 |
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
|
|
142 |
<div class="panel-body table-responsive">
|
|
143 |
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
|
144 |
<thead>
|
|
145 |
<tr>
|
|
146 |
<th><?=gettext("Host")?></th>
|
|
147 |
<th><?=gettext("Domain")?></th>
|
|
148 |
<th><?=gettext("IP")?></th>
|
|
149 |
<th><?=gettext("Description")?></th>
|
|
150 |
<th><?=gettext("Actions")?></th>
|
|
151 |
</tr>
|
|
152 |
</thead>
|
|
153 |
<tbody>
|
|
154 |
<?php
|
|
155 |
$i = 0;
|
|
156 |
foreach ($a_hosts as $hostent):
|
|
157 |
?>
|
|
158 |
<tr>
|
|
159 |
<td>
|
|
160 |
<?=$hostent['host']?>
|
|
161 |
</td>
|
|
162 |
<td>
|
|
163 |
<?=$hostent['domain']?>
|
|
164 |
</td>
|
|
165 |
<td>
|
|
166 |
<?=$hostent['ip']?>
|
|
167 |
</td>
|
|
168 |
<td>
|
|
169 |
<?=htmlspecialchars($hostent['descr'])?>
|
|
170 |
</td>
|
|
171 |
<td>
|
|
172 |
<a class="fa fa-pencil" title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a>
|
|
173 |
<a class="fa fa-trash" title="<?=gettext('Delete host override')?>" href="services_unbound_overrides.php?type=host&act=del&id=<?=$i?>"></a>
|
|
174 |
</td>
|
|
175 |
</tr>
|
|
176 |
|
|
177 |
<?php
|
|
178 |
if ($hostent['aliases']['item'] && is_array($hostent['aliases']['item'])):
|
|
179 |
foreach ($hostent['aliases']['item'] as $alias):
|
|
180 |
?>
|
|
181 |
<tr>
|
|
182 |
<td>
|
|
183 |
<?=$alias['host']?>
|
|
184 |
</td>
|
|
185 |
<td>
|
|
186 |
<?=$alias['domain']?>
|
|
187 |
</td>
|
|
188 |
<td>
|
|
189 |
<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
|
|
190 |
</td>
|
|
191 |
<td>
|
|
192 |
<i class="fa fa-angle-double-right text-info"></i>
|
|
193 |
<?=htmlspecialchars($alias['description'])?>
|
|
194 |
</td>
|
|
195 |
<td>
|
|
196 |
<a a class="fa fa-pencil" title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a>
|
|
197 |
</td>
|
|
198 |
</tr>
|
|
199 |
<?php
|
|
200 |
endforeach;
|
|
201 |
endif;
|
|
202 |
$i++;
|
|
203 |
endforeach;
|
|
204 |
?>
|
|
205 |
</tbody>
|
|
206 |
</table>
|
|
207 |
</div>
|
|
208 |
</div>
|
|
209 |
|
|
210 |
<nav class="action-buttons">
|
|
211 |
<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
|
|
212 |
<i class="fa fa-plus icon-embed-btn"></i>
|
|
213 |
<?=gettext('Add')?>
|
|
214 |
</a>
|
|
215 |
</nav>
|
|
216 |
|
|
217 |
<div class="panel panel-default">
|
|
218 |
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
|
|
219 |
<div class="panel-body table-responsive">
|
|
220 |
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
|
221 |
<thead>
|
|
222 |
<tr>
|
|
223 |
<th><?=gettext("Domain")?></th>
|
|
224 |
<th><?=gettext("IP")?></th>
|
|
225 |
<th><?=gettext("Description")?></th>
|
|
226 |
<th><?=gettext("Actions")?></th>
|
|
227 |
</tr>
|
|
228 |
</thead>
|
|
229 |
|
|
230 |
<tbody>
|
|
231 |
<?php
|
|
232 |
$i = 0;
|
|
233 |
foreach ($a_domainOverrides as $doment):
|
|
234 |
?>
|
|
235 |
<tr>
|
|
236 |
<td>
|
|
237 |
<?=$doment['domain']?>
|
|
238 |
</td>
|
|
239 |
<td>
|
|
240 |
<?=$doment['ip']?>
|
|
241 |
</td>
|
|
242 |
<td>
|
|
243 |
<?=htmlspecialchars($doment['descr'])?>
|
|
244 |
</td>
|
|
245 |
<td>
|
|
246 |
<a class="fa fa-pencil" title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a>
|
|
247 |
<a class="fa fa-trash" title="<?=gettext('Delete domain override')?>" href="services_unbound_overrides.php?act=del&type=doverride&id=<?=$i?>"></a>
|
|
248 |
</td>
|
|
249 |
</tr>
|
|
250 |
<?php
|
|
251 |
$i++;
|
|
252 |
endforeach;
|
|
253 |
?>
|
|
254 |
</tbody>
|
|
255 |
</table>
|
|
256 |
</div>
|
|
257 |
</div>
|
|
258 |
|
|
259 |
<nav class="action-buttons">
|
|
260 |
<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
|
|
261 |
<i class="fa fa-plus icon-embed-btn"></i>
|
|
262 |
<?=gettext('Add')?>
|
|
263 |
</a>
|
|
264 |
</nav>
|
|
265 |
|
|
266 |
<div class="infoblock">
|
|
267 |
<?php print_info_box(sprintf(gettext("If the DNS Resolver is enabled, the DHCP".
|
|
268 |
" service (if enabled) will automatically serve the LAN IP".
|
|
269 |
" address as a DNS server to DHCP clients so they will use".
|
|
270 |
" the DNS Resolver. If Forwarding is enabled, the DNS Resolver will use the DNS servers".
|
|
271 |
" entered in %sSystem: General setup%s".
|
|
272 |
" or those obtained via DHCP or PPP on WAN if "Allow".
|
|
273 |
" DNS server list to be overridden by DHCP/PPP on WAN"".
|
|
274 |
" is checked."), '<a href="system.php">', '</a>'), 'info', false); ?>
|
|
275 |
</div>
|
|
276 |
|
|
277 |
<?php include("foot.inc");
|
adding privileges and separating DNS Resolver overrides from general settings
(cherry picked from commit fc76a1e390c8ce9579df31457c74d1d0e572b78d)