Inheritance diagram for Ftp::Gateway:
Collaboration diagram for Ftp::Gateway:

Public Types

enum  {
  BEGIN,
  SENT_USER,
  SENT_PASS,
  SENT_TYPE,
  SENT_MDTM,
  SENT_SIZE,
  SENT_EPRT,
  SENT_PORT,
  SENT_EPSV_ALL,
  SENT_EPSV_1,
  SENT_EPSV_2,
  SENT_PASV,
  SENT_CWD,
  SENT_LIST,
  SENT_NLST,
  SENT_REST,
  SENT_RETR,
  SENT_STOR,
  SENT_QUIT,
  READING_DATA,
  WRITING_DATA,
  SENT_MKDIR,
  SENT_FEAT,
  SENT_PWD,
  SENT_CDUP,
  SENT_DATA_REQUEST,
  SENT_COMMAND,
  END
}
 
typedef CbcPointer< AsyncJobPointer
 
typedef CbcPointer< BodyProducerPointer
 
typedef CbcPointer< BodyConsumerPointer
 

Public Member Functions

 Gateway (FwdState *)
 
virtual ~Gateway ()
 
virtual void start ()
 called by AsyncStart; do not call directly More...
 
virtual Http::StatusCode failedHttpStatus (err_type &error)
 
int restartable ()
 
void appendSuccessHeader ()
 
void hackShortcut (StateMethod *nextState)
 
void unhack ()
 
void readStor ()
 
void parseListing ()
 
bool htmlifyListEntry (const char *line, PackableStream &)
 
void completedListing (void)
 
void listenForDataChannel (const Comm::ConnectionPointer &conn)
 create a data channel acceptor and start listening. More...
 
int checkAuth (const HttpHeader *req_hdr)
 
void checkUrlpath ()
 
void buildTitleUrl ()
 
void writeReplyBody (const char *, size_t len)
 
void printfReplyBody (const char *fmt,...)
 
virtual void completeForwarding ()
 
void processHeadResponse ()
 
void processReplyBody ()
 
void setCurrentOffset (int64_t offset)
 
int64_t getCurrentOffset () const
 
virtual void dataChannelConnected (const CommConnectCbParams &io)
 
virtual void timeout (const CommTimeoutCbParams &io)
 read timeout handler More...
 
void ftpAcceptDataConnection (const CommAcceptCbParams &io)
 
SBuf ftpRealm ()
 
void loginFailed (void)
 
virtual void haveParsedReplyHeaders ()
 called when we have final (possibly adapted) reply headers; kids extend More...
 
virtual bool haveControlChannel (const char *caller_name) const
 
virtual void failed (err_type error=ERR_NONE, int xerrno=0, ErrorState *ftperr=nullptr)
 handle a fatal transaction error, closing the control connection More...
 
virtual void maybeReadVirginBody ()
 read response data from the network More...
 
void writeCommand (const char *buf)
 
bool handlePasvReply (Ip::Address &remoteAddr)
 
bool handleEpsvReply (Ip::Address &remoteAddr)
 
bool sendEprt ()
 
bool sendPort ()
 
bool sendPassive ()
 
void connectDataChannel ()
 
bool openListenSocket ()
 
void switchTimeoutToDataChannel ()
 
virtual void noteMoreBodyDataAvailable (BodyPipe::Pointer)
 
virtual void noteBodyProductionEnded (BodyPipe::Pointer)
 
virtual void noteBodyProducerAborted (BodyPipe::Pointer)
 
virtual bool abortOnData (const char *reason)
 
virtual HttpRequestPointer originalRequest ()
 a hack to reach HttpStateData::orignal_request More...
 
virtual void noteAdaptationAnswer (const Adaptation::Answer &answer)
 
virtual void noteAdaptationAclCheckDone (Adaptation::ServiceGroupPointer group)
 
virtual void noteMoreBodySpaceAvailable (BodyPipe::Pointer)
 
virtual void noteBodyConsumerAborted (BodyPipe::Pointer)
 
virtual bool getMoreRequestBody (MemBuf &buf)
 either fill buf with available [encoded] request body bytes or return false More...
 
virtual void swanSong ()
 
virtual bool doneAll () const
 whether positive goal has been reached More...
 
void serverComplete ()
 
bool canBeCalled (AsyncCall &call) const
 whether we can be called More...
 
void callStart (AsyncCall &call)
 
virtual void callEnd ()
 called right after the called job method More...
 
virtual void callException (const std::exception &e)
 called when the job throws during an async call More...
 
virtual void * toCbdata ()=0
 

Static Public Member Functions

static HttpReplyftpAuthRequired (HttpRequest *request, SBuf &realm, AccessLogEntry::Pointer &)
 
static Pointer Start (AsyncJob *job)
 starts a freshly created job (i.e., makes the job asynchronous) More...
 

Public Attributes

char user [MAX_URL]
 
char password [MAX_URL]
 
int password_url
 
char * reply_hdr
 
int reply_hdr_state
 
String clean_url
 
String title_url
 
String base_href
 
int conn_att
 
int login_att
 
time_t mdtm
 
int64_t theSize
 
wordlistpathcomps
 
char * filepath
 
char * dirpath
 
int64_t restart_offset
 
char * proxy_host
 
size_t list_width
 
String cwd_message
 
char * old_filepath
 
char typecode
 
MemBuf listing
 FTP directory listing in HTML format. More...
 
GatewayFlags flags
 
CtrlChannel ctrl
 FTP control channel state. More...
 
