Project

General

Profile

Download (13.1 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dnsmasq.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 f0fe3d30 Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Bob Zoller <bob@kludgebox.com> and Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 f0fe3d30 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 f0fe3d30 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 f0fe3d30 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 f0fe3d30 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 1d333258 Scott Ullrich
/*	
32
	pfSense_MODULE:	dnsforwarder
33
*/
34 5b237745 Scott Ullrich
35 6b07c15a Matthew Grooms
##|+PRIV
36
##|*IDENT=page-services-dnsforwarder
37
##|*NAME=Services: DNS Forwarder page
38
##|*DESCR=Allow access to the 'Services: DNS Forwarder' page.
39
##|*MATCH=services_dnsmasq.php*
40
##|-PRIV
41
42 5b237745 Scott Ullrich
require("guiconfig.inc");
43 7a927e67 Scott Ullrich
require_once("functions.inc");
44
require_once("filter.inc");
45
require_once("shaper.inc");
46 5b237745 Scott Ullrich
47 4d6ba181 Scott Ullrich
$pconfig['enable']  = isset($config['dnsmasq']['enable']);
48 5b237745 Scott Ullrich
$pconfig['regdhcp'] = isset($config['dnsmasq']['regdhcp']);
49 6a01ea44 Bill Marquette
$pconfig['regdhcpstatic'] = isset($config['dnsmasq']['regdhcpstatic']);
50 5b237745 Scott Ullrich
51 4d6ba181 Scott Ullrich
if (!is_array($config['dnsmasq']['hosts'])) 
52 5b237745 Scott Ullrich
	$config['dnsmasq']['hosts'] = array();
53 0c2b5df7 Scott Ullrich
54 4d6ba181 Scott Ullrich
if (!is_array($config['dnsmasq']['domainoverrides'])) 
55 0c2b5df7 Scott Ullrich
       $config['dnsmasq']['domainoverrides'] = array();
56
57 4d6ba181 Scott Ullrich
58
$a_hosts 	   = &$config['dnsmasq']['hosts'];
59 0c2b5df7 Scott Ullrich
$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
60 5b237745 Scott Ullrich
61
if ($_POST) {
62
63
	$pconfig = $_POST;
64
65
	$config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false;
66
	$config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false;
67 6a01ea44 Bill Marquette
	$config['dnsmasq']['regdhcpstatic'] = ($_POST['regdhcpstatic']) ? true : false;
68 5b237745 Scott Ullrich
69
	write_config();
70 f0fe3d30 Scott Ullrich
71 5b237745 Scott Ullrich
	$retval = 0;
72 920b3bb0 Scott Ullrich
	$retval = services_dnsmasq_configure();
73 5b237745 Scott Ullrich
	$savemsg = get_std_save_message($retval);
74
75 020d757a Scott Ullrich
	// Relaod filter (we might need to sync to CARP hosts)
76
	filter_configure();
77
78 a368a026 Ermal Lu?i
	if ($retval == 0)
79
		clear_subsystem_dirty('hosts');
80 5b237745 Scott Ullrich
}
81
82
if ($_GET['act'] == "del") {
83 0c2b5df7 Scott Ullrich
       if ($_GET['type'] == 'host') {
84
               if ($a_hosts[$_GET['id']]) {
85
                       unset($a_hosts[$_GET['id']]);
86
                       write_config();
87 a368a026 Ermal Lu?i
			mark_subsystem_dirty('hosts');
88 0c2b5df7 Scott Ullrich
                       header("Location: services_dnsmasq.php");
89
                       exit;
90
               }
91
       }
92
       elseif ($_GET['type'] == 'doverride') {
93
               if ($a_domainOverrides[$_GET['id']]) {
94
                       unset($a_domainOverrides[$_GET['id']]);
95
                       write_config();
96 a368a026 Ermal Lu?i
			mark_subsystem_dirty('hosts');
97 0c2b5df7 Scott Ullrich
                       header("Location: services_dnsmasq.php");
98
                       exit;
99
               }
100
       }
101 5b237745 Scott Ullrich
}
102 0c2b5df7 Scott Ullrich
103 beb2bc00 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("DNS forwarder"));
104 b63695db Scott Ullrich
include("head.inc");
105 0c2b5df7 Scott Ullrich
106 5b237745 Scott Ullrich
?>
107
108 6a01ea44 Bill Marquette
<script language="JavaScript">
109
<!--
110
function enable_change(enable_over) {
111
	var endis;
112
	endis = !(document.iform.enable.checked || enable_over);
113
	document.iform.regdhcp.disabled = endis;
114
	document.iform.regdhcpstatic.disabled = endis;
115
}
116
//-->
117
</script>
118
119 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
120
<?php include("fbegin.inc"); ?>
121 6a01ea44 Bill Marquette
<form action="services_dnsmasq.php" method="post" name="iform" id="iform">
122 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
123 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('hosts')): ?><p>
124 619c72f9 Carlos Eduardo Ramos
<?php print_info_box_np(gettext("The DNS forwarder configuration has been changed") . ".<br>" . gettext("You must apply the changes in order for them to take effect."));?><br>
125 5b237745 Scott Ullrich
<?php endif; ?>
126 4d6ba181 Scott Ullrich
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
127 f0fe3d30 Scott Ullrich
                <tr>
