FtpServer.cc
Go to the documentation of this file.
743 request->http_ver = Http::ProtocolVersion(Ftp::ProtocolVersion().major, Ftp::ProtocolVersion().minor);
1107 mb.appendf("%i-Error-Detail-Brief: " SQUIDSBUFPH "\r\n", scode, SQUIDSBUFPRINT(detail->brief()));
1108 mb.appendf("%i-Error-Detail-Verbose: " SQUIDSBUFPH "\r\n", scode, SQUIDSBUFPRINT(detail->verbose(request)));
1542 ACLFilledChecklist bodyContinuationCheck(Config.accessList.forceRequestBodyContinuation, request, nullptr);
1836 writeCustomReply(master->userDataDone, master->userDataDone == 226 ? "Transfer complete" : "Server error; transfer aborted");
#define JobCallback(dbgSection, dbgLevel, Dialer, job, method)
Convenience macro to create a Dialer-based job callback.
Definition: AsyncJobCalls.h:69
#define CallJobHere(debugSection, debugLevel, job, Class, method)
Definition: AsyncJobCalls.h:58
CommCbFunPtrCallT< Dialer > * commCbCall(int debugSection, int debugLevel, const char *callName, const Dialer &dialer)
Definition: CommCalls.h:312
CBDATA_NAMESPACED_CLASS_INIT(Ftp, Server)
int httpHeaderParseQuotedString(const char *start, const int len, String *val)
Definition: HttpHeaderTools.cc:168
void comm_read(const Comm::ConnectionPointer &conn, char *buf, int len, AsyncCall::Pointer &callback)
Definition: Read.h:59
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition: TextException.h:63
Definition: FilledChecklist.h:32
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
Definition: FilledChecklist.h:101
void syncAle(HttpRequest *adaptedRequest, const char *logUri) const override
assigns uninitialized adapted_request and url ALE components
Definition: FilledChecklist.cc:121
HttpHeader allMeta
All REQMOD and RESPMOD meta headers merged. Last field wins conflicts.
Definition: History.h:63
Definition: AsyncCall.h:125
Definition: AsyncJob.h:32
virtual void callException(const std::exception &e)
called when the job throws during an async call
Definition: AsyncJob.cc:143
Definition: Subscription.h:49
Definition: CbcPointer.h:26
optimized set of C chars, with quick membership test and merge support
Definition: CharacterSet.h:18
CharacterSet complement(const char *complementLabel=nullptr) const
Definition: CharacterSet.cc:74
Definition: client_side_request.h:38
void initRequest(HttpRequest *)
Definition: client_side_request.cc:1609
size_t req_sz
raw request size on input, not current request size
Definition: client_side_request.h:162
static void Reset()
forgets the current context, setting it to nil/unknown
Definition: CodeContext.cc:77
Definition: CommCalls.h:93
AnyP::PortCfgPointer port
the configuration listening port this call relates to (may be nil)
Definition: CommCalls.h:100
Definition: CommCalls.h:196
Definition: CommCalls.h:281
Definition: CommCalls.h:166
Definition: CommCalls.h:128
Definition: CommCalls.h:105
Definition: CommCalls.h:114
Definition: ConnOpener.h:25
void leaveOrphanage()
resume relying on owner(s) to initiate an explicit connection closure
Definition: Connection.h:92
Definition: TcpAcceptor.h:39
Definition: client_side.h:84
virtual void clientPinnedConnectionClosed(const CommCloseCbParams &io)
Our close handler called by Comm when the pinned connection is closed.
Definition: client_side.cc:3697
struct ConnStateData::@36 flags
void noteBodyConsumerAborted(BodyPipe::Pointer) override=0
Definition: client_side.cc:2087
static bool Enabled(const int section, const int level)
whether debugging the given section and the given level produces output
Definition: Stream.h:75
Transaction information shared among our FTP client and server jobs.
Definition: FtpServer.h:43
void writeCustomReply(const int code, const char *msg, const HttpReply *reply=nullptr)
Definition: FtpServer.cc:507
void handleDataReply(const HttpReply *header, StoreIOBuffer receivedData)
Definition: FtpServer.cc:943
void calcUri(const SBuf *file)
computes uri member from host and, if tracked, working dir with file name
Definition: FtpServer.cc:345
bool handlePasvRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1413
bool handleDataRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1520
bool handleUploadRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1534
void writeForwardedReply(const HttpReply *reply)
Definition: FtpServer.cc:1036
void userDataCompletionCheckpoint(int finalStatusCode)
Definition: FtpServer.cc:1809
void connectedForData(const CommConnectCbParams ¶ms)
Done establishing a data connection to the user.
Definition: FtpServer.cc:1703
bool handleCdupRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1635
void writeForwardedForeign(const HttpReply *reply)
Definition: FtpServer.cc:1143
static void AcceptCtrlConnection(const CommAcceptCbParams ¶ms)
accept a new FTP control connection and hand it to a dedicated Server
Definition: FtpServer.cc:242
void maybeReadUploadData()
schedules another data connection read if needed
Definition: FtpServer.cc:109
void handleEprtReply(const HttpReply *header, StoreIOBuffer receivedData)
Definition: FtpServer.cc:1059
void changeState(const Ftp::ServerState newState, const char *reason)
Definition: FtpServer.cc:529
void handlePasvReply(const HttpReply *header, StoreIOBuffer receivedData)
Definition: FtpServer.cc:881
Http::Stream * earlyError(const EarlyErrorKind eek)
creates a context filled with an error message for a given early error
Definition: FtpServer.cc:570
void callException(const std::exception &e) override
called when the job throws during an async call
Definition: FtpServer.cc:1750
void handleFeatReply(const HttpReply *header, StoreIOBuffer receivedData)
Definition: FtpServer.cc:812
bool handlePortRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1491
void acceptDataConnection(const CommAcceptCbParams ¶ms)
Definition: FtpServer.cc:401
bool handleFeatRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1406
void writeErrorReply(const HttpReply *reply, const int status)
writes FTP error response with given status and reply-derived error details
Definition: FtpServer.cc:1095
void resetLogin(const char *reason)
clear client and server login-related state after the old login is gone
Definition: FtpServer.cc:336
void processParsedRequest(Http::StreamPointer &context) override
start processing a freshly parsed request
Definition: FtpServer.cc:156
void noteBodyConsumerAborted(BodyPipe::Pointer ptr) override
Definition: FtpServer.cc:231
void wroteReplyData(const CommIoCbParams &io)
called when we are done writing a chunk of the response data
Definition: FtpServer.cc:986
time_t idleTimeout() const override
timeout to use when waiting for the next request
Definition: FtpServer.cc:86
void clientPinnedConnectionClosed(const CommCloseCbParams &io) override
Our close handler called by Comm when the pinned connection is closed.
Definition: FtpServer.cc:316
bool writeControlMsgAndCall(HttpReply *rep, AsyncCall::Pointer &call) override
handle a control message received by context from a peer and call back
Definition: FtpServer.cc:1152
void handlePortReply(const HttpReply *header, StoreIOBuffer receivedData)
Definition: FtpServer.cc:921
void handleErrorReply(const HttpReply *header, StoreIOBuffer receivedData)
Definition: FtpServer.cc:934
void notePeerConnection(Comm::ConnectionPointer conn) override
called just before a FwdState-dispatched job starts using connection
Definition: FtpServer.cc:302
void handleReply(HttpReply *header, StoreIOBuffer receivedData) override
Definition: FtpServer.cc:778
bool createDataConnection(Ip::Address cltAddr)
[Re]initializes dataConn for active data transfers. Does not connect.
Definition: FtpServer.cc:1432
bool handleEpsvRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1596
void replyDataWritingCheckpoint()
ClientStream checks after (actual or skipped) reply data writing.
Definition: FtpServer.cc:1004
bool handlePassRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1628
void handleEpsvReply(const HttpReply *header, StoreIOBuffer receivedData)
Definition: FtpServer.cc:1072
void wroteEarlyReply(const CommIoCbParams &io)
Definition: FtpServer.cc:1234
Http::Stream * handleUserRequest(const SBuf &cmd, SBuf ¶ms)
Definition: FtpServer.cc:1358
void handleUploadReply(const HttpReply *header, StoreIOBuffer receivedData)
Definition: FtpServer.cc:1029
void noteMoreBodySpaceAvailable(BodyPipe::Pointer) override
Definition: FtpServer.cc:222
void shovelUploadData()
shovel upload data from the internal buffer to the body pipe if possible
Definition: FtpServer.cc:202
unsigned int listenForDataConnection()
Definition: FtpServer.cc:370
void writeForwardedReplyAndCall(const HttpReply *reply, AsyncCall::Pointer &call)
Definition: FtpServer.cc:1161
int pipelinePrefetchMax() const override
returning N allows a pipeline of 1+N requests (see pipeline_prefetch)
Definition: FtpServer.cc:80
bool checkDataConnPost() const
Check that client data connection is ready for immediate I/O.
Definition: FtpServer.cc:1692
void readUploadData(const CommIoCbParams &io)
imports more upload data from the data connection
Definition: FtpServer.cc:168
bool handleCwdRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1621
bool handleEprtRequest(String &cmd, String ¶ms)
Definition: FtpServer.cc:1567
void writeEarlyReply(const int code, const char *msg)
Definition: FtpServer.cc:476
Definition: HttpHeader.h:51
Definition: HttpHeader.h:75
HttpHeaderEntry * getEntry(HttpHeaderPos *pos) const
Definition: HttpHeader.cc:584
HttpHeaderEntry * findEntry(Http::HdrType id) const
Definition: HttpHeader.cc:603
void updateOrAddStr(Http::HdrType, const SBuf &)
Definition: HttpHeader.cc:1084
Definition: HttpReply.h:25
Definition: RequestMethod.h:27
Definition: HttpRequest.h:49
Adaptation::History::Pointer adaptHistory(bool createIfNone=false) const
Returns possibly nil history, creating it if requested.
Definition: HttpRequest.cc:404
bool forcedBodyContinuation
whether we have responded with HTTP 100 or FTP 150 already
Definition: HttpRequest.h:194
static HttpRequest * FromUrl(const SBuf &url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:517
const char * reason() const
retrieve the reason string for this status line
Definition: StatusLine.cc:44
Http::StatusCode status() const
retrieve the status code for this status line
Definition: StatusLine.h:45
Definition: Stream.h:73
struct Http::Stream::@74 flags
clientStreamNode * getClientReplyContext() const
Definition: Stream.cc:510
Definition: Address.h:41
unsigned int toHostStr(char *buf, const unsigned int len) const
Definition: Address.cc:842
static Pointer MakePortful(const AnyP::PortCfgPointer &aPort)
Definition: MasterXaction.h:54
Definition: MemBuf.h:24
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
Definition: Packable.h:61
Definition: Tokenizer.h:30
Definition: RequestFlags.h:23
int caseCmp(const SBuf &S, const size_type n) const
shorthand version for case-insensitive compare()
Definition: SBuf.h:283
SBuf & trim(const SBuf &toRemove, bool atBeginning=true, bool atEnd=true)
Definition: SBuf.cc:551
Definition: Server.h:32
struct SquidConfig::@107 accessList
struct SquidConfig::@93 Timeout
acl_access * forceRequestBodyContinuation
Definition: SquidConfig.h:404
struct StatCounters::@122 client_http
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
Definition: store.cc:1691
Definition: StoreIOBuffer.h:16
Definition: SquidString.h:26
Definition: client_side_reply.h:23
void setReplyToReply(HttpReply *reply)
creates a store entry for the reply and appends error reply to it
Definition: client_side_reply.cc:134
void createStoreEntry(const HttpRequestMethod &m, RequestFlags flags)
Definition: client_side_reply.cc:2081
Definition: clientStream.h:76
void clientProcessRequest(ConnStateData *conn, const Http1::RequestParserPointer &hp, Http::Stream *context)
Definition: client_side.cc:1588
void clientSetKeepaliveFlag(ClientHttpRequest *http)
decide whether to expect multiple requests on the corresponding connection
Definition: client_side.cc:698
void clientStartListeningOn(AnyP::PortCfgPointer &port, const RefCount< CommCbFunPtrCallT< CommAcceptCbPtrFun > > &subCall, const Ipc::FdNoteId fdNote)
accept requests to a given port and inform subCall about them
Definition: client_side.cc:3322
void comm_open_listener(int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note)
Definition: comm.cc:256
void clientStreamInit(dlink_list *list, CSR *func, CSD *rdetach, CSS *readstatus, ClientStreamData readdata, CSCB *callback, CSD *cdetach, ClientStreamData callbackdata, StoreIOBuffer tailBuffer)
Definition: clientStream.cc:112
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:25
void ReadCancel(int fd, AsyncCall::Pointer &callback)
Cancel the read pending on FD. No action if none pending.
Definition: Read.cc:219
void Write(const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE *free_func)
Definition: Write.cc:33
Definition: forward.h:24
static bool SupportedCommand(const SBuf &name)
Whether Squid FTP Relay supports a named feature (e.g., a command).
Definition: FtpServer.cc:1842
AnyP::ProtocolVersion ProtocolVersion()
Protocol version to use in Http::Message structures wrapping FTP messages.
Definition: Elements.cc:24
bool ParseProtoIpPort(const char *buf, Ip::Address &addr)
Definition: Parsing.cc:52
static bool CommandHasPathParameter(const SBuf &cmd)
whether the given FTP command has a pathname parameter
Definition: FtpServer.cc:544
bool ParseIpPort(const char *buf, const char *forceIp, Ip::Address &addr)
parses and validates "A1,A2,A3,A4,P1,P2" IP,port sequence
Definition: Parsing.cc:18
HttpReply * HttpReplyWrapper(const int ftpStatus, const char *ftpReason, const Http::StatusCode httpStatus, const int64_t clen)
Create an internal HttpReply structure to house FTP control response info.
Definition: Elements.cc:30
static void PrintReply(MemBuf &mb, const HttpReply *reply, const char *const prefix="")
Definition: FtpServer.cc:1213
AnyP::ProtocolVersion ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
HTTP version label information.
Definition: ProtocolVersion.h:19
Definition: parse.c:104
Definition: parse.c:160