DataChannel data
 FTP data channel state. More...
 
enum Ftp::Client:: { ... }  ftp_state_t
 
int state
 
char * old_request
 
char * old_reply
 
StoreEntryentry = nullptr
 
FwdState::Pointer fwd
 
HttpRequestPointer request
 

Static Public Attributes

static PF ftpDataWrite
 

Protected Member Functions

virtual void handleControlReply ()
 
virtual void dataClosed (const CommCloseCbParams &io)
 handler called by Comm when FTP data channel is closed unexpectedly More...
 
virtual void closeServer ()
 
virtual bool doneWithServer () const
 
virtual const Comm::ConnectionPointerdataConnection () const
 
virtual void abortAll (const char *reason)
 abnormal transaction termination; reason is for debugging only More...
 
void ctrlClosed (const CommCloseCbParams &io)
 handler called by Comm when FTP control channel is closed unexpectedly More...
 
void scheduleReadControlReply (int buffered_ok)
 
void readControlReply (const CommIoCbParams &io)
 
void writeCommandCallback (const CommIoCbParams &io)
 
void dataRead (const CommIoCbParams &io)
 
void dataComplete ()
 
AsyncCall::Pointer dataCloser ()
 creates a data channel Comm close callback More...
 
void initReadBuf ()
 
virtual void sentRequestBody (const CommIoCbParams &io)
 
virtual void doneSendingRequestBody ()
 
bool startRequestBodyFlow ()
 
void handleMoreRequestBodyAvailable ()
 
void handleRequestBodyProductionEnded ()
 
void sendMoreRequestBody ()
 
bool abortOnBadEntry (const char *abortReason)
 Entry-dependent callbacks use this check to quit if the entry went bad. More...
 
bool blockCaching ()
 whether to prevent caching of an otherwise cachable response More...
 
void startAdaptation (const Adaptation::ServiceGroupPointer &group, HttpRequest *cause)
 Initiate an asynchronous adaptation transaction which will call us back. More...
 
void adaptVirginReplyBody (const char *buf, ssize_t len)
 
void cleanAdaptation ()
 
virtual bool doneWithAdaptation () const
 
void handleMoreAdaptedBodyAvailable ()
 
void handleAdaptedBodyProductionEnded ()
 
void handleAdaptedBodyProducerAborted ()
 
void handleAdaptedHeader (Http::Message *msg)
 
void handleAdaptationCompleted ()
 
void handleAdaptationBlocked (const Adaptation::Answer &answer)
 
void handleAdaptationAborted (bool bypassable=false)
 
bool handledEarlyAdaptationAbort ()
 
void resumeBodyStorage ()
 called by StoreEntry when it has more buffer space available More...
 
void endAdaptedBodyConsumption ()
 called when the entire adapted response body is consumed More...
 
const HttpReplyvirginReply () const
 
HttpReplyvirginReply ()
 
HttpReplysetVirginReply (HttpReply *r)
 
HttpReplyfinalReply ()
 
HttpReplysetFinalReply (HttpReply *r)
 
void adaptOrFinalizeReply ()
 
void addVirginReplyBody (const char *buf, ssize_t len)
 
void storeReplyBody (const char *buf, ssize_t len)
 
size_t replyBodySpace (const MemBuf &readBuf, const size_t minSpace) const
 
size_t calcBufferSpaceToReserve (const size_t space, const size_t wantSpace) const
 determine how much space the buffer needs to reserve More...
 
void adjustBodyBytesRead (const int64_t delta)
 initializes bodyBytesRead stats if needed and applies delta More...
 
CbcPointer< Initiate > initiateAdaptation (Initiate *x)
 < starts freshly created initiate and returns a safe pointer to it More...
 
void clearAdaptation (CbcPointer< Initiate > &x)
 clears the pointer (does not call announceInitiatorAbort) More...
 
void announceInitiatorAbort (CbcPointer< Initiate > &x)
 inform the transaction about abnormal termination and clear the pointer More...
 
bool initiated (const CbcPointer< AsyncJob > &job) const
 Must(initiated(initiate)) instead of Must(initiate.set()), for clarity. More...
 
void deleteThis (const char *aReason)
 
void mustStop (const char *aReason)
 
bool done () const
 the job is destroyed in callEnd() when done() More...
 
virtual const char * status () const
 internal cleanup; do not call directly More...
 
void stopProducingFor (RefCount< BodyPipe > &, bool atEof)
 
void stopConsumingFrom (RefCount< BodyPipe > &)
 

Protected Attributes

int64_t currentOffset = 0
 
MemBufresponseBodyBuffer = nullptr
 
BodyPipe::Pointer requestBodySource
 
AsyncCall::Pointer requestSender
 
BodyPipe::Pointer virginBodyDestination
 
CbcPointer< Adaptation::InitiateadaptedHeadSource
 
BodyPipe::Pointer adaptedBodySource
 
bool adaptationAccessCheckPending = false
 
bool startedAdaptation = false
 
bool receivedWholeRequestBody = false
 handleRequestBodyProductionEnded called More...
 
const char * doneWithFwd = nullptr
 
const char * stopReason
 reason for forcing done() to be true More...
 
const char * typeName
 kid (leaf) class name, for debugging More...
 
AsyncCall::Pointer inCall
 the asynchronous call being handled, if any More...
 
const InstanceId< AsyncJobid
 job identifier More...
 

Private Member Functions

 CBDATA_CLASS (Gateway)
 
