Skip to content
Snippets Groups Projects
Commit d98359ab authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Move max concurrent connections check into http_session_thread()

We can't send a 4xx error (ie: client did something wrong) in
plaintext on a TLS connection.

Untested beyond a basic compile check.
parent b3db2c0d
No related branches found
No related tags found
No related merge requests found
Pipeline #7297 passed
...@@ -6804,6 +6804,17 @@ void http_session_thread(void* arg) ...@@ -6804,6 +6804,17 @@ void http_session_thread(void* arg)
session.subscan=(subscan_t*)calloc(scfg.total_subs, sizeof(subscan_t)); session.subscan=(subscan_t*)calloc(scfg.total_subs, sizeof(subscan_t));
if(startup->max_concurrent_connections > 0) {
int ip_len = strlen(session.host_ip) + 1;
uint connections = listCountMatches(&current_connections, session.host_ip, ip_len);
if(connections >= startup->max_concurrent_connections
&& !is_host_exempt(&scfg, session.host_ip, /* host_name */NULL)) {
lprintf(LOG_NOTICE, "%04d [%s] !Maximum concurrent connections (%u) exceeded"
,socket, session.host_ip, startup->max_concurrent_connections);
send_error(&session, __LINE__, error_429);
}
}
while(!session.finished) { while(!session.finished) {
init_error=false; init_error=false;
memset(&(session.req), 0, sizeof(session.req)); memset(&(session.req), 0, sizeof(session.req));
...@@ -7427,23 +7438,6 @@ void web_server(void* arg) ...@@ -7427,23 +7438,6 @@ void web_server(void* arg)
inet_addrtop(&client_addr, host_ip, sizeof(host_ip)); inet_addrtop(&client_addr, host_ip, sizeof(host_ip));
if(startup->max_concurrent_connections > 0) {
int ip_len = strlen(host_ip) + 1;
uint connections = listCountMatches(&current_connections, host_ip, ip_len);
if(connections >= startup->max_concurrent_connections
&& !is_host_exempt(&scfg, host_ip, /* host_name */NULL)) {
lprintf(LOG_NOTICE, "%04d [%s] !Maximum concurrent connections (%u) exceeded"
,client_socket, host_ip, startup->max_concurrent_connections);
static int len_429;
if(len_429 < 1)
len_429 = strlen(error_429);
if(sendsocket(client_socket, error_429, len_429) != len_429)
lprintf(LOG_ERR, "%04d FAILED sending error 429", client_socket);
close_socket(&client_socket);
continue;
}
}
if(trashcan(&scfg,host_ip,"ip-silent")) { if(trashcan(&scfg,host_ip,"ip-silent")) {
close_socket(&client_socket); close_socket(&client_socket);
continue; continue;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment