From a055f6714fd06aa3b633b1bc44a8dbf42a0eedb0 Mon Sep 17 00:00:00 2001 From: Samuel Mendoza-Jonas Date: Thu, 27 Oct 2016 14:56:05 +1100 Subject: Support HTTP(S) proxies when downloading resources Allow the user to specify a HTTP and HTTPS proxy server. The discover server will set the http_proxy and https_proxy environment variables, enabling the proxy servers for any further HTTP(S) requests. Signed-off-by: Samuel Mendoza-Jonas --- lib/pb-config/pb-config.c | 3 +++ lib/pb-protocol/pb-protocol.c | 13 +++++++++++++ lib/types/types.h | 3 +++ 3 files changed, 19 insertions(+) (limited to 'lib') diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c index 2f9af28..7fa925c 100644 --- a/lib/pb-config/pb-config.c +++ b/lib/pb-config/pb-config.c @@ -63,6 +63,9 @@ struct config *config_copy(void *ctx, const struct config *src) dest->network.dns_servers[i] = talloc_strdup(dest, src->network.dns_servers[i]); + dest->http_proxy = talloc_strdup(dest, src->http_proxy); + dest->https_proxy = talloc_strdup(dest, src->https_proxy); + dest->n_autoboot_opts = src->n_autoboot_opts; dest->autoboot_opts = talloc_array(dest, struct autoboot_option, dest->n_autoboot_opts); diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index 47d04a3..64bd161 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -305,6 +305,9 @@ int pb_protocol_config_len(const struct config *config) for (i = 0; i < config->network.n_dns_servers; i++) len += 4 + optional_strlen(config->network.dns_servers[i]); + len += 4 + optional_strlen(config->http_proxy); + len += 4 + optional_strlen(config->https_proxy); + len += 4; for (i = 0; i < config->n_autoboot_opts; i++) { if (config->autoboot_opts[i].boot_type == BOOT_DEVICE_TYPE) @@ -550,6 +553,9 @@ int pb_protocol_serialise_config(const struct config *config, config->network.dns_servers[i]); } + pos += pb_protocol_serialise_string(pos, config->http_proxy); + pos += pb_protocol_serialise_string(pos, config->https_proxy); + *(uint32_t *)pos = __cpu_to_be32(config->n_autoboot_opts); pos += 4; for (i = 0; i < config->n_autoboot_opts; i++) { @@ -1082,6 +1088,13 @@ int pb_protocol_deserialise_config(struct config *config, config->network.dns_servers[i] = str; } + if (read_string(config, &pos, &len, &str)) + goto out; + config->http_proxy = str; + if (read_string(config, &pos, &len, &str)) + goto out; + config->https_proxy = str; + if (read_u32(&pos, &len, &config->n_autoboot_opts)) goto out; config->autoboot_opts = talloc_array(config, struct autoboot_option, diff --git a/lib/types/types.h b/lib/types/types.h index 31922d0..d660d6b 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -161,6 +161,9 @@ struct config { unsigned int ipmi_bootdev; bool ipmi_bootdev_persistent; + char *http_proxy; + char *https_proxy; + bool allow_writes; char *boot_console; -- cgit v1.2.1