virtual bool mayReadVirginReplyBody () const
 whether we may receive more virgin response body bytes More...
 
virtual void handleRequestBodyProducerAborted ()
 
void loginParser (const SBuf &login, bool escaped)
 

Detailed Description

FTP Gateway: An FTP client that takes an HTTP request with an ftp:// URI, converts it into one or more FTP commands, and then converts one or more FTP responses into the final HTTP response.

Definition at line 92 of file FtpGateway.cc.

Member Typedef Documentation

◆ Pointer [1/3]

Definition at line 25 of file BodyPipe.h.

◆ Pointer [2/3]

Definition at line 34 of file AsyncJob.h.

◆ Pointer [3/3]

Definition at line 45 of file BodyPipe.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
BEGIN 
SENT_USER 
SENT_PASS 
SENT_TYPE 
SENT_MDTM 
SENT_SIZE 
SENT_EPRT 
SENT_PORT 
SENT_EPSV_ALL 
SENT_EPSV_1 
SENT_EPSV_2 
SENT_PASV 
SENT_CWD 
SENT_LIST 
SENT_NLST 
SENT_REST 
SENT_RETR 
SENT_STOR 
SENT_QUIT 
READING_DATA 
WRITING_DATA 
SENT_MKDIR 
SENT_FEAT 
SENT_PWD 
SENT_CDUP 
SENT_DATA_REQUEST 
SENT_COMMAND 
END 

Definition at line 127 of file FtpClient.h.

Constructor & Destructor Documentation

◆ Gateway()

◆ ~Gateway()

Member Function Documentation

◆ abortAll()

void Ftp::Client::abortAll ( const char *  reason)
protectedvirtualinherited

◆ abortOnBadEntry()

◆ abortOnData()

bool Client::abortOnData ( const char *  reason)
virtualinherited

abnormal data transfer termination

Return values
truethe transaction will be terminated (abortAll called)
falsethe transaction will survive

Reimplemented in Ftp::Relay.

Definition at line 287 of file Client.cc.

References Client::abortAll().

Referenced by Client::abortOnBadEntry(), Ftp::Client::dataRead(), Client::handleAdaptationBlocked(), Ftp::Client::readControlReply(), Client::sendBodyIsTooLargeError(), and Client::sentRequestBody().

◆ adaptOrFinalizeReply()

◆ adaptVirginReplyBody()

void Client::adaptVirginReplyBody ( const char *  buf,
ssize_t  len 
)
protectedinherited

◆ addVirginReplyBody()

◆ adjustBodyBytesRead()

void Client::adjustBodyBytesRead ( const int64_t  delta)
protectedinherited

◆ announceInitiatorAbort()

◆ appendSuccessHeader()

◆ blockCaching()

◆ buildTitleUrl()

◆ calcBufferSpaceToReserve()

size_t Client::calcBufferSpaceToReserve ( const size_t  space,
const size_t  wantSpace 
) const
protectedinherited

◆ callEnd()

void AsyncJob::callEnd ( )
virtualinherited

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)
inherited

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const
inherited

Definition at line 101 of file AsyncJob.cc.

References AsyncCall::cancel(), debugs, HERE(), AsyncJob::inCall, and NULL.

Referenced by AsyncJob::swanSong().

◆ CBDATA_CLASS()

Ftp::Gateway::CBDATA_CLASS ( Gateway  )
private

◆ checkAuth()

int Ftp::Gateway::checkAuth ( const HttpHeader req_hdr)

Locates the FTP user:password login.

Highest to lowest priority:

Special Case: A username-only may be provided in the URL and password in the HTTP headers.

TODO: we might be able to do something about locating username from other sources: ie, external ACL user=* tag or ident lookup

Return values
1if we have everything needed to complete this request.
0if something is missing.

Definition at line 1034 of file FtpGateway.cc.

References SquidConfig::anon_user, Ftp::GatewayFlags::authenticated, Http::AUTHORIZATION, Config, fatal(), flags, SquidConfig::Ftp, HttpHeader::getAuth(), loginParser(), MAX_URL, null_string, password, Client::request, Ftp::GatewayFlags::tried_auth_anonymous, Ftp::GatewayFlags::tried_auth_nopass, HttpRequest::url, user, AnyP::Uri::userInfo(), and xstrncpy().

Referenced by start().

◆ checkUrlpath()

◆ cleanAdaptation()

◆ clearAdaptation()

◆ closeServer()

void Ftp::Client::closeServer ( )
protectedvirtualinherited

◆ completedListing()

◆ completeForwarding()

void Ftp::Gateway::completeForwarding ( )
virtual

A hack to ensure we do not double-complete on the forward entry.

Todo:
Ftp::Gateway logic should probably be rewritten to avoid double-completion or FwdState should be rewritten to allow it.

Reimplemented from Client.

Definition at line 2692 of file FtpGateway.cc.

References Ftp::GatewayFlags::completed_forwarding, Client::completeForwarding(), Ftp::Channel::conn, Ftp::Client::ctrl, Ftp::Client::data, debugs, Comm::Connection::fd, flags, Client::fwd, and NULL.

◆ connectDataChannel()

◆ ctrlClosed()

void Ftp::Client::ctrlClosed ( const CommCloseCbParams io)
protectedinherited

◆ dataChannelConnected()

◆ dataClosed()

void Ftp::Gateway::dataClosed ( const CommCloseCbParams io)
protectedvirtual

Reimplemented from Ftp::Client.

Definition at line 318 of file FtpGateway.cc.

