128 void start()
override;
193#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]))
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 (*copyFrom && strchr(
w_space, *copyFrom))
636 if (*copyFrom && 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,
",");
703 p->
size = atoi(ct + 1);
707 tm = (time_t) strtol(ct + 1, &tmp, 0);
715 *(strstr(p->
date,
"\n")) =
'\0';
737 ct = strstr(ct,
",");
756 for (i = 0; i < n_tokens; ++i)
768 debugs(9, 7,
"line={" << line <<
"}");
770 if (strlen(line) > 1024) {
771 html <<
"<tr><td colspan=\"5\">" << line <<
"</td></tr>\n";
776 if (flags.dir_slash && dirpath && typecode !=
'D') {
783 html <<
"<tr class=\"entry\"><td colspan=\"5\">" << line <<
"</td></tr>\n";
786 for (p = line; *p &&
xisspace(*p); ++p);
788 flags.listformat_unknown = 1;
793 if (!strcmp(parts->
name,
".") || !strcmp(parts->
name,
"..")) {
809 switch (parts->
type) {
812 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
819 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
834 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
837 chdir.
appendf(
"<a href=\"%s/;type=d\"><img border=\"0\" src=\"%s\" "
838 "alt=\"[DIR]\"></a>",
846 icon.
appendf(
"<img border=\"0\" src=\"%s\" alt=\"%-6s\">",
854 if (parts->
type !=
'd') {
857 "alt=\"[VIEW]\"></a>",
863 "alt=\"[DOWNLOAD]\"></a>",
869 html <<
"<tr class=\"entry\">"
870 "<td class=\"icon\"><a href=\"" << href <<
"\">" << icon <<
"</a></td>"
871 "<td class=\"filename\"><a href=\"" << href <<
"\">" <<
html_quote(
text.
c_str()) <<
"</a></td>"
872 "<td class=\"date\">" << parts->
date <<
"</td>"
873 "<td class=\"size\">" <<
size <<
"</td>"
874 "<td class=\"actions\">" << chdir << view << download << link <<
"</td>"
884 char *buf = data.readBuf->content();
891 size_t len = data.readBuf->contentSize();
894 debugs(9, 3,
"no content to parse for " << entry->url() );
901 sbuf = (
char *)
xmalloc(len + 1);
903 end = sbuf + len - 1;
905 while (*end !=
'\r' && *end !=
'\n' && end > sbuf)
910 debugs(9, 3,
"usable = " << usable <<
" of " << len <<
" bytes.");
913 if (buf[0] ==
'\0' && len == 1) {
914 debugs(9, 3,
"NIL ends data from " << entry->url() <<
" transfer problem?");
915 data.readBuf->consume(len);
917 debugs(9, 3,
"didn't find end for " << entry->url());
924 debugs(9, 3, (
unsigned long int)len <<
" bytes to play with");
929 s += strspn(s,
crlf);
931 for (; s < end; s += strcspn(s,
crlf), s += strspn(s,
crlf)) {
932 debugs(9, 7,
"s = {" << s <<
"}");
933 linelen = strcspn(s,
crlf) + 1;
943 debugs(9, 7,
"{" << line <<
"}");
945 if (!strncmp(line,
"total", 5))
952 if (htmlifyListEntry(line, html)) {
960 data.readBuf->consume(usable);
976 if (!flags.http_header_sent && data.readBuf->contentSize() >= 0 && !flags.isdir)
977 appendSuccessHeader();
984 abortAll(
"entry aborted after calling appendSuccessHeader()");
990 if (adaptationAccessCheckPending) {
991 debugs(9, 3,
"returning from Ftp::Gateway::processReplyBody due to adaptationAccessCheckPending");
998 if (!flags.listing) {
1003 maybeReadVirginBody();
1005 }
else if (
const auto csize = data.readBuf->contentSize()) {
1006 writeReplyBody(data.readBuf->content(), csize);
1007 debugs(9, 5,
"consuming " << csize <<
" bytes of readBuf");
1008 data.readBuf->consume(csize);
1013 maybeReadVirginBody();
1038#if HAVE_AUTH_MODULE_BASIC
1041 if (!auth.isEmpty()) {
1042 flags.authenticated = 1;
1043 loginParser(auth,
false);
1051 loginParser(request->url.userInfo(),
true);
1063 if (strcmp(user,
"anonymous") == 0 && !flags.tried_auth_anonymous) {
1065 flags.tried_auth_anonymous=1;
1067 }
else if (!flags.tried_auth_nopass) {
1069 flags.tried_auth_nopass=1;
1085 static const SBuf middle(
";type=");
1086 const auto typeSpecStart = request->url.path().find(middle);
1088 const auto fullPath = request->url.path();
1089 const auto typecodePos = typeSpecStart + middle.
length();
1090 typecode = (typecodePos < fullPath.length()) ?
1091 static_cast<char>(
xtoupper(fullPath[typecodePos])) :
'\0';
1092 request->url.path(fullPath.substr(0, typeSpecStart));
1095 int l = request->url.path().length();
1101 flags.need_base_href = 1;
1102 }
else if (!request->url.path().cmp(
"/%2f/")) {
1106 }
else if ((l >= 1) && (request->url.path()[l-1] ==
'/')) {
1113 flags.dir_slash = 1;
1120 title_url =
"ftp://";
1122 if (strcmp(user,
"anonymous")) {
1123 title_url.append(user);
1124 title_url.append(
"@");
1129 title_url.
append(authority);
1130 title_url.
append(request->url.absolutePath());
1132 base_href =
"ftp://";
1134 if (strcmp(user,
"anonymous") != 0) {
1145 base_href.
append(authority);
1146 base_href.
append(request->url.path());
1153 if (!checkAuth(&request->header)) {
1155 SBuf realm(ftpRealm());
1156 const auto reply = ftpAuthRequired(request.getRaw(), realm, fwd->al);
1157 entry->replaceHttpReply(reply);
1164 debugs(9, 5,
"FD " << (ctrl.conn ? ctrl.conn->fd : -1) <<
" : host=" << request->url.host() <<
1165 ", path=" << request->url.absolutePath() <<
", user=" << user <<
", passwd=" << password);
1176 if (ctrl.message ==
nullptr)
1182 for (
wordlist *w = ctrl.message; w && w->next; w = w->next) {
1183 cwd_message.append(
'\n');
1184 cwd_message.append(w->key);
1208 }
else if (code == 120) {
1228 if ((state == SENT_USER || state == SENT_PASS) && ctrl.replycode >= 400) {
1229 if (ctrl.replycode == 421 || ctrl.replycode == 426) {
1232 }
else if (ctrl.replycode >= 430 && ctrl.replycode <= 439) {
1235 }
else if (ctrl.replycode >= 530 && ctrl.replycode <= 539) {
1249 failed(
ERR_NONE, ctrl.replycode, err);
1255#if HAVE_AUTH_MODULE_BASIC
1258 SBuf realm(ftpRealm());
1263 entry->replaceHttpReply(newrep);
1273 realm.
appendf(
"FTP %s ", user);
1275 realm.
append(
"unknown", 7);
1277 realm.
append(request->url.host());
1278 const auto &rport = request->url.port();
1279 if (rport && *rport != 21)
1280 realm.
appendf(
" port %hu", *rport);
1307 }
else if (code == 331) {
1330 debugs(9, 3,
"code=" << code);
1394 debugs(9, 3,
"code=" << code);
1404 p += strcspn(p,
"/");
1440 debugs(9, 3,
"the final component was a directory");
1452 debugs(9, 3,
"final component is probably a file");
1461 char *path =
nullptr;
1471 if (!strcmp(path,
"..") || !strcmp(path,
"/")) {
1490 if (code >= 200 && code < 300) {
1517 char *path =
nullptr;
1524 debugs(9, 3,
"with path=" << path);
1536 debugs(9, 3,
"path " << path <<
", code " << code);
1540 }
else if (code == 550) {
1563 debugs(9, 3,
"Directory path did not end in /");
1593 }
else if (code < 0) {
1633 debugs(9, 2,
"SIZE reported " <<
1638 }
else if (code < 0) {
1688 debugs(9, 5,
"handling HEAD response");
1690 appendSuccessHeader();
1698 abortAll(
"entry aborted while processing HEAD");
1703 if (adaptationAccessCheckPending) {
1704 debugs(9,3,
"returning due to adaptationAccessCheckPending");
1731 dataConnWait.finish();
1734 debugs(9, 2,
"Failed to connect. Retrying via another method.");
1738 writeCommand(
"ABOR\r\n");
1745 data.opened(io.
conn, dataCloser());
1753 if (ftpState->
data.
conn !=
nullptr) {
1763 debugs(9, 5,
"The control connection to the remote end is closed");
1782 &
on,
sizeof(
on)) == -1) {
1805 debugs(9,
DBG_IMPORTANT,
"FTP does not allow PORT method after 'EPSV ALL' has been sent.");
1830 struct addrinfo *AI =
nullptr;
1832 unsigned char *addrptr = (
unsigned char *) &((
struct sockaddr_in*)AI->ai_addr)->sin_addr;
1833 unsigned char *portptr = (
unsigned char *) &((
struct sockaddr_in*)AI->ai_addr)->sin_port;
1835 addrptr[0], addrptr[1], addrptr[2], addrptr[3],
1836 portptr[0], portptr[1]);
1851 debugs(9, 3,
"PORT not supported by remote end");
1866 debugs(9, 3,
"EPRT not supported by remote end");
1884 debugs(9, 5,
"The control connection to the remote end is closed");
1889 data.listenConn->close();
1890 data.listenConn =
nullptr;
1898 abortAll(
"entry aborted when accepting data conn");
1899 data.listenConn->close();
1900 data.listenConn =
nullptr;
1907 data.listenConn =
nullptr;
1927 "ERROR: FTP data connection from unexpected server (" <<
1929 data.conn->remote <<
" or " << ctrl.conn->remote);
1941 data.opened(io.
conn, dataCloser());
1944 debugs(9, 3,
"Connected data socket on " <<
1945 io.
conn <<
". FD table says: " <<
1946 "ctrl-peer= " <<
fd_table[ctrl.conn->fd].ipaddr <<
", " <<
1947 "data-peer= " <<
fd_table[data.conn->fd].ipaddr);
1949 assert(haveControlChannel(
"ftpAcceptDataConnection"));
1950 assert(ctrl.message ==
nullptr);
1987 if (ftpState->
filepath !=
nullptr) {
2012 int code = ctrl.replycode;
2016 if (!originalRequest()->body_pipe) {
2017 debugs(9, 3,
"zero-size STOR?");
2018 state = WRITING_DATA;
2023 if (!startRequestBodyFlow()) {
2029 debugs(9, 3,
"starting data transfer");
2030 switchTimeoutToDataChannel();
2031 sendMoreRequestBody();
2032 fwd->dontRetry(
true);
2033 state = WRITING_DATA;
2034 debugs(9, 3,
"writing data channel");
2035 }
else if (code == 150) {
2037 debugs(9, 3,
"ftpReadStor: accepting data channel");
2038 listenForDataChannel(data.conn);
2040 debugs(9,
DBG_IMPORTANT,
"ERROR: Unexpected reply code "<< std::setfill(
'0') << std::setw(3) << code);
2062 if (restart_offset > 0)
2065 if (!request->range)
2074 int64_t desired_offset = request->range->lowestOffset(theSize);
2076 if (desired_offset <= 0)
2079 if (desired_offset >= theSize)
2082 restart_offset = desired_offset;
2096 }
else if (code > 0) {
2097 debugs(9, 3,
"REST not supported");
2158 }
else if (code == 150) {
2198 }
else if (code == 150) {
2201 }
else if (code >= 300) {
2221 entry->lock(
"Ftp::Gateway");
2227 ctrl.message =
nullptr;
2230 entry->unlock(
"Ftp::Gateway");
2239 if (code == 226 || code == 250) {
2260 debugs(9, 3,
"ftpState=" <<
this);
2270 if (!(code == 226 || code == 250)) {
2339 if (old_request !=
nullptr) {
2349 setCurrentOffset(0);
2355 if (old_request ==
nullptr) {
2356 old_request = ctrl.last_command;
2357 ctrl.last_command =
nullptr;
2358 old_reply = ctrl.last_reply;
2359 ctrl.last_reply =
nullptr;
2361 if (pathcomps ==
nullptr && filepath !=
nullptr)
2362 old_filepath =
xstrdup(filepath);
2372 const bool slashHack = ftpState->
request->
url.
path().caseCmp(
"/%2f", 4)==0;
2377 " reply code " << code <<
"flags(" <<
2381 "mdtm=" << ftpState->
mdtm <<
", size=" << ftpState->
theSize <<
2382 "slashhack=" << (slashHack?
"T":
"F"));
2390 switch (ftpState->
state) {
2406 ftpState->
failed(error_code, 0, ftperr);
2408 HttpReply *newrep = ftperr->BuildHttpReply();
2425 if (ctrl.replycode > 500) {
2428 }
else if (ctrl.replycode == 421) {
2437 if (ctrl.replycode == 550) {
2460 debugs(9, 5,
"ftpState (" << ftpState <<
") is valid!");
2462 if (code == 226 || code == 250) {
2465 }
else if (code == 227) {
2499 if (flags.http_header_sent)
2504 flags.http_header_sent = 1;
2506 assert(entry->isEmpty());
2510 SBuf urlPath = request->url.path();
2511 auto t = urlPath.
rfind(
'/');
2514 const char *mime_type =
nullptr;
2515 const char *mime_enc =
nullptr;
2518 mime_type =
"text/html";
2523 mime_type =
"application/octet-stream";
2529 mime_type =
"text/plain";
2542 if (0 == getCurrentOffset()) {
2545 }
else if (theSize < getCurrentOffset()) {
2553 " current offset=" << getCurrentOffset() <<
2554 ", but theSize=" << theSize <<
2555 ". assuming full content response");
2560 range_spec.
offset = getCurrentOffset();
2561 range_spec.
length = theSize - getCurrentOffset();
2571 setVirginReply(reply);
2572 adaptOrFinalizeReply();
2585 if (flags.authenticated ||
2586 getCurrentOffset() ||
2597#if HAVE_AUTH_MODULE_BASIC
2613 static const SBuf nil;
2620 }
else if (!request->
url.
path().startsWith(newbuf)) {
2635 debugs(9, 5,
"writing " << dataLength <<
" bytes to the reply");
2636 addVirginReplyBody(dataToWrite, dataLength);
2648 if (fwd ==
nullptr || flags.completed_forwarding) {
2649 debugs(9, 3,
"avoid double-complete on FD " <<
2650 (ctrl.conn ? ctrl.conn->fd : -1) <<
", Data FD " << (data.conn ? data.conn->fd : -1) <<
2651 ", this " <<
this <<
", fwd " << fwd);
2655 flags.completed_forwarding =
true;
2668 if (doneWithServer())
2673 debugs(9,
DBG_IMPORTANT,
"WARNING: FTP Server Control channel is closed, but Data channel still active.");
2674 debugs(9, 2, caller_name <<
": attempted on a closed FTP channel.");
2685 return !doneWithServer();
#define Assure(condition)
#define JobCallback(dbgSection, dbgLevel, Dialer, job, method)
Convenience macro to create a Dialer-based job callback.
static FTPSM ftpReadTransferDone
static FTPSM ftpReadMkdir
static void ftpListPartsFree(ftpListParts **parts)
static FTPSM ftpWriteTransferDone
static void ftpOpenListenSocket(Ftp::Gateway *ftpState, int fallback)
static char cbuf[CTRL_BUFLEN]
static const char * Month[]
static void ftpTrySlashHack(Ftp::Gateway *ftpState)
static FTPSM ftpReadWelcome
static FTPSM ftpSendReply
static FTPSM ftpRestOrList
static int is_month(const char *buf)
static FTPSM ftpTraverseDirectory
static FTPSM ftpSendPassive
static FTPSM ftpSendMkdir
static ftpListParts * ftpListParseParts(const char *buf, struct Ftp::GatewayFlags flags)
void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, int64_t)
void SBufToCstring(char *d, const SBuf &s)
#define SQUIDSBUFPRINT(s)
void error(char *format,...)
int cbdataReferenceValid(const void *p)
#define CBDATA_NAMESPACED_CLASS_INIT(namespace, type)
static const SBuf & SlashPath()
the static '/' default URL-path
AnyP::UriScheme const & getScheme() const
static std::optional< SBuf > Decode(const SBuf &)
static void Start(const Pointer &job)
virtual void completeForwarding()
virtual void handleRequestBodyProducerAborted()=0
HttpRequestPointer request
void markParsedVirginReplyAsWhole(const char *reasonWeAreSure)
virtual void haveParsedReplyHeaders()
called when we have final (possibly adapted) reply headers; kids extend
int xerrno
The last errno to occur. non-zero if flag is Comm::COMM_ERROR.
Comm::Flag flag
comm layer result status.
Comm::ConnectionPointer conn
void detailError(const ErrorDetail::Pointer &dCode)
set error type-specific detail code
HttpRequestPointer request
HttpReply * BuildHttpReply(void)
struct ErrorState::@47 ftp
Comm::ConnectionPointer listenConn
void close()
planned close: removes the close handler and calls comm_close
void clear()
remove the close handler, leave connection open
Comm::ConnectionPointer conn
channel descriptor
FTP client functionality shared among FTP Gateway and Relay clients.
virtual Http::StatusCode failedHttpStatus(err_type &error)
void start() override
called by AsyncStart; do not call directly
bool handleEpsvReply(Ip::Address &remoteAddr)
virtual void handleControlReply()
void writeCommand(const char *buf)
virtual void timeout(const CommTimeoutCbParams &io)
read timeout handler
bool handlePasvReply(Ip::Address &remoteAddr)
void switchTimeoutToDataChannel()
void connectDataChannel()
DataChannel data
FTP data channel state.
void maybeReadVirginBody() override
read response data from the network
virtual void failed(err_type error=ERR_NONE, int xerrno=0, ErrorState *ftperr=nullptr)
handle a fatal transaction error, closing the control connection
CtrlChannel ctrl
FTP control channel state.
virtual void dataClosed(const CommCloseCbParams &io)
handler called by Comm when FTP data channel is closed unexpectedly
int checkAuth(const HttpHeader *req_hdr)
Http::StatusCode failedHttpStatus(err_type &error) override
std::optional< SBuf > decodedRequestUriPath() const
absolute request URI path after successful decoding of all pct-encoding sequences
bool htmlifyListEntry(const char *line, PackableStream &)
void handleControlReply() override
void writeReplyBody(const char *, size_t len)
void processHeadResponse()
void listenForDataChannel(const Comm::ConnectionPointer &conn)
create a data channel acceptor and start listening.
void dataClosed(const CommCloseCbParams &io) override
handler called by Comm when FTP data channel is closed unexpectedly
bool mayReadVirginReplyBody() const override
whether we may receive more virgin response body bytes
void hackShortcut(StateMethod *nextState)
void setCurrentOffset(int64_t offset)
void handleRequestBodyProducerAborted() override
void start() override
called by AsyncStart; do not call directly
virtual bool haveControlChannel(const char *caller_name) const
void haveParsedReplyHeaders() override
called when we have final (possibly adapted) reply headers; kids extend
void dataChannelConnected(const CommConnectCbParams &io) override
void completeForwarding() override
static HttpReply * ftpAuthRequired(HttpRequest *request, SBuf &realm, AccessLogEntry::Pointer &)
void timeout(const CommTimeoutCbParams &io) override
read timeout handler
void loginParser(const SBuf &login, bool escaped)
void appendSuccessHeader()
MemBuf listing
FTP directory listing in HTML format.
void processReplyBody() override
void completedListing(void)
int64_t getCurrentOffset() const
void ftpAcceptDataConnection(const CommAcceptCbParams &io)
AccessLogEntryPointer al
info for the future access.log entry
void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
AnyP::Uri url
the request URI
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
@ srcFtp
ftp_port or FTP server
uint32_t sources
The message sources.
static void FreeAddr(struct addrinfo *&ai)
void getAddrInfo(struct addrinfo *&ai, int force=AF_UNSPEC) const
unsigned short port() const
void init(mb_size_t szInit, mb_size_t szMax)
char * content()
start of the added data
mb_size_t contentSize() const
available data size
static const size_type npos
size_type length() const
Returns the number of bytes stored in SBuf.
SBuf & appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
size_type rfind(char c, size_type endPos=npos) const
size_type find(char c, size_type startPos=0) const
size_type copy(char *dest, size_type n) const
SBuf & append(const SBuf &S)
SBuf substr(size_type pos, size_type n=npos) const
MemBlob::size_type size_type
struct SquidConfig::@92 Ftp
void release(const bool shareable=false)
bool makePublic(const KeyScope keyScope=ksDefault)
void replaceHttpReply(const HttpReplyPointer &, const bool andStartWriting=true)
void append(char const *buf, int len)
void reset(char const *str)
void comm_open_listener(int sock_type, int proto, Comm::ConnectionPointer &conn, const char *note)
#define debugs(SECTION, LEVEL, CONTENT)
#define EBIT_TEST(flag, bit)
@ ERR_CACHE_ACCESS_DENIED
char * html_quote(const char *string)
void memFree(void *, int type)
Free a element allocated by memAllocate()
void * memAllocate(mem_type)
Allocate one element from the typed pool.
const char * mimeGetIconURL(const char *fn)
const char * mimeGetContentEncoding(const char *fn)
char mimeGetTransferMode(const char *fn)
bool mimeGetViewOption(const char *fn)
const char * mimeGetContentType(const char *fn)
bool mimeGetDownloadOption(const char *fn)
bool IsConnOpen(const Comm::ConnectionPointer &conn)
const SBuf & UrlWith2f(HttpRequest *)
void StartGateway(FwdState *const fwdState)
A new FTP Gateway job.
void() StateMethod(Ftp::Gateway *)
time_t ParseIso3307(const char *)
Convert from ISO 3307 style time: YYYYMMDDHHMMSS or YYYYMMDDHHMMSS.xxx.
char * rfc1738_do_escape(const char *url, int flags)
#define rfc1738_escape_part(x)
#define rfc1738_escape(x)
void rfc1738_unescape(char *url)
int xsetsockopt(int socketFd, int level, int option, const void *value, socklen_t valueLength)
POSIX setsockopt(2) equivalent.
int64_t strtoll(const char *nptr, char **endptr, int base)
bool completed_forwarding
bool pasv_supported
PASV command is allowed.
bool tried_auth_anonymous
auth has tried to use anonymous credentials already.
bool epsv_all_sent
EPSV ALL has been used. Must abort on failures.
bool authenticated
authentication success
bool tried_auth_nopass
auth tried username with no password already.
SBuf text("GET http://resource.com/path HTTP/1.1\r\n" "Host: resource.com\r\n" "Cookie: laijkpk3422r j1noin \r\n" "\r\n")
const char * wordlistAdd(wordlist **list, const char *key)
void wordlistDestroy(wordlist **list)
destroy a wordlist
char * wordlistChopHead(wordlist **wl)
void * xcalloc(size_t n, size_t sz)
const char * xstrerr(int error)
char * xstrncpy(char *dst, const char *src, size_t n)
char * xstrndup(const char *s, size_t n)