[PATCH] libopkg: support https_proxy

Vladislav Grigoryev vg.aetera at gmail.com
Tue Aug 31 22:48:08 PDT 2021


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 at gmail.com>
---
 libopkg/opkg_conf.c     | 1 +
 libopkg/opkg_conf.h     | 1 +
 libopkg/opkg_download.c | 8 +++++++-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
index e36f66b..0cbd1cc 100644
--- a/libopkg/opkg_conf.c
+++ b/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},
diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h
index cd69ceb..781c8f4 100644
--- a/libopkg/opkg_conf.h
+++ b/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;
diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c
index cce4b6d..af91f12 100644
--- a/libopkg/opkg_download.c
+++ b/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";
 		}
-- 
2.31.1




More information about the openwrt-devel mailing list