References Ftp::Client::dataClosed(), and ERR_FTP_FAILURE.

◆ dataCloser()

AsyncCall::Pointer Ftp::Client::dataCloser ( )
protectedinherited

◆ dataComplete()

void Client::dataComplete ( )
protectedinherited

◆ dataConnection()

const Comm::ConnectionPointer & Client::dataConnection ( ) const
protectedvirtualinherited
Returns
primary or "request data connection"

Implements Client.

Definition at line 883 of file FtpClient.cc.

References Ftp::Channel::conn, and Ftp::Client::data.

◆ dataRead()

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)
protectedinherited

◆ done()

◆ doneAll()

bool Client::doneAll ( ) const
virtualinherited

Reimplemented from AsyncJob.

Definition at line 193 of file Client.cc.

References AsyncJob::doneAll(), Client::doneWithAdaptation(), and Client::doneWithServer().

◆ doneSendingRequestBody()

void Ftp::Client::doneSendingRequestBody ( )
protectedvirtualinherited

called after we wrote the last byte of the request body

Implements Client.

Definition at line 1054 of file FtpClient.cc.

References Ftp::Client::dataComplete(), debugs, Client::doneSendingRequestBody(), and AsyncJob::status().

◆ doneWithAdaptation()

bool Client::doneWithAdaptation ( ) const
protectedvirtualinherited

◆ doneWithServer()

bool Ftp::Client::doneWithServer ( ) const
protectedvirtualinherited

Did we close all FTP server connection(s)?

Return values
trueBoth server control and data channels are closed. And not waiting for a new data connection to open.
falseEither control channel or data is still active.

Implements Client.

Definition at line 240 of file FtpClient.cc.

References Ftp::Channel::conn, Ftp::Client::ctrl, Ftp::Client::data, and Comm::IsConnOpen().

Referenced by Ftp::Relay::failed(), haveControlChannel(), and mayReadVirginReplyBody().

◆ endAdaptedBodyConsumption()

void Client::endAdaptedBodyConsumption ( )
protectedinherited

◆ failed()

◆ failedHttpStatus()

◆ finalReply()

HttpReply * Client::finalReply ( )
protectedinherited

Definition at line 128 of file Client.cc.

References assert, and Client::theFinalReply.

Referenced by HttpStateData::haveParsedReplyHeaders(), and HttpStateData::reusableReply().

◆ ftpAcceptDataConnection()

void Ftp::Gateway::ftpAcceptDataConnection ( const CommAcceptCbParams io)

"read" handler to accept FTP data connections.

Parameters
iocomm accept(2) callback parameters
Todo:
Need to send error message on control channel
When squid.conf ftp_sanitycheck is enabled, check the new connection is actually being made by the remote client which is connected to the FTP control socket. Or the one which we were told to listen for by control channel messages (may differ under NAT). This prevents third-party hacks, but also third-party load balancing handshakes.

On Comm::OK start using the accepted data socket and discard the temporary listen socket.

Definition at line 1923 of file FtpGateway.cc.

References Ftp::Client::abortAll(), Ftp::DataChannel::addr(), assert, Ftp::Channel::clear(), Ftp::Channel::close(), Comm::Connection::close(), Config, Ftp::Channel::conn, CommCommonCbParams::conn, Ftp::Client::ctrl, Ftp::Client::data, Ftp::Client::dataCloser(), DBG_IMPORTANT, debugs, EBIT_TEST, Client::entry, ENTRY_ABORTED, Comm::Connection::fd, fd_table, CommCommonCbParams::flag, StoreEntry::flags, SquidConfig::Ftp, ftpFail, haveControlChannel(), HERE(), Comm::IsConnOpen(), Ftp::Channel::listenConn, Ftp::CtrlChannel::message, NULL, Comm::OK, Ftp::Channel::opened(), Comm::Connection::remote, SquidConfig::sanitycheck, CommCommonCbParams::xerrno, and xstrerr().

Referenced by listenForDataChannel().

◆ ftpAuthRequired()

HttpReply * Ftp::Gateway::ftpAuthRequired ( HttpRequest request,
SBuf realm,
AccessLogEntry::Pointer ale 
)
static

◆ ftpRealm()

SBuf Ftp::Gateway::ftpRealm ( )

◆ getCurrentOffset()

int64_t Ftp::Gateway::getCurrentOffset ( ) const
inline

Definition at line 149 of file FtpGateway.cc.

Referenced by appendSuccessHeader(), and haveParsedReplyHeaders().

◆ getMoreRequestBody()

bool Client::getMoreRequestBody ( MemBuf buf)
virtualinherited

◆ hackShortcut()

◆ handleAdaptationAborted()

void Client::handleAdaptationAborted ( bool  bypassable = false)
protectedinherited

◆ handleAdaptationBlocked()

◆ handleAdaptationCompleted()

◆ handleAdaptedBodyProducerAborted()

◆ handleAdaptedBodyProductionEnded()

void Client::handleAdaptedBodyProductionEnded ( )
protectedinherited

◆ handleAdaptedHeader()

◆ handleControlReply()

void Ftp::Gateway::handleControlReply ( )
protectedvirtual

◆ handledEarlyAdaptationAbort()

bool Client::handledEarlyAdaptationAbort ( )
protectedinherited

◆ handleEpsvReply()

◆ handleMoreAdaptedBodyAvailable()

◆ handleMoreRequestBodyAvailable()

void Client::handleMoreRequestBodyAvailable ( )
protectedinherited

