]> git.ipfire.org Git - pakfire.git/commitdiff
downloader: Apply proxy settings
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 23 Apr 2021 16:26:02 +0000 (16:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 23 Apr 2021 16:26:02 +0000 (16:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
contrib/config/general.conf
src/libpakfire/downloader.c

index 81a250c06cd04b5d37d8303f898aafe137a2251c..bf5e25da656fe729ae7ddae620efda75a733310e 100644 (file)
@@ -1,8 +1,7 @@
 
-# This is the general configuration file for pakfire.
+# This is the general configuration file for Pakfire
 
-[downloader]
-# Pakfire can use a proxy for HTTP, HTTPS and FTP
+# Pakfire can use a proxy for HTTPS and HTTP
 # If no proxy setting is configured, Pakfire will
 # use the environment settings.
 #proxy = http://192.168.180.1:800
index 37bd43dff27d3dca354836ded84f21ed4a645981..b971cd0ecf3ca17a63dc6ea14872c30baeea8c3b 100644 (file)
@@ -238,6 +238,8 @@ static int debug_callback(CURL *handle, curl_infotype type,
 static struct pakfire_transfer* pakfire_downloader_create_transfer(
                struct pakfire_downloader* downloader, const char* baseurl, struct pakfire_mirrorlist* mirrors,
                const char* title, const char* url, const char* path, enum pakfire_transfer_flags flags) {
+       struct pakfire_config* config = NULL;
+
        DEBUG(downloader->pakfire, "Adding download of %s\n", url);
 
        // Reset baseurl it points to an empty string
@@ -290,6 +292,17 @@ static struct pakfire_transfer* pakfire_downloader_create_transfer(
        if (!transfer->handle)
                goto ERROR;
 
+       // Fetch global configuration
+       config = pakfire_get_config(downloader->pakfire);
+
+       // Set global configuration
+       if (config) {
+               const char* proxy = pakfire_config_get(config, NULL, "proxy", NULL);
+               if (proxy) {
+                       curl_easy_setopt(transfer->handle, CURLOPT_PROXY, proxy);
+               }
+       }
+
        // Enable logging/debugging
        curl_easy_setopt(transfer->handle, CURLOPT_VERBOSE, 0);
 
@@ -312,6 +325,8 @@ static struct pakfire_transfer* pakfire_downloader_create_transfer(
        return transfer;
 
 ERROR:
+       if (config)
+               pakfire_config_unref(config);
        pakfire_transfer_free(transfer);
 
        return NULL;