Go to the documentation of this file.
129 void start()
override;
193 #define CTRL_BUFLEN 16*1024
345 old_filepath(nullptr),
367 debugs(9, 3, entry->url());
371 "control channel " << ctrl.conn);
400 debugs(9, 4,
"login=" << login <<
", escaped=" << escaped);
401 debugs(9, 9,
"IN : login=" << login <<
", escaped=" << escaped <<
", user=" << user <<
", password=" << password);
407 debugs(9, 2,
"WARNING: Ignoring FTP credentials that start with a NUL character");
418 const SBuf userName = login.
substr(0, colonPos);
421 debugs(9, 9,
"found user=" << userName <<
' ' <<
422 (upto != userName.
length() ?
", truncated-to=" :
", length=") << upto <<
423 ", escaped=" << escaped);
426 debugs(9, 9,
"found user=" << user <<
" (" << strlen(user) <<
") unescaped.");
436 debugs(9, 9,
"found password=" << pass <<
" " <<
437 (upto != pass.
length() ?
", truncated-to=" :
", length=") << upto <<
438 ", escaped=" << escaped);
443 debugs(9, 9,
"found password=" << password <<
" (" << strlen(password) <<
") unescaped.");
446 debugs(9, 9,
"OUT: login=" << login <<
", escaped=" << escaped <<
", user=" << user <<
", password=" << password);
453 debugs(9, 5,
"The control connection to the remote end is closed");
463 const char *note = entry->url();
472 debugs(9, 3,
"Unconnected data socket created on " << conn);
475 conn->
tos = ctrl.conn->tos;
476 conn->
nfmark = ctrl.conn->nfmark;
482 data.opened(conn, dataCloser());
483 switchTimeoutToDataChannel();
489 if (SENT_PASV == state) {
491 flags.pasv_supported =
false;
495 dataConnWait.cancel(
"timeout");
504 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
505 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
513 for (i = 0; i < 12; ++i)
514 if (!strcasecmp(buf,
Month[i]))
530 #define MAX_TOKENS 64
537 struct FtpLineToken {
538 char *token =
nullptr;
543 static char tbuf[128];
544 char *xbuf =
nullptr;
545 static int scan_ftp_initialized = 0;
546 static regex_t scan_ftp_integer;
547 static regex_t scan_ftp_time;
548 static regex_t scan_ftp_dostime;
549 static regex_t scan_ftp_dosdate;
551 if (!scan_ftp_initialized) {
552 scan_ftp_initialized = 1;
553 regcomp(&scan_ftp_integer,
"^[0123456789]+$", REG_EXTENDED | REG_NOSUB);
554 regcomp(&scan_ftp_time,
"^[0123456789:]+$", REG_EXTENDED | REG_NOSUB);
555 regcomp(&scan_ftp_dosdate,
"^[0123456789]+-[0123456789]+-[0123456789]+$", REG_EXTENDED | REG_NOSUB);
556 regcomp(&scan_ftp_dostime,
"^[0123456789]+:[0123456789]+[AP]M$", REG_EXTENDED | REG_NOSUB | REG_ICASE);
580 tokens[n_tokens].pos = t - xbuf;
587 for (i = 3; i < n_tokens - 2; ++i) {
596 if (regexec(&scan_ftp_integer,
size, 0,
nullptr, 0) != 0)
599 if (regexec(&scan_ftp_integer, day, 0,
nullptr, 0) != 0)
602 if (regexec(&scan_ftp_time, year, 0,
nullptr, 0) != 0)
605 const auto *copyFrom = buf +
tokens[i].pos;
608 auto dateSize = snprintf(tbuf,
sizeof(tbuf),
"%s %2s %5s", month, day, year);
609 bool isTypeA = (dateSize == 12) && (strncmp(copyFrom, tbuf, dateSize) == 0);
612 dateSize = snprintf(tbuf,
sizeof(tbuf),
"%s %2s %-5s", month, day, year);
613 bool isTypeB = (dateSize == 12 || dateSize == 11) && (strncmp(copyFrom, tbuf, dateSize) == 0);
616 if (isTypeA || isTypeB) {
619 const auto finalDateSize = snprintf(tbuf,
sizeof(tbuf),
"%s %2s %5s", month, day, year);
620 assert(finalDateSize >= 0);
624 copyFrom = buf +
tokens[i + 2].pos + strlen(
tokens[i + 2].token);
626 while (strchr(
w_space, *copyFrom))
637 if (strchr(
w_space, *copyFrom))
643 if (p->
type ==
'l' && (t = strstr(p->
name,
" -> "))) {
656 regexec(&scan_ftp_dosdate,
tokens[0].token, 0,
nullptr, 0) == 0 &&
657 regexec(&scan_ftp_dostime,
tokens[1].token, 0,
nullptr, 0) == 0) {
658 if (!strcasecmp(
tokens[2].token,
"<dir>")) {
665 snprintf(tbuf,
sizeof(tbuf),
"%s %s",
tokens[0].token,
tokens[1].token);
668 if (p->
type ==
'd') {
685 const char *ct = buf + 1;
690 int l = strcspn(ct,
",");
704 p->
size = atoi(ct + 1);
708 tm = (time_t) strtol(ct + 1, &tmp, 0);
716 *(strstr(p->
date,
"\n")) =
'\0';
738 ct = strstr(ct,
",");
757 for (i = 0; i < n_tokens; ++i)
769 debugs(9, 7,
"line={" << line <<
"}");
771 if (strlen(line) > 1024) {
772 html <<
"<tr><td colspan=\"5\">" << line <<
"</td></tr>\n";
777 if (flags.dir_slash && dirpath && typecode !=
'D') {
784 html <<
"<tr class=\"entry\"><td colspan=\"5\">" << line <<
"</td></tr>\n";
787 for (p = line; *p &&
xisspace(*p); ++p);
789 flags.listformat_unknown = 1;
794 if (!strcmp(parts->
name,
".") || !strcmp(parts->
name,
"..")) {
810 switch (parts->
type) {
813 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
820 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
835 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
838 chdir.
appendf(
"<a href=\"%s/;type=d\"><img border=\"0\" src=\"%s\" "
839 "alt=\"[DIR]\"></a>",
847 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
855 if (parts->
type !=
'd') {
858 "alt=\"[VIEW]\"></a>",
864 "alt=\"[DOWNLOAD]\"></a>",
870 html <<
"<tr class=\"entry\">"
871 "<td class=\"icon\"><a href=\"" << href <<
"\">" << icon <<
"</a></td>"
872 "<td class=\"filename\"><a href=\"" << href <<
"\">" <<
html_quote(
text.
c_str()) <<
"</a></td>"
873 "<td class=\"date\">" << parts->
date <<
"</td>"
874 "<td class=\"size\">" <<
size <<
"</td>"
875 "<td class=\"actions\">" << chdir << view << download << link <<
"</td>"
885 char *buf = data.readBuf->content();
892 size_t len = data.readBuf->contentSize();
895 debugs(9, 3,
"no content to parse for " << entry->url() );
902 sbuf = (
char *)
xmalloc(len + 1);
904 end = sbuf + len - 1;
906 while (*end !=
'\r' && *end !=
'\n' && end > sbuf)
911 debugs(9, 3,
"usable = " << usable <<
" of " << len <<
" bytes.");
914 if (buf[0] ==
'\0' && len == 1) {
915 debugs(9, 3,
"NIL ends data from " << entry->url() <<
" transfer problem?");
916 data.readBuf->consume(len);
918 debugs(9, 3,
"didn't find end for " << entry->url());
925 debugs(9, 3, (
unsigned long int)len <<
" bytes to play with");
930 s += strspn(s,
crlf);
932 for (; s < end; s += strcspn(s,
crlf), s += strspn(s,
crlf)) {
933 debugs(9, 7,
"s = {" << s <<
"}");
934 linelen = strcspn(s,
crlf) + 1;
944 debugs(9, 7,
"{" << line <<
"}");
946 if (!strncmp(line,
"total", 5))
953 if (htmlifyListEntry(line, html)) {
961 data.readBuf->consume(usable);
977 if (!flags.http_header_sent && data.readBuf->contentSize() >= 0 && !flags.isdir)
978 appendSuccessHeader();
985 abortAll(
"entry aborted after calling appendSuccessHeader()");
991 if (adaptationAccessCheckPending) {
992 debugs(9, 3,
"returning from Ftp::Gateway::processReplyBody due to adaptationAccessCheckPending");
999 if (!flags.listing) {
1004 maybeReadVirginBody();
1006 }
else if (
const auto csize = data.readBuf->contentSize()) {
1007 writeReplyBody(data.readBuf->content(), csize);
1008 debugs(9, 5,
"consuming " << csize <<
" bytes of readBuf");
1009 data.readBuf->consume(csize);
1014 maybeReadVirginBody();
1039 #if HAVE_AUTH_MODULE_BASIC
1042 if (!auth.isEmpty()) {
1043 flags.authenticated = 1;
1044 loginParser(auth,
false);
1052 loginParser(request->url.userInfo(),
true);
1064 if (strcmp(user,
"anonymous") == 0 && !flags.tried_auth_anonymous) {
1066 flags.tried_auth_anonymous=1;
1068 }
else if (!flags.tried_auth_nopass) {
1070 flags.tried_auth_nopass=1;
1084 static const SBuf middle(
";type=");
1085 const auto typeSpecStart = request->url.path().find(middle);
1087 const auto fullPath = request->url.path();
1088 const auto typecodePos = typeSpecStart + middle.
length();
1089 typecode = (typecodePos < fullPath.length()) ?
1090 static_cast<char>(
xtoupper(fullPath[typecodePos])) :
'\0';
1091 request->url.path(fullPath.substr(0, typeSpecStart));
1094 int l = request->url.path().length();
1100 flags.need_base_href = 1;
1101 }
else if (!request->url.path().cmp(
"/%2f/")) {
1105 }
else if ((l >= 1) && (request->url.path()[l-1] ==
'/')) {
1112 flags.dir_slash = 1;
1119 title_url =
"ftp://";
1121 if (strcmp(user,
"anonymous")) {
1122 title_url.append(user);
1123 title_url.append(
"@");
1128 title_url.
append(authority);
1129 title_url.
append(request->url.path());
1131 base_href =
"ftp://";
1133 if (strcmp(user,
"anonymous") != 0) {
1144 base_href.
append(authority);
1145 base_href.
append(request->url.path());
1152 if (!checkAuth(&request->header)) {
1154 SBuf realm(ftpRealm());
1155 const auto reply = ftpAuthRequired(request.getRaw(), realm, fwd->al);
1156 entry->replaceHttpReply(reply);
1163 debugs(9, 5,
"FD " << (ctrl.conn ? ctrl.conn->fd : -1) <<
" : host=" << request->url.host() <<
1164 ", path=" << request->url.path() <<
", user=" << user <<
", passwd=" << password);
1175 if (ctrl.message ==
nullptr)
1182 cwd_message.append(
'\n');
1183 cwd_message.append(w->key);
1207 }
else if (code == 120) {
1227 if ((state == SENT_USER || state == SENT_PASS) && ctrl.replycode >= 400) {
1228 if (ctrl.replycode == 421 || ctrl.replycode == 426) {
1231 }
else if (ctrl.replycode >= 430 && ctrl.replycode <= 439) {
1234 }
else if (ctrl.replycode >= 530 && ctrl.replycode <= 539) {
1248 failed(
ERR_NONE, ctrl.replycode, err);
1254 #if HAVE_AUTH_MODULE_BASIC
1257 SBuf realm(ftpRealm());
1262 entry->replaceHttpReply(newrep);
1272 realm.
appendf(
"FTP %s ", user);
1274 realm.
append(
"unknown", 7);
1276 realm.
append(request->url.host());
1277 const auto &rport = request->url.port();
1278 if (rport && *rport != 21)
1279 realm.
appendf(
" port %hu", *rport);
1309 }
else if (code == 331) {
1332 debugs(9, 3,
"code=" << code);
1396 debugs(9, 3,
"code=" << code);
1406 p += strcspn(p,
"/");
1442 debugs(9, 3,
"the final component was a directory");
1454 debugs(9, 3,
"final component is probably a file");
1463 char *path =
nullptr;
1473 if (!strcmp(path,
"..") || !strcmp(path,
"/")) {
1492 if (code >= 200 && code < 300) {
1519 char *path =
nullptr;
1526 debugs(9, 3,
"with path=" << path);
1538 debugs(9, 3,
"path " << path <<
", code " << code);
1542 }
else if (code == 550) {
1565 debugs(9, 3,
"Directory path did not end in /");
1595 }
else if (code < 0) {
1635 debugs(9, 2,
"SIZE reported " <<
1640 }
else if (code < 0) {
1690 debugs(9, 5,
"handling HEAD response");
1692 appendSuccessHeader();
1700 abortAll(
"entry aborted while processing HEAD");
1705 if (adaptationAccessCheckPending) {
1706 debugs(9,3,
"returning due to adaptationAccessCheckPending");
1733 dataConnWait.finish();
1736 debugs(9, 2,
"Failed to connect. Retrying via another method.");
1740 writeCommand(
"ABOR\r\n");
1747 data.opened(io.
conn, dataCloser());
1755 if (ftpState->
data.
conn !=
nullptr) {
1765 debugs(9, 5,
"The control connection to the remote end is closed");
1784 &
on,
sizeof(
on)) == -1) {
1793 temp->local.port(0);
1807 debugs(9,
DBG_IMPORTANT,
"FTP does not allow PORT method after 'EPSV ALL' has been sent.");
1832 struct addrinfo *AI =
nullptr;
1834 unsigned char *addrptr = (
unsigned char *) &((
struct sockaddr_in*)AI->ai_addr)->sin_addr;
1835 unsigned char *portptr = (
unsigned char *) &((
struct sockaddr_in*)AI->ai_addr)->sin_port;
1837 addrptr[0], addrptr[1], addrptr[2], addrptr[3],
1838 portptr[0], portptr[1]);
1853 debugs(9, 3,
"PORT not supported by remote end");
1868 debugs(9, 3,
"EPRT not supported by remote end");
1886 debugs(9, 5,
"The control connection to the remote end is closed");
1891 data.listenConn->close();
1892 data.listenConn =
nullptr;
1900 abortAll(
"entry aborted when accepting data conn");
1901 data.listenConn->close();
1902 data.listenConn =
nullptr;
1909 data.listenConn =
nullptr;
1929 "ERROR: FTP data connection from unexpected server (" <<
1931 data.conn->remote <<
" or " << ctrl.conn->remote);
1943 data.opened(io.
conn, dataCloser());
1946 debugs(9, 3,
"Connected data socket on " <<
1947 io.
conn <<
". FD table says: " <<
1948 "ctrl-peer= " <<
fd_table[ctrl.conn->fd].ipaddr <<
", " <<
1949 "data-peer= " <<
fd_table[data.conn->fd].ipaddr);
1951 assert(haveControlChannel(
"ftpAcceptDataConnection"));
1952 assert(ctrl.message ==
nullptr);
1989 if (ftpState->
filepath !=
nullptr) {
2014 int code = ctrl.replycode;
2018 if (!originalRequest()->body_pipe) {
2019 debugs(9, 3,
"zero-size STOR?");
2020 state = WRITING_DATA;
2025 if (!startRequestBodyFlow()) {
2031 debugs(9, 3,
"starting data transfer");
2032 switchTimeoutToDataChannel();
2033 sendMoreRequestBody();
2034 fwd->dontRetry(
true);
2035 state = WRITING_DATA;
2036 debugs(9, 3,
"writing data channel");
2037 }
else if (code == 150) {
2039 debugs(9, 3,
"ftpReadStor: accepting data channel");
2040 listenForDataChannel(data.conn);
2042 debugs(9,
DBG_IMPORTANT,
"ERROR: Unexpected reply code "<< std::setfill(
'0') << std::setw(3) << code);
2064 if (restart_offset > 0)
2067 if (!request->range)
2076 int64_t desired_offset = request->range->lowestOffset(theSize);
2078 if (desired_offset <= 0)
2081 if (desired_offset >= theSize)
2084 restart_offset = desired_offset;
2098 }
else if (code > 0) {
2099 debugs(9, 3,
"REST not supported");
2160 }
else if (code == 150) {
2200 }
else if (code == 150) {
2203 }
else if (code >= 300) {
2223 entry->lock(
"Ftp::Gateway");
2229 ctrl.message =
nullptr;
2232 entry->unlock(
"Ftp::Gateway");
2241 if (code == 226 || code == 250) {
2262 debugs(9, 3,
"ftpState=" <<
this);
2272 if (!(code == 226 || code == 250)) {
2337 if (old_request !=
nullptr) {
2347 setCurrentOffset(0);
2353 if (old_request ==
nullptr) {
2354 old_request = ctrl.last_command;
2355 ctrl.last_command =
nullptr;
2356 old_reply = ctrl.last_reply;
2357 ctrl.last_reply =
nullptr;
2359 if (pathcomps ==
nullptr && filepath !=
nullptr)
2360 old_filepath =
xstrdup(filepath);
2370 const bool slashHack = ftpState->
request->
url.
path().caseCmp(
"/%2f", 4)==0;
2375 " reply code " << code <<
"flags(" <<
2378 "mdtm=" << ftpState->
mdtm <<
", size=" << ftpState->
theSize <<
2379 "slashhack=" << (slashHack?
"T":
"F"));
2386 switch (ftpState->
state) {
2402 ftpState->
failed(error_code, 0, ftperr);
2404 HttpReply *newrep = ftperr->BuildHttpReply();
2421 if (ctrl.replycode > 500) {
2424 }
else if (ctrl.replycode == 421) {
2433 if (ctrl.replycode == 550) {
2456 debugs(9, 5,
"ftpState (" << ftpState <<
") is valid!");
2458 if (code == 226 || code == 250) {
2461 }
else if (code == 227) {
2495 if (flags.http_header_sent)
2500 flags.http_header_sent = 1;
2502 assert(entry->isEmpty());
2506 SBuf urlPath = request->url.path();
2507 auto t = urlPath.
rfind(
'/');
2510 const char *mime_type =
nullptr;
2511 const char *mime_enc =
nullptr;
2514 mime_type =
"text/html";
2519 mime_type =
"application/octet-stream";
2525 mime_type =
"text/plain";
2538 if (0 == getCurrentOffset()) {
2541 }
else if (theSize < getCurrentOffset()) {
2549 " current offset=" << getCurrentOffset() <<
2550 ", but theSize=" << theSize <<
2551 ". assuming full content response");
2556 range_spec.
offset = getCurrentOffset();
2557 range_spec.
length = theSize - getCurrentOffset();
2567 setVirginReply(reply);
2568 adaptOrFinalizeReply();
2581 if (flags.authenticated ||
2582 getCurrentOffset() ||
2593 #if HAVE_AUTH_MODULE_BASIC
2609 static const SBuf nil;
2613 if (request->
url.
path()[0] ==
'/') {
2616 }
else if (!request->
url.
path().startsWith(newbuf)) {
2631 debugs(9, 5,
"writing " << dataLength <<
" bytes to the reply");
2632 addVirginReplyBody(dataToWrite, dataLength);
2644 if (fwd ==
nullptr || flags.completed_forwarding) {
2645 debugs(9, 3,
"avoid double-complete on FD " <<
2646 (ctrl.conn ? ctrl.conn->fd : -1) <<
", Data FD " << (data.conn ? data.conn->fd : -1) <<
2647 ", this " <<
this <<
", fwd " << fwd);
2651 flags.completed_forwarding =
true;
2664 if (doneWithServer())
2669 debugs(9,
DBG_IMPORTANT,
"WARNING: FTP Server Control channel is closed, but Data channel still active.");
2670 debugs(9, 2, caller_name <<
": attempted on a closed FTP channel.");
2681 return !doneWithServer();
static void ftpTrySlashHack(Ftp::Gateway *ftpState)
const char * xstrerr(int error)
void processReplyBody() override
void handleRequestBodyProducerAborted() override
void * xcalloc(size_t n, size_t sz)
size_type find(char c, size_type startPos=0) const
void wordlistDestroy(wordlist **list)
destroy a wordlist
AnyP::Uri url
the request URI
bool makePublic(const KeyScope keyScope=ksDefault)
static FTPSM ftpReadTransferDone
void maybeReadVirginBody() override
read response data from the network
void connectDataChannel()
void writeCommand(const char *buf)
bool pasv_supported
PASV command is allowed.
static void ftpOpenListenSocket(Ftp::Gateway *ftpState, int fallback)
HttpReply * BuildHttpReply(void)
virtual void handleRequestBodyProducerAborted()=0
void error(char *format,...)
AccessLogEntryPointer al
info for the future access.log entry
@ ERR_CACHE_ACCESS_DENIED
bool tried_auth_nopass
auth tried username with no password already.
void dataClosed(const CommCloseCbParams &io) override
handler called by Comm when FTP data channel is closed unexpectedly
struct ErrorState::@47 ftp
void init(mb_size_t szInit, mb_size_t szMax)
static HttpReply * ftpAuthRequired(HttpRequest *request, SBuf &realm, AccessLogEntry::Pointer &)
bool htmlifyListEntry(const char *line, PackableStream &)
void SBufToCstring(char *d, const SBuf &s)
void handleControlReply() override
int checkAuth(const HttpHeader *req_hdr)
static void FreeAddr(struct addrinfo *&ai)
void loginParser(const SBuf &login, bool escaped)
char * xstrncpy(char *dst, const char *src, size_t n)
void detailError(const ErrorDetail::Pointer &dCode)
set error type-specific detail code
int cbdataReferenceValid(const void *p)
bool IsConnOpen(const Comm::ConnectionPointer &conn)
#define rfc1738_escape(x)
virtual void failed(err_type error=ERR_NONE, int xerrno=0, ErrorState *ftperr=nullptr)
handle a fatal transaction error, closing the control connection
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
void * memAllocate(mem_type)
Allocate one element from the typed pool.
static FTPSM ftpSendMkdir
static FTPSM ftpRestOrList
virtual void haveParsedReplyHeaders()
called when we have final (possibly adapted) reply headers; kids extend
char * wordlistChopHead(wordlist **wl)
int xerrno
The last errno to occur. non-zero if flag is Comm::COMM_ERROR.
SBuf substr(size_type pos, size_type n=npos) const
FTP client functionality shared among FTP Gateway and Relay clients.
virtual void completeForwarding()
void() StateMethod(Ftp::Gateway *)
CBDATA_NAMESPACED_CLASS_INIT(Ftp, Gateway)
void comm_open_listener(int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note)
virtual bool haveControlChannel(const char *caller_name) const
size_type rfind(char c, size_type endPos=npos) const
bool handlePasvReply(Ip::Address &remoteAddr)
mb_size_t contentSize() const
available data size
static FTPSM ftpReadMkdir
void start() override
called by AsyncStart; do not call directly
static char cbuf[CTRL_BUFLEN]
bool completed_forwarding
void rfc1738_unescape(char *url)
#define SQUIDSBUFPRINT(s)
virtual void handleControlReply()
virtual void dataClosed(const CommCloseCbParams &io)
handler called by Comm when FTP data channel is closed unexpectedly
MemBlob::size_type size_type
void append(char const *buf, int len)
static FTPSM ftpReadWelcome
HttpRequestPointer request
char * html_quote(const char *string)
void appendSuccessHeader()
SBuf text("GET http://resource.com/path HTTP/1.1\r\n" "Host: resource.com\r\n" "Cookie: laijkpk3422r j1noin \r\n" "\r\n")
#define EBIT_TEST(flag, bit)
bool handleEpsvReply(Ip::Address &remoteAddr)
int xsetsockopt(int socketFd, int level, int option, const void *value, socklen_t valueLength)
POSIX setsockopt(2) equivalent.
void timeout(const CommTimeoutCbParams &io) override
read timeout handler
Comm::ConnectionPointer conn
@ srcFtp
ftp_port or FTP server
void close()
planned close: removes the close handler and calls comm_close
void ftpAcceptDataConnection(const CommAcceptCbParams &io)
bool tried_auth_anonymous
auth has tried to use anonymous credentials already.
bool authenticated
authentication success
bool mayReadVirginReplyBody() const override
whether we may receive more virgin response body bytes
Comm::Flag flag
comm layer result status.
static FTPSM ftpTraverseDirectory
const AnyP::UriScheme & getScheme() const
#define Assure(condition)
#define JobCallback(dbgSection, dbgLevel, Dialer, job, method)
Convenience macro to create a Dialer-based job callback.
Comm::ConnectionPointer conn
channel descriptor
int64_t strtoll(const char *nptr, char **endptr, int base)
size_type length() const
Returns the number of bytes stored in SBuf.
char * xstrndup(const char *s, size_t n)
SBuf & append(const SBuf &S)
void completeForwarding() override
DataChannel data
FTP data channel state.
static FTPSM ftpSendPassive
bool mimeGetViewOption(const char *fn)
static const size_type npos
void markParsedVirginReplyAsWhole(const char *reasonWeAreSure)
uint32_t sources
The message sources.
void writeReplyBody(const char *, size_t len)
static void ftpListPartsFree(ftpListParts **parts)
static const char * Month[]
void hackShortcut(StateMethod *nextState)
void clear()
remove the close handler, leave connection open
Comm::ConnectionPointer listenConn
const char * mimeGetContentType(const char *fn)
virtual Http::StatusCode failedHttpStatus(err_type &error)
MemBuf listing
FTP directory listing in HTML format.
void dataChannelConnected(const CommConnectCbParams &io) override
void getAddrInfo(struct addrinfo *&ai, int force=AF_UNSPEC) const
const SBuf & UrlWith2f(HttpRequest *)
static ftpListParts * ftpListParseParts(const char *buf, struct Ftp::GatewayFlags flags)
void processHeadResponse()
void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, int64_t)
char * content()
start of the added data
static int is_month(const char *buf)
void memFree(void *, int type)
Free a element allocated by memAllocate()
void StartGateway(FwdState *const fwdState)
A new FTP Gateway job.
const char * mimeGetContentEncoding(const char *fn)
void reset(char const *str)
struct SquidConfig::@92 Ftp
void listenForDataChannel(const Comm::ConnectionPointer &conn)
create a data channel acceptor and start listening.
Http::StatusCode failedHttpStatus(err_type &error) override
void completedListing(void)
void release(const bool shareable=false)
void haveParsedReplyHeaders() override
called when we have final (possibly adapted) reply headers; kids extend
time_t ParseIso3307(const char *)
Convert from ISO 3307 style time: YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx.
char * rfc1738_do_escape(const char *url, int flags)
int64_t getCurrentOffset() const
CtrlChannel ctrl
FTP control channel state.
const char * mimeGetIconURL(const char *fn)
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
bool mimeGetDownloadOption(const char *fn)
SBuf & appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
#define rfc1738_escape_part(x)
const char * wordlistAdd(wordlist **list, const char *key)
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
virtual void timeout(const CommTimeoutCbParams &io)
read timeout handler
void host(const char *src)
static FTPSM ftpSendReply
HttpRequestPointer request
#define debugs(SECTION, LEVEL, CONTENT)
void setCurrentOffset(int64_t offset)
void start() override
called by AsyncStart; do not call directly
void switchTimeoutToDataChannel()
size_type copy(char *dest, size_type n) const
char mimeGetTransferMode(const char *fn)
static FTPSM ftpWriteTransferDone
bool epsv_all_sent
EPSV ALL has been used. Must abort on failures.
static void Start(const Pointer &job)