FtpGateway.cc File Reference
#include "squid.h"
#include "acl/FilledChecklist.h"
#include "base/PackableStream.h"
#include "clients/forward.h"
#include "clients/FtpClient.h"
#include "comm.h"
#include "comm/ConnOpener.h"
#include "comm/Read.h"
#include "comm/TcpAcceptor.h"
#include "CommCalls.h"
#include "compat/strtoll.h"
#include "errorpage.h"
#include "fd.h"
#include "fde.h"
#include "FwdState.h"
#include "html/Quoting.h"
#include "HttpHdrContRange.h"
#include "HttpHeader.h"
#include "HttpHeaderRange.h"
#include "HttpReply.h"
#include "ip/tools.h"
#include "MemBuf.h"
#include "mime.h"
#include "rfc1738.h"
#include "SquidConfig.h"
#include "SquidString.h"
#include "StatCounters.h"
#include "Store.h"
#include "tools.h"
#include "util.h"
#include "wordlist.h"
#include "DelayPools.h"
#include "MemObject.h"
#include <cerrno>
Include dependency graph for FtpGateway.cc:

Go to the source code of this file.

Classes

struct  Ftp::GatewayFlags
 
class  Ftp::Gateway
 
struct  ftpListParts
 

Namespaces

namespace  Ftp
 

Macros

#define CTRL_BUFLEN   16*1024
 
#define MAX_TOKENS   64
 

Typedefs

typedef void() Ftp::StateMethod(Ftp::Gateway *)
 
typedef Ftp::StateMethod FTPSM
 

Functions

 CBDATA_NAMESPACED_CLASS_INIT (Ftp, Gateway)
 
static int is_month (const char *buf)
 
static void ftpListPartsFree (ftpListParts **parts)
 
static ftpListPartsftpListParseParts (const char *buf, struct Ftp::GatewayFlags flags)
 
static void ftpReadWelcome (Ftp::Gateway *ftpState)
 
static void ftpSendUser (Ftp::Gateway *ftpState)
 
static void ftpReadUser (Ftp::Gateway *ftpState)
 
static void ftpSendPass (Ftp::Gateway *ftpState)
 
static void ftpReadPass (Ftp::Gateway *ftpState)
 
static void ftpSendType (Ftp::Gateway *ftpState)
 
static void ftpReadType (Ftp::Gateway *ftpState)
 
static void ftpTraverseDirectory (Ftp::Gateway *ftpState)
 
static void ftpSendCwd (Ftp::Gateway *ftpState)
 
static void ftpReadCwd (Ftp::Gateway *ftpState)
 
static void ftpSendMkdir (Ftp::Gateway *ftpState)
 
static void ftpReadMkdir (Ftp::Gateway *ftpState)
 
static void ftpGetFile (Ftp::Gateway *ftpState)
 
static void ftpListDir (Ftp::Gateway *ftpState)
 
static void ftpSendMdtm (Ftp::Gateway *ftpState)
 
static void ftpReadMdtm (Ftp::Gateway *ftpState)
 
static void ftpSendSize (Ftp::Gateway *ftpState)
 
static void ftpReadSize (Ftp::Gateway *ftpState)
 
static void ftpReadEPSV (Ftp::Gateway *ftpState)
 
static void ftpSendPassive (Ftp::Gateway *ftpState)
 
static void ftpReadPasv (Ftp::Gateway *ftpState)
 
static void ftpOpenListenSocket (Ftp::Gateway *ftpState, int fallback)
 
static void ftpSendPORT (Ftp::Gateway *ftpState)
 
static void ftpReadPORT (Ftp::Gateway *ftpState)
 
static void ftpReadEPRT (Ftp::Gateway *ftpState)
 
static void ftpRestOrList (Ftp::Gateway *ftpState)
 
static void ftpSendStor (Ftp::Gateway *ftpState)
 
static void ftpReadStor (Ftp::Gateway *ftpState)
 
static void ftpSendRest (Ftp::Gateway *ftpState)
 
static void ftpReadRest (Ftp::Gateway *ftpState)
 
static void ftpSendList (Ftp::Gateway *ftpState)
 
static void ftpSendNlst (Ftp::Gateway *ftpState)
 
static void ftpReadList (Ftp::Gateway *ftpState)
 
static void ftpSendRetr (Ftp::Gateway *ftpState)
 
static void ftpReadRetr (Ftp::Gateway *ftpState)
 
static void ftpReadTransferDone (Ftp::Gateway *ftpState)
 
static void ftpWriteTransferDone (Ftp::Gateway *ftpState)
 
static void ftpSendQuit (Ftp::Gateway *ftpState)
 
static void ftpReadQuit (Ftp::Gateway *ftpState)
 
static void ftpTrySlashHack (Ftp::Gateway *ftpState)
 
