diff options
-rwxr-xr-x | usr/local/www/services_proxyarp.php | 45 | ||||
-rwxr-xr-x | usr/local/www/services_proxyarp_edit.php | 95 |
2 files changed, 77 insertions, 63 deletions
diff --git a/usr/local/www/services_proxyarp.php b/usr/local/www/services_proxyarp.php index c881f1b..d9cf8d9 100755 --- a/usr/local/www/services_proxyarp.php +++ b/usr/local/www/services_proxyarp.php @@ -3,20 +3,20 @@ /* services_proxyarp.php part of m0n0wall (http://m0n0.ch/wall) - + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.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 @@ -39,7 +39,7 @@ $a_proxyarp = &$config['proxyarp']['proxyarpnet']; if ($_POST) { $pconfig = $_POST; - + $retval = 0; if (!file_exists($d_sysrebootreqd_path)) { config_lock(); @@ -83,13 +83,26 @@ if ($_GET['act'] == "del") { <?php endif; ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> - <td width="40%" class="listhdrr">Network</td> - <td width="50%" class="listhdr">Description</td> + <td width="20%" class="listhdrr">Interface</td> + <td width="30%" class="listhdrr">Network</td> + <td width="40%" class="listhdr">Description</td> <td width="10%" class="list"></td> </tr> <?php $i = 0; foreach ($a_proxyarp as $arpent): ?> <tr> - <td class="listlr"> + <td class="listlr"> + <?php + if ($arpent['interface']) { + $iflabels = array('lan' => 'LAN', 'wan' => 'WAN'); + for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) + $iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; + echo htmlspecialchars($iflabels[$arpent['interface']]); + } else { + echo "WAN"; + } + ?> + </td> + <td class="listr"> <?php if (isset($arpent['network'])) { list($sa,$sn) = explode("/", $arpent['network']); if ($sn == 32) @@ -101,24 +114,22 @@ if ($_GET['act'] == "del") { ?> </td> <td class="listbg"> - <font color="#FFFFFF"><?=htmlspecialchars($arpent['descr']);?> + <?=htmlspecialchars($arpent['descr']);?> </td> <td valign="middle" nowrap class="list"> <a href="services_proxyarp_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a> <a href="services_proxyarp.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this network?')"><img src="x.gif" width="17" height="17" border="0"></a></td> </tr> <?php $i++; endforeach; ?> - <tr> - <td class="list" colspan="2"></td> + <tr> + <td class="list" colspan="3"></td> <td class="list"> <a href="services_proxyarp_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td> </tr> </table> </form> <p class="vexpl"><span class="red"><strong>Note:<br> </strong></span>Proxy ARP can be used if you need m0n0wall to send ARP - replies on the WAN interface for other IP addresses than its own WAN - IP address (e.g. for 1:1, advanced outbound or server NAT). It is not - necessary if you have a subnet routed to you or if you use PPPoE/PPTP, and it only works if - the WAN interface is configured with a static IP address or DHCP.</p> -<?php include("fend.inc"); ?> + replies on an interface for other IP addresses than its own (e.g. for 1:1, advanced outbound or server NAT). It is not + necessary on the WAN interface if you have a subnet routed to you or if you use PPPoE/PPTP, and it only works on the WAN interface if it's configured with a static IP address or DHCP.</p> + <?php include("fend.inc"); ?> </body> </html> diff --git a/usr/local/www/services_proxyarp_edit.php b/usr/local/www/services_proxyarp_edit.php index c49e5ca..7cfba55 100755 --- a/usr/local/www/services_proxyarp_edit.php +++ b/usr/local/www/services_proxyarp_edit.php @@ -1,22 +1,22 @@ #!/usr/local/bin/php -<?php +<?php /* services_proxyarp_edit.php - Copyright (C) 2004 Scott Ullrich - originally part of m0n0wall (http://m0n0.ch/wall) + part of m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.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 @@ -42,6 +42,10 @@ if (isset($_POST['id'])) $id = $_POST['id']; if (isset($id) && $a_proxyarp[$id]) { + if ($a_proxyarp[$id]['interface']) + $pconfig['interface'] = $a_proxyarp[$id]['interface']; + else + $pconfig['interface'] = "wan"; if (isset($a_proxyarp[$id]['network'])) list($pconfig['subnet'], $pconfig['subnet_bits']) = explode("/", $a_proxyarp[$id]['network']); else if (isset($a_proxyarp[$id]['range'])) { @@ -50,6 +54,7 @@ if (isset($id) && $a_proxyarp[$id]) { } $pconfig['descr'] = $a_proxyarp[$id]['descr']; } else { + $pconfig['interface'] = "wan"; $pconfig['subnet_bits'] = 32; } @@ -70,9 +75,9 @@ if ($_POST) { $reqdfields = explode(" ", "range_from range_to"); $reqdfieldsn = explode(",", "Range start,Range end"); } - + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); - + if ((($_POST['type'] != "range") && $_POST['subnet'] && !is_ipaddr($_POST['subnet']))) { $input_errors[] = "A valid address must be specified."; } @@ -87,9 +92,9 @@ if ($_POST) { foreach ($a_proxyarp as $arpent) { if (isset($id) && ($a_proxyarp[$id]) && ($a_proxyarp[$id] === $arpent)) continue; - + if (($_POST['type'] == "range") && isset($arpent['range'])) { - if (($_POST['range_from'] == $arpent['range']['from']) && + if (($_POST['range_from'] == $arpent['range']['from']) && ($_POST['range_to'] == $arpent['range']['to'])) { $input_errors[] = "This range already exists."; break; @@ -104,6 +109,7 @@ if ($_POST) { if (!$input_errors) { $arpent = array(); + $arpent['interface'] = $_POST['interface']; if ($_POST['type'] == "range") { $arpent['range']['from'] = $_POST['range_from']; $arpent['range']['to'] = $_POST['range_to']; @@ -115,14 +121,11 @@ if ($_POST) { $a_proxyarp[$id] = $arpent; else $a_proxyarp[] = $arpent; - - if($_POST['interface']) - $arpent['interface'] = $_POST['interface']; - + touch($d_proxyarpdirty_path); - + write_config(); - + header("Location: services_proxyarp.php"); exit; } @@ -168,27 +171,42 @@ function typesel_change() { <?php if ($input_errors) print_input_errors($input_errors); ?> <form action="services_proxyarp_edit.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="6" cellspacing="0"> - <tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Interface</td> + <td width="78%" class="vtable"> + <select name="interface" class="formfld"> + <?php $interfaces = array('wan' => 'WAN', 'lan' => 'LAN'); + for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) { + $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr']; + } + foreach ($interfaces as $iface => $ifacename): ?> + <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>> + <?=htmlspecialchars($ifacename);?> + </option> + <?php endforeach; ?> + </select> </td> + </tr> + <tr> <td valign="top" class="vncellreq">Network</td> <td class="vtable"> <table border="0" cellspacing="0" cellpadding="0"> - <tr> + <tr> <td>Type: </td> <td><select name="type" class="formfld" onChange="typesel_change()"> - <option value="single" <?php if (!$pconfig['range_from'] && $pconfig['subnet_bits'] == 32) echo "selected"; ?>> + <option value="single" <?php if (!$pconfig['range_from'] && $pconfig['subnet_bits'] == 32) echo "selected"; ?>> Single address</option> - <option value="network" <?php if (!$pconfig['range_from'] && $pconfig['subnet_bits'] != 32) echo "selected"; ?>> + <option value="network" <?php if (!$pconfig['range_from'] && $pconfig['subnet_bits'] != 32) echo "selected"; ?>> Network</option> - <option value="range" <?php if ($pconfig['range_from']) echo "selected"; ?>> + <option value="range" <?php if ($pconfig['range_from']) echo "selected"; ?>> Range</option> </select></td> </tr> - <tr> + <tr> <td>Address: </td> <td><input name="subnet" type="text" class="formfld" id="subnet" size="20" value="<?=htmlspecialchars($pconfig['subnet']);?>"> - / + / <select name="subnet_bits" class="formfld" id="select"> - <?php for ($i = 32; $i >= 0; $i--): ?> + <?php for ($i = 31; $i >= 0; $i--): ?> <option value="<?=$i;?>" <?php if ($i == $pconfig['subnet_bits']) echo "selected"; ?>> <?=$i;?> </option> @@ -196,41 +214,26 @@ function typesel_change() { </select> </td> </tr> - <tr> + <tr> <td>Range: </td> <td><input name="range_from" type="text" class="formfld" id="range_from" size="20" value="<?=htmlspecialchars($pconfig['range_from']);?>"> -- - <input name="range_to" type="text" class="formfld" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>"> +- + <input name="range_to" type="text" class="formfld" id="range_to" size="20" value="<?=htmlspecialchars($pconfig['range_to']);?>"> </td> </tr> </table> </td> </tr> - - <tr> - <td width="22%" valign="top" class="vncell"><b>Interface</td> - <td width="78%" class="vtable"><select name="interface"> - <?php if(isset($config['proxyarp']['proxyarpnet']['interface'])) - echo "<option value=\"". $config['proxyarp']['proxyarpnet']['interface'] . "\">" . $config['proxyarp']['proxyarpnet']['interface'] . "</option>"; - ?> - <option value="">WAN</option> - <option value="">LAN</option> - <?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): if (!isset($config['interfaces']['opt' . $i]['ovpn'])): ?> - <option value="<?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?>"><?=htmlspecialchars($config['interfaces']['opt' . $i]['descr']);?></option> - <?php endif; endfor; ?> - </td> - </tr> - - <tr> + <tr> <td width="22%" valign="top" class="vncell">Description</td> - <td width="78%" class="vtable"> + <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"> </td> - <td width="78%"> + <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save"> <?php if (isset($id) && $a_proxyarp[$id]): ?> <input name="id" type="hidden" value="<?=$id;?>"> |