Revision 0b07930d
Added by Jim Pingle over 6 years ago
src/usr/local/www/diag_packet_capture.php | ||
---|---|---|
112 | 112 |
$fn = "packetcapture.cap"; |
113 | 113 |
$snaplen = 0;//default packet length |
114 | 114 |
$count = 100;//default number of packets to capture |
115 |
$max_display_size = 50*1024*1024; // 50MB limit on GUI capture display. See https://redmine.pfsense.org/issues/9239 |
|
115 | 116 |
|
116 | 117 |
$fams = array('ip', 'ip6'); |
117 | 118 |
$protos = array('icmp', 'icmp6', 'tcp', 'udp', 'arp', 'carp', 'esp', 'pfsync', |
... | ... | |
259 | 260 |
$process_id = substr($process, 0, $process_id_pos); |
260 | 261 |
exec("kill $process_id"); |
261 | 262 |
} |
262 |
|
|
263 | 263 |
} elseif ($_POST['downloadbtn'] != "") { |
264 | 264 |
//download file |
265 | 265 |
$fs = filesize($fp.$fn); |
266 | 266 |
header("Content-Type: application/octet-stream"); |
267 |
header("Content-Disposition: attachment; filename=$fn"); |
|
268 |
header("Content-Length: $fs"); |
|
267 |
header("Content-Disposition: attachment; filename={$fn}"); |
|
268 |
header("Content-Length: {$fs}"); |
|
269 |
/* Ensure output buffering is off so PHP does not consume |
|
270 |
* memory in readfile(). https://redmine.pfsense.org/issues/9239 */ |
|
271 |
while (ob_get_level()) { |
|
272 |
@ob_end_clean(); |
|
273 |
} |
|
269 | 274 |
readfile($fp.$fn); |
275 |
@ob_end_flush(); |
|
270 | 276 |
exit; |
271 | 277 |
} |
272 | 278 |
} |
... | ... | |
398 | 404 |
'medium' => gettext('Medium'), |
399 | 405 |
'high' => gettext('High'), |
400 | 406 |
'full' => gettext('Full'), |
407 |
'none' => gettext('None'), |
|
401 | 408 |
) |
402 | 409 |
))->setHelp('This is the level of detail that will be displayed after hitting "Stop" when the packets have been captured.%s' . |
403 | 410 |
'This option does not affect the level of detail when downloading the packet capture. ', |
... | ... | |
538 | 545 |
} |
539 | 546 |
|
540 | 547 |
print('<textarea class="form-control" rows="20" style="font-size: 13px; font-family: consolas,monaco,roboto mono,liberation mono,courier;">'); |
541 |
system("/usr/sbin/tcpdump {$disabledns} {$detail_args} {$iscarp} -r {$fp}{$fn}"); |
|
548 |
if (filesize($fp.$fn) > $max_display_size) |
|
549 |
print(gettext("Packet capture file is too large to display in the GUI.") . |
|
550 |
"\n" . |
|
551 |
gettext("Download the file, or view it in the console or ssh shell.")); |
|
552 |
elseif ($detail == 'none') { |
|
553 |
print(gettext("Select a detail level to view the contents of the packet capture.")); |
|
554 |
} else { |
|
555 |
system("/usr/sbin/tcpdump {$disabledns} {$detail_args} {$iscarp} -r {$fp}{$fn}"); |
|
556 |
} |
|
542 | 557 |
print('</textarea>'); |
543 | 558 |
|
544 | 559 |
?> |
Also available in: Unified diff
Packet capture page fixes. Fixes #9239
consuming memory while downloading a large capture.
(cherry picked from commit 36192f4a459ec5d5baf06819102ba783c1725ba1)