static void ftpFail (Ftp::Gateway *ftpState)
 
static void ftpSendReply (Ftp::Gateway *ftpState)
 

Variables

static char cbuf [CTRL_BUFLEN]
 
static FTPSM ftpReadWelcome
 
static FTPSM ftpSendUser
 
static FTPSM ftpReadUser
 
static FTPSM ftpSendPass
 
static FTPSM ftpReadPass
 
static FTPSM ftpSendType
 
static FTPSM ftpReadType
 
static FTPSM ftpSendMdtm
 
static FTPSM ftpReadMdtm
 
static FTPSM ftpSendSize
 
static FTPSM ftpReadSize
 
static FTPSM ftpReadEPRT
 
static FTPSM ftpSendPORT
 
static FTPSM ftpReadPORT
 
static FTPSM ftpSendPassive
 
static FTPSM ftpReadEPSV
 
static FTPSM ftpReadPasv
 
static FTPSM ftpTraverseDirectory
 
static FTPSM ftpListDir
 
static FTPSM ftpGetFile
 
static FTPSM ftpSendCwd
 
static FTPSM ftpReadCwd
 
static FTPSM ftpRestOrList
 
static FTPSM ftpSendList
 
static FTPSM ftpSendNlst
 
static FTPSM ftpReadList
 
static FTPSM ftpSendRest
 
static FTPSM ftpReadRest
 
static FTPSM ftpSendRetr
 
static FTPSM ftpReadRetr
 
static FTPSM ftpReadTransferDone
 
static FTPSM ftpSendStor
 
static FTPSM ftpReadStor
 
static FTPSM ftpWriteTransferDone
 
static FTPSM ftpSendReply
 
static FTPSM ftpSendMkdir
 
static FTPSM ftpReadMkdir
 
static FTPSM ftpFail
 
static FTPSM ftpSendQuit
 
static FTPSM ftpReadQuit
 
FTPSMFTP_SM_FUNCS []
 
static const char * Month []
 

Macro Definition Documentation

◆ CTRL_BUFLEN

#define CTRL_BUFLEN   16*1024

Definition at line 192 of file FtpGateway.cc.

◆ MAX_TOKENS

#define MAX_TOKENS   64

Definition at line 523 of file FtpGateway.cc.

Typedef Documentation

◆ FTPSM

Definition at line 179 of file FtpGateway.cc.

Function Documentation

◆ CBDATA_NAMESPACED_CLASS_INIT()

CBDATA_NAMESPACED_CLASS_INIT ( Ftp  ,
Gateway   
)

◆ ftpFail()

◆ ftpGetFile()

static void ftpGetFile ( Ftp::Gateway ftpState)
static

◆ ftpListDir()

static void ftpListDir ( Ftp::Gateway ftpState)
static

◆ ftpListParseParts()

static ftpListParts * ftpListParseParts ( const char *  buf,
struct Ftp::GatewayFlags  flags 
)
static

◆ ftpListPartsFree()

static void ftpListPartsFree ( ftpListParts **  parts)
static

Definition at line 514 of file FtpGateway.cc.

References safe_free.

Referenced by ftpListParseParts(), and Ftp::Gateway::htmlifyListEntry().

◆ ftpOpenListenSocket()

static void ftpOpenListenSocket ( Ftp::Gateway ftpState,
int  fallback 
)
static

◆ ftpReadCwd()

◆ ftpReadEPRT()

static void ftpReadEPRT ( Ftp::Gateway ftpState)
static

◆ ftpReadEPSV()

static void ftpReadEPSV ( Ftp::Gateway ftpState)
static

◆ ftpReadList()

◆ ftpReadMdtm()

◆ ftpReadMkdir()

◆ ftpReadPass()

static void ftpReadPass ( Ftp::Gateway ftpState)
static

◆ ftpReadPasv()

static void ftpReadPasv ( Ftp::Gateway ftpState)
static

◆ ftpReadPORT()

static void ftpReadPORT ( Ftp::Gateway ftpState)
static

◆ ftpReadQuit()

static void ftpReadQuit ( Ftp::Gateway ftpState)
static

Completes a client FTP operation with success or other page generated and stored in the entry field by the code issuing QUIT.

Definition at line 2289 of file FtpGateway.cc.

References Client::serverComplete().

◆ ftpReadRest()

◆ ftpReadRetr()

◆ ftpReadSize()

◆ ftpReadStor()

static void ftpReadStor ( Ftp::Gateway ftpState)
static
Deprecated:
use ftpState->readStor() instead.

Definition at line 1999 of file FtpGateway.cc.

References Ftp::Gateway::readStor().

◆ ftpReadTransferDone()

◆ ftpReadType()

◆ ftpReadUser()

static void ftpReadUser ( Ftp::Gateway ftpState)
static

