mirror of https://github.com/aria2/aria2
Fix no-return warning in FtpInitiateConnectionCommand
... and untangle code a bit while at it.pull/122/head
parent
c3b42da8d9
commit
522ae80fd4
|
@ -73,26 +73,28 @@ FtpInitiateConnectionCommand::FtpInitiateConnectionCommand
|
||||||
|
|
||||||
FtpInitiateConnectionCommand::~FtpInitiateConnectionCommand() {}
|
FtpInitiateConnectionCommand::~FtpInitiateConnectionCommand() {}
|
||||||
|
|
||||||
std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommandProxied
|
||||||
(const std::string& hostname, const std::string& addr, uint16_t port,
|
(const std::string& hostname, const std::string& addr, uint16_t port,
|
||||||
const std::vector<std::string>& resolvedAddresses,
|
const std::vector<std::string>& resolvedAddresses,
|
||||||
const std::shared_ptr<Request>& proxyRequest)
|
const std::shared_ptr<Request>& proxyRequest)
|
||||||
{
|
{
|
||||||
if(proxyRequest) {
|
|
||||||
std::string options;
|
std::string options;
|
||||||
std::shared_ptr<SocketCore> pooledSocket;
|
std::shared_ptr<SocketCore> pooledSocket;
|
||||||
std::string proxyMethod = resolveProxyMethod(getRequest()->getProtocol());
|
std::string proxyMethod = resolveProxyMethod(getRequest()->getProtocol());
|
||||||
|
|
||||||
if(proxyMethod == V_GET) {
|
if(proxyMethod == V_GET) {
|
||||||
pooledSocket = getDownloadEngine()->popPooledSocket
|
pooledSocket = getDownloadEngine()->popPooledSocket
|
||||||
(getRequest()->getHost(), getRequest()->getPort(),
|
(getRequest()->getHost(), getRequest()->getPort(),
|
||||||
proxyRequest->getHost(), proxyRequest->getPort());
|
proxyRequest->getHost(), proxyRequest->getPort());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
pooledSocket = getDownloadEngine()->popPooledSocket
|
pooledSocket = getDownloadEngine()->popPooledSocket
|
||||||
(options, getRequest()->getHost(), getRequest()->getPort(),
|
(options, getRequest()->getHost(), getRequest()->getPort(),
|
||||||
getDownloadEngine()->getAuthConfigFactory()->createAuthConfig
|
getDownloadEngine()->getAuthConfigFactory()->createAuthConfig
|
||||||
(getRequest(), getOption().get())->getUser(),
|
(getRequest(), getOption().get())->getUser(),
|
||||||
proxyRequest->getHost(), proxyRequest->getPort());
|
proxyRequest->getHost(), proxyRequest->getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pooledSocket) {
|
if(!pooledSocket) {
|
||||||
A2_LOG_INFO(fmt(MSG_CONNECTING_TO_SERVER,
|
A2_LOG_INFO(fmt(MSG_CONNECTING_TO_SERVER,
|
||||||
getCuid(), addr.c_str(), port));
|
getCuid(), addr.c_str(), port));
|
||||||
|
@ -121,10 +123,12 @@ std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
||||||
} else {
|
} else {
|
||||||
// Unreachable
|
// Unreachable
|
||||||
assert(0);
|
assert(0);
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
setupBackupConnection(hostname, addr, port, c.get());
|
setupBackupConnection(hostname, addr, port, c.get());
|
||||||
return std::move(c);
|
return std::move(c);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
|
setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
|
||||||
if(proxyMethod == V_TUNNEL) {
|
if(proxyMethod == V_TUNNEL) {
|
||||||
// options contains "baseWorkingDir"
|
// options contains "baseWorkingDir"
|
||||||
|
@ -137,7 +141,13 @@ std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
||||||
pooledSocket,
|
pooledSocket,
|
||||||
FtpNegotiationCommand::SEQ_SEND_CWD_PREP,
|
FtpNegotiationCommand::SEQ_SEND_CWD_PREP,
|
||||||
options);
|
options);
|
||||||
} else if(proxyMethod == V_GET) {
|
}
|
||||||
|
|
||||||
|
if(proxyMethod != V_GET) {
|
||||||
|
assert(0);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Use GET for FTP via HTTP proxy.
|
// Use GET for FTP via HTTP proxy.
|
||||||
getRequest()->setMethod(Request::METHOD_GET);
|
getRequest()->setMethod(Request::METHOD_GET);
|
||||||
std::shared_ptr<SocketRecvBuffer> socketRecvBuffer
|
std::shared_ptr<SocketRecvBuffer> socketRecvBuffer
|
||||||
|
@ -154,12 +164,12 @@ std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
||||||
pooledSocket);
|
pooledSocket);
|
||||||
c->setProxyRequest(proxyRequest);
|
c->setProxyRequest(proxyRequest);
|
||||||
return std::move(c);
|
return std::move(c);
|
||||||
} else {
|
|
||||||
// Unreachable
|
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommandPlain
|
||||||
|
(const std::string& hostname, const std::string& addr, uint16_t port,
|
||||||
|
const std::vector<std::string>& resolvedAddresses)
|
||||||
|
{
|
||||||
std::string options;
|
std::string options;
|
||||||
std::shared_ptr<SocketCore> pooledSocket =
|
std::shared_ptr<SocketCore> pooledSocket =
|
||||||
getDownloadEngine()->popPooledSocket
|
getDownloadEngine()->popPooledSocket
|
||||||
|
@ -167,6 +177,7 @@ std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
||||||
getRequest()->getPort(),
|
getRequest()->getPort(),
|
||||||
getDownloadEngine()->getAuthConfigFactory()->createAuthConfig
|
getDownloadEngine()->getAuthConfigFactory()->createAuthConfig
|
||||||
(getRequest(), getOption().get())->getUser());
|
(getRequest(), getOption().get())->getUser());
|
||||||
|
|
||||||
if(!pooledSocket) {
|
if(!pooledSocket) {
|
||||||
A2_LOG_INFO(fmt(MSG_CONNECTING_TO_SERVER,
|
A2_LOG_INFO(fmt(MSG_CONNECTING_TO_SERVER,
|
||||||
getCuid(), addr.c_str(), port));
|
getCuid(), addr.c_str(), port));
|
||||||
|
@ -175,7 +186,7 @@ std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
||||||
getRequest()->setConnectedAddrInfo(hostname, addr, port);
|
getRequest()->setConnectedAddrInfo(hostname, addr, port);
|
||||||
auto c = make_unique<ConnectCommand>(getCuid(),
|
auto c = make_unique<ConnectCommand>(getCuid(),
|
||||||
getRequest(),
|
getRequest(),
|
||||||
proxyRequest, // must be null
|
nullptr,
|
||||||
getFileEntry(),
|
getFileEntry(),
|
||||||
getRequestGroup(),
|
getRequestGroup(),
|
||||||
getDownloadEngine(),
|
getDownloadEngine(),
|
||||||
|
@ -185,7 +196,8 @@ std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
||||||
c->setControlChain(chain);
|
c->setControlChain(chain);
|
||||||
setupBackupConnection(hostname, addr, port, c.get());
|
setupBackupConnection(hostname, addr, port, c.get());
|
||||||
return std::move(c);
|
return std::move(c);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// options contains "baseWorkingDir"
|
// options contains "baseWorkingDir"
|
||||||
auto command = make_unique<FtpNegotiationCommand>
|
auto command = make_unique<FtpNegotiationCommand>
|
||||||
(getCuid(),
|
(getCuid(),
|
||||||
|
@ -199,7 +211,17 @@ std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
||||||
setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
|
setConnectedAddrInfo(getRequest(), hostname, pooledSocket);
|
||||||
return std::move(command);
|
return std::move(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Command> FtpInitiateConnectionCommand::createNextCommand
|
||||||
|
(const std::string& hostname, const std::string& addr, uint16_t port,
|
||||||
|
const std::vector<std::string>& resolvedAddresses,
|
||||||
|
const std::shared_ptr<Request>& proxyRequest)
|
||||||
|
{
|
||||||
|
if (proxyRequest) {
|
||||||
|
return createNextCommandProxied(hostname, addr, port, resolvedAddresses,
|
||||||
|
proxyRequest);
|
||||||
}
|
}
|
||||||
|
return createNextCommandPlain(hostname, addr, port, resolvedAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -40,6 +40,15 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
class FtpInitiateConnectionCommand : public InitiateConnectionCommand {
|
class FtpInitiateConnectionCommand : public InitiateConnectionCommand {
|
||||||
|
private:
|
||||||
|
virtual std::unique_ptr<Command> createNextCommandProxied
|
||||||
|
(const std::string& hostname, const std::string& addr, uint16_t port,
|
||||||
|
const std::vector<std::string>& resolvedAddresses,
|
||||||
|
const std::shared_ptr<Request>& proxyRequest);
|
||||||
|
|
||||||
|
virtual std::unique_ptr<Command> createNextCommandPlain
|
||||||
|
(const std::string& hostname, const std::string& addr, uint16_t port,
|
||||||
|
const std::vector<std::string>& resolvedAddresses);
|
||||||
protected:
|
protected:
|
||||||
virtual std::unique_ptr<Command> createNextCommand
|
virtual std::unique_ptr<Command> createNextCommand
|
||||||
(const std::string& hostname, const std::string& addr, uint16_t port,
|
(const std::string& hostname, const std::string& addr, uint16_t port,
|
||||||
|
|
Loading…
Reference in New Issue