128
                  <td class="vtable"><p>
129 6a01ea44 Bill Marquette
                      <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable'] == "yes") echo "checked";?> onClick="enable_change(false)">
130 beb2bc00 Rafael Lucas
                      <strong><?=gettext("Enable DNS forwarder");?><br>
131 5b237745 Scott Ullrich
                      </strong></p></td>
132
                </tr>
133 f0fe3d30 Scott Ullrich
                <tr>
134
                  <td class="vtable"><p>
135 5b237745 Scott Ullrich
                      <input name="regdhcp" type="checkbox" id="regdhcp" value="yes" <?php if ($pconfig['regdhcp'] == "yes") echo "checked";?>>
136 beb2bc00 Rafael Lucas
                      <strong><?=gettext("Register DHCP leases in DNS forwarder");?><br>
137
                      </strong><?php printf(gettext("If this option is set, then machines that specify".
138
                     " their hostname when requesting a DHCP lease will be registered".
139
                     " in the DNS forwarder, so that their name can be resolved.".
140
                     " You should also set the domain in %sSystem:".
141
                     " General setup%s to the proper value."),'<a href="system.php">','</a>')?></p>
142 5b237745 Scott Ullrich
                    </td>
143
                </tr>
144 f0fe3d30 Scott Ullrich
                <tr>
145 6a01ea44 Bill Marquette
                  <td class="vtable"><p>
146
                      <input name="regdhcpstatic" type="checkbox" id="regdhcpstatic" value="yes" <?php if ($pconfig['regdhcpstatic'] == "yes") echo "checked";?>>
147 beb2bc00 Rafael Lucas
                      <strong><?=gettext("Register DHCP static mappings in DNS forwarder");?><br>
148
                      </strong><?php printf(gettext("If this option is set, then DHCP static mappings will ".
149
					  "be registered in the DNS forwarder, so that their name can be ".
150
					  "resolved. You should also set the domain in %s".
151
					  "System: General setup%s to the proper value."),'<a href="system.php">','</a>');?></p>
152 6a01ea44 Bill Marquette
                    </td>
153
                </tr>				
154
                <tr>
155 619c72f9 Carlos Eduardo Ramos
                  <td> <input name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)">
156 5b237745 Scott Ullrich
                  </td>
157
                </tr>
158 f0fe3d30 Scott Ullrich
                <tr>
159 16457bdd Renato Botelho
                  <td><p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
160 beb2bc00 Rafael Lucas
                      </strong></span><?php printf(gettext("If the DNS forwarder is enabled, the DHCP".
161
                     " service (if enabled) will automatically serve the LAN IP".
162
                     " address as a DNS server to DHCP clients so they will use".
163
                     " the forwarder. The DNS forwarder will use the DNS servers".
164
                     " entered in %sSystem: General setup%s".
165
                     " or those obtained via DHCP or PPP on WAN if the &quot;Allow".
166
                     " DNS server list to be overridden by DHCP/PPP on WAN&quot;".
167
                     " is checked. If you don't use that option (or if you use".
168
                     " a static IP address on WAN), you must manually specify at".
169
                     " least one DNS server on the %sSystem:".
170
                      "General setup%s page."),'<a href="system.php">','</a>','<a href="system.php">','</a>');?><br>
171 5b237745 Scott Ullrich
                      <br>
172 beb2bc00 Rafael Lucas
                      <?=gettext("You may enter records that override the results from the".
173
                     " forwarders below.");?></span></p></td>
174 5b237745 Scott Ullrich
                </tr>
175 4d6ba181 Scott Ullrich
        </table>
176
        &nbsp;<br>
177 bfdb8779 Scott Ullrich
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
178 5b237745 Scott Ullrich
                <tr>
179 beb2bc00 Rafael Lucas
                  <td width="20%" class="listhdrr"><?=gettext("Host");?></td>
180
                  <td width="25%" class="listhdrr"><?=gettext("Domain");?></td>
181
                  <td width="20%" class="listhdrr"><?=gettext("IP");?></td>
182
                  <td width="25%" class="listhdr"><?=gettext("Description");?></td>
183 d415d821 Seth Mos
                  <td width="10%" class="list">
184
                    <table border="0" cellspacing="0" cellpadding="1">
185
                      <tr>
186
			<td width="17"></td>
187
                        <td valign="middle"><a href="services_dnsmasq_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
188
                      </tr>
189
                    </table>
190
		  </td>
191
		</tr>
192 5b237745 Scott Ullrich
			  <?php $i = 0; foreach ($a_hosts as $hostent): ?>
193
                <tr>
