]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - config/updxlrator/updxlrator
Fix bug 11558 updxlrator: use mirror mode for SHA1, filenames
[ipfire-2.x.git] / config / updxlrator / updxlrator
index bea3dab0c856ceca9df0b3deb7c868ff4f5a70ce..bc98786385e33f275ca5600c01920d9cbca991ec 100644 (file)
@@ -70,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')) 
        {
@@ -80,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);
        }
 
@@ -108,8 +110,8 @@ while (<>) {
        # -----------------------------------------------------------
 
        if (
-               ($source_url =~ m@^[h|f]t?tp://[^?]+\.(deb|rpm)$@i) ||
-               ($source_url =~ m@^[h|f]t?tp://[^?]+/distfiles/[^?]+\.(tar\.gz|tar\.bz2|tgz|zip|patch\.bz2|gz|docx|patch|pdf|exe)$@i)
+               ($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);
@@ -155,12 +157,28 @@ 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
@@ -196,9 +214,11 @@ while (<>) {
 # ----------- ADD NEW SOURCES BEFORE THIS LINE !!! ------------------
        }
 
-       $request="$xlrator_url $hostaddr $username $method\n";
-
-       print $request;
+       if ($xlrator_url) {
+               print "OK rewrite-url=\"$xlrator_url\"\n";
+       } else {
+               print "ERR\n";
+       }
 }
 
 # -------------------------------------------------------------------
@@ -327,7 +347,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;
 
@@ -380,6 +402,17 @@ sub check_cache
                &debuglog("Retrieving file from cache ($updsource)");
                &setcachestatus("$updcachedir/$vendorid/$uuid/access.log",time);
                $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
        {