◆ handlePasvReply()

bool Client::handlePasvReply ( Ip::Address remoteAddr)
inherited

◆ handleRequestBodyProducerAborted()

void Ftp::Gateway::handleRequestBodyProducerAborted ( )
privatevirtual

◆ handleRequestBodyProductionEnded()

void Client::handleRequestBodyProductionEnded ( )
protectedinherited

◆ haveControlChannel()

bool Ftp::Gateway::haveControlChannel ( const char *  caller_name) const
virtual

Have we lost the FTP server control channel?

Return values
trueThe server control channel is available.
falseThe server control channel is not available.

Definition at line 2712 of file FtpGateway.cc.

References Ftp::Channel::conn, Ftp::Client::ctrl, DBG_IMPORTANT, debugs, Ftp::Client::doneWithServer(), and Comm::IsConnOpen().

Referenced by ftpAcceptDataConnection(), ftpReadPORT(), ftpSendCwd(), ftpSendList(), ftpSendMdtm(), ftpSendMkdir(), ftpSendNlst(), ftpSendPass(), ftpSendPassive(), ftpSendPORT(), ftpSendQuit(), ftpSendRest(), ftpSendRetr(), ftpSendSize(), ftpSendStor(), ftpSendType(), and ftpSendUser().

◆ haveParsedReplyHeaders()

void Ftp::Gateway::haveParsedReplyHeaders ( )
virtual

◆ htmlifyListEntry()

◆ initiateAdaptation()

◆ initiated()

◆ initReadBuf()

void Client::initReadBuf ( )
protectedinherited

◆ listenForDataChannel()

◆ loginFailed()

◆ loginParser()

void Ftp::Gateway::loginParser ( const SBuf login,
bool  escaped 
)
private

Parse a possible login username:password pair. Produces filled member variables user, password, password_url if anything found.

Parameters
logina decoded Basic authentication credential token or URI user-info token
escapedwhether to URL-decode the token after extracting user and password

Definition at line 399 of file FtpGateway.cc.

References SBuf::copy(), debugs, SBuf::find(), SBuf::isEmpty(), SBuf::length(), SBuf::npos, password, password_url, rfc1738_unescape(), SBuf::substr(), and user.

Referenced by checkAuth().

◆ maybeReadVirginBody()

◆ mayReadVirginReplyBody()

bool Ftp::Gateway::mayReadVirginReplyBody ( ) const
privatevirtual

Implements Client.

Definition at line 2728 of file FtpGateway.cc.

References Ftp::Client::doneWithServer().

◆ mustStop()

void AsyncJob::mustStop ( const char *  aReason)
protectedinherited

Definition at line 69 of file AsyncJob.cc.

References debugs, AsyncJob::inCall, Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.

Referenced by HttpStateData::abortAll(), Ftp::Client::abortAll(), Comm::TcpAcceptor::acceptOne(), Adaptation::Ecap::XactionRep::adaptationAborted(), Adaptation::AccessCheck::callBack(), AsyncJob::callException(), Security::PeerConnector::connectionClosed(), HttpStateData::continueAfterParsingHeader(), Ftp::Client::ctrlClosed(), Adaptation::Iterator::handleAdaptationBlock(), Adaptation::Iterator::handleAdaptationError(), Log::TcpLogger::handleClosure(), Adaptation::Icap::Xaction::handleCommClosed(), Http::Tunneler::handleConnectionClosure(), Mgr::Forwarder::handleError(), Ipc::Forwarder::handleError(), Ipc::Forwarder::handleException(), Ipc::Inquirer::handleException(), HttpStateData::handleMoreRequestBodyAvailable(), Ipc::Inquirer::handleRemoteAck(), Ipc::Forwarder::handleTimeout(), HttpStateData::httpStateConnClosed(), HttpStateData::httpTimeout(), Comm::ConnOpener::noteAbort(), Adaptation::Icap::ModXact::noteBodyConsumerAborted(), Snmp::Forwarder::noteCommClosed(), Snmp::Inquirer::noteCommClosed(), Mgr::Inquirer::noteCommClosed(), Mgr::Forwarder::noteCommClosed(), Mgr::StoreToCommWriter::noteCommClosed(), Adaptation::Icap::Xaction::noteCommRead(), Rock::HeaderUpdater::noteDoneReading(), Adaptation::Iterator::noteInitiatorAborted(), Adaptation::Icap::Xaction::noteInitiatorAborted(), Adaptation::Ecap::XactionRep::noteInitiatorAborted(), HttpStateData::readReply(), Comm::ConnOpener::sendAnswer(), Rock::Rebuild::start(), Security::PeerConnector::start(), HttpStateData::start(), Ipc::UdsSender::timedout(), and HttpStateData::wroteLast().

◆ noteAdaptationAclCheckDone()

void Client::noteAdaptationAclCheckDone ( Adaptation::ServiceGroupPointer  group)
virtualinherited

AccessCheck calls this back with a possibly nil service group to signal whether adaptation is needed and where it should start.

Reimplemented from Adaptation::Initiator.

Definition at line 905 of file Client.cc.

References Client::abortOnBadEntry(), Client::adaptationAccessCheckPending, debugs, HERE(), Client::originalRequest(), Client::processReplyBody(), Client::request, Client::sendBodyIsTooLargeError(), Client::setFinalReply(), Client::startAdaptation(), and Client::virginReply().

◆ noteAdaptationAnswer()

void Client::noteAdaptationAnswer ( const Adaptation::Answer answer)
virtualinherited

