X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=tools%2Fprivoxy-log-parser.pl;h=70af5987ec4530e6acbb3a78f33a2fe05de658d9;hb=7bd409013cced62a26e773deabd48dfc464eda01;hp=ab4b2f1a45d6d225abc20a4a8c8079f73d993f91;hpb=a13c0e8f98f4c0d8a90c43415fa42e9cfb3846cb;p=privoxy.git diff --git a/tools/privoxy-log-parser.pl b/tools/privoxy-log-parser.pl index ab4b2f1a..70af5987 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.146 2009/05/25 19:10:20 fk Exp $ +# $Id: privoxy-log-parser.pl,v 1.42 2009/07/21 14:04:25 fabiankeil Exp $ # # TODO: # - LOG_LEVEL_CGI, LOG_LEVEL_ERROR, LOG_LEVEL_WRITE content highlighting @@ -370,7 +370,7 @@ sub get_missing_css_lines () { my $css_line; - $css_line .= '.' . 'default' . ' {'; # XXX: lc() shouldn't be necessary + $css_line .= '.' . 'default' . ' {'; $css_line .= 'color:' . HEADER_DEFAULT_COLOUR . ';'; $css_line .= 'background-color:' . get_css_colour(DEFAULT_BACKGROUND) . ';'; $css_line .= '}' . "\n"; @@ -913,6 +913,9 @@ sub handle_loglevel_header ($) { or $c =~ m/A HTTP\/1\.1 response without/ or $c =~ m/Disabled filter mode on behalf of the client/ or $c =~ m/Keeping the (?:server|client) header / + or $c =~ m/Content modified with no Content-Length header set/ + or $c =~ m/^Appended client IP address to/ + or $c =~ m/^Removing 'Connection: close' to imply keep-alive./ ) { # XXX: Some of these may need highlighting @@ -954,6 +957,9 @@ sub handle_loglevel_header ($) { # Keeping the server header 'Connection: keep-alive' around. # Keeping the client header 'Connection: close' around. The connection will not be kept alive. # Keeping the client header 'Connection: keep-alive' around. The connection will be kept alive if possible. + # Content modified with no Content-Length header set. Creating a fake one for adjustment later on. + # Appended client IP address to X-Forwarded-For: 10.0.0.2, 10.0.0.1 + # Removing 'Connection: close' to imply keep-alive. } elsif ($c =~ m/^scanning headers for:/) { @@ -991,9 +997,10 @@ sub handle_loglevel_header ($) { # XXX: Could highlight more here. $content =~ s@(?<=^Content-Type: )(.*)(?= not replaced)@$h{'content-type'}$1$h{'Standard'}@; - } elsif ($c =~ m/^Server keep-alive timeout is/) { + } elsif ($c =~ m/^(Server|Client) keep-alive timeout is/) { # Server keep-alive timeout is 5. Sticking with 10. + # Client keep-alive timeout is 20. Sticking with 10. $content =~ s@(?<=timeout is )(\d+)@$h{'Number'}$1$h{'Standard'}@; $content =~ s@(?<=Sticking with )(\d+)@$h{'Number'}$1$h{'Standard'}@; @@ -1394,9 +1401,10 @@ sub handle_loglevel_connect ($) { $c =~ s@(?<=failed: )(.*)@$h{'error'}$1$h{'Standard'}@; - } elsif ($c =~ m/^to ([^\s]*) successful$/) { + } elsif ($c =~ m/^to ([^\s]*)( successful)?$/) { # Connect: to www.nzherald.co.nz successful + # Connect: to archiv.radiotux.de return '' if SUPPRESS_SUCCESSFUL_CONNECTIONS; $c = highlight_matched_host($c, '(?<=to )[^\s]+'); @@ -1580,10 +1588,22 @@ sub handle_loglevel_connect ($) { $c =~ s@(?<=server socket )(\d+)@$h{'Number'}$1$h{'Standard'}@; $c = highlight_matched_host($c, '(?<=to )[^\s]+'); + } elsif ($c =~ m/^Marking the server socket/) { + + # Marking the server socket 7 tainted. + + $c =~ s@(?<=server socket )(\d+)@$h{'Number'}$1$h{'Standard'}@; + } elsif ($c =~ m/^Looks like we rea/ or $c =~ m/^Unsetting keep-alive flag/ or $c =~ m/^No connections to wait/ or - $c =~ m/^Client request arrived in time or the client closed the connection/) { + $c =~ m/^Client request arrived in time or the client closed the connection/ or + $c =~ m/^Complete client request received/ or + $c =~ m/^Possible pipeline attempt detected./ or + $c =~ m/^POST request detected. The connection will not be kept alive./ or + $c =~ m/^The server still wants to talk, but the client hung up on us./ or + $c =~ m/^The server didn't specify how long the connection will stay open/ or + $c =~ m/^There might be a request body. The connection will not be kept alive/) { # Looks like we reached the end of the last chunk. We better stop reading. # Looks like we read the end of the last chunk together with the server \ @@ -1591,6 +1611,13 @@ sub handle_loglevel_connect ($) { # Unsetting keep-alive flag. # No connections to wait for left. # Client request arrived in time or the client closed the connection. + # Complete client request received + # Possible pipeline attempt detected. The connection will not be \ + # kept alive and we will only serve the first request. + # POST request detected. The connection will not be kept alive. + # The server still wants to talk, but the client hung up on us. + # The server didn't specify how long the connection will stay open. Assume it's only a second. + # There might be a request body. The connection will not be kept alive. } else { @@ -1853,26 +1880,27 @@ sub parse_loop () { my %log_level_count; my %log_level_handlers = ( - 'Re-Filter' => \&handle_loglevel_re_filter, - 'Header' => \&handle_loglevel_header, - 'Connect' => \&handle_loglevel_connect, - 'Redirect' => \&handle_loglevel_redirect, - 'Request' => \&handle_loglevel_request, - 'Crunch' => \&handle_loglevel_crunch, - 'Gif-Deanimate' => \&handle_loglevel_gif_deanimate, - 'Info' => \&handle_loglevel_info, - 'CGI' => \&handle_loglevel_cgi, - 'Force' => \&handle_loglevel_force, - 'Error' => \&handle_loglevel_ignore, - 'Fatal error' => \&handle_loglevel_ignore, - 'Writing' => \&handle_loglevel_ignore, + 'Re-Filter' => \&handle_loglevel_re_filter, + 'Header' => \&handle_loglevel_header, + 'Connect' => \&handle_loglevel_connect, + 'Redirect' => \&handle_loglevel_redirect, + 'Request' => \&handle_loglevel_request, + 'Crunch' => \&handle_loglevel_crunch, + 'Gif-Deanimate' => \&handle_loglevel_gif_deanimate, + 'Info' => \&handle_loglevel_info, + 'CGI' => \&handle_loglevel_cgi, + 'Force' => \&handle_loglevel_force, + 'Error' => \&handle_loglevel_ignore, + 'Fatal error' => \&handle_loglevel_ignore, + 'Writing' => \&handle_loglevel_ignore, + 'Unknown log level' => \&handle_loglevel_ignore, ); while (<>) { $output = ''; - if (m/^(\w{3} \d{2}) (\d\d:\d\d:\d\d)\.?(\d+)? (?:Privoxy\()?([^\)\s]*)[\)]? ([\w -]*): (.*)$/) { + if (m/^(\w{3} \d{2}) (\d\d:\d\d:\d\d)\.?(\d+)? (?:Privoxy\()?([^\)\s]*)[\)]? ([\w -]*): (.*?)\r?$/) { # XXX: Put in req hash? $day = $1; $time_stamp = $2;