e->packInto(p);
continue;
}
- switch (e->id) {
// TODO: When native FTP commands may end up in error pages and other
// sensitive places, hide HDR_FTP_ARGUMENTS for the FTP PASS command.
+ switch (e->id) {
case HDR_AUTHORIZATION:
case HDR_PROXY_AUTHORIZATION:
packerAppend(p, e->name.rawBuf(), e->name.size());
parseBytesOptionValue(&s->dynamicCertMemCacheSize, B_BYTES_STR, token + 28);
#endif
} else if (strcmp(token, "ftp-track-dirs=on") == 0) {
- s->ftp_track_dirs = true;
+ s->ftp_track_dirs = true;
} else if (strcmp(token, "ftp-track-dirs=off") == 0) {
- s->ftp_track_dirs = false;
+ s->ftp_track_dirs = false;
} else {
debugs(3, DBG_CRITICAL, "FATAL: Unknown http(s)_port option '" << token << "'.");
self_destruct();
#define SQUID_CLIENTSTREAM_H
#include "base/RefCount.h"
-#include "dlink.h"
#include "clientStreamForward.h"
+#include "dlink.h"
#include "StoreIOBuffer.h"
/**
#endif
void
-clientStartListeningOn(AnyP::PortCfgPointer &port, const RefCount< CommCbFunPtrCallT<CommAcceptCbPtrFun> > &subCall, const Ipc::FdNoteId fdNote) {
+clientStartListeningOn(AnyP::PortCfgPointer &port, const RefCount< CommCbFunPtrCallT<CommAcceptCbPtrFun> > &subCall, const Ipc::FdNoteId fdNote)
+{
// Fill out a Comm::Connection which IPC will open as a listener for us
port->listenConn = new Comm::Connection;
port->listenConn->local = port->s;
ConnStateData::pinConnection(const Comm::ConnectionPointer &pinServer, HttpRequest *request, CachePeer *aPeer, bool auth, bool monitor)
{
if (!Comm::IsConnOpen(pinning.serverConnection) ||
- pinning.serverConnection->fd != pinServer->fd)
+ pinning.serverConnection->fd != pinServer->fd)
pinNewConnection(pinServer, request, aPeer, auth);
if (monitor)
#include "squid.h"
#include "acl/FilledChecklist.h"
-#include "clients/FtpClient.h"
-#include "Mem.h"
-#include "SquidConfig.h"
-#include "StatCounters.h"
#include "client_side.h"
+#include "clients/FtpClient.h"
#include "comm/ConnOpener.h"
#include "comm/Read.h"
#include "comm/TcpAcceptor.h"
#include "fd.h"
#include "ftp/Parsing.h"
#include "ip/tools.h"
+#include "Mem.h"
+#include "SquidConfig.h"
#include "SquidString.h"
+#include "StatCounters.h"
#include "tools.h"
#include "wordlist.h"
#include <set>
-namespace Ftp {
+namespace Ftp
+{
const char *const crlf = "\r\n";
/// configures the channel with a descriptor and registers a close handler
void
Ftp::Channel::opened(const Comm::ConnectionPointer &newConn,
- const AsyncCall::Pointer &aCloser)
+ const AsyncCall::Pointer &aCloser)
{
assert(!Comm::IsConnOpen(conn));
assert(closer == NULL);
void
Ftp::DataChannel::addr(const Ip::Address &import)
{
- static char addrBuf[MAX_IPSTRLEN];
- import.toStr(addrBuf, sizeof(addrBuf));
- xfree(host);
- host = xstrdup(addrBuf);
- port = import.port();
+ static char addrBuf[MAX_IPSTRLEN];
+ import.toStr(addrBuf, sizeof(addrBuf));
+ xfree(host);
+ host = xstrdup(addrBuf);
+ port = import.port();
}
/* Ftp::Client */
typedef CommCbMemFunT<Client, CommCloseCbParams> Dialer;
const AsyncCall::Pointer closer = JobCallback(9, 5, Dialer, this,
- Ftp::Client::ctrlClosed);
+ Ftp::Client::ctrlClosed);
ctrl.opened(fwdState->serverConnection(), closer);
}
if (error == ERR_NONE)
error = ERR_FTP_FAILURE;
return error == ERR_READ_TIMEOUT ? Http::scGatewayTimeout :
- Http::scBadGateway;
+ Http::scBadGateway;
}
/**
return false;
}
-
/// Closes any old FTP-Data connection which may exist. */
data.close();
return true;
}
-
void
Ftp::Client::connectDataChannel()
{
typedef CommCbMemFunT<Client, CommTimeoutCbParams> TimeoutDialer;
AsyncCall::Pointer timeoutCall = JobCallback(9, 5, TimeoutDialer, this,
- Ftp::Client::timeout);
+ Ftp::Client::timeout);
commSetConnTimeout(data.conn, Config.Timeout.read, timeoutCall);
}
#include "Server.h"
class String;
-namespace Ftp {
+namespace Ftp
+{
extern const char *const crlf;
#include <cerrno>
-namespace Ftp {
+namespace Ftp
+{
/**
\defgroup ServerProtocolFTPInternal Server-Side FTP Internals
}
Ftp::Gateway::Gateway(FwdState *fwdState):
- AsyncJob("FtpStateData"),
- Ftp::Client(fwdState)
+ AsyncJob("FtpStateData"),
+ Ftp::Client(fwdState)
{
const char *url = entry->url();
debugs(9, 3, HERE << "'" << url << "'" );
#include "HttpHdrCc.h"
#include "HttpRequest.h"
#include "SBuf.h"
-#include "servers/FtpServer.h"
#include "Server.h"
+#include "servers/FtpServer.h"
#include "SquidTime.h"
#include "Store.h"
#include "wordlist.h"
-namespace Ftp {
+namespace Ftp
+{
/// An FTP client receiving native FTP commands from our FTP server
/// (Ftp::Server), forwarding them to the next FTP hop,
{
if (!master().clientReadGreeting)
Ftp::Client::start();
- else
- if (serverState() == fssHandleDataRequest ||
- serverState() == fssHandleUploadRequest)
+ else if (serverState() == fssHandleDataRequest ||
+ serverState() == fssHandleUploadRequest)
handleDataRequest();
else
sendCommand();
// the Sink will use this to call us back after writing 1xx to the client
typedef NullaryMemFunT<Relay> CbDialer;
const AsyncCall::Pointer call = JobCallback(11, 3, CbDialer, this,
- Ftp::Relay::proceedAfterPreliminaryReply);
+ Ftp::Relay::proceedAfterPreliminaryReply);
CallJobHere1(9, 4, request->clientConnectionManager, ConnStateData,
ConnStateData::sendControlMsg, HttpControlMsg(reply, call));
debugs(9, 5, "command: " << cmd << ", no parameters");
if (serverState() == fssHandlePasv ||
- serverState() == fssHandleEpsv ||
- serverState() == fssHandleEprt ||
- serverState() == fssHandlePort) {
+ serverState() == fssHandleEpsv ||
+ serverState() == fssHandleEprt ||
+ serverState() == fssHandlePort) {
sendPassive();
return;
}
template <class Cbc> class CbcPointer;
typedef CbcPointer<AsyncJob> AsyncJobPointer;
-namespace Ftp {
+namespace Ftp
+{
/// A new FTP Gateway job
AsyncJobPointer StartGateway(FwdState *const fwdState);
class SBuf;
class HttpReply;
-namespace Ftp {
+namespace Ftp
+{
/// Create an internal HttpReply structure to house FTP control response info.
HttpReply *HttpReplyWrapper(const int ftpStatus, const char *ftpReason, const Http::StatusCode httpStatus, const int64_t clen);
#include "ip/forward.h"
-namespace Ftp {
+namespace Ftp
+{
/// parses and validates "A1,A2,A3,A4,P1,P2" IP,port sequence
bool ParseIpPort(const char *buf, const char *forceIp, Ip::Address &addr);
#endif
#endif
-
/// convenience method: consumes up to n bytes, counts, and returns them
SBuf
-Parser::Tokenizer::consume(const SBuf::size_type n) {
+Parser::Tokenizer::consume(const SBuf::size_type n)
+{
// careful: n may be npos!
const SBuf result = buf_.consume(n);
parsed_ += result.length();
/// convenience method: consume()s up to n bytes and returns their count
SBuf::size_type
-Parser::Tokenizer::success(const SBuf::size_type n) {
+Parser::Tokenizer::success(const SBuf::size_type n)
+{
return consume(n).length();
}
#include "squid.h"
#include "base/CharacterSet.h"
#include "base/Subscription.h"
+#include "client_side_reply.h"
+#include "client_side_request.h"
#include "clientStream.h"
#include "comm/ConnOpener.h"
#include "comm/Read.h"
#include "comm/TcpAcceptor.h"
#include "comm/Write.h"
-#include "client_side_reply.h"
-#include "client_side_request.h"
#include "errorpage.h"
#include "fd.h"
#include "ftp/Elements.h"
CBDATA_NAMESPACED_CLASS_INIT(Ftp, Server);
-namespace Ftp {
+namespace Ftp
+{
static void PrintReply(MemBuf &mb, const HttpReply *reply, const char *const prefix = "");
static bool SupportedCommand(const SBuf &name);
static bool CommandHasPathParameter(const SBuf &cmd);
debugs(33, 5, "handling FTP request data for " << clientConnection);
const size_t putSize = bodyPipe->putMoreData(uploadBuf,
- uploadAvailSize);
+ uploadAvailSize);
if (putSize > 0) {
uploadAvailSize -= putSize;
if (uploadAvailSize > 0)
// direct new connections accepted by listenConn to Accept()
typedef CommCbFunPtrCallT<CommAcceptCbPtrFun> AcceptCall;
RefCount<AcceptCall> subCall = commCbCall(5, 5, "Ftp::Server::AcceptCtrlConnection",
- CommAcceptCbPtrFun(Ftp::Server::AcceptCtrlConnection,
- CommAcceptCbParams(NULL)));
+ CommAcceptCbPtrFun(Ftp::Server::AcceptCtrlConnection,
+ CommAcceptCbParams(NULL)));
clientStartListeningOn(s, subCall, Ipc::fdnFtpSocket);
}
}
debugs(33, 5, "late data connection?");
closeDataConnection(); // in case we are still listening
params.conn->close();
- } else
- if (params.conn->remote != clientConnection->remote) {
+ } else if (params.conn->remote != clientConnection->remote) {
debugs(33, 2, "rogue data conn? ctrl: " << clientConnection->remote);
params.conn->close();
// Some FTP servers close control connection here, but it may make
assert(99 < code && code < 1000);
const bool sendDetails = reply != NULL &&
- reply->header.has(HDR_FTP_STATUS) && reply->header.has(HDR_FTP_REASON);
+ reply->header.has(HDR_FTP_STATUS) && reply->header.has(HDR_FTP_REASON);
MemBuf mb;
mb.init();
Http::METHOD_PUT : Http::METHOD_GET;
const SBuf *path = params.length() && CommandHasPathParameter(cmd) ?
- ¶ms : NULL;
+ ¶ms : NULL;
calcUri(path);
char *newUri = xstrdup(uri.c_str());
HttpRequest *const request = HttpRequest::CreateFromUrlAndMethod(newUri, method);
assert(context != NULL);
if (context->http && context->http->al != NULL &&
- !context->http->al->reply && reply) {
+ !context->http->al->reply && reply) {
context->http->al->reply = reply;
HTTPMSGLOCK(context->http->al->reply);
}
/// ClientStream checks after (actual or skipped) reply data writing
void
-Ftp::Server::replyDataWritingCheckpoint() {
+Ftp::Server::replyDataWritingCheckpoint()
+{
switch (getCurrentContext()->socketState()) {
case STREAM_NONE:
debugs(33, 3, "Keep going");
// Status 125 or 150 implies upload or data request, but we still check
// the state in case the server is buggy.
if ((scode == 125 || scode == 150) &&
- (master.serverState == fssHandleUploadRequest ||
- master.serverState == fssHandleDataRequest)) {
+ (master.serverState == fssHandleUploadRequest ||
+ master.serverState == fssHandleDataRequest)) {
if (checkDataConnPost()) {
// If the data connection is ready, start reading data (here)
// and forward the response to client (further below).
switch (socketState) {
case STREAM_UNPLANNED_COMPLETE:
case STREAM_FAILED:
- io.conn->close();
- return;
+ io.conn->close();
+ return;
case STREAM_NONE:
case STREAM_COMPLETE:
}
bool
-Ftp::Server::handleRequest(String &cmd, String ¶ms) {
+Ftp::Server::handleRequest(String &cmd, String ¶ms)
+{
HttpRequest *request = getCurrentContext()->http->request;
Must(request);
typedef CommCbMemFunT<Server, CommConnectCbParams> Dialer;
connector = JobCallback(17, 3, Dialer, this, Ftp::Server::connectedForData);
Comm::ConnOpener *cs = new Comm::ConnOpener(dataConn, connector,
- Config.Timeout.connect);
+ Config.Timeout.connect);
AsyncJob::Start(cs);
return false; // ConnStateData::processFtpRequest waits handleConnectDone
}
#include "client_side.h"
-namespace Ftp {
+namespace Ftp
+{
typedef enum {
fssBegin,
#include "servers/forward.h"
#include "SquidConfig.h"
-namespace Http {
+namespace Http
+{
/// Manages a connection from an HTTP client.
class Server: public ConnStateData
template <class C> class RefCount;
typedef RefCount<MasterXaction> MasterXactionPointer;
-namespace Http {
+namespace Http
+{
/// create a new HTTP connection handler; never returns NULL
ConnStateData *NewServer(MasterXactionPointer &xact);
} // namespace Http
-namespace Https {
+namespace Https
+{
/// create a new HTTPS connection handler; never returns NULL
ConnStateData *NewServer(MasterXactionPointer &xact);
} // namespace Https
-namespace Ftp {
+namespace Ftp
+{
/// accept connections on all configured ftp_ports
void StartListening();