From: Michael Tremer Date: Fri, 23 Apr 2021 16:26:02 +0000 (+0000) Subject: downloader: Apply proxy settings X-Git-Tag: 0.9.28~1285^2~234 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=325c34c7dbbe7bb68e88aa0ab07e96357b63762d;p=pakfire.git downloader: Apply proxy settings Signed-off-by: Michael Tremer --- diff --git a/contrib/config/general.conf b/contrib/config/general.conf index 81a250c06..bf5e25da6 100644 --- a/contrib/config/general.conf +++ b/contrib/config/general.conf @@ -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 diff --git a/src/libpakfire/downloader.c b/src/libpakfire/downloader.c index 37bd43dff..b971cd0ec 100644 --- a/src/libpakfire/downloader.c +++ b/src/libpakfire/downloader.c @@ -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;