From 639b3148a6aee0fb79e4cdf6391fb1146c1fa5fd Mon Sep 17 00:00:00 2001 From: deniskovalchuk Date: Mon, 2 Oct 2023 17:31:49 +0300 Subject: [PATCH] refactor: reorder methods No functional changes. --- src/client.cpp | 80 +++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 068848c..21bc005 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -689,6 +689,33 @@ data_connection_ptr client::process_eprt_command(std::string_view command, repli return connection; } +std::string client::make_eprt_command(const boost::asio::ip::tcp::endpoint & endpoint) +{ + std::string command = "EPRT"; + command.append(" "); + command.append("|"); + + if (endpoint.address().is_v4()) + { + command.append("1"); + } + else if (endpoint.address().is_v6()) + { + command.append("2"); + } + else + { + throw ftp_exception("Cannot make the EPRT command. The IP address type is invalid."); + } + + command.append("|"); + command.append(net_utils::address_to_string(endpoint.address())); + command.append("|"); + command.append(std::to_string(endpoint.port())); + command.append("|"); + return command; +} + data_connection_ptr client::process_pasv_command(std::string_view command, replies & replies) { std::string pasv_command = make_command("PASV"); @@ -820,46 +847,6 @@ data_connection_ptr client::process_port_command(std::string_view command, repli return connection; } -std::string client::make_command(std::string_view command, const std::optional & argument) -{ - std::string result(command); - - if (argument) - { - result.append(" "); - result.append(argument.value()); - } - - return result; -} - -std::string client::make_eprt_command(const boost::asio::ip::tcp::endpoint & endpoint) -{ - std::string command = "EPRT"; - command.append(" "); - command.append("|"); - - if (endpoint.address().is_v4()) - { - command.append("1"); - } - else if (endpoint.address().is_v6()) - { - command.append("2"); - } - else - { - throw ftp_exception("Cannot make the EPRT command. The IP address type is invalid."); - } - - command.append("|"); - command.append(net_utils::address_to_string(endpoint.address())); - command.append("|"); - command.append(std::to_string(endpoint.port())); - command.append("|"); - return command; -} - std::string client::make_port_command(const boost::asio::ip::tcp::endpoint & endpoint) { std::string command = "PORT"; @@ -884,6 +871,19 @@ std::string client::make_port_command(const boost::asio::ip::tcp::endpoint & end return command; } +std::string client::make_command(std::string_view command, const std::optional & argument) +{ + std::string result(command); + + if (argument) + { + result.append(" "); + result.append(argument.value()); + } + + return result; +} + std::string client::make_type_command(transfer_type type) { if (type == transfer_type::binary)