Configurable MOTD (Message of the Day) on HTTPD root page

Also improve root page HTML: change <br> to <br />
This commit is contained in:
Andrew Bettison 2014-04-29 13:57:29 +09:30
parent 008dd6ab21
commit e80cce72a0
2 changed files with 11 additions and 5 deletions

View File

@ -333,6 +333,7 @@ STRING(256, interface_path, "", str_nonempty,, "Path of director
ATOM(bool_t, respawn_on_crash, 0, boolean,, "If true, server will exec(2) itself on fatal signals, eg SEGV")
ATOM(uint32_t, config_reload_interval_ms, 1000, uint32_nonzero,, "Time interval between configuration reload polls, in milliseconds")
SUB_STRUCT(watchdog, watchdog,)
STRING(120, motd, "", str_nonempty,, "Message Of The Day displayed on HTTPD root page")
END_STRUCT
STRUCT(monitor)

15
httpd.c
View File

@ -437,19 +437,24 @@ static int root_page(httpd_request *r, const char *remainder)
char temp[8192];
strbuf b = strbuf_local(temp, sizeof temp);
strbuf_sprintf(b, "<html><head><meta http-equiv=\"refresh\" content=\"5\" ></head><body>"
"<h1>Hello, I'm %s*</h1><br>"
"Interfaces;<br>",
"<h1>Hello, I'm %s*</h1>",
alloca_tohex_sid_t_trunc(my_subscriber->sid, 16));
if (config.server.motd[0]) {
strbuf_puts(b, "<p>");
strbuf_html_escape(b, config.server.motd, strlen(config.server.motd));
strbuf_puts(b, "</p>");
}
strbuf_puts(b, "Interfaces;<br />");
int i;
for (i=0;i<OVERLAY_MAX_INTERFACES;i++){
if (overlay_interfaces[i].state==INTERFACE_STATE_UP)
strbuf_sprintf(b, "<a href=\"/interface/%d\">%d: %s, TX: %d, RX: %d</a><br>",
strbuf_sprintf(b, "<a href=\"/interface/%d\">%d: %s, TX: %d, RX: %d</a><br />",
i, i, overlay_interfaces[i].name, overlay_interfaces[i].tx_count, overlay_interfaces[i].recv_count);
}
strbuf_puts(b, "Neighbours;<br>");
strbuf_puts(b, "Neighbours;<br />");
link_neighbour_short_status_html(b, "/neighbour");
if (is_rhizome_http_enabled()){
strbuf_puts(b, "<a href=\"/rhizome/status\">Rhizome Status</a><br>");
strbuf_puts(b, "<a href=\"/rhizome/status\">Rhizome Status</a><br />");
}
strbuf_puts(b, "</body></html>");
if (strbuf_overrun(b)) {