◆ noteBodyConsumerAborted()

void Client::noteBodyConsumerAborted ( BodyPipe::Pointer  )
virtualinherited

◆ noteBodyProducerAborted()

void Client::noteBodyProducerAborted ( BodyPipe::Pointer  bp)
virtualinherited

◆ noteBodyProductionEnded()

void Client::noteBodyProductionEnded ( BodyPipe::Pointer  bp)
virtualinherited

◆ noteMoreBodyDataAvailable()

void Client::noteMoreBodyDataAvailable ( BodyPipe::Pointer  bp)
virtualinherited

◆ noteMoreBodySpaceAvailable()

void Client::noteMoreBodySpaceAvailable ( BodyPipe::Pointer  )
virtualinherited

◆ openListenSocket()

bool Client::openListenSocket ( )
inherited

Definition at line 779 of file FtpClient.cc.

Referenced by Ftp::Client::sendEprt().

◆ originalRequest()

◆ parseListing()

◆ printfReplyBody()

void Ftp::Gateway::printfReplyBody ( const char *  fmt,
  ... 
)

Definition at line 2663 of file FtpGateway.cc.

References buf, and writeReplyBody().

◆ processHeadResponse()

◆ processReplyBody()

◆ readControlReply()

◆ readStor()

◆ replyBodySpace()

size_t Client::replyBodySpace ( const MemBuf readBuf,
const size_t  minSpace 
) const
protectedinherited

◆ restartable()

int Ftp::Gateway::restartable ( )

◆ resumeBodyStorage()

◆ scheduleReadControlReply()

◆ sendEprt()

◆ sendMoreRequestBody()

◆ sendPassive()

bool Client::sendPassive ( )
inherited
Checks for EPSV ALL special conditions: If enabled to be sent, squid MUST NOT request any other connect methods. If 'ALL' is sent and fails the entire FTP Session fails. NP: By my reading exact EPSV protocols maybe attempted, but only EPSV method.

Closes any old FTP-Data connection which may exist. */

Checks for previous EPSV/PASV failures on this server/session. Diverts to EPRT immediately if they are not working.
Send EPSV (ALL,2,1) or PASV on the control channel.
  • EPSV ALL is used if enabled.
  • EPSV 2 is used if ALL is disabled and IPv6 is available and ctrl channel is IPv6.
  • EPSV 1 is used if EPSV 2 (IPv6) fails or is not available or ctrl channel is IPv4.
  • PASV is used if EPSV 1 fails.

Definition at line 637 of file FtpClient.cc.

References SquidConfig::accessList, allow_t::allowed(), Packable::appendf(), Ftp::Channel::close(), Config, Ftp::Channel::conn, MemBuf::content(), Ftp::crlf, Ftp::Client::ctrl, Ftp::Client::data, DBG_IMPORTANT, debugs, SquidConfig::epsv_all, ERR_FTP_FAILURE, Ftp::Client::failed(), ACLChecklist::fastCheck(), SquidConfig::Ftp, SquidConfig::ftp_epsv, Client::fwd, Ip::Address::isIPv4(), Ip::Address::isIPv6(), Comm::Connection::local, Ftp::CtrlChannel::message, NULL, Ftp::CtrlChannel::offset, SquidConfig::passive, Comm::Connection::remote, FwdState::request, MemBuf::reset(), Ftp::Client::sendEprt(), Ftp::Client::SENT_EPSV_1, Ftp::Client::SENT_EPSV_2, Ftp::Client::SENT_EPSV_ALL, Ftp::Client::SENT_PASV, Ftp::Client::shortenReadTimeout, Ftp::Client::state, AsyncJob::status(), wordlistDestroy(), and Ftp::Client::writeCommand().

Referenced by ftpSendPassive(), Ftp::Client::handleEpsvReply(), and Ftp::Relay::sendCommand().

◆ sendPort()

bool Client::sendPort ( )
inherited

Definition at line 630 of file FtpClient.cc.

References ERR_FTP_FAILURE, and Ftp::Client::failed().

Referenced by Ftp::Client::sendEprt().

◆ sentRequestBody()

void Client::sentRequestBody ( const CommIoCbParams io)
protectedvirtualinherited

◆ serverComplete()

◆ setCurrentOffset()

void Ftp::Gateway::setCurrentOffset ( int64_t  offset)
inline

Definition at line 148 of file FtpGateway.cc.

Referenced by ftpReadRest(), and hackShortcut().

◆ setFinalReply()

◆ setVirginReply()

HttpReply * Client::setVirginReply ( HttpReply r)
protectedinherited

◆ Start()

◆ start()

◆ startAdaptation()

◆ startRequestBodyFlow()

◆ status()

◆ stopConsumingFrom()

◆ stopProducingFor()

◆ storeReplyBody()

void Client::storeReplyBody ( const char *  buf,
ssize_t  len 
)
protectedinherited

Definition at line 993 of file Client.cc.

References Client::currentOffset, Client::entry, len, and StoreEntry::write().

Referenced by Client::addVirginReplyBody().

◆ swanSong()

◆ switchTimeoutToDataChannel()

void Ftp::Client::switchTimeoutToDataChannel ( )
inherited

Cancel the timeout on the Control socket and establish one on the data socket

Definition at line 1032 of file FtpClient.cc.

References commSetConnTimeout(), commUnsetConnTimeout(), Config, Ftp::Channel::conn, Ftp::Client::ctrl, Ftp::Client::data, JobCallback, SquidConfig::read, Ftp::Client::timeout(), and SquidConfig::Timeout.

