Go to the documentation of this file.
128 void start()
override;
192 #define CTRL_BUFLEN 16*1024
344 old_filepath(nullptr),
366 debugs(9, 3, entry->url());
370 "control channel " << ctrl.conn);
399 debugs(9, 4,
"login=" << login <<
", escaped=" << escaped);
400 debugs(9, 9,
"IN : login=" << login <<
", escaped=" << escaped <<
", user=" << user <<
", password=" << password);
406 debugs(9, 2,
"WARNING: Ignoring FTP credentials that start with a NUL character");
417 const SBuf userName = login.
substr(0, colonPos);
420 debugs(9, 9,
"found user=" << userName <<
' ' <<
421 (upto != userName.
length() ?
", truncated-to=" :
", length=") << upto <<
422 ", escaped=" << escaped);
425 debugs(9, 9,
"found user=" << user <<
" (" << strlen(user) <<
") unescaped.");
435 debugs(9, 9,
"found password=" << pass <<
" " <<
436 (upto != pass.
length() ?
", truncated-to=" :
", length=") << upto <<
437 ", escaped=" << escaped);
442 debugs(9, 9,
"found password=" << password <<
" (" << strlen(password) <<
") unescaped.");
445 debugs(9, 9,
"OUT: login=" << login <<
", escaped=" << escaped <<
", user=" << user <<
", password=" << password);
452 debugs(9, 5,
"The control connection to the remote end is closed");
462 const char *note = entry->url();
471 debugs(9, 3,
"Unconnected data socket created on " << conn);
474 conn->
tos = ctrl.conn->tos;
475 conn->
nfmark = ctrl.conn->nfmark;
481 data.opened(conn, dataCloser());
482 switchTimeoutToDataChannel();
488 if (SENT_PASV == state) {
490 flags.pasv_supported =
false;
494 dataConnWait.cancel(
"timeout");
503 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
504 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
512 for (i = 0; i < 12; ++i)
513 if (!strcasecmp(buf,
Month[i]))
529 #define MAX_TOKENS 64
536 struct FtpLineToken {
537 char *token =
nullptr;
542 static char tbuf[128];
543 char *xbuf =
nullptr;
544 static int scan_ftp_initialized = 0;
545 static regex_t scan_ftp_integer;
546 static regex_t scan_ftp_time;
547 static regex_t scan_ftp_dostime;
548 static regex_t scan_ftp_dosdate;
550 if (!scan_ftp_initialized) {
551 scan_ftp_initialized = 1;
552 regcomp(&scan_ftp_integer,
"^[0123456789]+$", REG_EXTENDED | REG_NOSUB);
553 regcomp(&scan_ftp_time,
"^[0123456789:]+$", REG_EXTENDED | REG_NOSUB);
554 regcomp(&scan_ftp_dosdate,
"^[0123456789]+-[0123456789]+-[0123456789]+$", REG_EXTENDED | REG_NOSUB);
555 regcomp(&scan_ftp_dostime,
"^[0123456789]+:[0123456789]+[AP]M$", REG_EXTENDED | REG_NOSUB | REG_ICASE);
579 tokens[n_tokens].pos = t - xbuf;
586 for (i = 3; i < n_tokens - 2; ++i) {
595 if (regexec(&scan_ftp_integer,
size, 0,
nullptr, 0) != 0)
598 if (regexec(&scan_ftp_integer, day, 0,
nullptr, 0) != 0)
601 if (regexec(&scan_ftp_time, year, 0,
nullptr, 0) != 0)
604 const auto *copyFrom = buf +
tokens[i].pos;
607 auto dateSize = snprintf(tbuf,
sizeof(tbuf),
"%s %2s %5s", month, day, year);
608 bool isTypeA = (dateSize == 12) && (strncmp(copyFrom, tbuf, dateSize) == 0);
611 dateSize = snprintf(tbuf,
sizeof(tbuf),
"%s %2s %-5s", month, day, year);
612 bool isTypeB = (dateSize == 12 || dateSize == 11) && (strncmp(copyFrom, tbuf, dateSize) == 0);
615 if (isTypeA || isTypeB) {
618 const auto finalDateSize = snprintf(tbuf,
sizeof(tbuf),
"%s %2s %5s", month, day, year);
619 assert(finalDateSize >= 0);
623 copyFrom = buf +
tokens[i + 2].pos + strlen(
tokens[i + 2].token);
625 while (strchr(
w_space, *copyFrom))
636 if (strchr(
w_space, *copyFrom))
642 if (p->
type ==
'l' && (t = strstr(p->
name,
" -> "))) {
655 regexec(&scan_ftp_dosdate,
tokens[0].token, 0,
nullptr, 0) == 0 &&
656 regexec(&scan_ftp_dostime,
tokens[1].token, 0,
nullptr, 0) == 0) {
657 if (!strcasecmp(
tokens[2].token,
"<dir>")) {
664 snprintf(tbuf,
sizeof(tbuf),
"%s %s",
tokens[0].token,
tokens[1].token);
667 if (p->
type ==
'd') {
684 const char *ct = buf + 1;
689 int l = strcspn(ct,
",");
702 p->
size = atoi(ct + 1);
706 tm = (time_t) strtol(ct + 1, &tmp, 0);
713 *(strstr(p->
date,
"\n")) =
'\0';
735 ct = strstr(ct,
",");
754 for (i = 0; i < n_tokens; ++i)
766 debugs(9, 7,
"line={" << line <<
"}");
768 if (strlen(line) > 1024) {
769 html <<
"<tr><td colspan=\"5\">" << line <<
"</td></tr>\n";
774 if (flags.dir_slash && dirpath && typecode !=
'D') {
781 html <<
"<tr class=\"entry\"><td colspan=\"5\">" << line <<
"</td></tr>\n";
784 for (p = line; *p &&
xisspace(*p); ++p);
786 flags.listformat_unknown = 1;
791 if (!strcmp(parts->
name,
".") || !strcmp(parts->
name,
"..")) {
807 switch (parts->
type) {
810 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
817 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
832 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
835 chdir.
appendf(
"<a href=\"%s/;type=d\"><img border=\"0\" src=\"%s\" "
836 "alt=\"[DIR]\"></a>",
844 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
852 if (parts->
type !=
'd') {
855 "alt=\"[VIEW]\"></a>",
861 "alt=\"[DOWNLOAD]\"></a>",
867 html <<
"<tr class=\"entry\">"
868 "<td class=\"icon\"><a href=\"" << href <<
"\">" << icon <<
"</a></td>"
869 "<td class=\"filename\"><a href=\"" << href <<
"\">" <<
html_quote(
text.
c_str()) <<
"</a></td>"
870 "<td class=\"date\">" << parts->
date <<
"</td>"
871 "<td class=\"size\">" <<
size <<
"</td>"
872 "<td class=\"actions\">" << chdir << view << download << link <<
"</td>"
882 char *buf = data.readBuf->content();
889 size_t len = data.readBuf->contentSize();
892 debugs(9, 3,
"no content to parse for " << entry->url() );
899 sbuf = (
char *)
xmalloc(len + 1);
901 end = sbuf + len - 1;
903 while (*end !=
'\r' && *end !=
'\n' && end > sbuf)
908 debugs(9, 3,
"usable = " << usable <<
" of " << len <<
" bytes.");
911 if (buf[0] ==
'\0' && len == 1) {
912 debugs(9, 3,
"NIL ends data from " << entry->url() <<
" transfer problem?");
913 data.readBuf->consume(len);
915 debugs(9, 3,
"didn't find end for " << entry->url());
922 debugs(9, 3, (
unsigned long int)len <<
" bytes to play with");
927 s += strspn(s,
crlf);
929 for (; s < end; s += strcspn(s,
crlf), s += strspn(s,
crlf)) {
930 debugs(9, 7,
"s = {" << s <<
"}");
931 linelen = strcspn(s,
crlf) + 1;
941 debugs(9, 7,
"{" << line <<
"}");
943 if (!strncmp(line,
"total", 5))
950 if (htmlifyListEntry(line, html)) {
958 data.readBuf->consume(usable);
974 if (!flags.http_header_sent && data.readBuf->contentSize() >= 0 && !flags.isdir)
975 appendSuccessHeader();
982 abortAll(
"entry aborted after calling appendSuccessHeader()");
988 if (adaptationAccessCheckPending) {
989 debugs(9, 3,
"returning from Ftp::Gateway::processReplyBody due to adaptationAccessCheckPending");
996 if (!flags.listing) {
1001 maybeReadVirginBody();
1003 }
else if (
const auto csize = data.readBuf->contentSize()) {
1004 writeReplyBody(data.readBuf->content(), csize);
1005 debugs(9, 5,
"consuming " << csize <<
" bytes of readBuf");
1006 data.readBuf->consume(csize);
1011 maybeReadVirginBody();
1036 #if HAVE_AUTH_MODULE_BASIC
1039 if (!auth.isEmpty()) {
1040 flags.authenticated = 1;
1041 loginParser(auth,
false);
1049 loginParser(request->url.userInfo(),
true);
1061 if (strcmp(user,
"anonymous") == 0 && !flags.tried_auth_anonymous) {
1063 flags.tried_auth_anonymous=1;
1065 }
else if (!flags.tried_auth_nopass) {
1067 flags.tried_auth_nopass=1;
1081 static const SBuf middle(
";type=");
1082 const auto typeSpecStart = request->url.path().find(middle);
1084 const auto fullPath = request->url.path();
1085 const auto typecodePos = typeSpecStart + middle.
length();
1086 typecode = (typecodePos < fullPath.length()) ?
1087 static_cast<char>(
xtoupper(fullPath[typecodePos])) :
'\0';
1088 request->url.path(fullPath.substr(0, typeSpecStart));
1091 int l = request->url.path().length();
1097 flags.need_base_href = 1;
1098 }
else if (!request->url.path().cmp(
"/%2f/")) {
1102 }
else if ((l >= 1) && (request->url.path()[l-1] ==
'/')) {
1109 flags.dir_slash = 1;
1116 title_url =
"ftp://";
1118 if (strcmp(user,
"anonymous")) {
1119 title_url.append(user);
1120 title_url.append(
"@");
1126 title_url.
append(request->url.path().rawContent(), request->url.path().length());
1128 base_href =
"ftp://";
1130 if (strcmp(user,
"anonymous") != 0) {
1142 base_href.
append(request->url.path().rawContent(), request->url.path().length());
1149 if (!checkAuth(&request->header)) {
1151 SBuf realm(ftpRealm());
1152 const auto reply = ftpAuthRequired(request.getRaw(), realm, fwd->al);
1153 entry->replaceHttpReply(reply);
1160 debugs(9, 5,
"FD " << (ctrl.conn ? ctrl.conn->fd : -1) <<
" : host=" << request->url.host() <<
1161 ", path=" << request->url.path() <<
", user=" << user <<
", passwd=" << password);
1172 if (ctrl.message ==
nullptr)
1179 cwd_message.append(
'\n');
1180 cwd_message.append(w->key);
1204 }
else if (
code == 120) {
1224 if ((state == SENT_USER || state == SENT_PASS) && ctrl.replycode >= 400) {
1225 if (ctrl.replycode == 421 || ctrl.replycode == 426) {
1228 }
else if (ctrl.replycode >= 430 && ctrl.replycode <= 439) {
1231 }
else if (ctrl.replycode >= 530 && ctrl.replycode <= 539) {
1245 failed(
ERR_NONE, ctrl.replycode, err);
1251 #if HAVE_AUTH_MODULE_BASIC
1254 SBuf realm(ftpRealm());
1259 entry->replaceHttpReply(newrep);
1269 realm.
appendf(
"FTP %s ", user);
1271 realm.
append(
"unknown", 7);
1273 realm.
append(request->url.host());
1274 const auto &rport = request->url.port();
1275 if (rport && *rport != 21)
1276 realm.
appendf(
" port %hu", *rport);
1306 }
else if (
code == 331) {
1403 p += strcspn(p,
"/");
1439 debugs(9, 3,
"the final component was a directory");
1451 debugs(9, 3,
"final component is probably a file");
1460 char *path =
nullptr;
1470 if (!strcmp(path,
"..") || !strcmp(path,
"/")) {
1516 char *path =
nullptr;
1523 debugs(9, 3,
"with path=" << path);
1535 debugs(9, 3,
"path " << path <<
", code " <<
code);
1539 }
else if (
code == 550) {
1562 debugs(9, 3,
"Directory path did not end in /");
1592 }
else if (
code < 0) {
1632 debugs(9, 2,
"SIZE reported " <<
1637 }
else if (
code < 0) {
1687 debugs(9, 5,
"handling HEAD response");
1689 appendSuccessHeader();
1697 abortAll(
"entry aborted while processing HEAD");
1702 if (adaptationAccessCheckPending) {
1703 debugs(9,3,
"returning due to adaptationAccessCheckPending");
1730 dataConnWait.finish();
1733 debugs(9, 2,
"Failed to connect. Retrying via another method.");
1737 writeCommand(
"ABOR\r\n");
1744 data.opened(io.
conn, dataCloser());
1752 if (ftpState->
data.
conn !=
nullptr) {
1762 debugs(9, 5,
"The control connection to the remote end is closed");
1780 if (setsockopt(ftpState->
ctrl.
conn->
fd, SOL_SOCKET, SO_REUSEADDR,
1781 (
char *) &
on,
sizeof(
on)) == -1) {
1804 debugs(9,
DBG_IMPORTANT,
"FTP does not allow PORT method after 'EPSV ALL' has been sent.");
1829 struct addrinfo *AI =
nullptr;
1831 unsigned char *addrptr = (
unsigned char *) &((
struct sockaddr_in*)AI->ai_addr)->sin_addr;
1832 unsigned char *portptr = (
unsigned char *) &((
struct sockaddr_in*)AI->ai_addr)->sin_port;
1834 addrptr[0], addrptr[1], addrptr[2], addrptr[3],
1835 portptr[0], portptr[1]);
1850 debugs(9, 3,
"PORT not supported by remote end");
1865 debugs(9, 3,
"EPRT not supported by remote end");
1883 debugs(9, 5,
"The control connection to the remote end is closed");
1888 data.listenConn->close();
1889 data.listenConn =
nullptr;
1897 abortAll(
"entry aborted when accepting data conn");
1898 data.listenConn->close();
1899 data.listenConn =
nullptr;
1906 data.listenConn =
nullptr;
1926 "ERROR: FTP data connection from unexpected server (" <<
1928 data.conn->remote <<
" or " << ctrl.conn->remote);
1940 data.opened(io.
conn, dataCloser());
1943 debugs(9, 3,
"Connected data socket on " <<
1944 io.
conn <<
". FD table says: " <<
1945 "ctrl-peer= " <<
fd_table[ctrl.conn->fd].ipaddr <<
", " <<
1946 "data-peer= " <<
fd_table[data.conn->fd].ipaddr);
1948 assert(haveControlChannel(
"ftpAcceptDataConnection"));
1949 assert(ctrl.message ==
nullptr);
1986 if (ftpState->
filepath !=
nullptr) {
2011 int code = ctrl.replycode;
2015 if (!originalRequest()->body_pipe) {
2016 debugs(9, 3,
"zero-size STOR?");
2017 state = WRITING_DATA;
2022 if (!startRequestBodyFlow()) {
2028 debugs(9, 3,
"starting data transfer");
2029 switchTimeoutToDataChannel();
2030 sendMoreRequestBody();
2031 fwd->dontRetry(
true);
2032 state = WRITING_DATA;
2033 debugs(9, 3,
"writing data channel");
2034 }
else if (
code == 150) {
2036 debugs(9, 3,
"ftpReadStor: accepting data channel");
2037 listenForDataChannel(data.conn);
2061 if (restart_offset > 0)
2064 if (!request->range)
2073 int64_t desired_offset = request->range->lowestOffset(theSize);
2075 if (desired_offset <= 0)
2078 if (desired_offset >= theSize)
2081 restart_offset = desired_offset;
2095 }
else if (
code > 0) {
2096 debugs(9, 3,
"REST not supported");
2157 }
else if (
code == 150) {
2197 }
else if (
code == 150) {
2200 }
else if (
code >= 300) {
2220 entry->lock(
"Ftp::Gateway");
2225 ctrl.message =
nullptr;
2228 entry->unlock(
"Ftp::Gateway");
2258 debugs(9, 3,
"ftpState=" <<
this);
2268 if (!(
code == 226 ||
code == 250)) {
2333 if (old_request !=
nullptr) {
2343 setCurrentOffset(0);
2349 if (old_request ==
nullptr) {
2350 old_request = ctrl.last_command;
2351 ctrl.last_command =
nullptr;
2352 old_reply = ctrl.last_reply;
2353 ctrl.last_reply =
nullptr;
2355 if (pathcomps ==
nullptr && filepath !=
nullptr)
2356 old_filepath =
xstrdup(filepath);
2366 const bool slashHack = ftpState->
request->
url.
path().caseCmp(
"/%2f", 4)==0;
2371 " reply code " <<
code <<
"flags(" <<
2374 "mdtm=" << ftpState->
mdtm <<
", size=" << ftpState->
theSize <<
2375 "slashhack=" << (slashHack?
"T":
"F"));
2382 switch (ftpState->
state) {
2398 ftpState->
failed(error_code, 0, ftperr);
2400 HttpReply *newrep = ftperr->BuildHttpReply();
2417 if (ctrl.replycode > 500) {
2420 }
else if (ctrl.replycode == 421) {
2429 if (ctrl.replycode == 550) {
2452 debugs(9, 5,
"ftpState (" << ftpState <<
") is valid!");
2457 }
else if (
code == 227) {
2491 if (flags.http_header_sent)
2496 flags.http_header_sent = 1;
2498 assert(entry->isEmpty());
2502 SBuf urlPath = request->url.path();
2503 auto t = urlPath.
rfind(
'/');
2506 const char *mime_type =
nullptr;
2507 const char *mime_enc =
nullptr;
2510 mime_type =
"text/html";
2515 mime_type =
"application/octet-stream";
2521 mime_type =
"text/plain";
2534 if (0 == getCurrentOffset()) {
2537 }
else if (theSize < getCurrentOffset()) {
2545 " current offset=" << getCurrentOffset() <<
2546 ", but theSize=" << theSize <<
2547 ". assuming full content response");
2552 range_spec.
offset = getCurrentOffset();
2553 range_spec.
length = theSize - getCurrentOffset();
2563 setVirginReply(reply);
2564 adaptOrFinalizeReply();
2577 if (flags.authenticated ||
2578 getCurrentOffset() ||
2589 #if HAVE_AUTH_MODULE_BASIC
2605 static const SBuf nil;
2609 if (request->
url.
path()[0] ==
'/') {
2612 }
else if (!request->
url.
path().startsWith(newbuf)) {
2627 debugs(9, 5,
"writing " << dataLength <<
" bytes to the reply");
2628 addVirginReplyBody(dataToWrite, dataLength);
2640 if (fwd ==
nullptr || flags.completed_forwarding) {
2641 debugs(9, 3,
"avoid double-complete on FD " <<
2642 (ctrl.conn ? ctrl.conn->fd : -1) <<
", Data FD " << (data.conn ? data.conn->fd : -1) <<
2643 ", this " <<
this <<
", fwd " << fwd);
2647 flags.completed_forwarding =
true;
2660 if (doneWithServer())
2665 debugs(9,
DBG_IMPORTANT,
"WARNING: FTP Server Control channel is closed, but Data channel still active.");
2666 debugs(9, 2, caller_name <<
": attempted on a closed FTP channel.");
2677 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
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]
const char * rawContent() const
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()
unsigned short port() const
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)
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)
struct SquidConfig::@99 Ftp
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)
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
struct ErrorState::@54 ftp
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)