feat(FTPClientSession): activeDataConnection 1.11.0 cannot set specific data port #3372

This commit is contained in:
Alex Fabijanic 2022-06-23 23:35:09 +02:00
parent 391cb63c54
commit c8e66028ee
2 changed files with 17 additions and 7 deletions

View File

@ -58,18 +58,21 @@ public:
TYPE_BINARY /// TYPE I (Image/binary data)
};
FTPClientSession();
FTPClientSession(Poco::UInt16 activeDataPort = 0);
/// Creates an FTPClientSession.
///
/// Passive mode will be used for data transfers.
FTPClientSession(const StreamSocket& socket, bool readWelcomeMessage = true);
FTPClientSession(const StreamSocket& socket, bool readWelcomeMessage = true,
Poco::UInt16 activeDataPort = 0);
/// Creates an FTPClientSession using the given
/// connected socket for the control connection.
///
/// Passive mode will be used for data transfers.
FTPClientSession(const std::string& host, Poco::UInt16 port = FTP_PORT, const std::string& username = "", const std::string& password = "");
FTPClientSession(const std::string& host, Poco::UInt16 port = FTP_PORT,
const std::string& username = "", const std::string& password = "",
Poco::UInt16 activeDataPort = 0);
/// Creates an FTPClientSession using a socket connected
/// to the given host and port. If username is supplied,
/// login is attempted.
@ -350,6 +353,7 @@ private:
std::string _host;
Poco::UInt16 _port = FTP_PORT;
Poco::UInt16 _activeDataPort = 0;
bool _passiveMode = true;
FileType _fileType = TYPE_BINARY;
bool _supports1738 = true;

View File

@ -28,10 +28,11 @@ namespace Poco {
namespace Net {
FTPClientSession::FTPClientSession():
FTPClientSession::FTPClientSession(Poco::UInt16 activeDataPort):
_pControlSocket(0),
_pDataStream(0),
_port(FTP_PORT),
_activeDataPort(activeDataPort),
_passiveMode(true),
_fileType(TYPE_BINARY),
_supports1738(true),
@ -42,11 +43,14 @@ FTPClientSession::FTPClientSession():
}
FTPClientSession::FTPClientSession(const StreamSocket& socket, bool readWelcomeMessage):
FTPClientSession::FTPClientSession(const StreamSocket& socket,
bool readWelcomeMessage,
Poco::UInt16 activeDataPort):
_pControlSocket(new DialogSocket(socket)),
_pDataStream(0),
_host(socket.address().host().toString()),
_port(socket.address().port()),
_activeDataPort(activeDataPort),
_passiveMode(true),
_fileType(TYPE_BINARY),
_supports1738(true),
@ -69,11 +73,13 @@ FTPClientSession::FTPClientSession(const StreamSocket& socket, bool readWelcomeM
FTPClientSession::FTPClientSession(const std::string& host,
Poco::UInt16 port,
const std::string& username,
const std::string& password):
const std::string& password,
Poco::UInt16 activeDataPort):
_pControlSocket(new DialogSocket(SocketAddress(host, port))),
_pDataStream(0),
_host(host),
_port(port),
_activeDataPort(activeDataPort),
_passiveMode(true),
_fileType(TYPE_BINARY),
_supports1738(true),
@ -452,7 +458,7 @@ StreamSocket FTPClientSession::activeDataConnection(const std::string& command,
if (!isOpen())
throw FTPException("Connection is closed.");
ServerSocket server(SocketAddress(_pControlSocket->address().host(), 0));
ServerSocket server(SocketAddress(_pControlSocket->address().host(), _activeDataPort));
sendPortCommand(server.address());
std::string response;
int status = sendCommand(command, arg, response);