Referenced by ftpReadList(), ftpReadRetr(), listenForDataChannel(), and readStor().

◆ timeout()

◆ toCbdata()

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited

◆ unhack()

void Ftp::Gateway::unhack ( )

Forget hack status. Next error is shown to the user

Definition at line 2372 of file FtpGateway.cc.

References debugs, HERE(), NULL, Ftp::Client::old_reply, Ftp::Client::old_request, and safe_free.

Referenced by ftpReadCwd(), ftpReadMdtm(), and ftpReadSize().

◆ virginReply() [1/2]

◆ virginReply() [2/2]

HttpReply * Client::virginReply ( )
protectedinherited

Definition at line 103 of file Client.cc.

References assert, and Client::theVirginReply.

◆ writeCommand()

◆ writeCommandCallback()

◆ writeReplyBody()

void Ftp::Gateway::writeReplyBody ( const char *  dataToWrite,
size_t  dataLength 
)

Call this when there is data from the origin server which should be sent to either StoreEntry, or to ICAP...

Definition at line 2679 of file FtpGateway.cc.

References Client::addVirginReplyBody(), debugs, and HERE().

Referenced by printfReplyBody(), and processReplyBody().

Member Data Documentation

◆ adaptationAccessCheckPending

◆ adaptedBodySource

◆ adaptedHeadSource

CbcPointer<Adaptation::Initiate> Client::adaptedHeadSource
protectedinherited

to get adapted response headers

Definition at line 174 of file Client.h.

Referenced by Client::cleanAdaptation(), Client::doneWithAdaptation(), Client::noteAdaptationAnswer(), and Client::startAdaptation().

◆ base_href

String Ftp::Gateway::base_href

Definition at line 106 of file FtpGateway.cc.

Referenced by buildTitleUrl(), and ~Gateway().

◆ clean_url

String Ftp::Gateway::clean_url

Definition at line 104 of file FtpGateway.cc.

◆ conn_att

int Ftp::Gateway::conn_att

Definition at line 107 of file FtpGateway.cc.

◆ ctrl

CtrlChannel Ftp::Client::ctrl
inherited

Definition at line 124 of file FtpClient.h.

Referenced by Ftp::Client::abortAll(), Ftp::Relay::abortOnData(), Ftp::Client::Client(), Ftp::Client::closeServer(), completedListing(), completeForwarding(), Ftp::Client::connectDataChannel(), Ftp::Relay::createHttpReply(), Ftp::Client::ctrlClosed(), Ftp::Client::doneWithServer(), Ftp::Client::failed(), failedHttpStatus(), ftpAcceptDataConnection(), ftpFail(), ftpOpenListenSocket(), ftpReadCwd(), ftpReadEPRT(), ftpReadEPSV(), ftpReadList(), ftpReadMdtm(), ftpReadMkdir(), ftpReadPass(), ftpReadPORT(), ftpReadRest(), ftpReadRetr(), ftpReadSize(), ftpReadTransferDone(), ftpReadType(), ftpReadUser(), ftpReadWelcome(), ftpSendReply(), ftpWriteTransferDone(), hackShortcut(), Ftp::Relay::handleControlReply(), handleControlReply(), Ftp::Client::handleControlReply(), Ftp::Client::handleEpsvReply(), Ftp::Client::handlePasvReply(), haveControlChannel(), listenForDataChannel(), loginFailed(), Ftp::Client::parseControlReply(), Ftp::Client::readControlReply(), Ftp::Relay::readCwdOrCdupReply(), Ftp::Relay::readDataReply(), Ftp::Relay::readEpsvReply(), Ftp::Relay::readFeatReply(), Ftp::Relay::readGreeting(), Ftp::Relay::readPasvReply(), Ftp::Relay::readReply(), readStor(), Ftp::Relay::readTransferDoneReply(), Ftp::Relay::readUserOrPassReply(), Ftp::Client::scheduleReadControlReply(), Ftp::Client::sendPassive(), Ftp::Relay::serverComplete(), start(), Ftp::Relay::startDirTracking(), Ftp::Relay::stopDirTracking(), Ftp::Client::switchTimeoutToDataChannel(), Ftp::Client::writeCommand(), and ~Gateway().

◆ currentOffset

int64_t Client::currentOffset = 0
protectedinherited

Our current offset in the StoreEntry

Definition at line 160 of file Client.h.

Referenced by Client::handleMoreAdaptedBodyAvailable(), Client::haveParsedReplyHeaders(), and Client::storeReplyBody().

◆ cwd_message

String Ftp::Gateway::cwd_message

Definition at line 117 of file FtpGateway.cc.

Referenced by completedListing(), ftpReadCwd(), handleControlReply(), and ~Gateway().

◆ data

◆ dirpath

char* Ftp::Gateway::dirpath

Definition at line 113 of file FtpGateway.cc.

Referenced by ftpTraverseDirectory(), htmlifyListEntry(), and ~Gateway().

◆ doneWithFwd

const char* Client::doneWithFwd = nullptr
protectedinherited

whether we should not be talking to FwdState; XXX: clear fwd instead points to a string literal which is used only for debugging

Definition at line 184 of file Client.h.

Referenced by Client::completeForwarding(), Ftp::Client::ctrlClosed(), HttpStateData::httpStateConnClosed(), and Client::swanSong().

◆ entry

StoreEntry* Client::entry = nullptr
inherited

