summaryrefslogtreecommitdiffstats
path: root/usr/local
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2007-02-09 20:54:56 +0000
committerScott Ullrich <sullrich@pfsense.org>2007-02-09 20:54:56 +0000
commita09d815aaa3555e8efb0c0bf316326d75e7cdef0 (patch)
treef4dac8d9d35e7837946ab2f16bea72b881fb2942 /usr/local
parent4f135ed3e20338839e5a4343042de7bcc5361127 (diff)
downloadpfsense-a09d815aaa3555e8efb0c0bf316326d75e7cdef0.zip
pfsense-a09d815aaa3555e8efb0c0bf316326d75e7cdef0.tar.gz
Backport diagnostics, show states which now includes a kill state feature.
Diffstat (limited to 'usr/local')
-rwxr-xr-xusr/local/www/diag_dump_states.php242
1 files changed, 153 insertions, 89 deletions
diff --git a/usr/local/www/diag_dump_states.php b/usr/local/www/diag_dump_states.php
index 4611812..c13b483 100755
--- a/usr/local/www/diag_dump_states.php
+++ b/usr/local/www/diag_dump_states.php
@@ -1,29 +1,29 @@
<?php
/*
- diag_dump_states.php
- Copyright (C) 2005 Scott Ullrich, Colin Smith
- 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.
+ diag_dump_states.php
+ Copyright (C) 2005 Scott Ullrich, Colin Smith
+ 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.
*/
require_once("guiconfig.inc");
@@ -31,95 +31,159 @@ require_once("guiconfig.inc");
$pgtitle = "Diagnostics: Show States";
include("head.inc");
+/* handle AJAX operations */
+if($_GET['action']) {
+ if($_GET['action'] == "remove") {
+ $retval = mwexec("/sbin/pfctl -k '{$_GET['srcip']}' -k '{$_GET['dstip']}'");
+ echo "|{$_GET['srcip']}|{$_GET['dstip']}|{$retval}|";
+ exit;
+ }
+}
+
/* get our states */
if($_GET['filter']) {
- exec("/sbin/pfctl -ss | grep {$_GET['filter']}", $states);
-} else {
- exec("/sbin/pfctl -ss", $states);
+ exec("/sbin/pfctl -s state | grep " . escapeshellarg($_GET['filter']), $states);
+}
+else {
+ exec("/sbin/pfctl -s state", $states);
}
?>
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<script src="/javascript/sorttable.js"></script>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?=$jsevents["body"]["onload"];?>">
+<script src="/javascript/sorttable.js" type="text/javascript"></script>
<?php include("fbegin.inc"); ?>
<p class="pgtitle"><?=$pgtitle?></p>
<form action="diag_dump_states.php" method="get" name="iform">
+
+<script type="text/javascript">
+ function removeState(srcip, dstip) {
+ var busy = function(icon) {
+ icon.onclick = "";
+ icon.src = icon.src.replace("\.gif", "_d.gif");
+ icon.style.cursor = "wait";
+ }
+
+ $A(document.getElementsByName("i:" + srcip + ":" + dstip)).each(busy);
+
+ new Ajax.Request(
+ "<?=$_SERVER['SCRIPT_NAME'];?>" +
+ "?action=remove&srcip=" + srcip + "&dstip=" + dstip,
+ { method: "get", onComplete: removeComplete }
+ );
+ }
+
+ function removeComplete(req) {
+ var values = req.responseText.split("|");
+ if(values[3] != "0") {
+ alert('<?=gettext("An error occured.");?>');
+ return;
+ }
+
+ $A(document.getElementsByName("r:" + values[1] + ":" + values[2])).each(
+ function(row) { Effect.Fade(row, { duration: 1.0 }); }
+ );
+ }
+</script>
+
<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<tr><td>
-<?php
- $tab_array = array();
- $tab_array[0] = array("States", true, "diag_dump_states.php");
- $tab_array[1] = array("Reset States", false, "diag_resetstate.php");
- display_top_tabs($tab_array);
-?>
-</td></tr>
-
-<tr><td>
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td colspan="9">
- <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td style="font-weight:bold;" width="50" align="right">Filter:&nbsp;
-
- <input name="filter" type="text" id="" value="<?=$_GET['filter'];?>" size="30" style="font-size:11px;">
- <input type="submit" class="formbtn" value="Filter">
- </form>
- <td>
- </tr>
- </table>
- </td>
- </tr>
- <tr><td>
- <table id="sortabletable" name="sortabletable" class="sortable" width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>
+ <?php
+ $tab_array = array(
+ array(gettext("States"), true, "diag_dump_states.php"),
+ array(gettext("Reset states"), false, "diag_resetstate.php")
+ );
+ display_top_tabs($tab_array);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <div id="mainarea">
+
+<!-- Start of tab content -->
+
+<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>
+ <form action="<?=$_SERVER['SCRIPT_NAME'];?>" method="get">
+ <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
- <td class="listhdrr" width="10%">Proto</td>
- <td class="listhdrr" width="65">Source -> Router -> Destination</td>
- <td class="listhdr" width="15%">State</td>
- <td class="list" width="1%"></td>
+ <td style="font-weight:bold;" align="right">
+ <?=gettext("Filter expression:");?>
+ <input type="text" name="filter" class="formfld search" value="<?=$_GET['filter'];?>" size="30" />
+ <input type="submit" class="formbtn" value="<?=gettext("Filter");?>" />
+ <td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="tabcont sortable" width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td class="listhdrr" width="10%"><?=gettext("Proto");?></td>
+ <td class="listhdrr" width="65"><?=gettext("Source -> Router -> Destination");?></td>
+ <td class="listhdr" width="24%"><?=gettext("State");?></td>
+ <td class="list sort_ignore" width="1%"></td>
</tr>
<?php
-$state_counter = 0;
+$row = 0;
if(count($states) > 0) {
foreach($states as $line) {
- $state_counter++;
- if($state_counter > 1000)
+ if($row >= 1000)
break;
-
+
$line_split = preg_split("/\s+/", $line);
- $state = array_pop($line_split);
- $type = array_shift($line_split);
+ $type = array_shift($line_split);
$proto = array_shift($line_split);
- $info = implode(" ", $line_split);
-
- $towrite = <<<EOD
- <tr valign="top">
- <td class="listlr">{$proto}</td>
- <td class="listr">{$info}</td>
- <td class="listr">{$state}</td>
- </tr>
-EOD;
- print $towrite;
+ $state = array_pop($line_split);
+ $info = implode(" ", $line_split);
+
+ /* break up info and extract $srcip and $dstip */
+ $ends = preg_split("/\<?-\>?/", $info);
+ $parts = split(":", $ends[0]);
+ $srcip = trim($parts[0]);
+ $parts = split(":", $ends[count($ends) - 1]);
+ $dstip = trim($parts[0]);
+
+ echo "<tr valign='top' name='r:{$srcip}:{$dstip}'>
+ <td class='listlr'>{$proto}</td>
+ <td class='listr'>{$info}</td>
+ <td class='listr'>{$state}</td>
+ <td class='list'>
+ <img src='/themes/{$g['theme']}/images/icons/icon_x.gif' height='17' width='17' border='0'
+ onclick=\"removeState('{$srcip}', '{$dstip}');\" style='cursor:pointer;'
+ name='i:{$srcip}:{$dstip}'
+ title='" . gettext("Remove all state entries from") . " {$srcip} " . gettext("to") . " {$dstip}' alt='' />
+ </td>
+ </tr>";
+ $row++;
}
-} else {
- print '<tr><td colspan="4"><center>No states were found.</center></td></tr>';
}
-
+else {
+ echo "<tr>
+ <td class='list' colspan='4' align='center' valign='top'>
+ " . gettext("No states were found.") . "
+ </td>
+ </tr>";
+}
?>
-</td></tr></table>
+ </table>
+ </td>
+ </tr>
</table>
-</div>
-</center>
-</td></tr>
+
+<!-- End of tab content -->
+
+ </div>
+ </td>
+ </tr>
</table>
-<?php include("fend.inc"); ?>
-<?php if($_GET['filter']): ?>
<meta http-equiv="refresh" content="60;url=diag_dump_states.php?filter=<?php echo $_GET['filter']; ?>">
-<?php else: ?>
-<meta http-equiv="refresh" content="60;url=diag_dump_states.php">
-<?php endif; ?>
+<?php require("fend.inc"); ?>
</body>
</html>
OpenPOWER on IntegriCloud