Skip to content

Commit

Permalink
docs: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskovalchuk committed Oct 3, 2023
1 parent 598a66a commit 194f0d2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,13 +684,15 @@ bool client::try_parse_epsv_reply(const reply & reply, std::uint16_t & port)

data_connection_ptr client::process_eprt_command(std::string_view command, replies & replies)
{
/* Start to listen. */
boost::asio::ip::tcp::endpoint local_endpoint = control_connection_.get_local_endpoint();
boost::asio::ip::tcp::endpoint listen_endpoint(local_endpoint.address(), 0);

data_connection_ptr connection = std::make_unique<data_connection>();
connection->listen(listen_endpoint);
listen_endpoint = connection->get_listen_endpoint();

/* Process the EPRT command. */
std::string eprt_command = make_eprt_command(listen_endpoint);

reply reply = process_command(eprt_command, replies);
Expand All @@ -700,14 +702,18 @@ data_connection_ptr client::process_eprt_command(std::string_view command, repli
return nullptr;
}

/* Process the main command. */
reply = process_command(command, replies);

if (reply.is_negative())
{
return nullptr;
}

/* Accept an incoming data connection. */
connection->accept();

/* The data connection is ready for data transfer. */
return connection;
}

Expand Down Expand Up @@ -847,13 +853,15 @@ bool client::try_parse_pasv_reply(const reply & reply, std::string & ip, uint16_

data_connection_ptr client::process_port_command(std::string_view command, replies & replies)
{
/* Start to listen. */
boost::asio::ip::tcp::endpoint local_endpoint = control_connection_.get_local_endpoint();
boost::asio::ip::tcp::endpoint listen_endpoint(local_endpoint.address(), 0);

data_connection_ptr connection = std::make_unique<data_connection>();
connection->listen(listen_endpoint);
listen_endpoint = connection->get_listen_endpoint();

/* Process the PORT command. */
std::string port_command = make_port_command(listen_endpoint);

reply reply = process_command(port_command, replies);
Expand All @@ -863,14 +871,18 @@ data_connection_ptr client::process_port_command(std::string_view command, repli
return nullptr;
}

/* Process the main command. */
reply = process_command(command, replies);

if (reply.is_negative())
{
return nullptr;
}

/* Accept an incoming data connection. */
connection->accept();

/* The data connection is ready for data transfer. */
return connection;
}

Expand Down

0 comments on commit 194f0d2

Please sign in to comment.