144#if HAVE_SYSTEMD_SD_DAEMON_H
145#include <systemd/sd-daemon.h>
162 void print(std::ostream &os)
const override {
256 if (0 != aPing->
stop.tv_sec && 0 != aPing->
start.tv_sec)
267 switch (someEntry->
code) {
285 i = &someEntry->
ping;
325 assert(aLogEntry !=
nullptr);
377 debugs(33, 5,
"logging half-baked transaction: " <<
log_uri);
381 debugs(33, 9,
"clientLogRequest: al.url='" <<
al->
url <<
"'");
383 const auto findReply = [
this]() ->
const HttpReply * {
387 return le->hasFreshestReply();
390 if (
const auto reply = findReply()) {
430 debugs(33, 3, h->key() <<
" " << matched);
446 bool updatePerformanceCounters =
true;
453 if (updatePerformanceCounters) {
457 if (
getConn() !=
nullptr &&
getConn()->clientConnection !=
nullptr)
496 if (
auth_ ==
nullptr) {
497 if (aur !=
nullptr) {
547 if (aur ==
nullptr) {
548 debugs(33, 2,
"WARNING: Graceful closure on " <<
clientConnection <<
" due to connection-auth erase from " << by);
595 flags.readMore =
false;
608 setAuth(
nullptr,
"ConnStateData::SwanSong cleanup");
611 flags.swanSang =
true;
620 if (
const auto tex =
dynamic_cast<const TextException*
>(&ex))
631 const auto http = context->http;
633 http->updateError(
error);
716 debugs(33, 5,
"appending boundary: " << boundary);
758 clen += (*pos)->length;
760 debugs(33, 6,
"clientMRangeCLen: (clen += " << mb.
size <<
" + " << (*pos)->length <<
") == " << clen);
786 b.
append(key, strlen(key));
817 assert(context !=
nullptr);
823 context->deferRecipientForLater(
node, rep, receivedData);
825 context->deferRecipientForLater(
node, rep, receivedData);
878 if (deferredRequest->flags.deferred) {
880 assert(deferredRequest->http->out.size == 0);
883 deferredRequest->http,
884 deferredRequest->deferredparams.rep,
885 deferredRequest->deferredparams.queuedBuffer);
902 debugs(33, 2,
clientConnection <<
" Connection was pinned but server side gone. Terminating client connection");
922 debugs(33, 3,
"closing for earlier request error: " << reason);
946 if (deferredRequest !=
nullptr) {
949 }
else if (
flags.readMore) {
962 "; old receiving error: " <<
966 debugs(33, 3,
"already stopped sending: " << oldError);
973 debugs(33, 5,
"must still read " << expecting <<
974 " request body bytes with " <<
inBuf.
length() <<
" unused");
991 if (ctx->http->loggingTags().isTcpHit())
994 ctx->writeComplete(
size);
1005 tempBuffer.
data = context->reqbuf;
1038 char *result = aString;
1054 if (
nullptr == end) {
1055 end = uriAndHTTPVersion + strcspn(uriAndHTTPVersion,
"\r\n");
1059 for (; end > uriAndHTTPVersion; --end) {
1060 if (*end ==
'\n' || *end ==
'\r')
1064 if (strncasecmp(end + 1,
"HTTP/", 5) == 0)
1077 int vhost = conn->
port->vhost;
1078 int vport = conn->
port->vport;
1084 SBuf url = hp->requestUri();
1090 if (conn->
port->vhost)
1095 static const SBuf uriSchemeEnd(
"://");
1096 if (!
tok.skipAll(uriScheme) || !
tok.skip(uriSchemeEnd))
1103 if (!
tok.skipAll(authority))
1106 static const SBuf slashUri(
"/");
1107 const SBuf t =
tok.remaining();
1112 else if (t[0]==
'?' || t[0]==
'#') {
1119#if SHOULD_REJECT_UNKNOWN_URLS
1121 if (url.
isEmpty() || url[0] !=
'/') {
1130 char *receivedHost =
nullptr;
1131 if (vhost && (receivedHost = hp->getHostHeaderField())) {
1132 SBuf host(receivedHost);
1133 debugs(33, 5,
"ACCEL VHOST REWRITE: vhost=" << host <<
" + vport=" << vport);
1136 const auto lastColonPos = host.
rfind(
':');
1138 host.
chop(0, lastColonPos);
1144 char *uri =
static_cast<char *
>(
xcalloc(url_sz, 1));
1146 debugs(33, 5,
"ACCEL VHOST REWRITE: " << uri);
1148 }
else if (conn->
port->defaultsite ) {
1149 debugs(33, 5,
"ACCEL DEFAULTSITE REWRITE: defaultsite=" << conn->
port->defaultsite <<
" + vport=" << vport);
1153 snprintf(vportStr,
sizeof(vportStr),
":%d",vport);
1156 const int url_sz = scheme.
length() + strlen(conn->
port->defaultsite) +
sizeof(vportStr) + url.
length() + 32;
1157 char *uri =
static_cast<char *
>(
xcalloc(url_sz, 1));
1160 debugs(33, 5,
"ACCEL DEFAULTSITE REWRITE: " << uri);
1162 }
else if (vport > 0 ) {
1163 debugs(33, 5,
"ACCEL VPORT REWRITE: *_port IP + vport=" << vport);
1167 const int url_sz = scheme.
length() +
sizeof(ipbuf) + url.
length() + 32;
1168 char *uri =
static_cast<char *
>(
xcalloc(url_sz, 1));
1171 debugs(33, 5,
"ACCEL VPORT REWRITE: " << uri);
1181 char *uri =
nullptr;
1183 if (
const char *host = hp->getHostHeaderField()) {
1185 const int url_sz = scheme.
length() + strlen(host) + hp->requestUri().length() + 32;
1186 uri =
static_cast<char *
>(
xcalloc(url_sz, 1));
1200 if (!hp->requestUri().isEmpty() && hp->requestUri()[0] !=
'/')
1215 const int url_sz = scheme.
length() + useHost.
length() + hp->requestUri().length() + 32;
1216 uri =
static_cast<char *
>(
xcalloc(url_sz, 1));
1225 debugs(33, 5,
"TLS switching host rewrite: " << uri);
1233 if (!hp->requestUri().isEmpty() && hp->requestUri()[0] !=
'/')
1242 const int url_sz =
sizeof(ipbuf) + hp->requestUri().length() + 32;
1243 uri =
static_cast<char *
>(
xcalloc(url_sz, 1));
1250 debugs(33, 5,
"TRANSPARENT REWRITE: " << uri);
1264 const bool parsedOk = hp->parse(
inBuf);
1267 inBuf = hp->remaining();
1269 if (hp->needsMoreData()) {
1270 debugs(33, 5,
"Incomplete request, waiting for end of request line");
1279 tooBig ?
"error:request-too-large" :
"error:invalid-request");
1289 debugs(11, 2,
"HTTP Client REQUEST:\n---------\n" <<
1290 hp->method() <<
" " << hp->requestUri() <<
" " << hp->messageProtocol() <<
"\n" <<
1297 debugs(33,
DBG_IMPORTANT,
"WARNING: for request: " << hp->method() <<
" " << hp->requestUri() <<
" " << hp->messageProtocol());
1308 debugs(33,
DBG_IMPORTANT,
"WARNING: for request: " << hp->method() <<
" " << hp->requestUri() <<
" " << hp->messageProtocol());
1314 debugs(33,
DBG_IMPORTANT,
"WARNING: Unsupported method: " << hp->method() <<
" " << hp->requestUri() <<
" " << hp->messageProtocol());
1320 debugs(33, 3,
"complete request received. " <<
1321 "prefix_sz = " << hp->messageHeaderSize() <<
1322 ", request-line-size=" << hp->firstLineSize() <<
1323 ", mime-header-size=" << hp->headerBlockSize() <<
1324 ", mime header block:\n" << hp->mimeHeader() <<
"\n----------");
1329 http->
req_sz = hp->messageHeaderSize();
1343 debugs(33,5,
"Prepare absolute URL from " <<
1344 (
transparent()?
"intercept":(
port->flags.accelSurrogate ?
"accel":
"")));
1370 }
else if (
port->flags.accelSurrogate) {
1392 debugs(33, 4,
"yes, without active requests and unparsed input");
1397 debugs(33, 3,
"yes, without half_closed_clients");
1404 debugs(33, 3,
"no, honoring half_closed_clients");
1438 flags.readMore =
false;
1460 debugs(33, 5,
"Responding with delated error for " << http->
uri);
1476 debugs(33, 5,
"certificate matches requested host: " << *
host);
1479 debugs(33, 2,
"SQUID_X509_V_ERR_DOMAIN_MISMATCH: Certificate " <<
1482 bool allowDomainMismatch =
false;
1491 if (!allowDomainMismatch) {
1524 debugs(33, 5,
"disabled; send error: " << requestError);
1529 debugs(33, 3,
"may have forgotten client data; send error: " << requestError);
1536 const auto &answer = checklist.
fastCheck();
1537 if (answer.allowed() && answer.kind == 1) {
1538 debugs(33, 3,
"Request will be tunneled to server");
1540 const auto http = context ? context->http :
nullptr;
1541 const auto request = http ? http->request :
nullptr;
1543 context->finished();
1547 debugs(33, 3,
"denied; send error: " << requestError);
1571 bool mustReplyToOptions =
false;
1572 bool expectBody =
false;
1580 const bool isFtp = !hp;
1592 !conn->
port->allow_direct : 0;
1597 if (conn->
getAuth() !=
nullptr)
1621 conn, request.
getRaw(),
nullptr,
nullptr);
1671 conn, http->
request,
nullptr,
nullptr);
1687 debugs(33, 5,
"need more request body");
1739 const int internalRequest = 0;
1744 if (existingRequestCount >= concurrentRequestLimit) {
1745 debugs(33, 3,
clientConnection <<
" max concurrent requests reached (" << concurrentRequestLimit <<
")");
1782#if QUIET_PROXY_PROTOCOL
1784 static uint8_t hide = 0;
1815 debugs(33, 3,
"PROXY protocol: waiting for more than " <<
inBuf.
length() <<
" bytes");
1817 }
catch (
const std::exception &e) {
1873 context->registerWithConn();
1882 if (context->mayUseConnection()) {
1883 debugs(33, 3,
"Not parsing new requests, as this request may need the connection");
1904 flags.readMore =
false;
1982 debugs(33, 3,
"closing for earlier sending error: " << reason);
2041#if WE_KNOW_HOW_TO_SEND_ERRORS
2043 if (context !=
NULL && !context->http->out.offset) {
2054 context->pullData();
2060 debugs(33, 3,
"aborting chunked request without error " <<
error);
2063 flags.readMore =
false;
2096 debugs(33, 3,
"requestTimeout: FD " << io.
fd <<
": lifetime is expired.");
2115 , tlsParser(
Security::HandshakeParser::fromClient)
2135#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
2136 int i = IP_PMTUDISC_DONT;
2142 static bool reported =
false;
2145 debugs(33,
DBG_IMPORTANT,
"WARNING: Path MTU discovery disabling is not supported on your platform.");
2187 for (
unsigned int pool = 0; pool < pools.size(); ++pool) {
2190 if (pools[pool]->access) {
2193 if (answer.allowed()) {
2204 const double burst = floor(0.5 +
2206 cli->
setWriteLimiter(pools[pool]->rate, burst, pools[pool]->highwatermark);
2209 debugs(83, 4,
"Delay pool " << pool <<
" skipped because ACL " << answer);
2233 return handshakeResult;
2253 xact->tcpClient = params.
conn;
2267 debugs(33, 5,
"will negotiate TLS on " << conn);
2282 const auto handshakeResult = conn->
acceptTls();
2283 switch (handshakeResult.category) {
2296 debugs(83, (handshakeResult.important ?
Important(62) : 2),
"ERROR: Cannot accept a TLS connection" <<
2309 debugs(83, 2,
"Session " << SSL_get_session(session.get()) <<
2310 " reused on FD " << fd <<
" (" <<
fd_table[fd].ipaddr <<
2311 ":" << (
int)
fd_table[fd].remote_port <<
")");
2317#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x00908000L
2318 PEM_ASN1_write(
reinterpret_cast<i2d_of_void *
>(i2d_SSL_SESSION),
2320 reinterpret_cast<char *
>(SSL_get_session(session.get())),
2321 nullptr,
nullptr, 0,
nullptr,
nullptr);
2323#elif (ALLOW_ALWAYS_SSL_SESSION_DETAIL == 1)
2332 PEM_ASN1_write((
int(*)())i2d_SSL_SESSION, PEM_STRING_SSL_SESSION,
2334 reinterpret_cast<char *
>(SSL_get_session(session.get())),
2335 nullptr,
nullptr, 0,
nullptr,
nullptr);
2342 debugs(83, 4,
"With " OPENSSL_VERSION_TEXT
", session details are available only defining ALLOW_ALWAYS_SSL_SESSION_DETAIL=1 in the source.");
2348 debugs(83, 2,
"New session " << SSL_get_session(session.get()) <<
2349 " on FD " << fd <<
" (" <<
fd_table[fd].ipaddr <<
":" <<
2353 debugs(83, 2,
"TLS session reuse not yet implemented.");
2360 X509 *client_cert = SSL_get_peer_certificate(session.get());
2363 debugs(83, 3,
"FD " << fd <<
" client certificate: subject: " <<
2366 debugs(83, 3,
"FD " << fd <<
" client certificate: issuer: " <<
2369 X509_free(client_cert);
2371 debugs(83, 5,
"FD " << fd <<
" has no client certificate.");
2374 debugs(83, 2,
"Client certificate requesting not yet implemented.");
2417 if (!connState->
isOpen())
2453 xact->tcpClient = params.
conn;
2455 debugs(33, 4, params.
conn <<
" accepted, starting SSL negotiation.");
2467 if (
port->flags.tunnelSslBumping) {
2495 acl_checklist->al = connectAle;
2498 acl_checklist->al->cache.port =
port;
2499 acl_checklist->al->cache.caddr =
log_addr;
2501 acl_checklist->al->updateError(
bareError);
2503 acl_checklist->al->request = request;
2507 const char *log_uri = http ? http->
log_uri :
nullptr;
2508 acl_checklist->syncAle(request, log_uri);
2511 fatal(
"FATAL: SSL-Bump requires --with-openssl");
2531 debugs(33, 3,
"Connection gone while waiting for ssl_crtd helper reply; helper reply:" << reply);
2553 debugs(33, 5,
"Failed to set certificates to ssl object for PeekAndSplice mode");
2592 const char *param = ca->param;
2606 debugs(33, 5,
"Matches certificate adaptation algorithm: " <<
2607 alg <<
" param: " << (param ? param :
"-"));
2631 assert(
port->secure.untrustedSigningCa.cert);
2633 certProperties.
signWithPkey.resetAndLock(
port->secure.untrustedSigningCa.pkey.get());
2638 if (
port->secure.signingCa.pkey)
2639 certProperties.
signWithPkey.resetAndLock(
port->secure.signingCa.pkey.get());
2649 debugs(33, 5,
"Finding SSL certificate for " << cacheKey <<
" in cache");
2651 if (
const auto ctx = ssl_ctx_cache ? ssl_ctx_cache->get(cacheKey) :
nullptr) {
2653 debugs(33, 5,
"Cached SSL certificate for " << certProperties.
commonName <<
" is valid");
2656 debugs(33, 5,
"Cached SSL certificate for " << certProperties.
commonName <<
" is out of date. Delete this certificate from cache");
2658 ssl_ctx_cache->del(cacheKey);
2668 if (!ssl_ctx_cache || !ssl_ctx_cache->add(cacheKey, ctx)) {
2677 if (
port->secure.generateHostCertificates) {
2696 debugs(33, 5,
"Generating SSL certificate for " << certProperties.
commonName <<
" using ssl_crtd.");
2700 debugs(33, 5,
"SSL crtd request: " << request_message.
compose().c_str());
2703 }
catch (
const std::exception &e) {
2705 "request for " << certProperties.
commonName <<
2706 " certificate: " << e.what() <<
"; will now block to " <<
2707 "generate that certificate.");
2712 debugs(33, 5,
"Generating SSL certificate for " << certProperties.
commonName);
2717 debugs(33, 5,
"Failed to set certificates to ssl object for PeekAndSplice mode");
2737 if (
port->secure.generateHostCertificates && !ctx) {
2743 if (!
port->secure.staticContext) {
2748 debugs(33, 5,
"Using static TLS context.");
2749 ctx =
port->secure.staticContext;
2764 BIO *b = SSL_get_rbio(ssl);
2776 auto &request = http->
request;
2789 flags.readMore =
true;
2799 request->flags.sslPeek =
true;
2802 request->flags.sslPeek =
true;
2818 if (insideConnectTunnel)
2844 debugs(83, 2,
"exception: " << ex);
2850 parseErrorDetails = d;
2863 if (details && !details->serverName.isEmpty()) {
2871 if (parseErrorDetails) {
2873 Must(context && context->http);
2875 debugs(83, 5,
"Got something other than TLS Client Hello. Cannot SslBump.");
2886 debugs(83, 5,
"server-first skips step2; start forwarding the request");
2904 if (!connState->
isOpen())
2907 debugs(33, 5,
"Answer: " << answer <<
" kind:" << answer.
kind);
2919 http->al->ssl.bumpMode = bumpAction;
2925 }
else if (!connState->
splice())
2945 Must(context->http);
2948 context->finished();
2994 BIO *b = SSL_get_rbio(ssl);
3005 const auto handshakeResult =
acceptTls();
3006 if (!handshakeResult.wantsIo())
3013 debugs(83, 5,
"Peek and splice at step2 done. Start forwarding the request!!! ");
3024 switch (handshakeResult.
category) {
3059 BIO *b = SSL_get_rbio(ssl);
3063 debugs(33, 5,
"PeekAndSplice mode, proceed with client negotiation. Current state:" << SSL_state_string_long(ssl));
3095 if (
pinning.serverConnection !=
nullptr) {
3097 connectHost =
pinning.serverConnection->remote.toStr(ip,
sizeof(ip));
3098 if (
const auto remotePort =
pinning.serverConnection->remote.port())
3099 connectPort = remotePort;
3102 connectPort = cause->
url.
port();
3118 debugs(33, 2,
"Not able to compute URL, abort request tunneling for " << reason);
3125 debugs(33, 2,
"Request tunneling for " << reason);
3138 debugs(33, 2,
"fake a CONNECT request to force connState to tunnel for " << reason);
3209 flags.readMore =
false;
3224 fatalf(
"Unable to open %s",FdNote(portType));
3258 if (s->flags.tunnelSslBumping) {
3260 debugs(33,
DBG_IMPORTANT,
"WARNING: No ssl_bump configured. Disabling ssl-bump on " << scheme <<
"_port " << s->s);
3261 s->flags.tunnelSslBumping =
false;
3263 if (!s->secure.staticContext && !s->secure.generateHostCertificates) {
3264 debugs(1,
DBG_IMPORTANT,
"Will not bump SSL at " << scheme <<
"_port " << s->s <<
" due to TLS initialization failure.");
3265 s->flags.tunnelSslBumping =
false;
3267 s->secure.encryptTransport =
false;
3269 if (s->flags.tunnelSslBumping) {
3276 if (s->secure.encryptTransport && !s->secure.staticContext) {
3277 debugs(1,
DBG_CRITICAL,
"ERROR: Ignoring " << scheme <<
"_port " << s->s <<
" due to TLS context initialization failure.");
3281 const auto protocol = s->transport.protocol;
3298 port->listenConn->flags =
3307 const auto listenCall =
3308 asyncCall(33, 2,
"clientListenerConnectionOpened",
3310 port, fdNote, sub));
3334 (s->flags.natIntercept ?
"NAT intercepted " :
"") <<
3335 (s->flags.tproxyIntercept ?
"TPROXY intercepted " :
"") <<
3336 (s->flags.tunnelSslBumping ?
"SSL bumped " :
"") <<
3337 (s->flags.accelSurrogate ?
"reverse-proxy " :
"")
3338 << FdNote(portTypeNote) <<
" connections at "
3349 const auto result = sd_notify(1,
"READY=1");
3365 fatal(
"No HTTP, HTTPS, or FTP ports configured");
3374 if (s->listenConn !=
nullptr) {
3375 debugs(1,
Important(14),
"Closing HTTP(S) port " << s->listenConn->local);
3376 s->listenConn->close();
3377 s->listenConn =
nullptr;
3398#if X_ACCELERATOR_VARY
3407 debugs(33,
DBG_IMPORTANT,
"varyEvaluateMatch: Oops. Not a Vary object on second attempt, '" <<
3449 debugs(33,
DBG_IMPORTANT,
"varyEvaluateMatch: Oops. Not a Vary match on second attempt, '" <<
3472 if (!checklist.
al && http->
al) {
3477 if (
const auto conn = http->
getConn())
3485 if (
const auto http = context ? context->http :
nullptr)
3542 const int64_t haveAvailable =
static_cast<int64_t
>(
inBuf.
length());
3544 if (needToProduce <= haveAvailable)
3547 return needToProduce - haveAvailable;
3554 "; old sending error: " <<
3558 debugs(33, 3,
"already stopped receiving: " << oldError);
3565 debugs(33, 3,
"closing because also stopped sending: " << sendError);
3593 debugs(33, 5,
"finish dechunking: " << withSuccess);
3603 if (context !=
nullptr && context->http && context->http->request)
3604 context->http->request->setContentLength(myPipe->
bodySize());
3618 context->http->al->reply = msg.
reply;
3622 debugs(33, 3,
"ignoring 1xx due to earlier closure");
3643 debugs(33, 3,
" closing due to missing context for 1xx");
3665 pinning.closeHandler =
nullptr;
3666 const bool sawZeroReply =
pinning.zeroReply;
3667 pinning.serverConnection->noteClosure();
3671 debugs(33, 3,
"Closing client connection on pinned zero reply.");
3702 pinning.serverConnection->fd == pinServer->
fd) {
3703 debugs(33, 3,
"already pinned" << pinServer);
3709 pinning.serverConnection = pinServer;
3715 const char *pinnedHost =
"[unknown]";
3723 const auto peer =
pinning.peer();
3724 snprintf(desc,
FD_DESC_SZ,
"%s pinned connection for %s (%d)",
3725 (
pinning.auth || !peer) ? pinnedHost : peer->name,
3735 Params ¶ms = GetCommParams<Params>(
pinning.closeHandler);
3736 params.conn =
pinning.serverConnection;
3745 if (
pinning.readHandler !=
nullptr)
3757 if (
pinning.readHandler !=
nullptr) {
3759 pinning.readHandler =
nullptr;
3777 const int readResult = SSL_read(ssl, buf,
sizeof(buf));
3779 if (readResult > 0 || SSL_pending(ssl) > 0) {
3780 debugs(83, 2,
pinning.serverConnection <<
" TLS application data read");
3784 switch(
const int error = SSL_get_error(ssl, readResult)) {
3785 case SSL_ERROR_WANT_WRITE:
3789 case SSL_ERROR_NONE:
3790 case SSL_ERROR_WANT_READ:
3809 pinning.readHandler =
nullptr;
3823 debugs(33, 3,
"idle pinned " <<
pinning.serverConnection <<
" read " <<
3824 io.
size << (clientIsIdle ?
" with idle client" :
""));
3826 pinning.serverConnection->close();
3841 const auto pinningError = [&](
const err_type type) {
3856 if (
pinning.serverConnection->toGoneCachePeer())
3863 return pinning.serverConnection;
3869 if (
const auto connManager = request ? request->
pinnedConnection() :
nullptr)
3870 return connManager->borrowPinnedConnection(request, ale);
3884 if (
pinning.closeHandler !=
nullptr) {
3886 pinning.closeHandler =
nullptr;
3893 pinning.serverConnection->close();
3894 pinning.serverConnection =
nullptr;
3900 pinning.peerAccessDenied =
false;
3909 auto error = rawError;
3912 if (
error.details.empty()) {
3914 error.details.push_back(d);
3925 const auto intputToConsume =
3934 context->noteIoError(
error, lte);
3935 context->finished();
3940 debugs(83, 5,
"forgetting client " << intputToConsume <<
" bytes: " <<
inBuf.
length());
3964 http.
setErrorUri(
"error:transaction-end-before-headers");
void accessLogLog(const AccessLogEntryPointer &, ACLChecklist *)
#define Assure(condition)
RefCount< AsyncCallT< Dialer > > asyncCall(int aDebugSection, int aDebugLevel, const char *aName, const Dialer &aDialer)
#define JobCallback(dbgSection, dbgLevel, Dialer, job, method)
Convenience macro to create a Dialer-based job callback.
CommCbFunPtrCallT< Dialer > * commCbCall(int debugSection, int debugLevel, const char *callName, const Dialer &dialer)
void IOACB(const CommAcceptCbParams ¶ms)
#define COMM_INTERCEPTION
ErrorDetail::Pointer MakeNamedErrorDetail(const char *name)
#define Here()
source code location of the caller
void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, int64_t)
RawPointerT< Pointer > RawPointer(const char *label, const Pointer &ptr)
convenience wrapper for creating RawPointerT<> objects
void prepareLogWithRequestDetails(HttpRequest *, const AccessLogEntryPointer &)
int HttpSockets[MAXTCPLISTENPORTS]
AnyP::PortCfgPointer HttpPortList
list of Squid http(s)_port configured
#define MAXTCPLISTENPORTS
void SBufToCstring(char *d, const SBuf &s)
#define SQUIDSBUFPRINT(s)
#define SQUIDSTRINGPRINT(s)
std::ostream & CurrentException(std::ostream &os)
prints active (i.e., thrown but not yet handled) exception
bool urlCheckRequest(const HttpRequest *r)
void error(char *format,...)
int cbdataReferenceValid(const void *p)
Acl::Answer const & fastCheck()
void changeAcl(const acl_access *)
change the current ACL list
static MakingPointer Make(const acl_access *a, HttpRequest *r)
err_type requestErrorType
std::unique_ptr< ACLFilledChecklist > MakingPointer
ConnStateData * conn() const
The client connection manager.
void setRequest(HttpRequest *)
configure client request-related fields for the first time
void setConn(ConnStateData *)
set either conn
void updateAle(const AccessLogEntry::Pointer &)
static void NonBlockingCheck(MakingPointer &&p, ACLCB *cb, void *data)
CbcPointer< Security::CertErrors > sslErrors
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
void syncAle(HttpRequest *adaptedRequest, const char *logUri) const override
assigns uninitialized adapted_request and url ALE components
HttpRequest::Pointer request
char * last_meta
image of the last ICAP response header or eCAP meta received
struct timeval start_time
The time the master transaction started.
struct timeval trTime
The response time.
MessageSizes clientReplySz
counters for the response sent to client
const char * content_type
MessageSizes clientRequestSz
counters for the original request received from client
AnyP::ProtocolVersion version
struct timeval processingTime
total ICAP processing time
class AccessLogEntry::CacheDetails cache
void syncNotes(HttpRequest *request)
class AccessLogEntry::IcapLogEntry icap
class AccessLogEntry::Headers headers
class AccessLogEntry::HttpDetails http
HttpRequest * adapted_request
class AccessLogEntry::AdaptationDetails adapt
class AccessLogEntry::IcpDetails icp
int kind
the matched custom access list verb (or zero)
HttpHeader lastMeta
Last received meta header (REQMOD or RESPMOD, whichever comes last).
unsigned int major
major version number
ProtocolType protocol
which protocol this version is for
unsigned int minor
minor version number
void setScheme(const AnyP::ProtocolType &p, const char *str)
convert the URL scheme to that given
std::optional< Host > parsedHost() const
void port(const Port p)
reset authority port subcomponent
void host(const char *src)
a smart AsyncCall pointer for delivery of future results
static void Start(const Pointer &job)
virtual void start()
called by AsyncStart; do not call directly
void mustStop(const char *aReason)
void deleteThis(const char *aReason)
virtual void callException(const std::exception &e)
called when the job throws during an async call
virtual void releaseAuthServer()
uint64_t producedSize() const
void expectNoConsumption()
there will be no more setConsumer() calls
size_t putMoreData(const char *buf, size_t size)
const MemBuf & buf() const
bool bodySizeKnown() const
uint64_t unproducedSize() const
void setBodySize(uint64_t aSize)
const char * status() const
bool productionEnded() const
bool mayNeedMoreData() const
uint64_t bodySize() const
void enableAutoConsumption()
start or continue consuming when producing without consumer
void stopProducingFor(RefCount< BodyPipe > &, bool atEof)
optimized set of C chars, with quick membership test and merge support
static const CharacterSet DIGIT
static const CharacterSet ALPHA
static const CharacterSet HEXDIG
std::vector< ClientDelayPool::Pointer > pools
static ClientDelayPools * Instance()
struct ClientHttpRequest::Out out
void clearRequest()
resets the current request and log_uri to nil
HttpRequest *const request
int64_t mRangeCLen() const
ConnStateData * getConn() const
String rangeBoundaryStr() const
void initRequest(HttpRequest *)
void checkForInternalAccess()
Checks whether the current request is internal and adjusts it accordingly.
void updateError(const Error &)
if necessary, stores new error information (if any)
MemObject * memObject() const
size_t req_sz
raw request size on input, not current request size
void setErrorUri(const char *)
HttpHdrRangeIter range_iter
struct ClientHttpRequest::Flags flags
bool multipartRangeRequest() const
StoreEntry * storeEntry() const
ClientRequestContext * calloutContext
const LogTags & loggingTags() const
the processing tags associated with this request transaction.
const AccessLogEntry::Pointer al
access.log entry
StoreEntry * loggingEntry() const
struct ClientHttpRequest::Redirect redirect
void setWriteLimiter(const int aWriteSpeedLimit, const double anInitialBurst, const double aHighWatermark)
static const Pointer & Current()
static void Reset()
forgets the current context, setting it to nil/unknown
AnyP::PortCfgPointer port
the configuration listening port this call relates to (may be nil)
int xerrno
The last errno to occur. non-zero if flag is Comm::COMM_ERROR.
int fd
FD which the call was about. Set by the async call creator.
Comm::Flag flag
comm layer result status.
Comm::ConnectionPointer conn
time_t timeLeft(const time_t idleTimeout) const
Security::NegotiationHistory * tlsNegotiations()
parameters for the async notePinnedConnectionBecameIdle() call
Comm::ConnectionPointer connection
to-server connection to be pinned
HttpRequest::Pointer request
to-server request that initiated serverConnection
noteTakeServerConnectionControl() callback parameter
Comm::ConnectionPointer conn_
to-server connection
SBuf preReadServerBytes
post-101 bytes received from the server
virtual int pipelinePrefetchMax() const
returning N allows a pipeline of 1+N requests (see pipeline_prefetch)
void postHttpsAccept()
the second part of old httpsAccept, waiting for future HttpsServer home
Ssl::ServerBump * serverBump()
void endingShutdown() override
struct ConnStateData::@29 pinning
bool fakeAConnectRequest(const char *reason, const SBuf &payload)
bool switchedToHttps() const
void readNextRequest()
Traffic parsing.
virtual void clientPinnedConnectionClosed(const CommCloseCbParams &io)
Our close handler called by Comm when the pinned connection is closed.
char * prepareTlsSwitchingURL(const Http1::RequestParserPointer &hp)
Security::KeyLogger keyLogger
managers logging of the being-accepted TLS connection secrets
void afterClientRead() override
processing to be done after a Comm::Read()
Ssl::ServerBump * sslServerBump
HTTPS server cert. fetching state for bump-ssl-server-first.
Http::Stream * parseHttpRequest(const Http1::RequestParserPointer &)
virtual bool writeControlMsgAndCall(HttpReply *rep, AsyncCall::Pointer &call)=0
handle a control message received by context from a peer and call back
void switchToHttps(ClientHttpRequest *, Ssl::BumpMode bumpServerMode)
void startPinnedConnectionMonitoring()
const char * stoppedReceiving() const
true if we stopped receiving the request
void consumeInput(const size_t byteCount)
remove no longer needed leading bytes from the input buffer
void clientAfterReadingRequests()
ClientHttpRequest * buildFakeRequest(SBuf &useHost, AnyP::KnownPort usePort, const SBuf &payload)
build a fake http request
virtual void handleReply(HttpReply *header, StoreIOBuffer receivedData)=0
void setAuth(const Auth::UserRequest::Pointer &aur, const char *cause)
virtual Http::Stream * parseOneRequest()=0
BodyPipe::Pointer bodyPipe
set when we are reading request body
const SBuf & tlsClientSni() const
void sendControlMsg(HttpControlMsg) override
called to send the 1xx message and notify the Source
void kick()
try to make progress on a transaction or read more I/O
const Auth::UserRequest::Pointer & getAuth() const
void getSslContextStart()
Start to create dynamic Security::ContextPointer for host or uses static port SSL context.
void httpsPeeked(PinnedIdleContext pic)
called by FwdState when it is done bumping the server
bool initiateTunneledRequest(HttpRequest::Pointer const &cause, const char *reason, const SBuf &payload)
generates and sends to tunnel.cc a fake request with a given payload
bool splice()
Splice a bumped client connection on peek-and-splice mode.
void start() override
called by AsyncStart; do not call directly
SBuf tlsClientSni_
TLS client delivered SNI value. Empty string if none has been received.
Error bareError
a problem that occurred without a request (e.g., while parsing headers)
bool handleReadData() override
void expectNoForwarding()
cleans up virgin request [body] forwarding state
Http::Stream * abortRequestParsing(const char *const errUri)
stop parsing the request and create context for relaying error info
void startShutdown() override
void sslCrtdHandleReply(const Helper::Reply &reply)
Process response from ssl_crtd.
err_type handleChunkedRequestBody()
parses available chunked encoded body bytes, checks size, returns errors
SBuf sslCommonName_
CN name for SSL certificate generation.
void resetSslCommonName(const char *name)
void afterClientWrite(size_t) override
processing to sync state after a Comm::Write()
void doneWithControlMsg() override
void terminateAll(const Error &, const LogTagsErrors &) override
abort any pending transactions and prevent new ones (by closing)
void abortChunkedRequestBody(const err_type error)
quit on errors related to chunked request body handling
void pinConnection(const Comm::ConnectionPointer &pinServerConn, const HttpRequest &request)
Forward future client requests using the given server connection.
bool preservingClientData_
whether preservedClientData is valid and should be kept up to date
void callException(const std::exception &) override
called when the job throws during an async call
static void sslCrtdHandleReplyWrapper(void *data, const Helper::Reply &reply)
Callback function. It is called when squid receive message from ssl_crtd.
void lifetimeTimeout(const CommTimeoutCbParams ¶ms)
Ssl::CertSignAlgorithm signAlgorithm
The signing algorithm to use.
Security::ContextPointer getTlsContextFromCache(const SBuf &cacheKey, const Ssl::CertificateProperties &certProperties)
AnyP::Port tlsConnectPort
The TLS server port number as passed in the CONNECT request.
struct ConnStateData::@28 flags
Auth::UserRequest::Pointer auth_
some user details that can be used to perform authentication on this connection
Comm::ConnectionPointer borrowPinnedConnection(HttpRequest *, const AccessLogEntryPointer &)
ConnStateData-specific part of BorrowPinnedConnection()
bool shouldPreserveClientData() const
void notePinnedConnectionBecameIdle(PinnedIdleContext pic)
Called when a pinned connection becomes available for forwarding the next request.
void stopPinnedConnectionMonitoring()
The caller assumes responsibility for connection closure detection.
void pinBusyConnection(const Comm::ConnectionPointer &pinServerConn, const HttpRequest::Pointer &request)
bool handleIdleClientPinnedTlsRead()
bool proxyProtocolError(const char *reason)
bool serveDelayedError(Http::Stream *)
const char * stoppedSending_
the reason why we no longer write the response or nil
void resetReadTimeout(time_t timeout)
(re)sets timeout for receiving more bytes from the client
void quitAfterError(HttpRequest *request)
SBuf tlsConnectHostOrIp
The TLS server host name appears in CONNECT request or the server ip address for the intercepted requ...
~ConnStateData() override
void receivedFirstByte() override
Update flags and timeout after the first byte received.
uint64_t parsedBumpedRequestCount
The number of parsed HTTP requests headers on a bumped client connection.
Security::IoResult acceptTls()
BodyPipe::Pointer expectRequestBody(int64_t size)
void clientPinnedConnectionRead(const CommIoCbParams &io)
static Comm::ConnectionPointer BorrowPinnedConnection(HttpRequest *, const AccessLogEntryPointer &)
void stopReceiving(const char *error)
note request receiving error and close as soon as we write the response
void checkLogging()
log the last (attempt at) transaction if nobody else did
void unpinConnection(const bool andClose)
Undo pinConnection() and, optionally, close the pinned connection.
void handleSslBumpHandshakeError(const Security::IoResult &)
process a problematic Security::Accept() result on the SslBump code path
void startDechunkingRequest()
initialize dechunking state
void startPeekAndSplice()
Initializes and starts a peek-and-splice negotiation with the SSL client.
Ssl::BumpMode sslBumpMode
ssl_bump decision (Ssl::bumpEnd if n/a).
bool concurrentRequestQueueFilled() const
bool readMore
needs comm_read (for this request or new requests)
ConnStateData(const MasterXactionPointer &xact)
void extendLifetime()
(re)sets client_lifetime timeout
ProxyProtocol::HeaderPointer proxyProtocolHeader_
the parsed PROXY protocol header
bool shouldCloseOnEof() const override
whether to stop serving our client after reading EOF on its connection
void fillChecklist(ACLFilledChecklist &) const override
configure the given checklist (to reflect the current transaction state)
void requestTimeout(const CommTimeoutCbParams ¶ms)
virtual time_t idleTimeout() const =0
timeout to use when waiting for the next request
void finishDechunkingRequest(bool withSuccess)
put parsed content into input buffer and clean up
virtual void processParsedRequest(Http::StreamPointer &)=0
start processing a freshly parsed request
void getSslContextDone(Security::ContextPointer &)
finish configuring the newly created SSL context"
bool parseProxyProtocolHeader()
AnyP::Port port
destination port of the request that caused serverConnection
bool handleRequestBodyData()
void updateError(const Error &)
if necessary, stores new error information (if any)
void doPeekAndSpliceStep()
const char * stoppedReceiving_
the reason why we no longer read the request or nil
bool needProxyProtocolHeader_
whether PROXY protocol header is still expected
void noteBodyConsumerAborted(BodyPipe::Pointer) override=0
bool tunnelOnError(const err_type)
initiate tunneling if possible or return false otherwise
void stopSending(const char *error)
note response sending error and close as soon as we read the request
int64_t mayNeedToReadMoreBody() const
char * host
host name of pinned connection
Security::HandshakeParser tlsParser
void storeTlsContextToCache(const SBuf &cacheKey, Security::ContextPointer &ctx)
const char * stoppedSending() const
true if we stopped sending the response
SBuf sslBumpCertKey
Key to use to store/retrieve generated certificate.
NotePairs::Pointer notes()
Http1::TeChunkedParser * bodyParser
parses HTTP/1.1 chunked request body
void fillConnectionLevelDetails(ACLFilledChecklist &) const
NotePairs::Pointer theNotes
void connStateClosed(const CommCloseCbParams &io)
bool proxyProtocolValidateClient()
void add(const Http::StreamPointer &context)
registers a newly created stream
void buildSslCertGenerationParams(Ssl::CertificateProperties &certProperties)
static bool Enabled(const int section, const int level)
whether debugging the given section and the given level produces output
static std::ostream & Extra(std::ostream &)
static ErrorState * NewForwarding(err_type, HttpRequestPointer &, const AccessLogEntryPointer &)
Creates a general request forwarding error with the right http_status.
void update(const Error &)
if necessary, stores the given error information (if any)
void clear()
switch to the default "no error information" state
static void Start(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
Initiates request forwarding to a peer or origin server.
Helper::ResultCode result
The helper response 'result' field.
const MemBuf & other() const
AsyncCall::Pointer cbControlMsgSent
Call to schedule when the control msg has been sent.
void wroteControlMsg(const CommIoCbParams &)
callback to handle Comm::Write completion
virtual void doneWithControlMsg()
bundles HTTP 1xx reply and the "successfully forwarded" callback
Callback cbSuccess
called after successfully writing the 1xx message
HttpReply::Pointer reply
the 1xx message being forwarded
std::vector< HttpHdrRangeSpec * >::iterator iterator
bool multipartRangeRequest() const
NotePairs::Pointer notes()
SBuf vary_headers
The variant second-stage cache key. Generated from Vary header pattern for this request.
ConnStateData * pinnedConnection()
int dnsWait
sum of DNS lookup delays in milliseconds, for dt
Adaptation::History::Pointer adaptLogHistory() const
Returns possibly nil history, creating it if adapt. logging is enabled.
Auth::UserRequest::Pointer auth_user_request
Http::StatusCode checkEntityFraming() const
Error error
the first transaction problem encountered (or falsy)
Adaptation::Icap::History::Pointer icapHistory() const
Returns possibly nil history, creating it if icap logging is enabled.
AnyP::Uri url
the request URI
void manager(const CbcPointer< ConnStateData > &aMgr, const AccessLogEntryPointer &al)
associates the request with a from-client connection manager
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
@ srcHttp
http_port or HTTP server
@ srcHttps
https_port or bumped http_port tunnel; HTTPS server
@ srcFtp
ftp_port or FTP server
uint32_t sources
The message sources.
BodyPipe::Pointer body_pipe
optional pipeline to receive message body
AnyP::ProtocolVersion http_ver
const SBuf & remaining() const
the remaining unprocessed section of buffer
bool needsMoreData() const
bool parse(const SBuf &) override
bool needsMoreSpace() const
void setPayloadBuffer(MemBuf *parsedContent)
set the buffer to be used to store decoded chunk data
unsigned parsed_ok
Was this parsed correctly?
void registerWithConn()
register this stream with the Server
struct Http::Stream::@58 flags
char reqbuf[HTTP_REQBUF_SZ]
clientStreamNode * getClientReplyContext() const
bool mayUseConnection() const
void pullData()
get more data to send
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
unsigned int toHostStr(char *buf, const unsigned int len) const
void applyClientMask(const Address &mask)
char * toUrl(char *buf, unsigned int len) const
unsigned short port() const
dials clientListenerConnectionOpened call
Subscription::Pointer sub
The handler to be subscribed for this connection listener.
ListeningStartedDialer(Handler aHandler, AnyP::PortCfgPointer &aPortCfg, const Ipc::FdNoteId note, const Subscription::Pointer &aSub)
AnyP::PortCfgPointer portCfg
from HttpPortList
Ipc::StartListeningAnswer & answer() override
callback results setter
void print(std::ostream &os) const override
virtual void dial(AsyncCall &)
void(* Handler)(AnyP::PortCfgPointer &portCfg, const Ipc::FdNoteId note, const Subscription::Pointer &sub)
Ipc::FdNoteId portTypeNote
Type of IPC socket being opened.
Ipc::StartListeningAnswer answer_
StartListening() results.
virtual bool canDial(AsyncCall &) const
Comm::ConnectionPointer tcpClient
the client TCP connection which originated this transaction
static Pointer MakePortful(const AnyP::PortCfgPointer &aPort)
void append(const char *c, int sz) override
void init(mb_size_t szInit, mb_size_t szMax)
char * content()
start of the added data
mb_size_t contentSize() const
available data size
const char * urlXXX() const
const HttpReply & freshestReply() const
uint64_t payloadData
total size of payload block(s) excluding transfer encoding overheads
void add(const SBuf &key, const SBuf &value)
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
bool empty() const
whether there are none or any requests currently pipelined
size_t count() const
how many requests are currently pipelined
Http::StreamPointer front() const
get the first request context in the pipeline
void add(const Http::StreamPointer &)
register a new request context to the pipeline
Http::StreamPointer back() const
get the last request context in the pipeline
bool forceTunnel
whether to forward via TunnelStateData (instead of FwdState)
const char * rawContent() const
static const size_type npos
SBuf consume(size_type n=npos)
SBuf & chop(size_type pos, size_type n=npos)
size_type length() const
Returns the number of bytes stored in SBuf.
SBuf & appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
size_type rfind(char c, size_type endPos=npos) const
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
SBuf & append(const SBuf &S)
const_reverse_iterator rbegin() const
SBuf & assign(const SBuf &S)
TlsDetails::Pointer details
TLS handshake meta info. Never nil.
bool parseHello(const SBuf &data)
a summary a TLS I/O operation outcome
ErrorDetailPointer errorDetail
ioError case details (or nil)
Category category
primary outcome classification
bool important
whether the error was serious/unusual
void checkpoint(const Connection &, const Acl::ChecklistFiller &)
T * get() const
Returns raw and possibly nullptr pointer.
void retrieveParsedInfo(Security::TlsDetails::Pointer const &details)
Extract information from parser stored in TlsDetails object.
void retrieveNegotiatedInfo(const Security::SessionPointer &)
Extract negotiation information from TLS object.
void readSomeData()
maybe grow the inBuf and schedule Comm::Read()
Pipeline pipeline
set of requests waiting to be serviced
AnyP::ProtocolVersion transferProtocol
Comm::ConnectionPointer clientConnection
bool receivedFirstByte_
true if at least one byte received on this connection
SBuf inBuf
read I/O buffer for the client connection
time_t request_start_timeout
struct SquidConfig::@99 ssl_client
sslproxy_cert_adapt * cert_adapt
ClientDelayConfig ClientDelay
int64_t maxRequestBodySize
struct SquidConfig::@77 Timeout
sslproxy_cert_sign * cert_sign
struct SquidConfig::@85 Addrs
struct SquidConfig::@90 onoff
acl_access * stats_collection
size_t maxRequestHeaderSize
acl_access * on_unsupported_protocol
Ip::Address client_netmask
struct SquidConfig::@91 accessList
int pipeline_max_prefetch
acl_access * proxyProtocol
acceptable PROXY protocol clients
Security::PrivateKeyPointer signWithPkey
The key of the signing certificate.
Security::CertPointer signWithX509
Certificate to sign the generated request.
bool setCommonName
Replace the CN field of the mimicking subject with the given.
bool setValidAfter
Do not mimic "Not Valid After" field.
CertSignAlgorithm signAlgorithm
The signing algorithm to use.
bool setValidBefore
Do not mimic "Not Valid Before" field.
Security::CertPointer mimicCert
Certificate to mimic.
const EVP_MD * signHash
The signing hash to use.
std::string commonName
A CN to use for the generated certificate.
void setReadBufData(SBuf &data)
void hold(bool h)
Prevents or allow writing on socket.
void setCode(std::string const &aCode)
Set new request/reply code to compose.
static const std::string code_new_certificate
String code for "new_certificate" messages.
std::string const & getBody() const
Current body. If parsing is not finished the method returns incompleted body.
ParseResult parse(const char *buffer, size_t len)
void composeRequest(Ssl::CertificateProperties const &)
std::string compose() const
void addLocalStorage(Ip::Address const &address, size_t size_of_store)
Create new SSL context storage for the local listening address/port.
LocalContextStorage * getLocalStorage(Ip::Address const &address)
Return the local storage for the given listening address/port.
static void Submit(CrtdMessage const &message, HLPCB *callback, void *data)
Submit crtd message to external crtd server.
struct Ssl::ServerBump::@103 act
bumping actions at various bumping steps
bool at(const BumpStep stp) const
whether we are currently performing the given processing step
Security::CertErrors * sslErrors() const
SSL [certificate validation] errors.
Ssl::BumpMode step2
The SSL bump mode at step2.
Ssl::BumpMode step1
The SSL bump mode at step1.
Ssl::BumpStep step
The SSL bumping step.
HttpRequest::Pointer request
faked, minimal request; required by Client API
bool connectedOk() const
whether there was a successful connection to (and peeking at) the origin server
Security::CertPointer serverCert
struct StatCounters::@111 netdb
struct StatCounters::@110 cd
ByteCounter hit_kbytes_out
struct StatCounters::@106 icp
struct StatCounters::@104 client_http
const char * getMD5Text() const
int64_t contentLen() const
char const * termedBuf() const
void append(char const *buf, int len)
an std::runtime_error with thrower location info
SourceLocationId id() const
same-location exceptions have the same ID
access to a callback result carried by an asynchronous CallDialer
void setReplyToStoreEntry(StoreEntry *e, const char *reason)
replaces current response store entry with the given one
void setReplyToError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const char *, Auth::UserRequest::Pointer)
builds error using clientBuildError() and calls setReplyToError() below
ICP probing of cache_peers during peer selection.
int clientdbEstablished(const Ip::Address &addr, int delta)
void clientdbUpdate(const Ip::Address &addr, const LogTags <ype, AnyP::ProtocolType p, size_t size)
ClientInfo * clientdbGetInfo(const Ip::Address &addr)
static void clientListenerConnectionOpened(AnyP::PortCfgPointer &s, const Ipc::FdNoteId portTypeNote, const Subscription::Pointer &sub)
process clientHttpConnectionsOpen result
static void clientUpdateStatHistCounters(const LogTags &logType, int svc_time)
static char * prepareTransparentURL(ConnStateData *conn, const Http1::RequestParserPointer &hp)
static void clientHttpConnectionsOpen(void)
const char * findTrailingHTTPVersion(const char *uriAndHTTPVersion, const char *end)
static bool clientPingHasFinished(ping_data const *aPing)
static void httpsEstablish(ConnStateData *connState, const Security::ContextPointer &ctx)
void prepareLogWithRequestDetails(HttpRequest *, const AccessLogEntryPointer &)
void clientProcessRequestFinished(ConnStateData *conn, const HttpRequest::Pointer &request)
static void httpsSslBumpAccessCheckDone(Acl::Answer answer, void *data)
void clientOpenListenSockets(void)
void clientProcessRequest(ConnStateData *conn, const Http1::RequestParserPointer &hp, Http::Stream *context)
static bool httpsCreate(const ConnStateData *connState, const Security::ContextPointer &ctx)
Create TLS connection structure and update fd_table.
static bool OpenedHttpSocket(const Comm::ConnectionPointer &c, const Ipc::FdNoteId portType)
check FD after clientHttp[s]ConnectionOpened, adjust HttpSockets as needed
static void clientNegotiateSSL(int fd, void *data)
static char * buildUrlFromHost(ConnStateData *conn, const Http1::RequestParserPointer &hp)
static int clientIsRequestBodyTooLargeForPolicy(int64_t bodyLength)
void httpRequestFree(void *data)
static bool AddOpenedHttpSocket(const Comm::ConnectionPointer &conn)
find any unused HttpSockets[] slot and store fd there or return false
static void httpsAccept(const CommAcceptCbParams ¶ms)
static void clientUpdateHierCounters(HierarchyLogEntry *)
ACLFilledChecklist::MakingPointer clientAclChecklistCreate(const acl_access *acl, ClientHttpRequest *http)
void clientSetKeepaliveFlag(ClientHttpRequest *http)
decide whether to expect multiple requests on the corresponding connection
void clientPackTermBound(String boundary, MemBuf *mb)
put terminating boundary for multiparts to the buffer
static char * prepareAcceleratedURL(ConnStateData *conn, const Http1::RequestParserPointer &hp)
static void ClientSocketContextPushDeferredIfNeeded(Http::StreamPointer deferredRequest, ConnStateData *conn)
char * skipLeadingSpace(char *aString)
int varyEvaluateMatch(StoreEntry *entry, HttpRequest *request)
static void clientUpdateStatCounters(const LogTags &logType)
std::ostream & operator<<(std::ostream &os, const ConnStateData::PinnedIdleContext &pic)
void clientAclChecklistFill(ACLFilledChecklist &checklist, ClientHttpRequest *http)
static void httpsSslBumpStep2AccessCheckDone(Acl::Answer answer, void *data)
void clientStartListeningOn(AnyP::PortCfgPointer &port, const RefCount< CommCbFunPtrCallT< CommAcceptCbPtrFun > > &subCall, const Ipc::FdNoteId fdNote)
accept requests to a given port and inform subCall about them
void clientConnectionsClose()
void clientPackRangeHdr(const HttpReplyPointer &rep, const HttpHdrRangeSpec *spec, String boundary, MemBuf *mb)
append a "part" HTTP header (as in a multi-part/range reply) to the buffer
void clientProcessRequestFinished(ConnStateData *, const HttpRequest::Pointer &)
CSCB clientSocketRecipient
AsyncCall::Pointer comm_add_close_handler(int fd, CLCB *handler, void *data)
void comm_remove_close_handler(int fd, CLCB *handler, void *data)
void commSetConnTimeout(const Comm::ConnectionPointer &conn, time_t timeout, AsyncCall::Pointer &callback)
void comm_reset_close(const Comm::ConnectionPointer &conn)
bool commIsHalfClosed(int fd)
#define debugs(SECTION, LEVEL, CONTENT)
#define FQDN_LOOKUP_IF_MISS
#define COMM_SELECT_WRITE
@ ERR_SECURE_CONNECT_FAIL
@ ERR_REQUEST_PARSE_TIMEOUT
@ ERR_REQUEST_START_TIMEOUT
void fatal(const char *message)
void fatalf(const char *fmt,...)
void fd_note(int fd, const char *s)
char const * visible_appname_string
void clientStreamAbort(clientStreamNode *thisObject, ClientHttpRequest *http)
void clientStreamInit(dlink_list *list, CSR *func, CSD *rdetach, CSS *readstatus, const ClientStreamData &readdata, CSCB *callback, CSD *cdetach, const ClientStreamData &callbackdata, StoreIOBuffer tailBuffer)
void clientStreamDetach(clientStreamNode *thisObject, ClientHttpRequest *http)
const char * fqdncache_gethostbyaddr(const Ip::Address &addr, int flags)
Security::ContextPointer GenerateSslContext(CertificateProperties const &, Security::ServerOptions &, bool trusted)
const char * bumpMode(int bm)
bool configureSSL(SSL *ssl, CertificateProperties const &properties, AnyP::PortCfg &port)
void InRamCertificateDbKey(const Ssl::CertificateProperties &certProperties, SBuf &key)
Security::ContextPointer createSSLContext(Security::CertPointer &x509, Security::PrivateKeyPointer &pkey, Security::ServerOptions &)
Create SSL context and apply ssl certificate and private key to it.
bool verifySslCertificate(const Security::ContextPointer &, CertificateProperties const &)
bool configureSSLUsingPkeyAndCertFromMemory(SSL *ssl, const char *data, AnyP::PortCfg &port)
Security::ContextPointer GenerateSslContextUsingPkeyAndCertFromMemory(const char *data, Security::ServerOptions &, bool trusted)
void configureUnconfiguredSslContext(Security::ContextPointer &, Ssl::CertSignAlgorithm signAlgorithm, AnyP::PortCfg &)
const char * sslGetUserEmail(SSL *ssl)
const char * CertAdaptAlgorithmStr[]
void HTTPMSGUNLOCK(M *&a)
void HTTPMSGLOCK(Http::Message *a)
SBuf httpMakeVaryMark(HttpRequest *request, HttpReply const *reply)
char * internalLocalUri(const char *dir, const SBuf &name)
bool internalCheck(const SBuf &urlPath)
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
std::optional< KnownPort > Port
validated/supported port number (if any)
uint16_t KnownPort
validated/supported port number; these values are never zero
void ReadCancel(int fd, AsyncCall::Pointer &callback)
Cancel the read pending on FD. No action if none pending.
void ResetSelect(int fd)
reset/undo/unregister the watch for an FD which was set by Comm::SetSelect()
void Read(const Comm::ConnectionPointer &conn, AsyncCall::Pointer &callback)
bool IsConnOpen(const Comm::ConnectionPointer &conn)
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
bool ResolveClientAddressesAsap
whether to do reverse DNS lookups for source IPs of accepted connections
void StopListening()
reject new connections to any configured ftp_port
void StartListening()
accept connections on all configured ftp_ports
@ scRequestHeaderFieldsTooLarge
ConnStateData * NewServer(const MasterXactionPointer &xact)
create a new HTTP connection handler; never returns NULL
AnyP::ProtocolVersion ProtocolVersion()
ConnStateData * NewServer(const MasterXactionPointer &xact)
create a new HTTPS connection handler; never returns NULL
FdNoteId
We cannot send char* FD notes to other processes. Pass int IDs and convert.
void StartListening(int sock_type, int proto, const Comm::ConnectionPointer &listenConn, FdNoteId, StartListeningCallback &)
Parsed Parse(const SBuf &)
Network/connection security abstraction layer.
SBuf IssuerName(Certificate &)
The Issuer field of the given certificate (if found) or an empty SBuf.
std::shared_ptr< SSL_CTX > ContextPointer
bool CreateServerSession(const Security::ContextPointer &, const Comm::ConnectionPointer &, Security::PeerOptions &, const char *squidCtx)
IoResult Accept(Comm::Connection &transport)
accept a TLS connection over the specified to-Squid transport connection
std::shared_ptr< SSL > SessionPointer
bool SessionIsResumed(const Security::SessionPointer &)
whether the session is a resumed one
SBuf SubjectName(Certificate &)
The SubjectName field of the given certificate (if found) or an empty SBuf.
Security::ContextPointer GetFrom(Security::SessionPointer &s)
Helper function to retrieve a (non-locked) ContextPointer from a SessionPointer.
bool HasSubjectName(X509 &, const AnyP::Host &)
whether at least one common or alternate subject name matches the given one
GlobalContextStorage & TheGlobalContextStorage()
Global cache for store all SSL server certificates.
const EVP_MD * DefaultSignHash
void * BIO_get_data(BIO *table)
@ SQUID_X509_V_ERR_DOMAIN_MISMATCH
int xsetsockopt(int socketFd, int level, int option, const void *value, socklen_t valueLength)
POSIX setsockopt(2) equivalent.
size_t headers_sz
Response header bytes written to the client connection.
uint64_t size
Response header and body bytes written to the client connection.
void tvSub(struct timeval &res, struct timeval const &t1, struct timeval const &t2)
int tvSubUsec(struct timeval t1, struct timeval t2)
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
int tvSubMsec(struct timeval t1, struct timeval t2)
void * xcalloc(size_t n, size_t sz)
const char * xstrerr(int error)