Enable/disable captive portal from preferences

Fixed HTTP bug that prevented ntopng to work on standard ports (80, 443)
Fixed minor UI glitches
This commit is contained in:
Luca Deri 2017-01-18 22:25:22 +01:00
parent e49e8c046e
commit ddf6601f9a
9 changed files with 113 additions and 42 deletions

View file

@ -69,13 +69,20 @@ int send_error(struct mg_connection *conn, int status, const char *reason, const
static void redirect_to_ssl(struct mg_connection *conn,
const struct mg_request_info *request_info) {
const char *p, *host = mg_get_header(conn, "Host");
const char *host = mg_get_header(conn, "Host");
// u_int16_t port = ntop->get_HTTPserver()->get_port();
if(host != NULL && (p = strchr(host, ':')) != NULL) {
mg_printf(conn, "HTTP/1.1 302 Found\r\n"
"Location: https://%.*s:%u/%s\r\n\r\n",
(int) (p - host), host, ntop->getPrefs()->get_https_port(), request_info->uri);
if(host != NULL) {
const char *p = strchr(host, ':');
if(p)
mg_printf(conn, "HTTP/1.1 302 Found\r\n"
"Location: https://%.*s:%u/%s\r\n\r\n",
(int) (p - host), host, ntop->getPrefs()->get_https_port(), request_info->uri);
else
mg_printf(conn, "HTTP/1.1 302 Found\r\n"
"Location: https://%s:%u/%s\r\n\r\n",
host, ntop->getPrefs()->get_https_port(), request_info->uri);
} else {
mg_printf(conn, "%s", "HTTP/1.1 500 Error\r\n\r\nHost: header is not set");
}