◆ ftpReadWelcome()

◆ ftpRestOrList()

◆ ftpSendCwd()

◆ ftpSendList()

◆ ftpSendMdtm()

◆ ftpSendMkdir()

◆ ftpSendNlst()

◆ ftpSendPass()

◆ ftpSendPassive()

static void ftpSendPassive ( Ftp::Gateway ftpState)
static

Send Passive connection request. Default method is to use modern EPSV request. The failover mechanism should check for previous state and re-call with alternates on failure.

Checks the server control channel is still available before running.

Checks for 'HEAD' method request and passes off for special handling by Ftp::Gateway::processHeadResponse().

Definition at line 1657 of file FtpGateway.cc.

References debugs, Ftp::GatewayFlags::epsv_all_sent, Ftp::Gateway::flags, Ftp::Gateway::haveControlChannel(), Ftp::GatewayFlags::isdir, HttpRequest::method, Http::METHOD_HEAD, MYNAME, Ftp::Gateway::processHeadResponse(), Client::request, Ftp::Client::sendPassive(), Ftp::Client::SENT_EPSV_ALL, Ftp::Client::state, and Ftp::Gateway::theSize.

◆ ftpSendPORT()

◆ ftpSendQuit()

static void ftpSendQuit ( Ftp::Gateway ftpState)
static

◆ ftpSendReply()

◆ ftpSendRest()

◆ ftpSendRetr()

◆ ftpSendSize()

◆ ftpSendStor()

◆ ftpSendType()

◆ ftpSendUser()

◆ ftpTraverseDirectory()

◆ ftpTrySlashHack()

◆ ftpWriteTransferDone()

◆ is_month()

static int is_month ( const char *  buf)
static

Definition at line 502 of file FtpGateway.cc.

References Month.

Referenced by ftpListParseParts().

Variable Documentation

◆ cbuf

◆ FTP_SM_FUNCS

FTPSM* FTP_SM_FUNCS[]
Initial value:
= {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr
}
static FTPSM ftpReadPass
Definition: FtpGateway.cc:205
static FTPSM ftpReadTransferDone
Definition: FtpGateway.cc:231
static FTPSM ftpReadMkdir
Definition: FtpGateway.cc:237
static FTPSM ftpReadStor
Definition: FtpGateway.cc:233
static FTPSM ftpWriteTransferDone
Definition: FtpGateway.cc:234
static FTPSM ftpReadPORT
Definition: FtpGateway.cc:214
static FTPSM ftpReadPasv
Definition: FtpGateway.cc:217
static FTPSM ftpReadEPSV
Definition: FtpGateway.cc:216
static FTPSM ftpReadList
Definition: FtpGateway.cc:226
static FTPSM ftpReadWelcome
Definition: FtpGateway.cc:201
static FTPSM ftpReadUser
Definition: FtpGateway.cc:203
static FTPSM ftpReadRest
Definition: FtpGateway.cc:228
static FTPSM ftpReadQuit
Definition: FtpGateway.cc:240
static FTPSM ftpReadRetr
Definition: FtpGateway.cc:230
static FTPSM ftpReadSize
Definition: FtpGateway.cc:211
static FTPSM ftpReadMdtm
Definition: FtpGateway.cc:209
static FTPSM ftpReadCwd
Definition: FtpGateway.cc:222
static FTPSM ftpReadEPRT
Definition: FtpGateway.cc:212
static FTPSM ftpReadType
Definition: FtpGateway.cc:207

Definition at line 284 of file FtpGateway.cc.

Referenced by Ftp::Gateway::handleControlReply().

◆ ftpFail

◆ ftpGetFile

FTPSM ftpGetFile
static

Definition at line 220 of file FtpGateway.cc.

Referenced by ftpTraverseDirectory(), and ftpTrySlashHack().

◆ ftpListDir

FTPSM ftpListDir
static

Definition at line 219 of file FtpGateway.cc.

Referenced by ftpReadType(), and ftpTraverseDirectory().

◆ ftpReadCwd

FTPSM ftpReadCwd
static

Definition at line 222 of file FtpGateway.cc.

◆ ftpReadEPRT

FTPSM ftpReadEPRT
static

Definition at line 212 of file FtpGateway.cc.

◆ ftpReadEPSV

FTPSM ftpReadEPSV
static

Definition at line 216 of file FtpGateway.cc.

◆ ftpReadList

FTPSM ftpReadList
static

Definition at line 226 of file FtpGateway.cc.

◆ ftpReadMdtm

FTPSM ftpReadMdtm
static

Definition at line 209 of file FtpGateway.cc.

◆ ftpReadMkdir

FTPSM ftpReadMkdir
static

Definition at line 237 of file FtpGateway.cc.

◆ ftpReadPass

