use strict; use warnings; use Sniffer::HTTP; my $VERBOSE = 0; my $debug = 0; my $sniffer = Sniffer::HTTP->new( callbacks => { request => sub { my ( $req, $conn ) = @_; my $src = $conn->tcp_connection->src_host; my $sport = $conn->tcp_connection->src_port; my $dst = $conn->tcp_connection->dest_host; my $dport = $conn->tcp_connection->dest_port; print "Request: $src:$sport -> $dst:$dport\n"; }, response => sub { my ( $res, $req, $conn ) = @_; }, log => sub { print $_[0] if $VERBOSE }, tcp_log => sub { print $_[0] if $VERBOSE > 1 }, }, timeout => 5 * 60, # seconds after which a connection is considered stale stale_connection => sub { my ( $s, $conn, $key ); if ($key) { print "Connection stalled .... $key ....\n" if $debug; $s->log->("Connection $key is stale."); $s->remove_connection($key); } }, ); $sniffer->run('wlan0');