[pacman-dev] [PATCH 1/1] Introduce a 'stupid-proxy' option
From: Christian Hesse <mail@eworm.de> Add command line option ('--stupid-proxy') and config file option ('StupidProxy') to disable defaults for low speed limit and timeout on downloads. Use this if you have issues downloading files with proxy and/or security gateway. Signed-off-by: Christian Hesse <mail@eworm.de> Tested-by: Martin <martin@herndl.org> --- doc/pacman.8.txt | 4 ++++ doc/pacman.conf.5.txt | 4 ++++ lib/libalpm/alpm.h | 2 ++ lib/libalpm/dload.c | 6 ++++-- lib/libalpm/handle.c | 10 ++++++++++ lib/libalpm/handle.h | 1 + src/pacman/conf.c | 4 ++++ src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 5 +++++ 9 files changed, 37 insertions(+), 3 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 231e0bc..a99db45 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -193,6 +193,10 @@ Options *\--confirm*:: Cancels the effects of a previous '\--noconfirm'. +*\--stupid-proxy*:: + Disable defaults for low speed limit and timeout on downloads. Use this + if you have issues downloading files with proxy and/or security gateway. + Transaction Options (apply to '-S', '-R' and '-U') -------------------------------------------------- diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt index c665870..3d2ce31 100644 --- a/doc/pacman.conf.5.txt +++ b/doc/pacman.conf.5.txt @@ -209,6 +209,10 @@ Options Displays name, version and size of target packages formatted as a table for upgrade, sync and remove operations. +*StupidProxy*:: + Disable defaults for low speed limit and timeout on downloads. Use this + if you have issues downloading files with proxy and/or security gateway. + Repository Sections ------------------- diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 168d71b..5b3954f 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -925,6 +925,8 @@ int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t l alpm_siglevel_t alpm_option_get_remote_file_siglevel(alpm_handle_t *handle); int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, alpm_siglevel_t level); +int alpm_option_set_stupidproxy(alpm_handle_t *handle, unsigned short stupidproxy); + /** @} */ /** @addtogroup alpm_api_databases Database Functions diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 31ae82c..ae5397d 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -295,8 +295,10 @@ static void curl_set_handle_opts(struct dload_payload *payload, curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, dload_progress_cb); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void *)payload); - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L); - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); + if(!handle->stupidproxy) { + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L); + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); + } curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)payload); curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index e9439a0..6ef5c86 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -844,4 +844,14 @@ alpm_siglevel_t SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *ha } } +int SYMEXPORT alpm_option_set_stupidproxy(alpm_handle_t *handle, + unsigned short stupidproxy) +{ + CHECK_HANDLE(handle, return -1); +#ifdef HAVE_LIBCURL + handle->stupidproxy = stupidproxy; +#endif + return 0; +} + /* vim: set noet: */ diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index a1d0f9a..d4d949b 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -60,6 +60,7 @@ struct __alpm_handle_t { #ifdef HAVE_LIBCURL /* libcurl handle */ CURL *curl; /* reusable curl_easy handle */ + unsigned short stupidproxy; #endif #ifdef HAVE_LIBGPGME diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 25de7af..0608cf0 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -499,6 +499,8 @@ static int _parse_options(const char *key, char *value, config->color = isatty(fileno(stdout)) ? PM_COLOR_ON : PM_COLOR_OFF; enable_colors(config->color); } + } else if(strcmp(key, "StupidProxy") == 0) { + config->stupidproxy = 1; } else { pm_printf(ALPM_LOG_WARNING, _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), @@ -816,6 +818,8 @@ static int setup_libalpm(void) alpm_option_set_noupgrades(handle, config->noupgrade); alpm_option_set_noextracts(handle, config->noextract); + alpm_option_set_stupidproxy(handle, config->stupidproxy); + for(i = config->assumeinstalled; i; i = i->next) { char *entry = i->data; alpm_depend_t *dep = alpm_dep_from_string(entry); diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 2aba8bf..043fb1c 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -55,6 +55,7 @@ typedef struct __config_t { unsigned short checkspace; unsigned short usesyslog; unsigned short color; + unsigned short stupidproxy; double deltaratio; char *arch; char *print_format; @@ -201,7 +202,8 @@ enum { OP_VERBOSE, OP_DOWNLOADONLY, OP_REFRESH, - OP_ASSUMEINSTALLED + OP_ASSUMEINSTALLED, + OP_STUPIDPROXY }; /* clean method */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index be52d1b..0b078a2 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -221,6 +221,7 @@ static void usage(int op, const char * const myname) addlist(_(" --logfile <path> set an alternate log file\n")); addlist(_(" --noconfirm do not ask for any confirmation\n")); addlist(_(" --confirm always ask for confirmation\n")); + addlist(_(" --stupid-proxy use relaxed timeouts for download\n")); } list = alpm_list_msort(list, alpm_list_count(list), options_cmp); for(i = list; i; i = alpm_list_next(i)) { @@ -443,6 +444,9 @@ static int parsearg_global(int opt) free(config->rootdir); config->rootdir = strdup(optarg); break; + case OP_STUPIDPROXY: + config->stupidproxy = 1; + break; case OP_VERBOSE: case 'v': (config->verbose)++; @@ -934,6 +938,7 @@ static int parseargs(int argc, char *argv[]) {"gpgdir", required_argument, 0, OP_GPGDIR}, {"dbonly", no_argument, 0, OP_DBONLY}, {"color", required_argument, 0, OP_COLOR}, + {"stupid-proxy", no_argument, 0, OP_STUPIDPROXY}, {0, 0, 0, 0} }; -- 2.9.2
On 08/12/16 at 06:04pm, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
Add command line option ('--stupid-proxy') and config file option ('StupidProxy') to disable defaults for low speed limit and timeout on downloads. Use this if you have issues downloading files with proxy and/or security gateway.
Signed-off-by: Christian Hesse <mail@eworm.de> Tested-by: Martin <martin@herndl.org> --- doc/pacman.8.txt | 4 ++++ doc/pacman.conf.5.txt | 4 ++++ lib/libalpm/alpm.h | 2 ++ lib/libalpm/dload.c | 6 ++++-- lib/libalpm/handle.c | 10 ++++++++++ lib/libalpm/handle.h | 1 + src/pacman/conf.c | 4 ++++ src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 5 +++++ 9 files changed, 37 insertions(+), 3 deletions(-)
There was discussion in 2014 about adding low speed limit and timeout options that would allow actually configuring them rather than simply disabling them. The patch was mostly finished, but Allan asked for some small changes that were never completed. It might be worth picking up and finishing that patch instead. Initial submission: https://lists.archlinux.org/pipermail/pacman-dev/2014-March/018955.html Allan's final requests: https://lists.archlinux.org/pipermail/pacman-dev/2014-May/019017.html apg
Andrew Gregory <andrew.gregory.8@gmail.com> on Sat, 2016/08/20 12:38:
On 08/12/16 at 06:04pm, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
Add command line option ('--stupid-proxy') and config file option ('StupidProxy') to disable defaults for low speed limit and timeout on downloads. Use this if you have issues downloading files with proxy and/or security gateway.
Signed-off-by: Christian Hesse <mail@eworm.de> Tested-by: Martin <martin@herndl.org> --- doc/pacman.8.txt | 4 ++++ doc/pacman.conf.5.txt | 4 ++++ lib/libalpm/alpm.h | 2 ++ lib/libalpm/dload.c | 6 ++++-- lib/libalpm/handle.c | 10 ++++++++++ lib/libalpm/handle.h | 1 + src/pacman/conf.c | 4 ++++ src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 5 +++++ 9 files changed, 37 insertions(+), 3 deletions(-)
There was discussion in 2014 about adding low speed limit and timeout options that would allow actually configuring them rather than simply disabling them. The patch was mostly finished, but Allan asked for some small changes that were never completed. It might be worth picking up and finishing that patch instead.
Initial submission: https://lists.archlinux.org/pipermail/pacman-dev/2014-March/018955.html
Allan's final requests: https://lists.archlinux.org/pipermail/pacman-dev/2014-May/019017.html
Allan, any opinion on this? If you prefer the code from 2014 I will pick it up and make the required changes. -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
From: Christian Hesse <mail@eworm.de> Add command line option ('--stupid-proxy') and config file option ('StupidProxy') to disable defaults for low speed limit and timeout on downloads. Use this if you have issues downloading files with proxy and/or security gateway. Signed-off-by: Christian Hesse <mail@eworm.de> --- doc/pacman.8.txt | 4 ++++ doc/pacman.conf.5.txt | 4 ++++ lib/libalpm/alpm.h | 2 ++ lib/libalpm/dload.c | 6 ++++-- lib/libalpm/handle.c | 10 ++++++++++ lib/libalpm/handle.h | 1 + src/pacman/conf.c | 4 ++++ src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 5 +++++ 9 files changed, 37 insertions(+), 3 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 0fa727e..bb05fc6 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -193,6 +193,10 @@ Options *\--confirm*:: Cancels the effects of a previous '\--noconfirm'. +*\--stupid-proxy*:: + Disable defaults for low speed limit and timeout on downloads. Use this + if you have issues downloading files with proxy and/or security gateway. + Transaction Options (apply to '-S', '-R' and '-U') -------------------------------------------------- diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt index c665870..3d2ce31 100644 --- a/doc/pacman.conf.5.txt +++ b/doc/pacman.conf.5.txt @@ -209,6 +209,10 @@ Options Displays name, version and size of target packages formatted as a table for upgrade, sync and remove operations. +*StupidProxy*:: + Disable defaults for low speed limit and timeout on downloads. Use this + if you have issues downloading files with proxy and/or security gateway. + Repository Sections ------------------- diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 2d2491d..4aff800 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -926,6 +926,8 @@ int alpm_option_set_local_file_siglevel(alpm_handle_t *handle, int level); int alpm_option_get_remote_file_siglevel(alpm_handle_t *handle); int alpm_option_set_remote_file_siglevel(alpm_handle_t *handle, int level); +int alpm_option_set_stupidproxy(alpm_handle_t *handle, unsigned short stupidproxy); + /** @} */ /** @addtogroup alpm_api_databases Database Functions diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 9d80358..f3f0f68 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -305,8 +305,10 @@ static void curl_set_handle_opts(struct dload_payload *payload, curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, dload_progress_cb); curl_easy_setopt(curl, CURLOPT_XFERINFODATA, (void *)payload); - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L); - curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); + if(!handle->stupidproxy) { + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L); + curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); + } curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)payload); curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 28e8148..a387ee6 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -844,4 +844,14 @@ int SYMEXPORT alpm_option_get_remote_file_siglevel(alpm_handle_t *handle) } } +int SYMEXPORT alpm_option_set_stupidproxy(alpm_handle_t *handle, + unsigned short stupidproxy) +{ + CHECK_HANDLE(handle, return -1); +#ifdef HAVE_LIBCURL + handle->stupidproxy = stupidproxy; +#endif + return 0; +} + /* vim: set noet: */ diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index 652f17d..be7ff78 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -60,6 +60,7 @@ struct __alpm_handle_t { #ifdef HAVE_LIBCURL /* libcurl handle */ CURL *curl; /* reusable curl_easy handle */ + unsigned short stupidproxy; #endif #ifdef HAVE_LIBGPGME diff --git a/src/pacman/conf.c b/src/pacman/conf.c index d8d64fb..0fb7e7a 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -498,6 +498,8 @@ static int _parse_options(const char *key, char *value, config->color = isatty(fileno(stdout)) ? PM_COLOR_ON : PM_COLOR_OFF; enable_colors(config->color); } + } else if(strcmp(key, "StupidProxy") == 0) { + config->stupidproxy = 1; } else { pm_printf(ALPM_LOG_WARNING, _("config file %s, line %d: directive '%s' in section '%s' not recognized.\n"), @@ -815,6 +817,8 @@ static int setup_libalpm(void) alpm_option_set_noupgrades(handle, config->noupgrade); alpm_option_set_noextracts(handle, config->noextract); + alpm_option_set_stupidproxy(handle, config->stupidproxy); + for(i = config->assumeinstalled; i; i = i->next) { char *entry = i->data; alpm_depend_t *dep = alpm_dep_from_string(entry); diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 945de7c..6b685be 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -55,6 +55,7 @@ typedef struct __config_t { unsigned short checkspace; unsigned short usesyslog; unsigned short color; + unsigned short stupidproxy; double deltaratio; char *arch; char *print_format; @@ -203,7 +204,8 @@ enum { OP_VERBOSE, OP_DOWNLOADONLY, OP_REFRESH, - OP_ASSUMEINSTALLED + OP_ASSUMEINSTALLED, + OP_STUPIDPROXY }; /* clean method */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index be52d1b..0b078a2 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -221,6 +221,7 @@ static void usage(int op, const char * const myname) addlist(_(" --logfile <path> set an alternate log file\n")); addlist(_(" --noconfirm do not ask for any confirmation\n")); addlist(_(" --confirm always ask for confirmation\n")); + addlist(_(" --stupid-proxy use relaxed timeouts for download\n")); } list = alpm_list_msort(list, alpm_list_count(list), options_cmp); for(i = list; i; i = alpm_list_next(i)) { @@ -443,6 +444,9 @@ static int parsearg_global(int opt) free(config->rootdir); config->rootdir = strdup(optarg); break; + case OP_STUPIDPROXY: + config->stupidproxy = 1; + break; case OP_VERBOSE: case 'v': (config->verbose)++; @@ -934,6 +938,7 @@ static int parseargs(int argc, char *argv[]) {"gpgdir", required_argument, 0, OP_GPGDIR}, {"dbonly", no_argument, 0, OP_DBONLY}, {"color", required_argument, 0, OP_COLOR}, + {"stupid-proxy", no_argument, 0, OP_STUPIDPROXY}, {0, 0, 0, 0} }; -- 2.10.2
Without intending to come across as overly sensitive, but does it have to be called stupidproxy? cheers! mar77i
Martin Kühne <mysatyre@gmail.com> on Fri, 2016/11/11 22:26:
Without intending to come across as overly sensitive, but does it have to be called stupidproxy?
cheers! mar77i
That originates from Allan's comment [0] about his intention to accept a "--stupid-proxy" flag. I am happy with what ever name Allan decides to choose. ;) [0] https://bugs.archlinux.org/task/50368#comment149944 -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
participants (3)
-
Andrew Gregory
-
Christian Hesse
-
Martin Kühne