]> git.ipfire.org Git - people/arne_f/ipfire-2.x.git/commitdiff
url-filter: Use upstream proxy when downloading blacklists
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 16 Jun 2015 12:39:26 +0000 (14:39 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 16 Jun 2015 12:39:26 +0000 (14:39 +0200)
Fixes #10690

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/network-functions.pl
config/urlfilter/autoupdate.pl

index 029ffc09eee5308dddc5d777e7eb11417e347e3b..1cd2814ec1b0c32f3592b36a377ca15060dab6b2 100644 (file)
@@ -23,6 +23,8 @@
 
 package Network;
 
+require "/var/ipfire/general-functions.pl";
+
 use Socket;
 
 my %PREFIX2NETMASK = (
@@ -244,6 +246,31 @@ sub ip_address_in_network($$) {
        return (($address_bin ge $network_bin) && ($address_bin le $broadcast_bin));
 }
 
+sub setup_upstream_proxy() {
+       my %proxysettings = ();
+       &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
+
+       if ($proxysettings{'UPSTREAM_PROXY'}) {
+               my $credentials = "";
+
+               if ($proxysettings{'UPSTREAM_USER'}) {
+                       $credentials = $proxysettings{'UPSTREAM_USER'};
+
+                       if ($proxysettings{'UPSTREAM_PASSWORD'}) {
+                               $credentials .= ":" . $proxysettings{'UPSTREAM_PASSWORD'};
+                       }
+
+                       $credentials .= "@";
+               }
+
+               my $proxy = "http://" . $credentials . $proxysettings{'UPSTREAM_PROXY'};
+
+               $ENV{'http_proxy'} = $proxy;
+               $ENV{'https_proxy'} = $proxy;
+               $ENV{'ftp_proxy'} = $proxy;
+       }
+}
+
 1;
 
 # Remove the next line to enable the testsuite
index fa6ec91dd0473d696a6134e8e80ce7968a5470c8..39b9b4f0b572f9fb0c6e1a68f851e86101d9cc69 100644 (file)
@@ -8,6 +8,8 @@
 #
 use strict;
 
+require "/var/ipfire/general-functions.pl";
+
 my $make_clean = 1;
 
 my $swroot = "/var/ipfire";
@@ -72,6 +74,7 @@ unless ($blacklist_url eq '')
        if (-d $target) { system("rm -rf $target"); }
        system("mkdir $target");
 
+       &Network::setup_upstream_proxy();
        system("/usr/bin/wget -o $target/wget.log -O $blacklist $blacklist_url");
 
        if (-e $blacklist)