Inheritance diagram for TunnelStateData:
Collaboration diagram for TunnelStateData:

Classes

class  Connection
 

Public Member Functions

 TunnelStateData (ClientHttpRequest *)
 
 ~TunnelStateData () override
 
 TunnelStateData (const TunnelStateData &)
 
TunnelStateDataoperator= (const TunnelStateData &)
 
bool noConnections () const
 
void closeConnections ()
 closes both client and server connections More...
 
const char * getHost () const
 
void commitToServer (const Comm::ConnectionPointer &)
 
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...
 
void noteDestination (Comm::ConnectionPointer conn) override
 called when a new unique destination has been found More...
 
void noteDestinationsEnd (ErrorState *selectionError) override
 
void syncHierNote (const Comm::ConnectionPointer &server, const char *origin)
 
void noteConnection (HappyConnOpenerAnswer &)
 
void connectDone (const Comm::ConnectionPointer &conn, const char *origin, const bool reused)
 Start using an established connection. More...
 
void notifyConnOpener ()
 makes sure connection opener knows that the 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
 
intstatus_ptr
 pointer for logging HTTP status More...
 
SBuf preReadClientData
 
SBuf preReadServerData
 
time_t startTime
 object creation time, before any peer selection/connection attempts More...
 
ResolvedPeersPointer destinations
 paths for forwarding the request More...
 
bool destinationsFound
 At least one candidate path found. More...
 
bool committedToServer
 whether the decision to tunnel to a particular destination was final More...
 
int n_tries
 the number of forwarding attempts so far More...
 
const char * banRetries
 a reason to ban reforwarding attempts (or nil) More...
 
CodeContext::Pointer codeContext
 our creator context More...
 
JobWait< HappyConnOpenertransportWait
 waits for a transport connection to the peer to be established/opened More...
 
JobWait< Security::PeerConnectorencryptionWait
 waits for the established transport connection to be secured/encrypted More...
 
JobWait< Http::TunnelerpeerWait
 
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 ()
 
bool transporting () const
 
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...
 
void cancelStep (const char *reason)
 
bool exhaustedTries () const
 whether we have used up all permitted forwarding attempts More...
 
void updateAttempts (int)
 sets n_tries to the given value (while keeping ALE in sync) More...
 
virtual void finalizedInCbdataChild ()=0
 hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE() 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 74 of file tunnel.cc.

Constructor & Destructor Documentation

◆ TunnelStateData() [1/2]

◆ ~TunnelStateData()

TunnelStateData::~TunnelStateData ( )
override

Definition at line 382 of file tunnel.cc.

References assert, cancelStep(), debugs, noConnections(), 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 
)
private

◆ cancelStep()

void TunnelStateData::cancelStep ( const char *  reason)
private

Notify a pending subtask, if any, that we no longer need its help. We do not have to do this – the subtask job will eventually end – but ending it earlier reduces waste and may reduce DoS attack surface.

Definition at line 1391 of file tunnel.cc.

References JobWaitBase::cancel(), encryptionWait, peerWait, and transportWait.

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

◆ CBDATA_CHILD()

TunnelStateData::CBDATA_CHILD ( TunnelStateData  )
private

◆ checkRetry()

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

Definition at line 400 of file tunnel.cc.

References banRetries, FwdState::EnoughTimeToReForward(), exhaustedTries(), HttpRequest::hier, Http::IsReforwardableStatus(), noConnections(), HierarchyLogEntry::peer_reply_status, request, Http::scNone, shutting_down, and startTime.

Referenced by retryOrBail().

◆ clientClosed()

◆ clientExpectsConnectResponse()

◆ closeConnections()

void TunnelStateData::closeConnections ( )

◆ closePendingConnection()

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

◆ commitToServer()

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

store the given to-server connection; prohibit retries and do not look for any other destinations

Definition at line 1041 of file tunnel.cc.

References banRetries, committedToServer, conn, TunnelStateData::Connection::initConnection(), server, PeerSelectionInitiator::subscribed, and tunnelServerClosed.

Referenced by notePeerReadyToShovel(), and switchToTunnel().

◆ connectDone()

◆ connectedToPeer()

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

Definition at line 1253 of file tunnel.cc.

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

Referenced by connectToPeer(), and noteSecurityPeerConnectorAnswer().

◆ connectToPeer()

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

Definition at line 1186 of file tunnel.cc.

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 ( )
private

Definition at line 337 of file tunnel.cc.

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

Referenced by clientClosed(), and retryOrBail().

◆ establishTunnelThruProxy()

void TunnelStateData::establishTunnelThruProxy ( const Comm::ConnectionPointer conn)
private

◆ exhaustedTries()

bool TunnelStateData::exhaustedTries ( ) const
private

Definition at line 1133 of file tunnel.cc.

References Config, SquidConfig::forward_max_tries, and n_tries.

Referenced by checkRetry().

◆ finalizedInCbdataChild()

virtual void CbdataParent::finalizedInCbdataChild ( )
privatepure virtualinherited

