X-Git-Url: http://git.treefish.org/fex.git/blobdiff_plain/97b87610331f53e756d032ad21db786037f921a1..3aae246cf7f4af7ae49da09e5ed0c180f31f0c12:/bin/logwatch?ds=sidebyside diff --git a/bin/logwatch b/bin/logwatch index 733673c..3aafafb 100755 --- a/bin/logwatch +++ b/bin/logwatch @@ -44,6 +44,7 @@ $ignore = join('|',qw( GET./browserconfig\.xml User-Agent:.*(Webnote|FeedFetcher|\w+bot|bot/|Website.Watcher|crawler|spider|searchme|Yandex|Slurp|ScoutJet|findlinks|urlmon|nagios) User-Agent:.fnb.*quak + User-Agent:.Google.favicon From:.*(msnbot|yandex|googlebot|webcrawler) Referer:.*sex.*stream Referer:.*stream.*sex @@ -64,16 +65,20 @@ $ignore = join('|',qw( DNT: Via: profile: + Upgrade-Insecure-Requests: if-modified-since Surrogate-Capability Proxy-Authorization http\. + Device-Stock NOKIA_ GPRS X-Proxy-ID X-Moz X.Wap X-FH + X-FB + X-WS X-Nokia X-UCBrowser X-NSN @@ -88,10 +93,13 @@ $ignore = join('|',qw( X-Country X-ClickOnceSupport X-Newrelic + X-IMForwards + X-Clearswift + X-MDS .*:\s*$ ); -$/ = "\n\n"; +$/ = "\n\n"; $| = 1; if (-t STDIN or $ENV{GATEWAY_INTERFACE}) { @@ -110,8 +118,13 @@ for (;;) { foreach $weed (@weed) { while (s/\n$weed.*\n/\n/i) {} } + $post = /\nPOST\s/; if (/^\n*(CONNECT|CONTINUE).*\s\[([\d_]+)\]/i) { $pid = $2 } - if (/\n(POST|GET)\s+\/(\w+)/i) { $cgi = $2 } + if (/\n(POST|GET)\s+(\S+)/i) { + $cgi = $2; + $cgi =~ s:.*/::; + $cgi =~ s:\?.*::; + } if (/Content-Length: (\d+)/i) { $d = $1; while ($d =~ s/(\d)(\d\d\d\b)/$1,$2/) {}; @@ -146,7 +159,7 @@ for (;;) { read_skey($1); print "\n"; } - if ($debug and $pid and $cgi) { + if ($debug and $pid and $post) { &read_debug_log; }; $pid = $cgi = ''; @@ -159,16 +172,19 @@ sub read_debug_log { my (@log,$log); local $/ = "\n"; local $_; - local $^W; + # https://rt.cpan.org/Public/Bug/Display.html?id=88592 + # local $^W; # no warnings "all"; + no warnings 'utf8'; for (1..2) { sleep 1; @log = `ls -rt $logdir[0]/.debug/*_${pid}.$cgi 2>/dev/null`; if ($log = $log[-1] and open $log,$log) { - # binmode($log,":encoding(UTF-8)"); + binmode($log,":utf8"); while (<$log>) { s/\r//; + s/[^\x09\x20-\xFF]/_/g; if (/^Content-Disposition:.*name="FILE".*filename="(.+)"/i) { print " FILE=\"$1\"\n"; } elsif (/^Content-Disposition:.*name="(\w+)"/i) { @@ -176,9 +192,14 @@ sub read_debug_log { $_ = <$log>; my $v = <$log>||''; $v =~ s/[\r\n]+//; - printf " %s=\"%s\"\n",$p,utf8decode($v)||$v if $v; - read_akey($v) if $p eq 'AKEY'; - read_skey($v) if $p eq 'SKEY'; + if ($v) { + my $vv = utf8decode($v)||$v; + $vv =~ s/[\x00-\x1F]/_/g; + $vv =~ s/[\x80-\x9F]/_/g; + printf " %s=\"%s\"\n",$p,$vv; + read_akey($v) if $p eq 'AKEY'; + read_skey($v) if $p eq 'SKEY'; + } } elsif (/^(Param|Exp): (\w+=".+")/) { print " $2\n"; }