Browse Source

libopkg: support https_proxy

Add support for https_proxy since feeds switched to HTTPS.
In general case, https_proxy may not match http_proxy.
Process http_proxy, https_proxy, and ftp_proxy separately.

Signed-off-by: Vladislav Grigoryev <vg.aetera@gmail.com>
Vladislav Grigoryev 2 years ago
parent
commit
d038e5b6d1
3 changed files with 9 additions and 1 deletions
  1. 1 0
      libopkg/opkg_conf.c
  2. 1 0
      libopkg/opkg_conf.h
  3. 7 1
      libopkg/opkg_download.c

+ 1 - 0
libopkg/opkg_conf.c

@@ -58,6 +58,7 @@ opkg_option_t options[] = {
 	{"ftp_proxy", OPKG_OPT_TYPE_STRING, &_conf.ftp_proxy},
 	{"http_proxy", OPKG_OPT_TYPE_STRING, &_conf.http_proxy},
 	{"http_timeout", OPKG_OPT_TYPE_STRING, &_conf.http_timeout},
+	{"https_proxy", OPKG_OPT_TYPE_STRING, &_conf.https_proxy},
 	{"no_proxy", OPKG_OPT_TYPE_STRING, &_conf.no_proxy},
 	{"test", OPKG_OPT_TYPE_BOOL, &_conf.noaction},
 	{"noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction},

+ 1 - 0
libopkg/opkg_conf.h

@@ -96,6 +96,7 @@ struct opkg_conf {
 	/* proxy options */
 	char *http_proxy;
 	char *http_timeout;
+	char *https_proxy;
 	char *ftp_proxy;
 	char *no_proxy;
 	char *proxy_user;

+ 7 - 1
libopkg/opkg_download.c

@@ -133,6 +133,12 @@ opkg_download(const char *src, const char *dest_file_name,
 			 conf->http_proxy);
 		setenv("http_proxy", conf->http_proxy, 1);
 	}
+	if (conf->https_proxy) {
+		opkg_msg(DEBUG,
+			 "Setting environment variable: https_proxy = %s.\n",
+			 conf->https_proxy);
+		setenv("https_proxy", conf->https_proxy, 1);
+	}
 	if (conf->ftp_proxy) {
 		opkg_msg(DEBUG,
 			 "Setting environment variable: ftp_proxy = %s.\n",
@@ -160,7 +166,7 @@ opkg_download(const char *src, const char *dest_file_name,
 			argv[i++] = "--timeout";
 			argv[i++] = conf->http_timeout;
 		}
-		if (conf->http_proxy || conf->ftp_proxy) {
+		if (conf->http_proxy || conf->https_proxy || conf->ftp_proxy) {
 			argv[i++] = "-Y";
 			argv[i++] = "on";
 		}