[ previous ] [ next ] [ threads ]
 
 From:  Joe Suhre <jsuhre at nullconcepts dot com>
 To:  Manuel Kasper <mk at neon1 dot net>, m0n0wall at lists dot m0n0 dot ch
 Subject:  Re: [m0n0wall] Bugs to be fixed before 1.2 release?
 Date:  Mon, 29 Aug 2005 16:09:27 -0400
Manuel,
   I wrote a patch adding some functionality to dnsmasq in m0n0wall. I 
got a very possitive response from Chris Buechler on it. The first 
e-mail in a thread discussing the functionality can be found at 
http://www.m0n0.ch/wall/list/?action=show_msg&actionargs[]=173&actionargs[]=74 
. I've also attached the patch for concideration.

Thanks
    Joe!


Manuel Kasper wrote:

>Hello m0n0wall users,
>
>I'm back from my vacation and planning on finally making the
>(much-anticipated) m0n0wall 1.2 release - now that people have
>started calling 1.2b9 better/more stable than 1.11 (which, I must
>say, is also my opinion :).
>
>1.2 won't be much different from 1.2b9, aside from a couple of small
>patches/updates. Now, a question to all m0n0wall users who are
>already running 1.2b9:
>
>Do you have any open bugs to report that are reproducible, not just
>related to your specific setup and that need to be fixed before 1.2?
>If so, please post them in this thread, and if you already have a fix
>for them, that would be very much appreciated of course.
>
>On a related note - OpenVPN will be gone in 1.2 since it has issues
>(optional interfaces handling) that I don't have the resources to fix
>at present - unless somebody else steps in.
>
>Regards,
>
>Manuel
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: m0n0wall dash unsubscribe at lists dot m0n0 dot ch
>For additional commands, e-mail: m0n0wall dash help at lists dot m0n0 dot ch
>
>  
>
diff -ruN ./etc/inc/services.inc ../../DEVEL_net45xx-1.2b9/fs/etc/inc/services.inc
--- ./etc/inc/services.inc	Sun Jun 19 05:58:25 2005
+++ ../../DEVEL_net45xx-1.2b9/fs/etc/inc/services.inc	Fri Jul  1 10:24:51 2005
@@ -365,6 +365,12 @@
 				" -s {$config['system']['domain']}";
 		}
 
+		if (isset($config['dnsmasq']['domainoverrides']) &&
is_array($config['dnsmasq']['domainoverrides'])) {
+			foreach($config['dnsmasq']['domainoverrides'] as $override) {
+				$args .= ' --server=/' . $override['domain'] . '/' . $override['ip'];
+			}
+		}
+
 		/* run dnsmasq */
 		mwexec("/usr/local/sbin/dnsmasq {$args}");
 