◆ getHost()

const char * TunnelStateData::getHost ( ) const
inline

◆ keepGoingAfterRead()

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

◆ noConnections()

bool TunnelStateData::noConnections ( ) const

◆ noteConnection()

◆ noteDestination()

void TunnelStateData::noteDestination ( Comm::ConnectionPointer  path)
overridevirtual

◆ noteDestinationsEnd()

void TunnelStateData::noteDestinationsEnd ( ErrorState error)
overridevirtual

called when there will be no more noteDestination() calls

Parameters
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 1299 of file tunnel.cc.

References al, assert, debugs, destinations, ResolvedPeers::destinationsFinalized, destinationsFound, ERR_CANNOT_FORWARD, RefCount< C >::getRaw(), Must, notifyConnOpener(), request, savedError, Http::scInternalServerError, sendError(), PeerSelectionInitiator::subscribed, transporting(), and transportWait.

◆ notePeerReadyToShovel()

◆ noteSecurityPeerConnectorAnswer()

◆ notifyConnOpener()

void TunnelStateData::notifyConnOpener ( )

◆ 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 
)
static

Definition at line 574 of file tunnel.cc.

References assert, cbdataReferenceValid(), 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 
)
static

Definition at line 529 of file tunnel.cc.

References assert, cbdataReferenceValid(), debugs, 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 1362 of file tunnel.cc.

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

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

◆ serverClosed()

void TunnelStateData::serverClosed ( )

Definition at line 308 of file tunnel.cc.

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

Referenced by tunnelServerClosed().

◆ startConnecting()

void TunnelStateData::startConnecting ( )

◆ startSelectingDestinations()

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

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

Definition at line 335 of file peer_select.cc.

References peerSelect(), 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

Parameters
originthe name of the origin server we were trying to reach

Definition at line 490 of file tunnel.cc.

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

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

◆ toCbdata()

virtual void * CbdataParent::toCbdata ( )
pure virtualinherited

◆ transporting()

bool TunnelStateData::transporting ( ) const
private

Whether a tunneling attempt to some selected destination X is in progress (after successfully opening/reusing a transport connection to X).

See also
transportWait

Definition at line 1344 of file tunnel.cc.

References committedToServer, encryptionWait, and peerWait.

Referenced by noteDestination(), noteDestinationsEnd(), and startConnecting().

◆ tunnelEstablishmentDone()

◆ updateAttempts()

void TunnelStateData::updateAttempts ( int  newValue)
private

Definition at line 498 of file tunnel.cc.

References al, Assure, debugs, n_tries, and AccessLogEntry::requestAttempts.

Referenced by noteConnection(), and usePinned().

◆ usePinned()

◆ writeClientDone()

◆ WriteClientDone()

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

◆ writeServerDone()

◆ WriteServerDone()

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

Member Data Documentation

◆ al

◆ banRetries

const char* TunnelStateData::banRetries

Definition at line 199 of file tunnel.cc.

Referenced by checkRetry(), commitToServer(), and noteConnection().

◆ client

◆ codeContext

CodeContext::Pointer TunnelStateData::codeContext

Definition at line 202 of file tunnel.cc.

Referenced by tunnelDelayedClientRead(), and tunnelDelayedServerRead().

◆ committedToServer

bool TunnelStateData::committedToServer

Definition at line 194 of file tunnel.cc.

Referenced by commitToServer(), and transporting().

◆ destinations

ResolvedPeersPointer TunnelStateData::destinations

◆ destinationsFound

bool TunnelStateData::destinationsFound

Definition at line 191 of file tunnel.cc.

Referenced by noteDestination(), and noteDestinationsEnd().

◆ encryptionWait

◆ http

◆ n_tries

int TunnelStateData::n_tries

Definition at line 196 of file tunnel.cc.

Referenced by exhaustedTries(), startConnecting(), updateAttempts(), and usePinned().

◆ peerWait

JobWait<Http::Tunneler> TunnelStateData::peerWait

waits for an HTTP CONNECT tunnel through a cache_peer to be negotiated over the (encrypted, if needed) transport connection to that cache_peer

Definition at line 212 of file tunnel.cc.

Referenced by cancelStep(), establishTunnelThruProxy(), transporting(), tunnelEstablishmentDone(), and tunnelStartShoveling().

◆ preReadClientData

SBuf TunnelStateData::preReadClientData

Definition at line 187 of file tunnel.cc.

Referenced by copyClientBytes(), and tunnelStartShoveling().

◆ preReadServerData

SBuf TunnelStateData::preReadServerData

Definition at line 188 of file tunnel.cc.

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

◆ request

◆ savedError

ErrorState* TunnelStateData::savedError = nullptr
private

◆ server

◆ startTime

time_t TunnelStateData::startTime

Definition at line 189 of file tunnel.cc.

Referenced by checkRetry(), and startConnecting().

◆ status_ptr

◆ subscribed

◆ transportWait

◆ url

char* TunnelStateData::url

Definition at line 94 of file tunnel.cc.

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


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors