X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=tools%2Fprivoxy-log-parser.pl;h=aff6e5395374331b1fe800566cd3d5cc3eddd309;hb=bf7b21672039889da16f3c26db39ff30a3dfbe02;hp=5d56400065141724f4208371203c42d925b18fef;hpb=0dc5c4227c2560f5f758c00ff70b6d197deaa54f;p=privoxy.git diff --git a/tools/privoxy-log-parser.pl b/tools/privoxy-log-parser.pl index 5d564000..aff6e539 100755 --- a/tools/privoxy-log-parser.pl +++ b/tools/privoxy-log-parser.pl @@ -8,7 +8,7 @@ # # http://www.fabiankeil.de/sourcecode/privoxy-log-parser/ # -# $Id: privoxy-log-parser.pl,v 1.114 2011/04/19 13:10:11 fabiankeil Exp $ +# $Id: privoxy-log-parser.pl,v 1.125 2011/12/31 14:53:47 fabiankeil Exp $ # # TODO: # - LOG_LEVEL_CGI, LOG_LEVEL_ERROR, LOG_LEVEL_WRITE content highlighting @@ -913,6 +913,7 @@ sub handle_loglevel_header ($) { or $c =~ m/^keep-alive support is disabled/ or $c =~ m/^Continue hack in da house/ or $c =~ m/^Merged multiple header lines to:/ + or $c =~ m/^Added header: / ) { # XXX: Some of these may need highlighting @@ -960,6 +961,7 @@ sub handle_loglevel_header ($) { # keep-alive support is disabled. Crunching: Keep-Alive: 300. # Continue hack in da house. # Merged multiple header lines to: 'X-FORWARDED-PROTO: http X-HOST: 127.0.0.1' + # Added header: Content-Encoding: deflate } elsif ($c =~ m/^scanning headers for:/) { @@ -1193,6 +1195,13 @@ sub handle_loglevel_re_filter ($) { # Adding dynamic re_filter job s@^(?:\w*)\s+.*\s+HTTP/\d\.\d\s*@IP-ADDRESS: $origin@D\ # to filter client-ip-address succeeded. + } elsif ($c =~ m/^Compressed content from /) { + + # Compressed content from 29258 to 8630 bytes. Compression level: 3 + $content =~ s@(?<=from )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $content =~ s@(?<=to )(\d+)@$h{'Number'}$1$h{'Standard'}@; + $content =~ s@(?<=level: )(\d+)@$h{'Number'}$1$h{'Standard'}@; + } elsif ($c =~ m/^Reading in filter/) { return '' unless SHOW_FILTER_READIN_IN; @@ -1258,6 +1267,11 @@ sub handle_loglevel_redirect ($) { # XXX: assume the same? $c = highlight_matched_url($c, '(?<=assuming that \")[^"]*'); + } elsif ($c =~ m/^Percent-encoding redirect/) { + + # Percent-encoding redirect URL: http://www.example.org/\x02 + $c = highlight_matched_url($c, '(?<=redirect URL: ).*'); + } else { found_unknown_content($c); @@ -1751,12 +1765,15 @@ sub handle_loglevel_info ($) { # Request from 10.0.0.1 denied. limit-connect{,} doesn't allow CONNECT requests to port 443. # Request from 10.0.0.1 marked for blocking. limit-connect{,} doesn't allow CONNECT requests to port 443. + # 3.0.18 and later: + # Request from 10.0.0.1 marked for blocking. limit-connect{0} doesn't allow CONNECT requests to www.example.org:443 # Malformed server response detected. Downgrading to HTTP/1.0 impossible. $c =~ s@(?<=Request from )([^\s]*)@$h{'ip-address'}$1$h{'Standard'}@; $c =~ s@(denied|blocking)@$h{'warning'}$1$h{'Standard'}@; $c =~ s@(CONNECT)@$h{'method'}$1$h{'Standard'}@; $c =~ s@(?<=to port )(\d+)@$h{'port'}$1$h{'Standard'}@; + $c =~ s@(?<=to )([^\s]+)@$h{'request_'}$1$h{'Standard'}@; } elsif ($c =~ m/^Status code/) { @@ -1856,14 +1873,24 @@ sub handle_loglevel_error ($) { my $c = shift; - if ($c =~ m/^Empty server or forwarder response received on socket \d+./) { + if ($c =~ m/^(?:Empty|No) server or forwarder response received on socket \d+\./) { # Empty server or forwarder response received on socket 4. # Empty server or forwarder response received on socket 3. \ # Closing client socket 15 without sending data. + # Used by Privoxy 3.0.18 and later: + # No server or forwarder response received on socket 8. \ + # Closing client socket 10 without sending data. + $c =~ s@(?<=on socket )(\d+)@$h{'Number'}$1$h{'Standard'}@; $c =~ s@(?<=client socket )(\d+)@$h{'Number'}$1$h{'Standard'}@; + + } elsif ($c =~ m/^Didn't receive data in time:/) { + + # Didn't receive data in time: a.fsdn.com:443 + $c =~ s@(?<=in time: )(.*)@$h{'destination'}$1$h{'Standard'}@; } + # XXX: There are probably more messages that deserve highlighting. return $c; @@ -1970,7 +1997,7 @@ sub gather_loglevel_header_stats ($$) { # scan: HTTP/1.1 200 OK $stats{'method'}{$2}++; - $stats{'ressource'}{$3}++; + $stats{'resource'}{$3}++; $stats{'http-version'}{$4}++; } elsif ($c =~ m/^scan: Host: ([^\s]+)/) { @@ -2060,12 +2087,12 @@ sub print_stats () { print "URL statistics are disabled. Increase --url-statistics-threshold to enable them.\n"; } else { print "Requested URLs:\n"; - foreach my $ressource (sort {$stats{'ressource'}{$b} <=> $stats{'ressource'}{$a}} keys %{$stats{'ressource'}}) { - if ($stats{'ressource'}{$ressource} < $cli_options{'url-statistics-threshold'}) { + foreach my $resource (sort {$stats{'resource'}{$b} <=> $stats{'resource'}{$a}} keys %{$stats{'resource'}}) { + if ($stats{'resource'}{$resource} < $cli_options{'url-statistics-threshold'}) { print "Skipped statistics for URLs below the treshold.\n"; last; } - printf "%d : %s\n", $stats{'ressource'}{$ressource}, $ressource; + printf "%d : %s\n", $stats{'resource'}{$resource}, $resource; } } @@ -2356,8 +2383,8 @@ sub get_cli_options () { 'accept-unknown-messages' => \$cli_options{'accept-unknown-messages'}, 'statistics' => \$cli_options{'statistics'}, 'unbreak-lines-only' => \$cli_options{'unbreak-lines-only'}, - 'url-statistics-threshold=s'=> \$cli_options{'url-statistics-threshold'}, - 'host-statistics-threshold=s'=> \$cli_options{'host-statistics-threshold'}, + 'url-statistics-threshold=i'=> \$cli_options{'url-statistics-threshold'}, + 'host-statistics-threshold=i'=> \$cli_options{'host-statistics-threshold'}, 'version' => sub { VersionMessage && exit(0) }, 'help' => \&help, ) or exit(1); @@ -2491,7 +2518,7 @@ Only fixes some breakage, but may be good enough or at least better than nothing Doesn't do anything else, so you probably want to pipe the output into B again. -[B<--url-statistics-threshold>] Only show the request count for a ressource +[B<--url-statistics-threshold>] Only show the request count for a resource if it's above or equal to the given threshold. If the threshold is 0, URL statistics are disabled.