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 --- ui/ncurses/nc-config-help.c | 4 ++++ ui/ncurses/nc-config.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/ncurses/nc-config-help.c b/ui/ncurses/nc-config-help.c index a0cbb20..6b0d59f 100644 --- a/ui/ncurses/nc-config-help.c +++ b/ui/ncurses/nc-config-help.c @@ -44,6 +44,10 @@ mask, gateway, and a DNS server or servers for a network interface. Select \ this option if you do not have a DHCP server, or want explicit control of \ network settings.\n" "\n" +"HTTP(S) Proxy: Allows you to specify an optional HTTP or HTTPS proxy server \ +if required, for example: \"http://proxy:3128\". Any HTTP(S) requests made by \ +the pb-discover server will use these details.\n" +"\n" "Disk R/W: Certain bootloader configurations may request write access to \ disks to save information or update parameters (eg. GRUB2). " "Use this option to control access to disks.\n"); diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 1bc77e8..8349629 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -33,7 +33,7 @@ #include "nc-config.h" #include "nc-widgets.h" -#define N_FIELDS 44 +#define N_FIELDS 48 extern struct help_text config_help_text; @@ -106,6 +106,10 @@ struct config_screen { struct nc_widget_textbox *dns_f; struct nc_widget_label *dns_dhcp_help_l; struct nc_widget_label *dns_help_l; + struct nc_widget_label *http_proxy_l; + struct nc_widget_textbox *http_proxy_f; + struct nc_widget_label *https_proxy_l; + struct nc_widget_textbox *https_proxy_f; struct nc_widget_label *allow_write_l; struct nc_widget_select *allow_write_f; @@ -335,6 +339,13 @@ static int screen_process_form(struct config_screen *screen) } } + talloc_free(config->http_proxy); + talloc_free(config->https_proxy); + str = widget_textbox_get_value(screen->widgets.http_proxy_f); + config->http_proxy = talloc_strdup(config, str); + str = widget_textbox_get_value(screen->widgets.https_proxy_f); + config->https_proxy = talloc_strdup(config, str); + allow_write = widget_select_get_value(screen->widgets.allow_write_f); if (allow_write != config->allow_writes) config->allow_writes = allow_write; @@ -585,6 +596,13 @@ static void config_screen_layout_widgets(struct config_screen *screen) y += 1; } + wf = widget_textbox_base(screen->widgets.http_proxy_f); + layout_pair(screen, y, screen->widgets.http_proxy_l, wf); + y++; + wf = widget_textbox_base(screen->widgets.https_proxy_f); + layout_pair(screen, y, screen->widgets.https_proxy_l, wf); + y++; + y += 1; layout_pair(screen, y, screen->widgets.allow_write_l, @@ -1028,6 +1046,15 @@ static void config_screen_setup_widgets(struct config_screen *screen, screen->widgets.dns_dhcp_help_l = widget_new_label(set, 0, 0, _("(if not provided by DHCP server)")); + screen->widgets.http_proxy_l = widget_new_label(set, 0, 0, + _("HTTP Proxy:")); + screen->widgets.http_proxy_f = widget_new_textbox(set, 0, 0, 32, + config->http_proxy); + screen->widgets.https_proxy_l = widget_new_label(set, 0, 0, + _("HTTPS Proxy:")); + screen->widgets.https_proxy_f = widget_new_textbox(set, 0, 0, 32, + config->https_proxy); + if (config->safe_mode) screen->widgets.safe_mode = widget_new_label(set, 0, 0, _("Selecting 'OK' will exit safe mode")); -- cgit v1.2.1