diff --git a/src/core/client/main.cpp b/src/core/client/main.cpp index f97bd4f7..36095354 100644 --- a/src/core/client/main.cpp +++ b/src/core/client/main.cpp @@ -151,7 +151,7 @@ int main(int argc, char** argv) { if (p_service.get() != nullptr) { if (ec) { SSF_LOG(kLogError) << "client: service <" << p_service->GetName() - << "> NOK"; + << "> KO"; } else { SSF_LOG(kLogInfo) << "client: service <" << p_service->GetName() << "> OK"; diff --git a/src/core/command_line/standard/command_line.cpp b/src/core/command_line/standard/command_line.cpp index 4918eec8..a8665526 100644 --- a/src/core/command_line/standard/command_line.cpp +++ b/src/core/command_line/standard/command_line.cpp @@ -25,7 +25,7 @@ void CommandLine::PopulateLocalOptions(OptionDescription& local_opts) { local_opts.add_options() ("status,S", boost::program_options::bool_switch()->default_value(false), - "Display micro services statuses (on/off)"); + "Display micro services status (on/off)"); // clang-format on } diff --git a/src/core/transport_virtual_layer_policies/transport_protocol_policy.h b/src/core/transport_virtual_layer_policies/transport_protocol_policy.h index 51256653..969d6693 100644 --- a/src/core/transport_virtual_layer_policies/transport_protocol_policy.h +++ b/src/core/transport_virtual_layer_policies/transport_protocol_policy.h @@ -33,7 +33,7 @@ class TransportProtocolPolicy { TransportProtocolPolicy(Callback callback) : callback_(callback) {} void DoSSFInitiate(SocketPtr p_socket) { - SSF_LOG(kLogInfo) << "transport: starting SSF protocol"; + SSF_LOG(kLogDebug) << "transport: starting SSF protocol"; uint32_t version = GetVersion(); auto p_ssf_request = std::make_shared(version); @@ -81,7 +81,7 @@ class TransportProtocolPolicy { void DoSSFValidReceive(SSFRequestPtr p_ssf_request, SocketPtr p_socket, const boost::system::error_code& ec, size_t length) { if (!ec) { - SSF_LOG(kLogInfo) << "transport: SSF request sent"; + SSF_LOG(kLogDebug) << "transport: SSF request sent"; auto p_ssf_reply = std::make_shared(); @@ -101,7 +101,7 @@ class TransportProtocolPolicy { size_t length) { if (!ec) { if (p_ssf_reply->result()) { - SSF_LOG(kLogInfo) << "transport: SSF reply OK"; + SSF_LOG(kLogDebug) << "transport: SSF reply OK"; callback_(p_socket, ec); } else { boost::system::error_code result_ec(::error::wrong_protocol_type, diff --git a/src/services/admin/admin.ipp b/src/services/admin/admin.ipp index 5c721ae2..1a293663 100644 --- a/src/services/admin/admin.ipp +++ b/src/services/admin/admin.ipp @@ -157,7 +157,9 @@ void Admin::InitializeRemoteServices( // If something went wrong remote_all_started_ > 0 if (remote_all_started_) { - SSF_LOG(kLogWarning) << "service[admin]: remote could not start"; + SSF_LOG(kLogError) << "service[admin]: could not start remote " + "microservice for service[" + << user_services_[i_]->GetName() << "]"; Notify(ssf::services::initialisation::SERVICE, user_services_[i_], boost::system::error_code(::error::operation_canceled, @@ -183,7 +185,9 @@ void Admin::InitializeRemoteServices( // If something went wrong local_all_started_ == false if (!local_all_started_) { - SSF_LOG(kLogWarning) << "service[admin]: local could not start"; + SSF_LOG(kLogError) << "service[admin]: could not start local " + "microservice for service[" + << user_services_[i_]->GetName() << "]"; Notify(ssf::services::initialisation::SERVICE, user_services_[i_], boost::system::error_code(::error::operation_canceled, diff --git a/src/services/copy_file/fiber_to_file/fiber_to_file.h b/src/services/copy_file/fiber_to_file/fiber_to_file.h index 63c24d33..993dc149 100644 --- a/src/services/copy_file/fiber_to_file/fiber_to_file.h +++ b/src/services/copy_file/fiber_to_file/fiber_to_file.h @@ -46,8 +46,9 @@ class FiberToFile : public BaseService { // Start service and listen new fiber on demux port kServicePort virtual void start(boost::system::error_code& ec) { endpoint ep(this->get_demux(), kServicePort); - SSF_LOG(kLogInfo) << "service[fiber to file]: start accept on fiber port " - << kServicePort; + SSF_LOG(kLogInfo) + << "microservice[fiber to file]: start accept on fiber port " + << kServicePort; fiber_acceptor_.bind(ep, ec); fiber_acceptor_.listen(boost::asio::socket_base::max_connections, ec); if (ec) { @@ -58,7 +59,7 @@ class FiberToFile : public BaseService { // Stop service virtual void stop(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "service[fiber to file]: stopping"; + SSF_LOG(kLogInfo) << "microservice[fiber to file]: stopping"; manager_.stop_all(); fiber_acceptor_.close(ec); fiber_.close(ec); @@ -99,7 +100,7 @@ class FiberToFile : public BaseService { // Create a session to transmit files for the new connection void StartDataForwarderSessionHandler(const boost::system::error_code& ec) { if (ec) { - SSF_LOG(kLogInfo) << "service[fiber to file]: fail accept fiber"; + SSF_LOG(kLogInfo) << "microservice[fiber to file]: fail accept fiber"; return; } diff --git a/src/services/copy_file/file_enquirer/file_enquirer.h b/src/services/copy_file/file_enquirer/file_enquirer.h index f3736259..9c970129 100644 --- a/src/services/copy_file/file_enquirer/file_enquirer.h +++ b/src/services/copy_file/file_enquirer/file_enquirer.h @@ -92,9 +92,8 @@ class FileEnquirer : public BaseService { } reenter(coroutine_) { - SSF_LOG(kLogDebug) - << "service[file enquirer]: connect to remote fiber acceptor port " - << remote_endpoint_.port(); + SSF_LOG(kLogDebug) << "microservice[file enquirer]: connect to remote " + "fiber acceptor port " << remote_endpoint_.port(); yield fiber_.async_connect( remote_endpoint_, diff --git a/src/services/copy_file/file_to_fiber/file_to_fiber.h b/src/services/copy_file/file_to_fiber/file_to_fiber.h index 4f3f6779..5560ac51 100644 --- a/src/services/copy_file/file_to_fiber/file_to_fiber.h +++ b/src/services/copy_file/file_to_fiber/file_to_fiber.h @@ -89,8 +89,9 @@ class FileToFiber : public BaseService { if (accept_) { endpoint ep(this->get_demux(), kServicePort); - SSF_LOG(kLogInfo) << "service[file to fiber]: start accept on fiber port " - << kServicePort; + SSF_LOG(kLogInfo) + << "microservice[file to fiber]: start accept on fiber port " + << kServicePort; fiber_acceptor_.bind(ep, ec); fiber_acceptor_.listen(boost::asio::socket_base::max_connections, ec); if (ec) { @@ -104,7 +105,7 @@ class FileToFiber : public BaseService { // Stop service virtual void stop(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "service[file to fiber]: stopping"; + SSF_LOG(kLogInfo) << "microservice[file to fiber]: stopping"; manager_.stop_all(); boost::system::error_code close_ec; fiber_acceptor_.close(close_ec); @@ -282,7 +283,7 @@ class FileToFiber : public BaseService { std::make_shared(this->get_demux().get_io_service()); SSF_LOG(kLogDebug) - << "service[file to fiber]: connect to remote fiber acceptor port " + << "microservice[file to fiber]: connect to remote fiber acceptor port " << ssf::services::copy_file::fiber_to_file::FiberToFile< Demux>::kServicePort; @@ -310,11 +311,12 @@ class FileToFiber : public BaseService { if (from_stdin) { SSF_LOG(kLogInfo) - << "service[file to fiber]: start forward data from stdin to " + << "microservice[file to fiber]: start forward data from stdin to " << output_file; } else { - SSF_LOG(kLogInfo) << "service[file to fiber]: start forward data from " - << input_file << " to " << output_file; + SSF_LOG(kLogInfo) + << "microservice[file to fiber]: start forward data from " + << input_file << " to " << output_file; } if (!from_stdin) { diff --git a/src/services/datagrams_to_fibers/datagrams_to_fibers.ipp b/src/services/datagrams_to_fibers/datagrams_to_fibers.ipp index 7f2cfb57..676bfe6d 100644 --- a/src/services/datagrams_to_fibers/datagrams_to_fibers.ipp +++ b/src/services/datagrams_to_fibers/datagrams_to_fibers.ipp @@ -24,7 +24,7 @@ DatagramsToFibers::DatagramsToFibers(boost::asio::io_service& io_service, template void DatagramsToFibers::start(boost::system::error_code& ec) { SSF_LOG(kLogInfo) - << "service[datagrams to fibers]: starting relay on local port udp " + << "microservice[datagrams to fibers]: start forwarding local UDP port " << local_port_; boost::asio::ip::udp::resolver resolver(socket_.get_io_service()); @@ -33,9 +33,8 @@ void DatagramsToFibers::start(boost::system::error_code& ec) { auto ep_it = resolver.resolve(query, ec); if (ec) { - SSF_LOG(kLogError) - << "service[datagrams to fibers]: could not resolve query "; + SSF_LOG(kLogError) << "microservice[datagrams to fibers]: could not " + "resolve query "; return; } @@ -44,22 +43,24 @@ void DatagramsToFibers::start(boost::system::error_code& ec) { boost::system::error_code close_ec; socket_.open(boost::asio::ip::udp::v4(), ec); if (ec) { - SSF_LOG(kLogError) << "service[datagrams to fibers]: could not open socket"; + SSF_LOG(kLogError) + << "microservice[datagrams to fibers]: could not open socket"; socket_.close(close_ec); return; } boost::asio::socket_base::reuse_address reuse_address_option(true); socket_.set_option(reuse_address_option, ec); if (ec) { - SSF_LOG(kLogError) - << "service[datagrams to fibers]: could not set reuse address option"; + SSF_LOG(kLogError) << "microservice[datagrams to fibers]: could not set " + "reuse address option"; socket_.close(close_ec); return; } socket_.bind(endpoint_, ec); if (ec) { - SSF_LOG(kLogError) << "service[datagrams to fibers]: could not bind socket"; + SSF_LOG(kLogError) + << "microservice[datagrams to fibers]: could not bind socket"; socket_.close(close_ec); return; } @@ -71,11 +72,11 @@ void DatagramsToFibers::start(boost::system::error_code& ec) { template void DatagramsToFibers::stop(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "service[datagrams to fibers]: stopping"; + SSF_LOG(kLogInfo) << "microservice[datagrams to fibers]: stopping"; socket_.close(ec); if (ec) { - SSF_LOG(kLogDebug) << "service[datagrams to fibers]: error on stop " + SSF_LOG(kLogDebug) << "microservice[datagrams to fibers]: error on stop " << ec.message(); } @@ -89,7 +90,8 @@ uint32_t DatagramsToFibers::service_type_id() { template void DatagramsToFibers::StartReceivingDatagrams() { - SSF_LOG(kLogTrace) << "service[datagrams to fibers]: receiving new datagrams"; + SSF_LOG(kLogTrace) + << "microservice[datagrams to fibers]: receiving new datagrams"; socket_.async_receive_from( boost::asio::buffer(working_buffer_), endpoint_, diff --git a/src/services/fibers_to_datagrams/fibers_to_datagrams.ipp b/src/services/fibers_to_datagrams/fibers_to_datagrams.ipp index 7f6b9cba..bce6637c 100644 --- a/src/services/fibers_to_datagrams/fibers_to_datagrams.ipp +++ b/src/services/fibers_to_datagrams/fibers_to_datagrams.ipp @@ -24,9 +24,9 @@ FibersToDatagrams::FibersToDatagrams(boost::asio::io_service& io_service, template void FibersToDatagrams::start(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) - << "service[fibers to datagrams]: starting relay on local port udp " - << local_port_; + SSF_LOG(kLogInfo) << "microservice[fibers to datagrams]: start forwarding " + "fiber datagrams from port " << local_port_ << " to <" + << ip_ << ":" << remote_port_ << ">"; // fiber.open() fiber_.bind(datagram_endpoint(this->get_demux(), local_port_), ec); @@ -46,7 +46,7 @@ void FibersToDatagrams::start(boost::system::error_code& ec) { template void FibersToDatagrams::stop(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "service[fibers to datagrams]: stopping"; + SSF_LOG(kLogInfo) << "microservice[fibers to datagrams]: stopping"; ec.assign(::error::success, ::error::get_ssf_category()); fiber_.close(); @@ -60,7 +60,8 @@ uint32_t FibersToDatagrams::service_type_id() { template void FibersToDatagrams::StartReceivingDatagrams() { - SSF_LOG(kLogTrace) << "service[fibers to datagrams]: receiving new datagrams"; + SSF_LOG(kLogTrace) + << "microservice[fibers to datagrams]: receiving new datagrams"; fiber_.async_receive_from( boost::asio::buffer(working_buffer_), received_from_, diff --git a/src/services/fibers_to_sockets/fibers_to_sockets.ipp b/src/services/fibers_to_sockets/fibers_to_sockets.ipp index 10c6d527..0b93da69 100644 --- a/src/services/fibers_to_sockets/fibers_to_sockets.ipp +++ b/src/services/fibers_to_sockets/fibers_to_sockets.ipp @@ -26,9 +26,9 @@ FibersToSockets::FibersToSockets(boost::asio::io_service& io_service, template void FibersToSockets::start(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) - << "service[fibers to sockets]: starting relay on local port tcp " - << local_port_; + SSF_LOG(kLogInfo) << "microservice[fibers to sockets]: start " + "forwarding stream fiber from port " << local_port_ + << " to <" << ip_ << ":" << remote_port_ << ">"; endpoint ep(this->get_demux(), local_port_); fiber_acceptor_.bind(ep, ec); @@ -49,7 +49,7 @@ void FibersToSockets::start(boost::system::error_code& ec) { template void FibersToSockets::stop(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "service[fibers to sockets]: stopping"; + SSF_LOG(kLogInfo) << "microservice[fibers to sockets]: stopping"; ec.assign(::error::success, ::error::get_ssf_category()); fiber_acceptor_.close(); @@ -63,7 +63,8 @@ uint32_t FibersToSockets::service_type_id() { template void FibersToSockets::StartAcceptFibers() { - SSF_LOG(kLogTrace) << "service[fibers to sockets]: accepting new clients"; + SSF_LOG(kLogTrace) + << "microservice[fibers to sockets]: accepting new clients"; fiber_acceptor_.async_accept( fiber_, Then(&FibersToSockets::FiberAcceptHandler, this->SelfFromThis())); @@ -72,7 +73,7 @@ void FibersToSockets::StartAcceptFibers() { template void FibersToSockets::FiberAcceptHandler( const boost::system::error_code& ec) { - SSF_LOG(kLogTrace) << "service[fibers to sockets]: accept handler"; + SSF_LOG(kLogTrace) << "microservice[fibers to sockets]: accept handler"; if (!fiber_acceptor_.is_open()) { return; @@ -88,7 +89,7 @@ void FibersToSockets::FiberAcceptHandler( template void FibersToSockets::SocketConnectHandler( const boost::system::error_code& ec) { - SSF_LOG(kLogTrace) << "service[fibers to sockets]: connect handler"; + SSF_LOG(kLogTrace) << "microservice[fibers to sockets]: connect handler"; if (!ec) { auto session = SessionForwarder::create( diff --git a/src/services/process/posix/session.ipp b/src/services/process/posix/session.ipp index 82307a5b..8830aee9 100644 --- a/src/services/process/posix/session.ipp +++ b/src/services/process/posix/session.ipp @@ -42,14 +42,14 @@ Session::Session(SessionManager* p_session_manager, fiber client, template void Session::start(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "session[process]: start"; + SSF_LOG(kLogInfo) << "session[shell]: start"; int master_tty; int slave_tty; InitMasterSlaveTty(&master_tty, &slave_tty, ec); if (ec) { - SSF_LOG(kLogError) << "session[process]: init tty failed"; + SSF_LOG(kLogError) << "session[shell]: init tty failed"; stop(ec); return; } @@ -57,14 +57,14 @@ void Session::start(boost::system::error_code& ec) { signal_.add(SIGCHLD, ec); if (ec) { SSF_LOG(kLogError) - << "session[process]: init signal handler on SIGCHLD failed"; + << "session[shell]: init signal handler on SIGCHLD failed"; stop(ec); return; } child_pid_ = fork(); if (child_pid_ < 0) { - SSF_LOG(kLogError) << "session[process]: fork failed"; + SSF_LOG(kLogError) << "session[shell]: fork failed"; ec.assign(::error::process_not_created, ::error::get_ssf_category()); stop(ec); return; @@ -78,7 +78,7 @@ void Session::start(boost::system::error_code& ec) { tcgetattr(slave_tty, &new_term_settings); // IGNCR: ignore carriage return on input - new_term_settings.c_iflag |= ( IGNCR ); + new_term_settings.c_iflag |= (IGNCR); tcsetattr(slave_tty, TCSANOW, &new_term_settings); // new process as session leader @@ -138,11 +138,11 @@ void Session::start(boost::system::error_code& ec) { template void Session::stop(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "session[process]: stop"; + SSF_LOG(kLogInfo) << "session[shell]: stop"; client_.close(); if (ec) { - SSF_LOG(kLogError) << "session[process]: stop error " << ec.message(); + SSF_LOG(kLogError) << "session[shell]: stop error " << ec.message(); } if (child_pid_ > 0) { @@ -253,7 +253,7 @@ void Session::InitMasterSlaveTty(int* p_master_tty, int* p_slave_tty, // open an available pseudo terminal device (master/slave pair) *p_master_tty = posix_openpt(O_RDWR | O_NOCTTY); if (*p_master_tty < 0) { - SSF_LOG(kLogError) << "session[process]: could not open master tty"; + SSF_LOG(kLogError) << "session[shell]: could not open master tty"; ec.assign(::error::broken_pipe, ::error::get_ssf_category()); return; } @@ -273,7 +273,7 @@ void Session::InitMasterSlaveTty(int* p_master_tty, int* p_slave_tty, // open slave side *p_slave_tty = open(ptsname(*p_master_tty), O_RDWR | O_NOCTTY); if (*p_slave_tty < 0) { - SSF_LOG(kLogError) << "session[process]: could not open slave tty"; + SSF_LOG(kLogError) << "session[shell]: could not open slave tty"; ec.assign(::error::broken_pipe, ::error::get_ssf_category()); return; } @@ -283,8 +283,7 @@ template void Session::StartForwarding(boost::system::error_code& ec) { sd_.assign(master_tty_, ec); if (ec) { - SSF_LOG(kLogError) - << "session[process]: could not initialize stream handle"; + SSF_LOG(kLogError) << "session[shell]: could not initialize stream handle"; return; } diff --git a/src/services/process/server.ipp b/src/services/process/server.ipp index 341393b2..dfac9ee1 100644 --- a/src/services/process/server.ipp +++ b/src/services/process/server.ipp @@ -34,24 +34,25 @@ void Server::start(boost::system::error_code& ec) { if (ec) { SSF_LOG(kLogError) - << "service[process]: fiber acceptor could not bind on port " + << "microservice[shell]: fiber acceptor could not bind on port " << local_port_; return; } fiber_acceptor_.listen(boost::asio::socket_base::max_connections, ec); if (ec) { - SSF_LOG(kLogError) << "service[process]: fiber acceptor could not listen"; + SSF_LOG(kLogError) + << "microservice[shell]: fiber acceptor could not listen"; return; } if (!CheckBinaryPath()) { - SSF_LOG(kLogError) << "service[process]: binary not found"; + SSF_LOG(kLogError) << "microservice[shell]: binary not found"; ec.assign(::error::file_not_found, ::error::get_ssf_category()); return; } - SSF_LOG(kLogInfo) << "service[process]: starting server on port " + SSF_LOG(kLogInfo) << "microservice[shell]: starting server on port " << local_port_; this->StartAccept(); @@ -61,7 +62,7 @@ template void Server::stop(boost::system::error_code& ec) { ec.assign(boost::system::errc::success, boost::system::system_category()); - SSF_LOG(kLogInfo) << "service[process]: stopping server"; + SSF_LOG(kLogInfo) << "microservice[shell]: stopping server"; this->HandleStop(); } @@ -72,7 +73,7 @@ uint32_t Server::service_type_id() { template void Server::StartAccept() { - SSF_LOG(kLogTrace) << "service[process]: accept new session"; + SSF_LOG(kLogTrace) << "microservice[shell]: accepting new session"; fiber_acceptor_.async_accept( new_connection_, boost::bind(&Server::HandleAccept, this->SelfFromThis(), _1)); @@ -80,19 +81,20 @@ void Server::StartAccept() { template void Server::HandleAccept(const boost::system::error_code& ec) { - SSF_LOG(kLogTrace) << "service[process]: HandleAccept"; + SSF_LOG(kLogTrace) << "microservice[shell]: HandleAccept"; if (!fiber_acceptor_.is_open()) { return; } if (ec) { - SSF_LOG(kLogError) << "service[process]: error accepting new connection: " - << ec.message() << " " << ec.value(); + SSF_LOG(kLogError) + << "microservice[shell]: error accepting new connections: " + << ec.message() << " " << ec.value(); this->StartAccept(); } - SSF_LOG(kLogInfo) << "service[process]: start session"; + SSF_LOG(kLogInfo) << "microservice[shell]: start session"; ssf::BaseSessionPtr new_process_session = std::make_shared( &(this->session_manager_), std::move(this->new_connection_), binary_path_, binary_args_); diff --git a/src/services/process/windows/session.ipp b/src/services/process/windows/session.ipp index b9d50bc4..d3a9eb92 100644 --- a/src/services/process/windows/session.ipp +++ b/src/services/process/windows/session.ipp @@ -45,18 +45,18 @@ Session::Session(SessionManager* p_session_manager, fiber client, template void Session::start(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "session[process]: start"; + SSF_LOG(kLogInfo) << "session[shell]: start"; InitPipes(ec); if (ec) { - SSF_LOG(kLogError) << "session[process]: pipes initialization failed"; + SSF_LOG(kLogError) << "session[shell]: pipes initialization failed"; stop(ec); return; } StartProcess(ec); if (ec) { - SSF_LOG(kLogError) << "session[process]: start process failed"; + SSF_LOG(kLogError) << "session[shell]: start process failed"; stop(ec); return; } @@ -64,7 +64,7 @@ void Session::start(boost::system::error_code& ec) { StartForwarding(ec); if (ec) { SSF_LOG(kLogError) - << "session[process]: forwarding data from process to client failed"; + << "session[shell]: forwarding data from process to client failed"; stop(ec); return; } @@ -72,7 +72,7 @@ void Session::start(boost::system::error_code& ec) { template void Session::stop(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "session[process]: stop"; + SSF_LOG(kLogInfo) << "session[shell]: stop"; if (process_info_.hProcess != INVALID_HANDLE_VALUE) { ::TerminateProcess(process_info_.hProcess, 0); @@ -111,7 +111,7 @@ void Session::stop(boost::system::error_code& ec) { client_.close(); if (ec) { - SSF_LOG(kLogError) << "session[process]: stop error " << ec.message(); + SSF_LOG(kLogError) << "session[shell]: stop error " << ec.message(); } } @@ -131,21 +131,21 @@ void Session::StartForwarding(boost::system::error_code& ec) { h_out_.assign(data_out_, ec); if (ec) { SSF_LOG(kLogError) - << "session[process]: could not initialize out stream handle"; + << "session[shell]: could not initialize out stream handle"; return; } data_out_ = INVALID_HANDLE_VALUE; h_err_.assign(data_err_, ec); if (ec) { SSF_LOG(kLogError) - << "session[process]: could not initialize err stream handle"; + << "session[shell]: could not initialize err stream handle"; return; } data_err_ = INVALID_HANDLE_VALUE; h_in_.assign(data_in_, ec); if (ec) { SSF_LOG(kLogError) - << "session[process]: could not initialize in stream handle"; + << "session[shell]: could not initialize in stream handle"; return; } data_in_ = INVALID_HANDLE_VALUE; @@ -188,7 +188,7 @@ void Session::StartProcess(boost::system::error_code& ec) { NULL, TRUE, CREATE_NEW_CONSOLE, NULL, (home_dir_set ? home_dir : NULL), &startup_info, &process_info_)) { - SSF_LOG(kLogError) << "session[process]: create process <" << command_line + SSF_LOG(kLogError) << "session[shell]: create process <" << command_line << "> failed"; ec.assign(::error::process_not_created, ::error::get_ssf_category()); } @@ -206,8 +206,7 @@ template void Session::InitPipes(boost::system::error_code& ec) { auto local_fib_ep = client_.remote_endpoint(ec); if (ec) { - SSF_LOG(kLogError) - << "session[process]: could not get fiber local endpoint"; + SSF_LOG(kLogError) << "session[shell]: could not get fiber local endpoint"; return; } @@ -225,21 +224,21 @@ void Session::InitPipes(boost::system::error_code& ec) { InitOutNamedPipe(out_pipe_name_, &data_out_, &proc_out_, &sec_attr, pipe_size, ec); if (ec) { - SSF_LOG(kLogError) << "session[process]: init out pipe failed"; + SSF_LOG(kLogError) << "session[shell]: init out pipe failed"; return; } InitOutNamedPipe(err_pipe_name_, &data_err_, &proc_err_, &sec_attr, pipe_size, ec); if (ec) { - SSF_LOG(kLogError) << "session[process]: init err pipe failed"; + SSF_LOG(kLogError) << "session[shell]: init err pipe failed"; return; } InitInNamedPipe(in_pipe_name_, &proc_in_, &data_in_, &sec_attr, pipe_size, ec); if (ec) { - SSF_LOG(kLogError) << "session[process]: init in pipe failed"; + SSF_LOG(kLogError) << "session[shell]: init in pipe failed"; return; } } @@ -256,7 +255,7 @@ void Session::InitOutNamedPipe(const std::string& pipe_name, 0, p_pipe_attributes); if (read_pipe_tmp == INVALID_HANDLE_VALUE) { - SSF_LOG(kLogError) << "session[process]: create read side of named pipe <" + SSF_LOG(kLogError) << "session[shell]: create read side of named pipe <" << pipe_name << "> failed"; ec.assign(::error::broken_pipe, ::error::get_ssf_category()); goto cleanup; @@ -268,7 +267,7 @@ void Session::InitOutNamedPipe(const std::string& pipe_name, if (*p_write_pipe == INVALID_HANDLE_VALUE) { ec.assign(::error::broken_pipe, ::error::get_ssf_category()); - SSF_LOG(kLogError) << "session[process]: create write side of named pipe <" + SSF_LOG(kLogError) << "session[shell]: create write side of named pipe <" << pipe_name << "> failed"; goto cleanup; } @@ -276,9 +275,8 @@ void Session::InitOutNamedPipe(const std::string& pipe_name, if (!::DuplicateHandle(GetCurrentProcess(), read_pipe_tmp, GetCurrentProcess(), p_read_pipe, 0, FALSE, DUPLICATE_SAME_ACCESS)) { - SSF_LOG(kLogError) - << "session[process]: duplicate read side of named pipe <" << pipe_name - << "> failed"; + SSF_LOG(kLogError) << "session[shell]: duplicate read side of named pipe <" + << pipe_name << "> failed"; ec.assign(::error::broken_pipe, ::error::get_ssf_category()); goto cleanup; } @@ -301,7 +299,7 @@ void Session::InitInNamedPipe(const std::string& pipe_name, 0, p_pipe_attributes); if (write_pipe_tmp == INVALID_HANDLE_VALUE) { - SSF_LOG(kLogError) << "session[process]: create write side of named pipe <" + SSF_LOG(kLogError) << "session[shell]: create write side of named pipe <" << pipe_name << "> failed"; ec.assign(::error::broken_pipe, ::error::get_ssf_category()); goto cleanup; @@ -312,7 +310,7 @@ void Session::InitInNamedPipe(const std::string& pipe_name, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, 0); if (*p_read_pipe == INVALID_HANDLE_VALUE) { - SSF_LOG(kLogError) << "session[process]: create read side of named pipe <" + SSF_LOG(kLogError) << "session[shell]: create read side of named pipe <" << pipe_name << "> failed"; ec.assign(::error::broken_pipe, ::error::get_ssf_category()); goto cleanup; @@ -321,9 +319,8 @@ void Session::InitInNamedPipe(const std::string& pipe_name, if (!::DuplicateHandle(::GetCurrentProcess(), write_pipe_tmp, ::GetCurrentProcess(), p_write_pipe, 0, FALSE, DUPLICATE_SAME_ACCESS)) { - SSF_LOG(kLogError) - << "session[process]: duplicate write side of named pipe <" << pipe_name - << "> failed"; + SSF_LOG(kLogError) << "session[shell]: duplicate write side of named pipe <" + << pipe_name << "> failed"; ec.assign(::error::broken_pipe, ::error::get_ssf_category()); goto cleanup; } diff --git a/src/services/sockets_to_fibers/sockets_to_fibers.ipp b/src/services/sockets_to_fibers/sockets_to_fibers.ipp index a2b9f375..de76a01a 100644 --- a/src/services/sockets_to_fibers/sockets_to_fibers.ipp +++ b/src/services/sockets_to_fibers/sockets_to_fibers.ipp @@ -22,7 +22,7 @@ SocketsToFibers::SocketsToFibers(boost::asio::io_service& io_service, template void SocketsToFibers::start(boost::system::error_code& ec) { SSF_LOG(kLogInfo) - << "service[sockets to fibers]: starting relay on local port tcp " + << "microservice[sockets to fibers]: start forwarding local TCP port " << local_port_; boost::asio::ip::tcp::resolver resolver(socket_.get_io_service()); @@ -31,9 +31,8 @@ void SocketsToFibers::start(boost::system::error_code& ec) { auto ep_it = resolver.resolve(query, ec); if (ec) { - SSF_LOG(kLogError) - << "service[sockets to fibers]: could not resolve query "; + SSF_LOG(kLogError) << "microservice[sockets to fibers]: could not resolve " + "query "; return; } @@ -49,22 +48,24 @@ void SocketsToFibers::start(boost::system::error_code& ec) { boost::asio::socket_base::reuse_address option(true); socket_acceptor_.set_option(option, ec); if (ec) { - SSF_LOG(kLogError) - << "service[sockets to fibers]: could not set reuse address option"; + SSF_LOG(kLogError) << "microservice[sockets to fibers]: could not set " + "reuse address option"; socket_acceptor_.close(close_ec); return; } socket_acceptor_.bind(endpoint, ec); if (ec) { - SSF_LOG(kLogError) << "service[sockets to fibers]: could not bind acceptor"; + SSF_LOG(kLogError) + << "microservice[sockets to fibers]: could not bind acceptor"; socket_acceptor_.close(close_ec); return; } socket_acceptor_.listen(boost::asio::socket_base::max_connections, ec); if (ec) { - SSF_LOG(kLogError) << "service[sockets to fibers]: could not listen"; + SSF_LOG(kLogError) + << "microservice[sockets to fibers]: could not listen new connections"; socket_acceptor_.close(close_ec); return; } @@ -74,10 +75,10 @@ void SocketsToFibers::start(boost::system::error_code& ec) { template void SocketsToFibers::stop(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "service[sockets to fibers]: stopping"; + SSF_LOG(kLogInfo) << "microservice[sockets to fibers]: stopping"; socket_acceptor_.close(ec); if (ec) { - SSF_LOG(kLogDebug) << "service[sockets to fibers]: " << ec.message(); + SSF_LOG(kLogDebug) << "microservice[sockets to fibers]: " << ec.message(); } manager_.stop_all(); } @@ -89,7 +90,8 @@ uint32_t SocketsToFibers::service_type_id() { template void SocketsToFibers::StartAcceptSockets() { - SSF_LOG(kLogTrace) << "service[sockets to fibers]: accepting new clients"; + SSF_LOG(kLogTrace) + << "microservice[sockets to fibers]: accepting new clients"; if (!socket_acceptor_.is_open()) { return; @@ -103,7 +105,7 @@ void SocketsToFibers::StartAcceptSockets() { template void SocketsToFibers::SocketAcceptHandler( const boost::system::error_code& ec) { - SSF_LOG(kLogTrace) << "service[sockets to fibers]: accept handler"; + SSF_LOG(kLogTrace) << "microservice[sockets to fibers]: accept handler"; if (!socket_acceptor_.is_open()) { return; @@ -119,7 +121,7 @@ void SocketsToFibers::SocketAcceptHandler( template void SocketsToFibers::FiberConnectHandler( const boost::system::error_code& ec) { - SSF_LOG(kLogTrace) << "service[sockets to fibers]: connect handler"; + SSF_LOG(kLogTrace) << "microservice[sockets to fibers]: connect handler"; if (!ec) { auto session = SessionForwarder::create( diff --git a/src/services/socks/socks_server.ipp b/src/services/socks/socks_server.ipp index 1ad2588d..c00ca18f 100644 --- a/src/services/socks/socks_server.ipp +++ b/src/services/socks/socks_server.ipp @@ -34,7 +34,7 @@ SocksServer::SocksServer(boost::asio::io_service& io_service, template void SocksServer::start(boost::system::error_code& ec) { - SSF_LOG(kLogInfo) << "service[socks]: starting server on port " + SSF_LOG(kLogInfo) << "microservice[socks]: start server on fiber port " << local_port_; ec = init_ec_; @@ -47,7 +47,7 @@ template void SocksServer::stop(boost::system::error_code& ec) { ec.assign(boost::system::errc::success, boost::system::system_category()); - SSF_LOG(kLogInfo) << "service[socks]: stopping server"; + SSF_LOG(kLogInfo) << "microservice[socks]: stopping server"; this->HandleStop(); } @@ -64,52 +64,55 @@ void SocksServer::StartAccept() { template void SocksServer::HandleAccept(const boost::system::error_code& ec) { - SSF_LOG(kLogTrace) << "service[socks]: HandleAccept"; + SSF_LOG(kLogTrace) << "microservice[socks]: HandleAccept"; if (!fiber_acceptor_.is_open()) { return; } if (ec) { - SSF_LOG(kLogError) << "service[socks]: error accepting new connection: " - << ec.message() << " " << ec.value(); + SSF_LOG(kLogError) + << "microservice[socks]: error accepting new connection: " + << ec.message() << " " << ec.value(); this->StartAccept(); } std::shared_ptr p_version(new Version()); auto self = this->SelfFromThis(); - auto start_handler = [this, self, p_version](boost::system::error_code ec, - std::size_t) { - if (ec) { - SSF_LOG(kLogError) << "service[socks]: error reading protocol version: " - << ec.message() << " " << ec.value(); - fiber fib = std::move(this->new_connection_); - this->StartAccept(); - } else if (p_version->Number() == 4) { - SSF_LOG(kLogTrace) << "service[socks]: version accepted: v4"; - ssf::BaseSessionPtr new_socks_session = - std::make_shared >( - &(this->session_manager_), std::move(this->new_connection_)); - boost::system::error_code e; - this->session_manager_.start(new_socks_session, e); - this->StartAccept(); - } else if (p_version->Number() == 5) { - SSF_LOG(kLogTrace) << "service[socks]: version accepted: v5"; - ssf::BaseSessionPtr new_socks_session = - std::make_shared >( - &(this->session_manager_), std::move(this->new_connection_)); - boost::system::error_code e; - this->session_manager_.start(new_socks_session, e); - this->StartAccept(); - } else { - SSF_LOG(kLogError) << "service[socks]: protocol not supported yet: " - << p_version->Number(); - this->new_connection_.close(); - fiber fib = std::move(this->new_connection_); - this->StartAccept(); - } - }; + auto start_handler = + [this, self, p_version](boost::system::error_code ec, std::size_t) { + if (ec) { + SSF_LOG(kLogError) + << "microservice[socks]: error reading protocol version: " + << ec.message() << " " << ec.value(); + fiber fib = std::move(this->new_connection_); + this->StartAccept(); + } else if (p_version->Number() == 4) { + SSF_LOG(kLogTrace) << "microservice[socks]: version accepted: v4"; + ssf::BaseSessionPtr new_socks_session = + std::make_shared >( + &(this->session_manager_), std::move(this->new_connection_)); + boost::system::error_code e; + this->session_manager_.start(new_socks_session, e); + this->StartAccept(); + } else if (p_version->Number() == 5) { + SSF_LOG(kLogTrace) << "microservice[socks]: version accepted: v5"; + ssf::BaseSessionPtr new_socks_session = + std::make_shared >( + &(this->session_manager_), std::move(this->new_connection_)); + boost::system::error_code e; + this->session_manager_.start(new_socks_session, e); + this->StartAccept(); + } else { + SSF_LOG(kLogError) + << "microservice[socks]: protocol not supported yet: " + << p_version->Number(); + this->new_connection_.close(); + fiber fib = std::move(this->new_connection_); + this->StartAccept(); + } + }; // Read the version field of the SOCKS header boost::asio::async_read(new_connection_, p_version->Buffer(), start_handler); diff --git a/src/services/user_services/port_forwarding.h b/src/services/user_services/port_forwarding.h index 1f438791..2913c5ad 100644 --- a/src/services/user_services/port_forwarding.h +++ b/src/services/user_services/port_forwarding.h @@ -57,7 +57,7 @@ class PortForwarding : public BaseUserService { static std::string GetValueName() { return "loc_port:dest_ip:dest_port"; } static std::string GetParseDesc() { - return "Forward local port on given target from server"; + return "Forward TCP client port on given target from server"; } public: diff --git a/src/services/user_services/process.h b/src/services/user_services/process.h index d3ec07f7..04d3263e 100644 --- a/src/services/user_services/process.h +++ b/src/services/user_services/process.h @@ -25,15 +25,15 @@ class Process : public BaseUserService { : local_port_(local_port), remoteServiceId_(0), localServiceId_(0) {} public: - static std::string GetFullParseName() { return "process,X"; } + static std::string GetFullParseName() { return "shell,X"; } - static std::string GetParseName() { return "process"; } + static std::string GetParseName() { return "shell"; } static std::string GetValueName() { return "local_port"; } static std::string GetParseDesc() { return "Open a port on the client side, each connection to that port " - "creates a process with I/O forwarded to/from the server side"; + "creates a shell with I/O forwarded to/from the server side"; } static std::shared_ptr CreateServiceOptions( @@ -93,7 +93,7 @@ class Process : public BaseUserService { GetRemoteServiceId(demux)); }; - std::string GetName() { return "process"; }; + std::string GetName() { return "shell"; }; bool StartLocalServices(Demux& demux) { services::admin::CreateServiceRequest l_forward( @@ -106,7 +106,7 @@ class Process : public BaseUserService { localServiceId_ = p_service_factory->CreateRunNewService( l_forward.service_id(), l_forward.parameters(), ec); if (ec) { - SSF_LOG(kLogError) << "user_service[process]: " + SSF_LOG(kLogError) << "user_service[shell]: " << "local_service[sockets to fibers]: start failed: " << ec.message(); } diff --git a/src/services/user_services/remote_port_forwarding.h b/src/services/user_services/remote_port_forwarding.h index 2149e046..61b53f74 100644 --- a/src/services/user_services/remote_port_forwarding.h +++ b/src/services/user_services/remote_port_forwarding.h @@ -57,7 +57,7 @@ class RemotePortForwarding : public BaseUserService { static std::string GetValueName() { return "rem_port:dest_ip:dest_port"; } static std::string GetParseDesc() { - return "Forward remote port on given target from client"; + return "Forward TCP server port on given target from client"; } public: diff --git a/src/services/user_services/remote_process.h b/src/services/user_services/remote_process.h index 77c00bd9..89e8d405 100644 --- a/src/services/user_services/remote_process.h +++ b/src/services/user_services/remote_process.h @@ -25,15 +25,15 @@ class RemoteProcess : public BaseUserService { : remote_port_(remote_port), remoteServiceId_(0), localServiceId_(0) {} public: - static std::string GetFullParseName() { return "remote_process,Y"; } + static std::string GetFullParseName() { return "remote_shell,Y"; } - static std::string GetParseName() { return "remote_process"; } + static std::string GetParseName() { return "remote_shell"; } static std::string GetValueName() { return "remote_port"; } static std::string GetParseDesc() { return "Open a port on the server side, each connection to that port " - "creates a process with I/O forwarded to/from the client side"; + "creates a shell with I/O forwarded to/from the client side"; } static std::shared_ptr CreateServiceOptions( @@ -95,7 +95,7 @@ class RemoteProcess : public BaseUserService { GetRemoteServiceId(demux)); }; - std::string GetName() { return "remote_process"; }; + std::string GetName() { return "remote_shell"; }; bool StartLocalServices(Demux& demux) { services::admin::CreateServiceRequest l_process_server( @@ -107,7 +107,7 @@ class RemoteProcess : public BaseUserService { localServiceId_ = p_service_factory->CreateRunNewService( l_process_server.service_id(), l_process_server.parameters(), ec); if (ec) { - SSF_LOG(kLogError) << "user_service[remote process]: " + SSF_LOG(kLogError) << "user_service[remote_shell]: " << "local_service[process]: start failed: " << ec.message(); } diff --git a/src/services/user_services/udp_port_forwarding.h b/src/services/user_services/udp_port_forwarding.h index 51a6daa1..f98506db 100644 --- a/src/services/user_services/udp_port_forwarding.h +++ b/src/services/user_services/udp_port_forwarding.h @@ -57,7 +57,7 @@ class UdpPortForwarding : public BaseUserService { static std::string GetValueName() { return "local_port:dest_ip:dest_port"; } static std::string GetParseDesc() { - return "Forward UDP local port on given target from server"; + return "Forward UDP client port on given target from server"; } public: diff --git a/src/services/user_services/udp_remote_port_forwarding.h b/src/services/user_services/udp_remote_port_forwarding.h index 4a4bf747..0b020c39 100644 --- a/src/services/user_services/udp_remote_port_forwarding.h +++ b/src/services/user_services/udp_remote_port_forwarding.h @@ -57,7 +57,7 @@ class UdpRemotePortForwarding : public BaseUserService { static std::string GetValueName() { return "rem_port:dest_ip:dest_port"; } static std::string GetParseDesc() { - return "Forward remote udp port on given target from client"; + return "Forward UDP server port on given target from client"; } public: