Inheritance diagram for TunnelStateData:
Collaboration diagram for TunnelStateData:


class  Connection
class  MyAnswerDialer
 Gives Security::PeerConnector access to Answer in the TunnelStateData callback dialer. More...

Public Member Functions

 TunnelStateData (ClientHttpRequest *)
virtual ~TunnelStateData ()
 TunnelStateData (const TunnelStateData &)
TunnelStateDataoperator= (const TunnelStateData &)
bool noConnections () const
void closeConnections ()
 closes both client and server connections More...
const char * getHost () const
bool clientExpectsConnectResponse () const
 Whether the client sent a CONNECT request to us. More...
void startConnecting ()
void closePendingConnection (const Comm::ConnectionPointer &conn, const char *reason)
void notePeerReadyToShovel (const Comm::ConnectionPointer &)
 called when negotiations with the peer have been successfully completed More...
void copyRead (Connection &from, IOCB *completion)
void connectToPeer (const Comm::ConnectionPointer &)
 continue to set up connection to a peer, going async for SSL peers More...
void secureConnectionToPeer (const Comm::ConnectionPointer &)
 encrypts an established TCP connection to peer More...
virtual void noteDestination (Comm::ConnectionPointer conn) override
 called when a new unique destination has been found More...
virtual void noteDestinationsEnd (ErrorState *selectionError) override
void syncHierNote (const Comm::ConnectionPointer &server, const char *origin)
void noteConnection (HappyConnOpenerAnswer &)
bool opening () const
void cancelOpening (const char *reason)
void connectDone (const Comm::ConnectionPointer &conn, const char *origin, const bool reused)
 Start using an established connection. More...
void notifyConnOpener ()
 makes sure connOpener knows that destinations have changed More...
void saveError (ErrorState *finalError)
 remembers an error to be used if there will be no more connection attempts More...
void sendError (ErrorState *finalError, const char *reason)
bool keepGoingAfterRead (size_t len, Comm::Flag errcode, int xerrno, Connection &from, Connection &to)
void copy (size_t len, Connection &from, Connection &to, IOCB *)
void readServer (char *buf, size_t len, Comm::Flag errcode, int xerrno)
void readClient (char *buf, size_t len, Comm::Flag errcode, int xerrno)
void writeClientDone (char *buf, size_t len, Comm::Flag flag, int xerrno)
void writeServerDone (char *buf, size_t len, Comm::Flag flag, int xerrno)
void copyClientBytes ()
void copyServerBytes ()
void clientClosed ()
 handles client-to-Squid connection closure; may destroy us More...
void serverClosed ()
 handles Squid-to-server connection closure; may destroy us More...
void retryOrBail (const char *context)
void startSelectingDestinations (HttpRequest *request, const AccessLogEntry::Pointer &ale, StoreEntry *entry)
virtual void * toCbdata ()=0

Static Public Member Functions

static void ReadClient (const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag errcode, int xerrno, void *data)
static void ReadServer (const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag errcode, int xerrno, void *data)
static void WriteClientDone (const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data)
static void WriteServerDone (const Comm::ConnectionPointer &, char *buf, size_t len, Comm::Flag flag, int xerrno, void *data)

Public Attributes

char * url
CbcPointer< ClientHttpRequesthttp
HttpRequest::Pointer request
AccessLogEntryPointer al
Connection client
Connection server
 pointer for logging HTTP status More...
 pointer for logging Squid processing code More...
SBuf preReadClientData
SBuf preReadServerData
time_t startTime
bool waitingForConnectExchange
 Whether we are waiting for the CONNECT request/response exchange with the peer. More...
HappyConnOpenerPointer connOpener
 current connection opening job More...
ResolvedPeersPointer destinations
 paths for forwarding the request More...
bool destinationsFound
bool retriable
CodeContext::Pointer codeContext
 our creator context More...
struct {
   AsyncCall::Pointer   connector
 a call linking us to the ConnOpener producing serverConn. More...
bool subscribed = false
 whether noteDestination() and noteDestinationsEnd() calls are allowed More...

Private Member Functions

 CBDATA_CHILD (TunnelStateData)
void usePinned ()
 send request on an existing connection dedicated to the requesting client More...
void noteSecurityPeerConnectorAnswer (Security::EncryptorAnswer &)
 callback handler for the Security::PeerConnector encryptor More...
void connectedToPeer (const Comm::ConnectionPointer &)
 called after connection setup (including any encryption) More...
void establishTunnelThruProxy (const Comm::ConnectionPointer &)
template<typename StepStart >
void advanceDestination (const char *stepDescription, const Comm::ConnectionPointer &conn, const StepStart &startStep)
 starts a preparation step for an established connection; retries on failures More...
const char * checkRetry ()
void tunnelEstablishmentDone (Http::TunnelerAnswer &answer)
 resumes operations after the (possibly failed) HTTP CONNECT exchange More...
void deleteThis ()
 destroys the tunnel (after performing potentially-throwing cleanup) More...

Private Attributes

ErrorStatesavedError = nullptr
 details of the "last tunneling attempt" failure (if it failed) More...

Detailed Description

TunnelStateData is the state engine performing the tasks for setup of a TCP tunnel from an existing open client FD to a server then shuffling binary data between the resulting FD pair.

Definition at line 70 of file

Constructor & Destructor Documentation

◆ TunnelStateData() [1/2]

◆ ~TunnelStateData()

TunnelStateData::~TunnelStateData ( )

Definition at line 386 of file

References assert, cancelOpening(), debugs, noConnections(), opening(), savedError, url, and xfree.

◆ TunnelStateData() [2/2]

TunnelStateData::TunnelStateData ( const TunnelStateData )

Member Function Documentation

◆ advanceDestination()

template<typename StepStart >
void TunnelStateData::advanceDestination ( const char *  stepDescription,
const Comm::ConnectionPointer conn,
const StepStart &  startStep 

◆ cancelOpening()

void TunnelStateData::cancelOpening ( const char *  reason)

Notify connOpener that we no longer need connections. We do not have to do this – connOpener would eventually notice on its own, but notifying reduces waste and speeds up spare connection opening for other transactions (that could otherwise wait for this transaction to use its spare allowance).

Definition at line 1348 of file

References assert, calls, CbcPointer< Cbc >::clear(), connOpener, and notifyConnOpener().

Referenced by ~TunnelStateData(), and sendError().


TunnelStateData::CBDATA_CHILD ( TunnelStateData  )

◆ checkRetry()

const char * TunnelStateData::checkRetry ( )
whether the request should be retried (nil) or the description why it should not

Definition at line 405 of file

References FwdState::EnoughTimeToReForward(), noConnections(), retriable, shutting_down, and startTime.

Referenced by retryOrBail().

◆ clientClosed()

◆ clientExpectsConnectResponse()

◆ closeConnections()

void TunnelStateData::closeConnections ( )

◆ closePendingConnection()

void TunnelStateData::closePendingConnection ( const Comm::ConnectionPointer conn,
const char *  reason 

◆ connectDone()

◆ connectedToPeer()

void TunnelStateData::connectedToPeer ( const Comm::ConnectionPointer conn)

Definition at line 1217 of file

References advanceDestination(), conn, and establishTunnelThruProxy().

Referenced by connectToPeer(), and noteSecurityPeerConnectorAnswer().

◆ connectToPeer()

void TunnelStateData::connectToPeer ( const Comm::ConnectionPointer conn)

Definition at line 1152 of file

References advanceDestination(), conn, connectedToPeer(), and secureConnectionToPeer().

Referenced by connectDone().

◆ copy()

void TunnelStateData::copy ( size_t  len,
Connection from,
Connection to,
IOCB completion 

◆ copyClientBytes()

◆ copyRead()

◆ copyServerBytes()

◆ deleteThis()

void TunnelStateData::deleteThis ( )

Definition at line 343 of file

References assert, http, noConnections(), and CbcPointer< Cbc >::valid().

Referenced by clientClosed(), and retryOrBail().

◆ establishTunnelThruProxy()

◆ getHost()

const char* TunnelStateData::getHost ( ) const

◆ keepGoingAfterRead()

bool TunnelStateData::keepGoingAfterRead ( size_t  len,
Comm::Flag  errcode,
int  xerrno,
Connection from,
Connection to 

◆ noConnections()

bool TunnelStateData::noConnections ( ) const

◆ noteConnection()

◆ noteDestination()

◆ noteDestinationsEnd()

void TunnelStateData::noteDestinationsEnd ( ErrorState error)

called when there will be no more noteDestination() calls

erroris a possible reason why no destinations were found; it is guaranteed to be nil if there was at least one noteDestination() call

Implements PeerSelectionInitiator.

Definition at line 1272 of file

References al, TunnelStateData::Connection::conn, destinations, ResolvedPeers::destinationsFinalized, destinationsFound, ERR_CANNOT_FORWARD, RefCount< C >::getRaw(), Comm::IsConnOpen(), Must, notifyConnOpener(), opening(), request, savedError, Http::scInternalServerError, sendError(), server, and PeerSelectionInitiator::subscribed.

◆ notePeerReadyToShovel()

◆ noteSecurityPeerConnectorAnswer()

◆ notifyConnOpener()

void TunnelStateData::notifyConnOpener ( )

◆ opening()

bool TunnelStateData::opening ( ) const

whether we are waiting for HappyConnOpener same as calls.connector but may differ from connOpener.valid()

Definition at line 217 of file

References connOpener, and CbcPointer< Cbc >::set().

Referenced by ~TunnelStateData(), noteDestination(), noteDestinationsEnd(), sendError(), and startConnecting().

◆ operator=()

TunnelStateData& TunnelStateData::operator= ( const TunnelStateData )

◆ readClient()

◆ ReadClient()

void TunnelStateData::ReadClient ( const Comm::ConnectionPointer ,
char *  buf,
size_t  len,
Comm::Flag  errcode,
int  xerrno,
void *  data 

Definition at line 560 of file

References assert, buf, cbdataReferenceValid(), data, len, and readClient().

Referenced by copyClientBytes(), and tunnelDelayedClientRead().

◆ readServer()

◆ ReadServer()

void TunnelStateData::ReadServer ( const Comm::ConnectionPointer c,
char *  buf,
size_t  len,
Comm::Flag  errcode,
int  xerrno,
void *  data 

Definition at line 515 of file

References assert, buf, cbdataReferenceValid(), data, debugs, HERE(), len, and readServer().

Referenced by copyServerBytes(), and tunnelDelayedServerRead().

◆ retryOrBail()

◆ saveError()

void TunnelStateData::saveError ( ErrorState finalError)

◆ secureConnectionToPeer()

void TunnelStateData::secureConnectionToPeer ( const Comm::ConnectionPointer conn)

◆ sendError()

void TunnelStateData::sendError ( ErrorState finalError,
const char *  reason 

Starts sending the given error message to the client, leading to the eventual transaction termination. Call with savedError to send savedError.

Definition at line 1317 of file

References assert, ErrorState::callback, ErrorState::callback_data, cancelOpening(), client, TunnelStateData::Connection::conn, debugs, errorSend(), HttpRequest::hier, ErrorState::httpStatus, opening(), request, savedError, status_ptr, HierarchyLogEntry::stopPeerClock(), PeerSelectionInitiator::subscribed, and tunnelErrorComplete.

Referenced by noteDestinationsEnd(), retryOrBail(), and usePinned().

◆ serverClosed()

void TunnelStateData::serverClosed ( )

Definition at line 316 of file

References TunnelStateData::Connection::noteClosure(), and server.

Referenced by tunnelServerClosed().

◆ startConnecting()

void TunnelStateData::startConnecting ( )

starts connecting to the next hop, either for the first time or while recovering from the previous connect failure

Definition at line 1358 of file

References al, assert, asyncCall(), calls, connOpener, destinations, ResolvedPeers::empty(), HttpRequest::hier, AnyP::Uri::host(), noteConnection(), ResolvedPeers::notificationPending, opening(), request, AsyncJob::Start(), HierarchyLogEntry::startPeerClock(), startTime, and HttpRequest::url.

Referenced by noteDestination(), and retryOrBail().

◆ startSelectingDestinations()

void PeerSelectionInitiator::startSelectingDestinations ( HttpRequest request,
const AccessLogEntry::Pointer ale,
StoreEntry entry 

Initiates asynchronous peer selection that eventually results in zero or more noteDestination() calls and exactly one noteDestinationsEnd() call.

Definition at line 334 of file

References peerSelect(), request(), and PeerSelectionInitiator::subscribed.

Referenced by FwdState::start(), and tunnelStart().

◆ syncHierNote()

void TunnelStateData::syncHierNote ( const Comm::ConnectionPointer conn,
const char *  origin 

update "hierarchy" annotations with a new (possibly failed) destination

originthe name of the origin server we were trying to reach

Definition at line 490 of file

References al, conn, AccessLogEntry::hier, HttpRequest::hier, request, and HierarchyLogEntry::resetPeerNotes().

Referenced by connectDone(), noteConnection(), and usePinned().

◆ toCbdata()

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited

◆ tunnelEstablishmentDone()

◆ usePinned()

◆ writeClientDone()

◆ WriteClientDone()

void TunnelStateData::WriteClientDone ( const Comm::ConnectionPointer ,
char *  buf,
size_t  len,
Comm::Flag  flag,
int  xerrno,
void *  data 

◆ writeServerDone()

◆ WriteServerDone()

void TunnelStateData::WriteServerDone ( const Comm::ConnectionPointer ,
char *  buf,
size_t  len,
Comm::Flag  flag,
int  xerrno,
void *  data 

Member Data Documentation

◆ al

◆ calls

struct { ... } TunnelStateData::calls

◆ client

◆ codeContext

CodeContext::Pointer TunnelStateData::codeContext

Definition at line 192 of file

Referenced by tunnelDelayedClientRead(), and tunnelDelayedServerRead().

◆ connector

AsyncCall::Pointer TunnelStateData::connector

Definition at line 196 of file

Referenced by secureConnectionToPeer().

◆ connOpener

HappyConnOpenerPointer TunnelStateData::connOpener

Definition at line 185 of file

Referenced by cancelOpening(), noteConnection(), notifyConnOpener(), opening(), and startConnecting().

◆ destinations

ResolvedPeersPointer TunnelStateData::destinations

◆ destinationsFound

bool TunnelStateData::destinationsFound

At least one candidate path found

Definition at line 187 of file

Referenced by noteDestination(), and noteDestinationsEnd().

◆ http

◆ logTag_ptr

LogTags* TunnelStateData::logTag_ptr

Definition at line 178 of file

Referenced by TunnelStateData(), tunnelEstablishmentDone(), and tunnelStartShoveling().

◆ preReadClientData

SBuf TunnelStateData::preReadClientData

Definition at line 180 of file

Referenced by copyClientBytes(), and tunnelStartShoveling().

◆ preReadServerData

SBuf TunnelStateData::preReadServerData

Definition at line 181 of file

Referenced by copyServerBytes(), switchToTunnel(), and tunnelEstablishmentDone().

◆ request

◆ retriable

bool TunnelStateData::retriable

whether another destination may be still attempted if the TCP connection was unexpectedly closed

Definition at line 190 of file

Referenced by checkRetry(), notePeerReadyToShovel(), and switchToTunnel().

◆ savedError

ErrorState* TunnelStateData::savedError = nullptr

◆ server

◆ startTime

time_t TunnelStateData::startTime

object creation time, before any peer selection/connection attempts

Definition at line 182 of file

Referenced by checkRetry(), and startConnecting().

◆ status_ptr

◆ subscribed

◆ url

char* TunnelStateData::url

Definition at line 90 of file

Referenced by TunnelStateData(), ~TunnelStateData(), and tunnelStart().

◆ waitingForConnectExchange

bool TunnelStateData::waitingForConnectExchange

The documentation for this class was generated from the following file:






Web Site Translations