* Purpose : Main file. Contains main() method, main loop, and
* the main connection-handling function.
*
- * Copyright : Written by and Copyright (C) 2001-2022 the
+ * Copyright : Written by and Copyright (C) 2001-2023 the
* Privoxy team. https://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
if (to_read != 0)
{
log_error(LOG_LEVEL_CONNECT,
- "Not enough request body has been read: expected %lu more bytes",
+ "Not enough request body has been read: expected %lu more bytes.",
to_read);
return 1;
}
log_error(LOG_LEVEL_CONNECT,
- "The last %d bytes of the request body have been read", len);
+ "The last %d bytes of the request body have been read.", len);
return 0;
}
if (len <= 0)
{
log_error(LOG_LEVEL_CONNECT,
- "Did not receive the whole encrypted request body from %s",
+ "Did not receive the whole encrypted request body from %s.",
csp->ip_addr_str);
return 1;
}
if (to_read != 0)
{
log_error(LOG_LEVEL_CONNECT,
- "Not enough encrypted request body has been read: expected %lu more bytes",
+ "Not enough encrypted request body has been read: expected %lu more bytes.",
to_read);
return 1;
}
log_error(LOG_LEVEL_CONNECT,
- "The last %llu bytes of the encrypted request body have been read",
+ "The last %llu bytes of the encrypted request body have been read.",
csp->expected_client_content_length);
return 0;
}
{
int content_length_known = csp->expected_client_content_length != 0;
- while ((content_length_known && csp->expected_client_content_length != 0) ||
- (is_ssl_pending(&(csp->ssl_client_attr)) ||
- data_is_available(csp->cfd, csp->config->socket_timeout)))
+ while (is_ssl_pending(&(csp->ssl_client_attr))
+ || (content_length_known && csp->expected_client_content_length != 0))
{
unsigned char buf[BUFFER_SIZE];
int len;
/* XXX: Does this actually happen? */
break;
}
- log_error(LOG_LEVEL_CONNECT, "Forwarding %d bytes of encrypted request body",
+ log_error(LOG_LEVEL_CONNECT, "Forwarding %d bytes of encrypted request body.",
len);
len = ssl_send_data(&(csp->ssl_server_attr), buf, (size_t)len);
if (len == -1)
}
if (csp->expected_client_content_length == 0)
{
- log_error(LOG_LEVEL_CONNECT, "Forwarded the last %d bytes", len);
+ log_error(LOG_LEVEL_CONNECT, "Forwarded the last %d bytes.", len);
break;
}
}
}
- log_error(LOG_LEVEL_CONNECT, "Done forwarding encrypted request body");
+ log_error(LOG_LEVEL_CONNECT, "Done forwarding encrypted request body.");
return 0;
if (hdr == NULL)
{
/* FIXME Should handle error properly */
- log_error(LOG_LEVEL_FATAL, "Out of memory parsing client header");
+ log_error(LOG_LEVEL_FATAL, "Out of memory parsing client header.");
}
list_remove_all(csp->https_headers);
if (csp->expected_client_content_length < flushed)
{
log_error(LOG_LEVEL_ERROR,
- "Flushed %ld bytes of request body while only expecting %llu",
+ "Flushed %ld bytes of request body while only expecting %llu.",
flushed, csp->expected_client_content_length);
csp->expected_client_content_length = 0;
}
else
{
log_error(LOG_LEVEL_CONNECT,
- "Flushed %ld bytes of request body while expecting %llu",
+ "Flushed %ld bytes of request body while expecting %llu.",
flushed, csp->expected_client_content_length);
csp->expected_client_content_length -= (unsigned)flushed;
if (receive_and_send_encrypted_post_data(csp))
else
{
log_error(LOG_LEVEL_CONNECT,
- "Flushed %ld bytes of request body", flushed);
+ "Flushed %ld bytes of request body.", flushed);
}
}
- log_error(LOG_LEVEL_CONNECT, "Encrypted request sent");
+ log_error(LOG_LEVEL_CONNECT, "Encrypted request sent.");
return 0;
do
{
- log_error(LOG_LEVEL_HEADER, "Waiting for encrypted client headers");
+ log_error(LOG_LEVEL_HEADER, "Waiting for encrypted client headers.");
if (!is_ssl_pending(&(csp->ssl_client_attr)) &&
!data_is_available(csp->cfd, csp->config->socket_timeout))
{
log_error(LOG_LEVEL_CONNECT,
- "Socket %d timed out while waiting for client headers", csp->cfd);
+ "Socket %d timed out while waiting for client headers.", csp->cfd);
return JB_ERR_PARSE;
}
len = ssl_recv_data(&(csp->ssl_client_attr),
if (len == 0)
{
log_error(LOG_LEVEL_CONNECT,
- "Socket %d closed while waiting for client headers", csp->cfd);
+ "Socket %d closed while waiting for client headers.", csp->cfd);
return JB_ERR_PARSE;
}
if (len == -1)
p = strstr(csp->client_iob->cur, "\r\n\r\n");
} while (p == NULL);
- log_error(LOG_LEVEL_HEADER, "Encrypted headers received completely");
+ log_error(LOG_LEVEL_HEADER, "Encrypted headers received completely.");
return JB_ERR_OK;
}
*/
if (chunk_offset >= len)
{
- log_error(LOG_LEVEL_CONNECT,
- "Reducing chunk offset from %lu to %lu after flushing %ld bytes",
+ log_error(LOG_LEVEL_CONNECT, "Reducing the chunk offset "
+ "from %lu to %lu after flushing %ld bytes.",
chunk_offset, (chunk_offset - (unsigned)len), len);
chunk_offset = chunk_offset - (unsigned)len;
}
else
{
log_error(LOG_LEVEL_CONNECT,
- "Keeping chunk offset at %lu despite flushing %ld bytes",
+ "Keeping chunk offset at %lu despite flushing %ld bytes.",
chunk_offset, len);
/*
* If we can't parse the chunk-encoded data we should
if (!accept_connection(csp, bfds))
{
- log_error(LOG_LEVEL_CONNECT, "accept failed: %E");
+ log_error(LOG_LEVEL_CONNECT,
+ "Failed to accept() incoming connection: %E");
freez(csp_list);
continue;
}