]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - config/updxlrator/updxlrator
update accelerator: Do not attempt to cache IPFire updates any more
[people/pmueller/ipfire-2.x.git] / config / updxlrator / updxlrator
index ffbc9c7ab617a3d5612d493da7363f1fccec8702..cdc7eeb503589af0bd350910dd56e30f4ed9520b 100644 (file)
@@ -2,9 +2,16 @@
 #
 # This code is distributed under the terms of the GPL
 #
-# (c) 2006-2008 marco.s - http://update-accelerator.advproxy.net
+# (c) 2006-2009 marco.s - http://update-accelerator.advproxy.net
 #
-# $Id: updxlrator,v 2.0 2008/04/06 00:00:00 marco.s Exp $
+# Portions (c) 2008 by dotzball - http://www.blockouttraffic.de
+#
+# $Id: updxlrator,v 2.1 2009/01/10 00:00:00 marco.s Exp $
+#
+# ChangeLog:
+#
+# 2012-10-26: nightshift - move curly bracket to capture AVG download source.
+#                       - Adding BIG HINT for new update source#
 #
 
 use strict;
@@ -16,7 +23,7 @@ my $swroot="/var/ipfire";
 my $updcachedir="/var/updatecache";
 my $apphome="/var/ipfire/updatexlrator";
 my $logfile="/var/log/updatexlrator/cache.log";
-my $wget="$apphome/bin/wget";
+my $wget="/usr/bin/wget";
 my $debug=(-e "$apphome/debug");
 my $http_port='81';
 my %netsettings=();
@@ -44,10 +51,12 @@ if (-e "$swroot/updatexlrator/settings")
        if ($xlratorsettings{'ENABLE_LOG'} eq 'on') { $logging=1; };
        if ($xlratorsettings{'PASSIVE_MODE'} eq 'on') { $passive_mode=1; };
        $maxusage=$xlratorsettings{'MAX_DISK_USAGE'};
-       if ($xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} eq 'on') { $nice='/usr/bin/nice --adjustment=15 '; };
+       if ($xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} eq 'on') { $nice='/bin/nice --adjustment=15 '; };
 }
 if (!$maxusage) { $maxusage=75; };
 