FTPSM ftpReadPass
static

Definition at line 205 of file FtpGateway.cc.

Referenced by ftpReadUser().

◆ ftpReadPasv

FTPSM ftpReadPasv
static

Definition at line 217 of file FtpGateway.cc.

◆ ftpReadPORT

FTPSM ftpReadPORT
static

Definition at line 214 of file FtpGateway.cc.

Referenced by ftpSendPORT().

◆ ftpReadQuit

FTPSM ftpReadQuit
static

Definition at line 240 of file FtpGateway.cc.

◆ ftpReadRest

FTPSM ftpReadRest
static

Definition at line 228 of file FtpGateway.cc.

◆ ftpReadRetr

FTPSM ftpReadRetr
static

Definition at line 230 of file FtpGateway.cc.

◆ ftpReadSize

FTPSM ftpReadSize
static

Definition at line 211 of file FtpGateway.cc.

◆ ftpReadStor

FTPSM ftpReadStor
static

Definition at line 233 of file FtpGateway.cc.

◆ ftpReadTransferDone

FTPSM ftpReadTransferDone
static

Definition at line 231 of file FtpGateway.cc.

◆ ftpReadType

FTPSM ftpReadType
static

Definition at line 207 of file FtpGateway.cc.

◆ ftpReadUser

FTPSM ftpReadUser
static

Definition at line 203 of file FtpGateway.cc.

◆ ftpReadWelcome

FTPSM ftpReadWelcome
static

Definition at line 201 of file FtpGateway.cc.

◆ ftpRestOrList

FTPSM ftpRestOrList
static

Definition at line 223 of file FtpGateway.cc.

Referenced by Ftp::Gateway::dataChannelConnected(), ftpReadEPRT(), and ftpReadPORT().

◆ ftpSendCwd

FTPSM ftpSendCwd
static

Definition at line 221 of file FtpGateway.cc.

Referenced by ftpReadMkdir(), ftpReadRetr(), and ftpTraverseDirectory().

◆ ftpSendList

FTPSM ftpSendList
static

Definition at line 224 of file FtpGateway.cc.

Referenced by ftpRestOrList().

◆ ftpSendMdtm

FTPSM ftpSendMdtm
static

Definition at line 208 of file FtpGateway.cc.

Referenced by ftpGetFile().

◆ ftpSendMkdir

FTPSM ftpSendMkdir
static

Definition at line 236 of file FtpGateway.cc.

Referenced by ftpReadCwd(), and ftpRestOrList().

◆ ftpSendNlst

FTPSM ftpSendNlst
static

Definition at line 225 of file FtpGateway.cc.

Referenced by ftpReadList(), and ftpRestOrList().

◆ ftpSendPass

FTPSM ftpSendPass
static

Definition at line 204 of file FtpGateway.cc.

Referenced by ftpReadUser().

◆ ftpSendPassive

FTPSM ftpSendPassive
static

◆ ftpSendPORT

FTPSM ftpSendPORT
static

Definition at line 213 of file FtpGateway.cc.

Referenced by ftpReadEPRT().

◆ ftpSendQuit

FTPSM ftpSendQuit
static

◆ ftpSendReply

FTPSM ftpSendReply
static

Definition at line 235 of file FtpGateway.cc.

Referenced by ftpReadMkdir(), ftpSendStor(), and ftpWriteTransferDone().

◆ ftpSendRest

FTPSM ftpSendRest
static

Definition at line 227 of file FtpGateway.cc.

Referenced by ftpRestOrList().

◆ ftpSendRetr

FTPSM ftpSendRetr
static

Definition at line 229 of file FtpGateway.cc.

Referenced by ftpReadRest(), and ftpRestOrList().

◆ ftpSendSize

FTPSM ftpSendSize
static

Definition at line 210 of file FtpGateway.cc.

Referenced by ftpReadMdtm().

◆ ftpSendStor

FTPSM ftpSendStor
static

Definition at line 232 of file FtpGateway.cc.

Referenced by ftpRestOrList().

◆ ftpSendType

FTPSM ftpSendType
static

Definition at line 206 of file FtpGateway.cc.

Referenced by ftpReadPass().

◆ ftpSendUser

FTPSM ftpSendUser
static

Definition at line 202 of file FtpGateway.cc.

Referenced by ftpReadWelcome().

◆ ftpTraverseDirectory

FTPSM ftpTraverseDirectory
static

Definition at line 218 of file FtpGateway.cc.

Referenced by ftpReadCwd(), and ftpReadType().

◆ ftpWriteTransferDone

FTPSM ftpWriteTransferDone
static

Definition at line 234 of file FtpGateway.cc.

◆ Month

const char* Month[]
static
Initial value:
= {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}

Definition at line 496 of file FtpGateway.cc.

Referenced by is_month().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors