summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/html.c7
-rw-r--r--src/html.h1
-rw-r--r--src/web.c5
-rw-r--r--src/web.h1
4 files changed, 10 insertions, 4 deletions
diff --git a/src/html.c b/src/html.c
index 20007f9..ec7064c 100644
--- a/src/html.c
+++ b/src/html.c
@@ -409,7 +409,7 @@ char *html_render_clients_page(const char *host, const struct ListClientResult *
return buf;
}
-char *html_render_client_detail_page(const char *host, const struct GetClientOnlyResult *client_result, const struct GetBackupsResult *backups_result, size_t *out_len) {
+char *html_render_client_detail_page(const char *host, const char* proto, const struct GetClientOnlyResult *client_result, const struct GetBackupsResult *backups_result, size_t *out_len) {
// Determine status and staleness
int is_stale = 0;
const char *current_status = "OK";
@@ -468,14 +468,15 @@ char *html_render_client_detail_page(const char *host, const struct GetClientOnl
" <details>\n"
" <summary>How To</summary>\n"
" <div>\n"
- " <pre><code>curl -s -X POST %s \\\n"
+ " <pre><code>curl -s -X POST %s://%s \\\n"
" -H \"Content-Type: application/json\" \\\n"
" -d \'{\"client\": \"%s\", \"secret\": \"%s\", \"event\": \"begin_backup\"}\'"
"</pre></code>\n"
" </div>\n"
" </details>\n",
client_result->secret,
- host ? host : "localhost",
+ proto != NULL ? proto : "http",
+ host != NULL ? host : "localhost",
client_result->name,
client_result->secret
);
diff --git a/src/html.h b/src/html.h
index f244cdb..d4aaea5 100644
--- a/src/html.h
+++ b/src/html.h
@@ -12,6 +12,7 @@ char *html_render_clients_page(
char *html_render_client_detail_page(
const char *host,
+ const char *proto,
const struct GetClientOnlyResult *client,
const struct GetBackupsResult *backups,
size_t *out_len);
diff --git a/src/web.c b/src/web.c
index 9c0789b..e85abaa 100644
--- a/src/web.c
+++ b/src/web.c
@@ -144,7 +144,10 @@ static enum MHD_Result handler(
*ptr = request;
request->server = server;
+ // @COMPL: The proxy might rewrite this, and we should support that
request->host = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "Host");
+ // @COMPL: There are other headers we should look into
+ request->proto = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "X-Forwarded-Proto");
if(strcmp(method, "POST") == 0) {
if(strcmp(url, "/clients") == 0 || strcmp(url, "/clients/delete") == 0 || strcmp(url, "/login") == 0) {
@@ -518,7 +521,7 @@ static enum MHD_Result handler(
// Render HTML
size_t html_len;
- char *html = html_render_client_detail_page(request->host, &client_result, backups_result, &html_len);
+ char *html = html_render_client_detail_page(request->host, request->proto, &client_result, backups_result, &html_len);
free(backups_result);
if (!html) {
diff --git a/src/web.h b/src/web.h
index 2bd85ea..d957427 100644
--- a/src/web.h
+++ b/src/web.h
@@ -39,4 +39,5 @@ struct Request {
struct MHD_PostProcessor *post_proc; // NULL when using PostCollector
struct FormData form;
const char *host;
+ const char *proto;
};