Révision 5344099a
Ajouté par jim-p il y a presque 10 ans
usr/local/www/diag_dump_states.php | ||
---|---|---|
40 | 40 |
##|-PRIV |
41 | 41 |
|
42 | 42 |
require_once("guiconfig.inc"); |
43 |
require_once("interfaces.inc"); |
|
43 | 44 |
|
44 | 45 |
/* handle AJAX operations */ |
45 | 46 |
if($_GET['action']) { |
... | ... | |
50 | 51 |
} else { |
51 | 52 |
echo gettext("invalid input"); |
52 | 53 |
} |
53 |
exit;
|
|
54 |
return;
|
|
54 | 55 |
} |
55 | 56 |
} |
56 | 57 |
|
... | ... | |
59 | 60 |
$tokill = escapeshellarg($_GET['filter'] . "/32"); |
60 | 61 |
} elseif (is_subnet($_GET['filter'])) { |
61 | 62 |
$tokill = escapeshellarg($_GET['filter']); |
63 |
} else { |
|
64 |
// Invalid filter |
|
65 |
$tokill = ""; |
|
66 |
} |
|
67 |
if (!empty($tokill)) { |
|
68 |
$retval = mwexec("/sbin/pfctl -k {$tokill} -k 0/0"); |
|
69 |
$retval = mwexec("/sbin/pfctl -k 0.0.0.0/0 -k {$tokill}"); |
|
62 | 70 |
} |
63 |
$retval = mwexec("/sbin/pfctl -k {$tokill} -k 0/0"); |
|
64 |
$retval = mwexec("/sbin/pfctl -k 0.0.0.0/0 -k {$tokill}"); |
|
65 | 71 |
} |
66 | 72 |
|
67 | 73 |
$pgtitle = array(gettext("Diagnostics"),gettext("Show States")); |
... | ... | |
155 | 161 |
<table class="tabcont sortable" width="100%" border="0" cellspacing="0" cellpadding="0" summary="results"> |
156 | 162 |
<thead> |
157 | 163 |
<tr> |
158 |
<th class="listhdrr" width="10%"><?=gettext("Proto");?></th> |
|
164 |
<th class="listhdrr" width="5%"><?=gettext("Int");?></th> |
|
165 |
<th class="listhdrr" width="5%"><?=gettext("Proto");?></th> |
|
159 | 166 |
<th class="listhdrr" width="65"><?=gettext("Source -> Router -> Destination");?></th> |
160 | 167 |
<th class="listhdr" width="24%"><?=gettext("State");?></th> |
161 | 168 |
<th class="list sort_ignore" width="1%"></th> |
... | ... | |
165 | 172 |
<?php |
166 | 173 |
$row = 0; |
167 | 174 |
/* get our states */ |
168 |
$grepline = ($_GET['filter']) ? "| grep " . escapeshellarg(htmlspecialchars($_GET['filter'])) : ""; |
|
175 |
$grepline = ($_GET['filter']) ? "| /usr/bin/egrep " . escapeshellarg(htmlspecialchars($_GET['filter'])) : "";
|
|
169 | 176 |
$fd = popen("/sbin/pfctl -s state {$grepline}", "r" ); |
170 | 177 |
while ($line = chop(fgets($fd))) { |
171 | 178 |
if($row >= 10000) |
172 | 179 |
break; |
173 | 180 |
|
174 | 181 |
$line_split = preg_split("/\s+/", $line); |
175 |
$type = array_shift($line_split); |
|
182 |
|
|
183 |
$iface = array_shift($line_split); |
|
176 | 184 |
$proto = array_shift($line_split); |
177 | 185 |
$state = array_pop($line_split); |
178 | 186 |
$info = implode(" ", $line_split); |
179 | 187 |
|
188 |
// We may want to make this optional, with a large state table, this could get to be expensive. |
|
189 |
$iface = convert_real_interface_to_friendly_descr($iface); |
|
190 |
|
|
180 | 191 |
/* break up info and extract $srcip and $dstip */ |
181 | 192 |
$ends = preg_split("/\<?-\>?/", $info); |
182 | 193 |
$parts = explode(":", $ends[0]); |
... | ... | |
185 | 196 |
$dstip = trim($parts[0]); |
186 | 197 |
|
187 | 198 |
?> |
188 |
<tr valign="top" id="r:<?= $srcip ?>:<?= $dstip ?>"> |
|
189 |
<td class="listlr"><?= $proto ?></td> |
|
199 |
<tr valign="top" id="r:<?= $srcip ?>:<?= $dstip ?>" name="r:<?= $srcip ?>:<?= $dstip ?>"> |
|
200 |
<td class="listlr"><?= $iface ?></td> |
|
201 |
<td class="listr"><?= $proto ?></td> |
|
190 | 202 |
<td class="listr"><?= $info ?></td> |
191 | 203 |
<td class="listr"><?= $state ?></td> |
192 | 204 |
<td class="list"> |
Formats disponibles : Unified diff
Various fixes to diag_dump_states.php (Add interface column, some extra validation safety, etc). Should fix #2121