diff -ruN ./etc/inc/xmlparse.inc ../../DEVEL_net45xx-1.2b9/fs/etc/inc/xmlparse.inc
--- ./etc/inc/xmlparse.inc	Sun Jun 19 05:58:27 2005
+++ ../../DEVEL_net45xx-1.2b9/fs/etc/inc/xmlparse.inc	Fri Jul  1 10:27:31 2005
@@ -33,7 +33,7 @@
 $listtags = explode(" ", "rule user key dnsserver winsserver " .
 	"encryption-algorithm-option hash-algorithm-option hosts tunnel onetoone " .
 	"staticmap route alias pipe queue shellcmd cacert earlyshellcmd mobilekey " .
-	"servernat proxyarpnet passthrumac allowedip wolentry vlan");
+	"servernat proxyarpnet passthrumac allowedip wolentry vlan domainoverrides");
 
 function startElement($parser, $name, $attrs) {
 	global $depth, $curpath, $config, $havedata, $listtags;
diff -ruN ./usr/local/www/guiconfig.inc ../../DEVEL_net45xx-1.2b9/fs/usr/local/www/guiconfig.inc
--- ./usr/local/www/guiconfig.inc	Sun Jun 19 05:58:18 2005
+++ ../../DEVEL_net45xx-1.2b9/fs/usr/local/www/guiconfig.inc	Fri Jul  1 10:24:51 2005
@@ -46,7 +46,7 @@
 $d_ipsecconfdirty_path = $g['varrun_path'] . "/ipsec.conf.dirty";
 $d_shaperconfdirty_path = $g['varrun_path'] . "/shaper.conf.dirty";
 $d_pptpuserdirty_path = $g['varrun_path'] . "/pptpd.user.dirty";
-$d_hostsdirty_path = $g['varrun_path'] . "/hosts.dirty";
+$d_dnsmasqdirty_path = $g['varrun_path'] . "/dnsmasq.dirty";
 $d_staticmapsdirty_path = $g['varrun_path'] . "/staticmaps.dirty";
 $d_staticroutesdirty_path = $g['varrun_path'] . "/staticroutes.dirty";
 $d_aliasesdirty_path = $g['varrun_path'] . "/aliases.dirty";
diff -ruN ./usr/local/www/services_dnsmasq.php
../../DEVEL_net45xx-1.2b9/fs/usr/local/www/services_dnsmasq.php
--- ./usr/local/www/services_dnsmasq.php	Sun Jun 19 05:58:13 2005
+++ ../../DEVEL_net45xx-1.2b9/fs/usr/local/www/services_dnsmasq.php	Fri Jul  1 10:28:51 2005
@@ -38,8 +38,14 @@
 if (!is_array($config['dnsmasq']['hosts'])) {
 	$config['dnsmasq']['hosts'] = array();
 }
+
+if (!is_array($config['dnsmasq']['domainoverrides'])) {
+	$config['dnsmasq']['domainoverrides'] = array();
+}
+
 hosts_sort();
 $a_hosts = &$config['dnsmasq']['hosts'];
+$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
 
 if ($_POST) {
 
@@ -59,25 +65,36 @@
 	$savemsg = get_std_save_message($retval);
 
 	if ($retval == 0) {
-		if (file_exists($d_hostsdirty_path))
-			unlink($d_hostsdirty_path);
+		if (file_exists($d_dnsmasqdirty_path))
+			unlink($d_dnsmasqdirty_path);
 	}
 }
 
 if ($_GET['act'] == "del") {
-	if ($a_hosts[$_GET['id']]) {
-		unset($a_hosts[$_GET['id']]);
-		write_config();
-		touch($d_hostsdirty_path);
-		header("Location: services_dnsmasq.php");
-		exit;
+	if ($_GET['type'] == 'host') {
+		if ($a_hosts[$_GET['id']]) {
+			unset($a_hosts[$_GET['id']]);
+			write_config();
+			touch($d_dnsmasqdirty_path);
+			header("Location: services_dnsmasq.php");
+			exit;
+		}
+	}
+	elseif ($_GET['type'] == 'doverride') {
+		if ($a_domainOverrides[$_GET['id']]) {
+			unset($a_domainOverrides[$_GET['id']]);
+			write_config();
+			touch($d_dnsmasqdirty_path);
+			header("Location: services_dnsmasq.php");
+			exit;
+		}
 	}
 }
 ?>
 <?php include("fbegin.inc"); ?>
 <form action="services_dnsmasq.php" method="post">
 <?php if ($savemsg) print_info_box($savemsg); ?>
-<?php if (file_exists($d_hostsdirty_path)): ?><p>
+<?php if (file_exists($d_dnsmasqdirty_path)): ?><p>
 <?php print_info_box_np("The DNS forwarder configuration has been changed.<br>You must apply the
changes in order for them to take effect.");?><br>
 <input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
 <?php endif; ?>
@@ -143,7 +160,7 @@
                     <?=htmlspecialchars($hostent['descr']);?>&nbsp;
                   </td>
                   <td valign="middle" nowrap class="list"> <a
href="services_dnsmasq_edit.php?id=<?=$i;?>"><img src="e.gif" title="edit host" width="17"
height="17" border="0"></a>
-                     &nbsp;<a href="services_dnsmasq.php?act=del&id=<?=$i;?>" onclick="return
confirm('Do you really want to delete this host?')"><img src="x.gif" title="delete host" width="17"
height="17" border="0"></a></td>
+                     &nbsp;<a href="services_dnsmasq.php?act=del&type=host&id=<?=$i;?>"
onclick="return confirm('Do you really want to delete this host?')"><img src="x.gif" title="delete
host" width="17" height="17" border="0"></a></td>
 				</tr>
 			  <?php $i++; endforeach; ?>
                 <tr> 
@@ -151,5 +168,38 @@
                   <td class="list"> <a href="services_dnsmasq_edit.php"><img src="plus.gif"
title="add host" width="17" height="17" border="0"></a></td>
 				</tr>
               </table>
+ <!-- update to enable domain overrides -->
+			  <table width="100%" border="0" cellpadding="6" cellspacing="0">
+                <tr> 
+                  <td><p>Below you can override an entire domain by specifying an
+                         authoritative dns server to be queried for that domain.</p></td>
+                </tr>
+              </table>
+              <table width="100%" border="0" cellpadding="0" cellspacing="0">
+                <tr>
+                  <td width="35%" class="listhdrr">Domain</td>
+                  <td width="20%" class="listhdrr">IP</td>
+                  <td width="35%" class="listhdr">Description</td>
+                  <td width="10%" class="list"></td>
+				</tr>
+			  <?php $i = 0; foreach ($a_domainOverrides as $doment): ?>
+                <tr>
+                  <td class="listlr">
+                    <?=strtolower($doment['domain']);?>&nbsp;
+                  </td>
+                  <td class="listr">
+                    <?=$doment['ip'];?>&nbsp;
+                  </td>
+                  <td class="listbg">
+                    <?=htmlspecialchars($doment['descr']);?>&nbsp;
+                  </td>
+                  <td valign="middle" nowrap class="list"> <a
href="services_dnsmasq_domainoverride_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17"
border="0"></a>
+                     &nbsp;<a href="services_dnsmasq.php?act=del&type=doverride&id=<?=$i;?>"
onclick="return confirm('Do you really want to delete this domain override?')"><img src="x.gif"
width="17" height="17" border="0"></a></td>
+				</tr>
+			  <?php $i++; endforeach; ?>
+                <tr> 
+                  <td class="list" colspan="3"></td>
+                  <td class="list"> <a href="services_dnsmasq_domainoverride_edit.php"><img
src="plus.gif" width="17" height="17" border="0"></a></td>
+				</tr>
             </form>
 <?php include("fend.inc"); ?>
diff -ruN ./usr/local/www/services_dnsmasq_domainoverride_edit.php
../../DEVEL_net45xx-1.2b9/fs/usr/local/www/services_dnsmasq_domainoverride_edit.php
--- ./usr/local/www/services_dnsmasq_domainoverride_edit.php	Wed Dec 31 19:00:00 1969
+++ ../../DEVEL_net45xx-1.2b9/fs/usr/local/www/services_dnsmasq_domainoverride_edit.php	Fri Jul  1
10:24:51 2005
@@ -0,0 +1,135 @@
+#!/usr/local/bin/php
+<?php 
+/*
+	services_dnsmasq_domainoverride_edit.php
+	part of m0n0wall (http://m0n0.ch/wall)
+	
+	Copyright (C) 2003-2005 Bob Zoller <bob at kludgebox dot com> and Manuel Kasper <mk at neon1 dot net>.
+	All rights reserved.
+	
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions are met:
+	
+	1. Redistributions of source code must retain the above copyright notice,
+	   this list of conditions and the following disclaimer.
+	
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+	
+	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+	POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$pgtitle = array("Services", "DNS forwarder", "Edit Domain Override");
+require("guiconfig.inc");
+
+if (!is_array($config['dnsmasq']['domainoverrides'])) {
+	$config['dnsmasq']['domainoverrides'] = array();
+}
+$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
+
+$id = $_GET['id'];
+if (isset($_POST['id']))
+	$id = $_POST['id'];
+
+if (isset($id) && $a_domainOverrides[$id]) {
+	$pconfig['domain'] = $a_domainOverrides[$id]['domain'];
+	$pconfig['ip'] = $a_domainOverrides[$id]['ip'];
+	$pconfig['descr'] = $a_domainOverrides[$id]['descr'];
+}
+
+if ($_POST) {
+
+	unset($input_errors);
+	$pconfig = $_POST;
+
+	/* input validation */
+	$reqdfields = explode(" ", "domain ip");
+	$reqdfieldsn = explode(",", "Domain,IP address");
+	
+	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+	
+	if (($_POST['domain'] && !is_domain($_POST['domain']))) {
+		$input_errors[] = "A valid domain must be specified.";
+	}
+	if (($_POST['ip'] && !is_ipaddr($_POST['ip']))) {
+		$input_errors[] = "A valid IP address must be specified.";
+	}
+
+	/* check for overlaps */
+	foreach ($a_domainOverrides as $doment) {
+		if (isset($id) && ($a_domainOverrides[$id]) && ($a_domainOverrides[$id] === $doment))
+			continue;
+
+		if (($doment['host'] == $_POST['host']) && ($doment['domain'] == $_POST['domain'])) {
+			$input_errors[] = "A override already exists for this domain.";
+			break;
+		}
+	}
+
+	if (!$input_errors) {
+		$doment = array();
+		$doment['domain'] = $_POST['domain'];
+		$doment['ip'] = $_POST['ip'];
+		$doment['descr'] = $_POST['descr'];
+
+		if (isset($id) && $a_domainOverrides[$id])
+			$a_domainOverrides[$id] = $doment;
+		else
+			$a_domainOverrides[] = $doment;
+		
+		touch($d_dnsmasqdirty_path);
+		
+		write_config();
+		
+		header("Location: services_dnsmasq.php");
+		exit;
+	}
+}
+?>
+<?php include("fbegin.inc"); ?>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+            <form action="services_dnsmasq_domainoverride_edit.php" method="post" name="iform"
id="iform">
+              <table width="100%" border="0" cellpadding="6" cellspacing="0">
+				<tr>
+                  <td width="22%" valign="top" class="vncellreq">Domain</td>
+                  <td width="78%" class="vtable"> 
+                    <?=$mandfldhtml;?><input name="domain" type="text" class="formfld" id="domain"
size="40" value="<?=htmlspecialchars($pconfig['domain']);?>">
+                    <br> <span class="vexpl">Domain to override (NOTE: this does not have to be a
valid TLD!)<br>
+                    e.g. <em>test</em></span></td>
+                </tr>
+				<tr>
+                  <td width="22%" valign="top" class="vncellreq">IP address</td>
+                  <td width="78%" class="vtable"> 
+                    <?=$mandfldhtml;?><input name="ip" type="text" class="formfld" id="ip"
size="40" value="<?=htmlspecialchars($pconfig['ip']);?>">
+                    <br> <span class="vexpl">IP address of the authoritative dns server for this
domain<br>
+                    e.g. <em>192.168.100.100</em></span></td>
+                </tr>
+				<tr>
+                  <td width="22%" valign="top" class="vncell">Description</td>
+                  <td width="78%" class="vtable"> 
+                    <input name="descr" type="text" class="formfld" id="descr" size="40"
value="<?=htmlspecialchars($pconfig['descr']);?>">
+                    <br> <span class="vexpl">You may enter a description here
+                    for your reference (not parsed).</span></td>
+                </tr>
+                <tr>
+                  <td width="22%" valign="top">&nbsp;</td>
+                  <td width="78%"> 
+                    <input name="Submit" type="submit" class="formbtn" value="Save">
+                    <?php if (isset($id) && $a_domainOverrides[$id]): ?>
+                    <input name="id" type="hidden" value="<?=$id;?>">
+                    <?php endif; ?>
+                  </td>
+                </tr>
+              </table>
+</form>
+<?php include("fend.inc"); ?>
diff -ruN ./usr/local/www/services_dnsmasq_edit.php
../../DEVEL_net45xx-1.2b9/fs/usr/local/www/services_dnsmasq_edit.php
--- ./usr/local/www/services_dnsmasq_edit.php	Sun Jun 19 05:58:13 2005
+++ ../../DEVEL_net45xx-1.2b9/fs/usr/local/www/services_dnsmasq_edit.php	Fri Jul  1 10:24:51 2005
@@ -93,7 +93,7 @@
 		else
 			$a_hosts[] = $hostent;
 		
-		touch($d_hostsdirty_path);
+		touch($d_dnsmasqdirty_path);
 		
 		write_config();