+# dotzball: check for dead downloads
+system("$apphome/bin/checkdeaddl &");
 
 while (<>) {
 
@@ -61,7 +70,7 @@ while (<>) {
        $username   = $tmp[2]; if ($username eq '') { $username='-'; };
        $method     = $tmp[3];
 
-       $xlrator_url = $source_url;
+       $xlrator_url = "";
 
        if (($method eq 'GET') || ($method eq 'HEAD')) 
        {
@@ -71,12 +80,14 @@ while (<>) {
        # -----------------------------------------------------------
 
        if (
-           (($source_url =~ m@^http://[^/]*\.microsoft\.com/.*\.(exe|psf|msi|msp|cab)$@i) ||
-            ($source_url =~ m@^http://[^/]*\.windowsupdate\.com/.*\.(exe|psf|msi|msp|cab)$@i))
+           (($source_url =~ m@^http://[^/]*\.microsoft\.com/.*\.(exe|psf|msi|msp|msu|cab)$@i) ||
+            ($source_url =~ m@^http://[^/]*\.windowsupdate\.com/.*\.(exe|psf|msi|msp|msu|cab)$@i))
        &&   ($source_url !~ m@^http://[^/]*\.microsoft\.com/.*(/autoupd|selfupdate/).*\.cab@i)
        &&   ($source_url !~ m@\&@)
           )
        {
+               # NOTE: check_cache will change to $mirror instead of $unique if the filename contains an SHA1 hash
+               # and the URL is not found in cache!
                $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Microsoft",$unique);
        }
 
@@ -84,9 +95,10 @@ while (<>) {
        #  Section: Adobe Downloads
        # -----------------------------------------------------------
 
+
        if (
-           ($source_url =~ m@^http://(ar)?download\.adobe\.com/.*\.(exe|msi|bin|dmg|idx|gz)$@i) ||
-           ($source_url =~ m@^http://swupdl\.adobe\.com/updates/.*\.(exe|msi|bin|dmg|idx|gz|[a-z][a-z]_[A-Z][A-Z])$@i) ||
+           ($source_url =~ m@^http://(ar)?download\.adobe\.com/.*\.(exe|ms[ip]|bin|dmg|idx|gz)$@i) ||
+           ($source_url =~ m@^http://swupdl\.adobe\.com/updates/.*\.(exe|ms[ip]|bin|dmg|idx|gz|[a-z][a-z]_[A-Z][A-Z])$@i) ||
            ($source_url =~ m@^http://swupmf\.adobe\.com/manifest/.*\.upd$@i)
           )
        {
@@ -97,7 +109,10 @@ while (<>) {
        #  Section: Linux Downloads
        # -----------------------------------------------------------
 
-       if ($source_url =~ m@^[h|f]t?tp://[^?]+\.(deb|rpm)$@i)
+       if (
+               ($source_url =~ m@^[h|f]t?tp://[^?]+\.(pkg\.tar\.xz|deb|rpm)$@i) ||
+               ($source_url =~ m@^[h|f]t?tp://[^?]+/distfiles/[^?]+\.(tar\.gz|tar\.bz2|tar\.xz|tgz|zip|patch\.bz2|gz|docx|patch|pdf|exe)$@i)
+       )
        {
                $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Linux",$mirror);
        }
@@ -130,7 +145,7 @@ while (<>) {
        # -----------------------------------------------------------
 
        if (
-           (($source_url =~ m@^http://swcdn\.apple\.com/content/downloads/.*\.(tar)$@i) ||
+            (($source_url =~ m@^http://swcdn\.apple\.com/content/downloads/.*\.(tar|pkg)$@i) ||
             ($source_url =~ m@^http://appldnld\.apple\.com\.edgesuite\.net/.*\.(exe|dmg)$@i) ||
             ($source_url =~ m@^http://.*\.g.akamai.net/.*/3093/1/.*\.(tar|pkg|dmg|exe)$@i))
           )
@@ -142,45 +157,59 @@ while (<>) {
        #  Section: Avast Downloads
        # -----------------------------------------------------------
 
-       if ($source_url =~ m@^http://download[\d]+\.avast\.com/.*\.(exe|vpu)$@i)
+       if ($source_url =~ m@^http://(ion|download)[\d]+\.avast\.com/.*\.(exe|vpu|vpx)$@i)
        {
                $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Avast",$mirror);
        }
 
+        # -----------------------------------------------------------
+        #  Section: Mozilla Downloads
+        # -----------------------------------------------------------
+
+       if ($source_url=~ m@^http://.*\.mozilla\.net/.*\.((complete|partial)\.mar|exe)$@i)
+       { 
+               $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Mozilla",$unique);
+       }
+
+       # -----------------------------------------------------------
+       #  Section: Mcafee
        # -----------------------------------------------------------
        
+       if ($source_url =~ m@^http://update\.nai\.com/.*\.(mcs|z|gem|dat|zip)$@i)
+       {
+               $xlrator_url = &check_cache($source_url,$hostaddr,$username,"mcafee",$mirror);
+       }
+       
        # -----------------------------------------------------------
        # Section: Avira Downloads
        # -----------------------------------------------------------
 
-       if ($source_url =~ m@^http://dl[0-9]\.avgate\.net/.*\.(htm|html|gz)$@i)
+       if (
+               ($source_url =~ m@^http://dl[0-9]\.avgate\.net/.*\.(htm|html|gz)$@i) ||
+               ($source_url =~ m@^http://80.190.130.19[4-5]/update/.*\.(htm|html|gz)$@i) ||
+               ($source_url =~ m@^http://62.146.64.14[6-7]/update/.*\.(htm|html|gz)$@i)
+       )
        {
                $xlrator_url = &check_cache($source_url,$hostaddr,$username,"Avira",$mirror);
        }
 
        # -----------------------------------------------------------
-       # Section: IPFire Downloads
+       # Section: AVG Downloads
        # -----------------------------------------------------------
 
-       if ($source_url =~ m@^[f|h]t?tp://.*\.(ipfire)$@i)
-       {
-               $xlrator_url = &check_cache($source_url,$hostaddr,$username,"IPFire",$mirror);
-       }
+#      if ($source_url =~ m@^http://[^/]*\.(grisoft|avg)\.com/.*\.(bin)$@i)
+#      {
+#              $xlrator_url = &check_cache($source_url,$hostaddr,$username,"AVG",$mirror);
+#      }
 
+# ----------- ADD NEW SOURCES BEFORE THIS LINE !!! ------------------
        }
-       
-       # -----------------------------------------------------------
-       # Section: AVG Downloads
-       # -----------------------------------------------------------
 
-       if ($source_url =~ m@^http://[^/]*\.(grisoft|avg)\.com/.*\.(bin)$@i)
-       {
-               $xlrator_url = &check_cache($source_url,$hostaddr,$username,"AVG",$mirror);
+       if ($xlrator_url) {
+               print "OK rewrite-url=\"$xlrator_url\"\n";
+       } else {
+               print "ERR\n";
        }
-
-       $request="$xlrator_url $hostaddr $username $method\n";
-
-       print $request;
 }
 
 # -------------------------------------------------------------------
@@ -309,7 +338,9 @@ sub check_cache
        my $sourceurl=$_[0];
        my $cfmirror=$_[4];
 
+       $sourceurl =~ s@\%2b@+@ig;
        $sourceurl =~ s@\%2f@/@ig;
+       $sourceurl =~ s@\%7e@~@ig;
        $updfile = substr($sourceurl,rindex($sourceurl,"/")+1);
        $updfile =~ s@\%20@ @ig;
 
@@ -359,10 +390,20 @@ sub check_cache
           )
        {
                &debuglog("File exists in cache and is up to date");
-               &debuglog("Retrieving file from cache ($updsource)");
+               &debuglog("Retrieving file from cache ($updsource) for $hostaddr");
                &setcachestatus("$updcachedir/$vendorid/$uuid/access.log",time);
-               system("$apphome/bin/setperms $vendorid/$uuid/access.log");
                $cacheurl="http://$netsettings{'GREEN_ADDRESS'}:$http_port/updatecache/$vendorid/$uuid/$updfile";
+       }
+       elsif (
+               ($cfmirror == $unique) &&
+               ($vendorid == "microsoft") &&
+               ($source_url =~ m@.*[0-9a-f]{40}\.[^\.]+@i)
+             )
+       {
+                       # Most Microsoft updates now have an SHA1 hash in the name. These should be treated as unique files.
+                       # Since it wasn't found in the URL cache, switch to mirror mode and try again using just the filename.
+                       &debuglog("SHA1: $vendorid $uuid not cached. Reprocessing as mirror $sourceurl");
+                       $cacheurl = &check_cache($source_url,$hostaddr,$username,$vendorid,$mirror);
        }
                else
        {
@@ -377,7 +418,7 @@ sub check_cache
                &debuglog("Free disk space: " . &diskfree($updcachedir));
                &debuglog("Disk usage: " . &diskusage($updcachedir) . "% (max. $maxusage%)");
                if (-e "$updcachedir/download/$vendorid/$updfile") { &debuglog("File download/$vendorid/$updfile exists"); }
-               &debuglog("Retrieving file from source ($updsource)");
+               &debuglog("Retrieving file from source ($updsource) for $hostaddr");
                if ((!$passive_mode) && (&diskusage($updcachedir) <= $maxusage) && ($remote_size <= &diskfree($updcachedir)) && (!-e "$updcachedir/download/$vendorid/$updfile"))
                {
                        &debuglog("Running command $nice$apphome/bin/download $vendorid $sourceurl $cfmirror &");