Minor optimization to avoid scanning a list twice

This commit is contained in:
Luca Deri 2017-05-28 22:13:39 +02:00
parent 6e0a0b4d21
commit ae0556b874

View file

@ -325,11 +325,14 @@ static int is_authorized(const struct mg_connection *conn,
/* ****************************************** */
static int isCaptiveConnection(struct mg_connection *conn) {
char *host = (char*)mg_get_header(conn, "Host");
return(ntop->getPrefs()->isCaptivePortalEnabled()
&& (ntohs(conn->client.lsa.sin.sin_port) == 80)
&& (mg_get_header(conn, "Host"))
&& (strcasestr((char*)mg_get_header(conn, "Host"), CONST_HELLO_HOST) == NULL)
&& (ntop->getPrefs()->get_alt_http_port() != 0));
&& (ntop->getPrefs()->get_alt_http_port() != 0)
&& host
&& (strcasestr(host, CONST_HELLO_HOST) == NULL)
);
}
/* ****************************************** */