Definition at line 164 of file Client.h.

Referenced by Client::abortOnBadEntry(), appendSuccessHeader(), Client::blockCaching(), HttpStateData::buildRequestPrefix(), Client::Client(), completedListing(), HttpStateData::continueAfterParsingHeader(), Ftp::Client::dataRead(), Ftp::Relay::failed(), Ftp::Client::failed(), Ftp::Relay::failedErrorMessage(), Ftp::Relay::forwardReply(), ftpAcceptDataConnection(), ftpFail(), ftpSendReply(), ftpWriteTransferDone(), Gateway(), Client::handleAdaptationAborted(), Client::handleAdaptationBlocked(), Client::handleAdaptedBodyProducerAborted(), Client::handledEarlyAdaptationAbort(), Client::handleMoreAdaptedBodyAvailable(), HttpStateData::handleMoreRequestBodyAvailable(), HttpStateData::handleRequestBodyProducerAborted(), HttpStateData::haveParsedReplyHeaders(), haveParsedReplyHeaders(), HttpStateData::HttpStateData(), HttpStateData::httpTimeout(), HttpStateData::keepaliveAccounting(), listenForDataChannel(), loginFailed(), Ftp::Client::maybeReadVirginBody(), parseListing(), HttpStateData::peerSupportsConnectionPinning(), processHeadResponse(), Ftp::Relay::processReplyBody(), HttpStateData::processReplyBody(), processReplyBody(), HttpStateData::processReplyHeader(), HttpStateData::processSurrogateControl(), Ftp::Client::readControlReply(), HttpStateData::readReply(), Ftp::Relay::Relay(), HttpStateData::reusableReply(), Client::sentRequestBody(), Client::setFinalReply(), start(), HttpStateData::statusIfComplete(), Client::storeReplyBody(), Ftp::Client::timeout(), HttpStateData::wroteLast(), Client::~Client(), and ~Gateway().

◆ filepath

◆ flags

◆ ftp_state_t

enum { ... } Ftp::Client::ftp_state_t

◆ ftpDataWrite

PF Ftp::Gateway::ftpDataWrite
static

Definition at line 152 of file FtpGateway.cc.

◆ fwd

◆ id

const InstanceId<AsyncJob> AsyncJob::id
protectedinherited

Definition at line 72 of file AsyncJob.h.

◆ inCall

◆ list_width

size_t Ftp::Gateway::list_width

Definition at line 116 of file FtpGateway.cc.

◆ listing

MemBuf Ftp::Gateway::listing

Definition at line 120 of file FtpGateway.cc.

Referenced by completedListing(), parseListing(), and processReplyBody().

◆ login_att

int Ftp::Gateway::login_att

Definition at line 108 of file FtpGateway.cc.

Referenced by ftpReadWelcome().

◆ mdtm

time_t Ftp::Gateway::mdtm

Definition at line 109 of file FtpGateway.cc.

Referenced by appendSuccessHeader(), ftpFail(), ftpReadMdtm(), and ftpSendReply().

◆ old_filepath

char* Ftp::Gateway::old_filepath

Definition at line 118 of file FtpGateway.cc.

Referenced by hackShortcut(), and ~Gateway().

◆ old_reply

char* Ftp::Client::old_reply
inherited

◆ old_request

char* Ftp::Client::old_request
inherited

◆ password

char Ftp::Gateway::password[MAX_URL]

Definition at line 100 of file FtpGateway.cc.

Referenced by buildTitleUrl(), checkAuth(), ftpSendPass(), Gateway(), loginParser(), and start().

◆ password_url

int Ftp::Gateway::password_url

Definition at line 101 of file FtpGateway.cc.

Referenced by buildTitleUrl(), failedHttpStatus(), loginFailed(), and loginParser().

◆ pathcomps

wordlist* Ftp::Gateway::pathcomps

◆ proxy_host

char* Ftp::Gateway::proxy_host

Definition at line 115 of file FtpGateway.cc.

Referenced by ftpSendUser().

◆ receivedWholeRequestBody

bool Client::receivedWholeRequestBody = false
protectedinherited

◆ reply_hdr

char* Ftp::Gateway::reply_hdr

Definition at line 102 of file FtpGateway.cc.

Referenced by ~Gateway().

◆ reply_hdr_state

int Ftp::Gateway::reply_hdr_state

Definition at line 103 of file FtpGateway.cc.

◆ request

◆ requestBodySource

◆ requestSender

◆ responseBodyBuffer

MemBuf* Client::responseBodyBuffer = nullptr
protectedinherited

◆ restart_offset

int64_t Ftp::Gateway::restart_offset

Definition at line 114 of file FtpGateway.cc.

Referenced by ftpReadRest(), ftpSendRest(), hackShortcut(), and restartable().

◆ startedAdaptation

bool Client::startedAdaptation = false
protectedinherited

◆ state

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ theSize

int64_t Ftp::Gateway::theSize

◆ title_url

String Ftp::Gateway::title_url

Definition at line 105 of file FtpGateway.cc.

Referenced by buildTitleUrl(), ftpListDir(), ftpReadSize(), and ~Gateway().

◆ typecode

char Ftp::Gateway::typecode

◆ typeName

◆ user

char Ftp::Gateway::user[MAX_URL]

Definition at line 99 of file FtpGateway.cc.

Referenced by buildTitleUrl(), checkAuth(), ftpRealm(), ftpSendUser(), Gateway(), loginParser(), and start().

◆ virginBodyDestination


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors