debugs(33, 2, HERE << "sslBump not needed for " << connState->clientConnection);
connState->sslBumpMode = Ssl::bumpNone;
}
-
- // fake a CONNECT request to force connState to tunnel
- static char ip[MAX_IPSTRLEN];
- connState->clientConnection->local.toUrl(ip, sizeof(ip));
- // Pre-pend this fake request to the TLS bits already in the buffer
- SBuf retStr;
- retStr.append("CONNECT ").append(ip).append(" HTTP/1.1\r\nHost: ").append(ip).append("\r\n\r\n");
- connState->in.buf = retStr.append(connState->in.buf);
- bool ret = connState->handleReadData();
- if (ret)
- ret = connState->clientParseRequests();
-
- if (!ret) {
- debugs(33, 2, "Failed to start fake CONNECT request for SSL bumped connection: " << connState->clientConnection);
- connState->clientConnection->close();
- }
+ connState->fakeAConnectRequest("ssl-bump", connState->in.buf);
}
/** handle a new HTTPS connection */
if (connState->transparent()) {
// fake a CONNECT request to force connState to tunnel
- static char ip[MAX_IPSTRLEN];
- connState->clientConnection->local.toUrl(ip, sizeof(ip));
- connState->in.buf.assign("CONNECT ").append(ip).append(" HTTP/1.1\r\nHost: ").append(ip).append("\r\n\r\n").append(rbuf.content(), rbuf.contentSize());
- bool ret = connState->handleReadData();
- if (ret)
- ret = connState->clientParseRequests();
-
- if (!ret) {
- debugs(33, 2, "Failed to start fake CONNECT request for ssl spliced connection: " << connState->clientConnection);
- connState->clientConnection->close();
- }
+ // XXX: copy from MemBuf reallocates, not a regression since old code did too
+ SBuf temp;
+ temp.append(rbuf.content(), rbuf.contentSize());
+ connState->fakeAConnectRequest("intercepted TLS spliced", temp);
} else {
// in.buf still has the "CONNECT ..." request data, reset it to SSL hello message
connState->in.buf.append(rbuf.content(), rbuf.contentSize());
#endif /* USE_OPENSSL */
+void
+ConnStateData::fakeAConnectRequest(const char *reason, const SBuf &payload)
+{
+ // fake a CONNECT request to force connState to tunnel
+ static char ip[MAX_IPSTRLEN];
+ clientConnection->local.toUrl(ip, sizeof(ip));
+ // Pre-pend this fake request to the TLS bits already in the buffer
+ SBuf retStr;
+ retStr.append("CONNECT ");
+ retStr.append(ip);
+ retStr.append(" HTTP/1.1\r\nHost: ");
+ retStr.append(ip);
+ retStr.append("\r\n\r\n");
+ retStr.append(payload);
+ in.buf = retStr;
+ bool ret = handleReadData();
+ if (ret)
+ ret = clientParseRequests();
+
+ if (!ret) {
+ debugs(33, 2, "Failed to start fake CONNECT request for " << reason << " connection: " << clientConnection);
+ clientConnection->close();
+ }
+}
+
/// check FD after clientHttp[s]ConnectionOpened, adjust HttpSockets as needed
static bool
OpenedHttpSocket(const Comm::ConnectionPointer &c, const Ipc::FdNoteId portType)