194 835f9aca Bill Marquette
                  <td class="listlr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
195 5b237745 Scott Ullrich
                    <?=strtolower($hostent['host']);?>&nbsp;
196
                  </td>
197 835f9aca Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
198 5b237745 Scott Ullrich
                    <?=strtolower($hostent['domain']);?>&nbsp;
199
                  </td>
200 835f9aca Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
201 5b237745 Scott Ullrich
                    <?=$hostent['ip'];?>&nbsp;
202
                  </td>
203 835f9aca Bill Marquette
                  <td class="listbg" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
204 0e1dce26 Scott Ullrich
                    <?=htmlspecialchars($hostent['descr']);?>&nbsp;
205 5b237745 Scott Ullrich
                  </td>
206 ebe566eb Bill Marquette
                  <td valign="middle" nowrap class="list">
207
                    <table border="0" cellspacing="0" cellpadding="1">
208
                      <tr>
209 677c0869 Erik Kristensen
                        <td valign="middle"><a href="services_dnsmasq_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
210 beb2bc00 Rafael Lucas
                        <td><a href="services_dnsmasq.php?type=host&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this host?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
211 ebe566eb Bill Marquette
		      </tr>
212
                   </table>
213
                </tr>
214
		<?php $i++; endforeach; ?>
215 f0fe3d30 Scott Ullrich
                <tr>
216 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
217 ebe566eb Bill Marquette
                  <td class="list">
218
                    <table border="0" cellspacing="0" cellpadding="1">
219
                      <tr>
220 d415d821 Seth Mos
			<td width="17"></td>
221 677c0869 Erik Kristensen
                        <td valign="middle"><a href="services_dnsmasq_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
222 ebe566eb Bill Marquette
                      </tr>
223
                    </table>
224 ed137452 Scott Ullrich
		   </td>
225 4d6ba181 Scott Ullrich
	</table>
226 0c2b5df7 Scott Ullrich
<!-- update to enable domain overrides -->
227 4d6ba181 Scott Ullrich
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
228 c21d4582 Scott Ullrich
	       <tr><td>&nbsp;</td></tr>
229 0c2b5df7 Scott Ullrich
               <tr>
230 beb2bc00 Rafael Lucas
                 <td><p><?=gettext("Below you can override an entire domain by specifying an".
231
                       " authoritative DNS server to be queried for that domain.");?></p></td>
232 0c2b5df7 Scott Ullrich
               </tr>
233 4d6ba181 Scott Ullrich
        </table>
234
	&nbsp;<br>
235
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
236 0c2b5df7 Scott Ullrich
               <tr>
237 beb2bc00 Rafael Lucas
                 <td width="35%" class="listhdrr"><?=gettext("Domain");?></td>
238
                 <td width="20%" class="listhdrr"><?=gettext("IP");?></td>
239
                 <td width="35%" class="listhdr"><?=gettext("Description");?></td>
240 d415d821 Seth Mos
                 <td width="10%" class="list">
241
			<table border="0" cellspacing="0" cellpadding="1">
242
			    <tr>
243
				<td width="17" heigth="17"></td>			
244
				<td><a href="services_dnsmasq_domainoverride_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
245
			    </tr>
246
			</table>
247
		 </td>
248 0c2b5df7 Scott Ullrich
                              </tr>
249
                        <?php $i = 0; foreach ($a_domainOverrides as $doment): ?>
250
               <tr>
251
                 <td class="listlr">
252
                   <?=strtolower($doment['domain']);?>&nbsp;
253
                 </td>
254
                 <td class="listr">
255
                   <?=$doment['ip'];?>&nbsp;
256
                 </td>
257 d4da6249 Scott Ullrich
                 <td class="listbg">
258 0c2b5df7 Scott Ullrich
                   <?=htmlspecialchars($doment['descr']);?>&nbsp;
259
                 </td>
260 677c0869 Erik Kristensen
                 <td valign="middle" nowrap class="list"> <a href="services_dnsmasq_domainoverride_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
261 beb2bc00 Rafael Lucas
                    &nbsp;<a href="services_dnsmasq.php?act=del&type=doverride&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this domain override?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
262 0c2b5df7 Scott Ullrich
                              </tr>
263
                        <?php $i++; endforeach; ?>
264
               <tr>
265
                 <td class="list" colspan="3"></td>
266 d415d821 Seth Mos
                 <td class="list">
267
			<table border="0" cellspacing="0" cellpadding="1">
268
			    <tr>
269
				<td width="17" heigth="17"></td>			
270
				<td><a href="services_dnsmasq_domainoverride_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
271
			    </tr>
272
			</table>
273
		 </td>
274 0c2b5df7 Scott Ullrich
	       </tr>
275 4d6ba181 Scott Ullrich
        </table>
276
        </form>
277 6a01ea44 Bill Marquette
<script language="JavaScript">
278
<!--
279
enable_change(false);
280
//-->
281
</script>
282 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
283
</body>
284
</html>