summaryrefslogtreecommitdiff
path: root/louloulibs/network
diff options
context:
space:
mode:
Diffstat (limited to 'louloulibs/network')
-rw-r--r--louloulibs/network/credentials_manager.cpp6
-rw-r--r--louloulibs/network/poller.cpp14
-rw-r--r--louloulibs/network/tcp_socket_handler.cpp40
3 files changed, 30 insertions, 30 deletions
diff --git a/louloulibs/network/credentials_manager.cpp b/louloulibs/network/credentials_manager.cpp
index c5b8493..ee83c3b 100644
--- a/louloulibs/network/credentials_manager.cpp
+++ b/louloulibs/network/credentials_manager.cpp
@@ -41,7 +41,7 @@ void BasicCredentialsManager::verify_certificate_chain(const std::string& type,
const std::string& purported_hostname,
const std::vector<Botan::X509_Certificate>& certs)
{
- log_debug("Checking remote certificate (" << type << ") for hostname " << purported_hostname);
+ log_debug("Checking remote certificate (", type, ") for hostname ", purported_hostname);
try
{
Botan::Credentials_Manager::verify_certificate_chain(type, purported_hostname, certs);
@@ -49,7 +49,7 @@ void BasicCredentialsManager::verify_certificate_chain(const std::string& type,
}
catch (const std::exception& tls_exception)
{
- log_warning("TLS certificate check failed: " << tls_exception.what());
+ log_warning("TLS certificate check failed: ", tls_exception.what());
if (!this->trusted_fingerprint.empty() && !certs.empty() &&
this->trusted_fingerprint == certs[0].fingerprint() &&
certs[0].matches_dns_name(purported_hostname))
@@ -78,7 +78,7 @@ void BasicCredentialsManager::load_certs()
try
{
Botan::DataSource_Stream bundle(path);
- log_debug("Using ca bundle: " << path);
+ log_debug("Using ca bundle: ", path);
while (!bundle.end_of_data() && bundle.check_available(27))
{
// TODO: remove this work-around for Botan 1.11.29
diff --git a/louloulibs/network/poller.cpp b/louloulibs/network/poller.cpp
index 959567e..8a6fd97 100644
--- a/louloulibs/network/poller.cpp
+++ b/louloulibs/network/poller.cpp
@@ -20,7 +20,7 @@ Poller::Poller()
this->epfd = ::epoll_create1(0);
if (this->epfd == -1)
{
- log_error("epoll failed: " << strerror(errno));
+ log_error("epoll failed: ", strerror(errno));
throw std::runtime_error("Could not create epoll instance");
}
#endif
@@ -54,7 +54,7 @@ void Poller::add_socket_handler(SocketHandler* socket_handler)
const int res = ::epoll_ctl(this->epfd, EPOLL_CTL_ADD, socket_handler->get_socket(), &event);
if (res == -1)
{
- log_error("epoll_ctl failed: " << strerror(errno));
+ log_error("epoll_ctl failed: ", strerror(errno));
throw std::runtime_error("Could not add socket to epoll");
}
#endif
@@ -86,7 +86,7 @@ void Poller::remove_socket_handler(const socket_t socket)
const int res = ::epoll_ctl(this->epfd, EPOLL_CTL_DEL, socket, nullptr);
if (res == -1)
{
- log_error("epoll_ctl failed: " << strerror(errno));
+ log_error("epoll_ctl failed: ", strerror(errno));
throw std::runtime_error("Could not remove socket from epoll");
}
#endif
@@ -109,7 +109,7 @@ void Poller::watch_send_events(SocketHandler* socket_handler)
const int res = ::epoll_ctl(this->epfd, EPOLL_CTL_MOD, socket_handler->get_socket(), &event);
if (res == -1)
{
- log_error("epoll_ctl failed: " << strerror(errno));
+ log_error("epoll_ctl failed: ", strerror(errno));
throw std::runtime_error("Could not modify socket flags in epoll");
}
#endif
@@ -132,7 +132,7 @@ void Poller::stop_watching_send_events(SocketHandler* socket_handler)
const int res = ::epoll_ctl(this->epfd, EPOLL_CTL_MOD, socket_handler->get_socket(), &event);
if (res == -1)
{
- log_error("epoll_ctl failed: " << strerror(errno));
+ log_error("epoll_ctl failed: ", strerror(errno));
throw std::runtime_error("Could not modify socket flags in epoll");
}
#endif
@@ -165,7 +165,7 @@ int Poller::poll(const std::chrono::milliseconds& timeout)
{
if (errno == EINTR)
return true;
- log_error("poll failed: " << strerror(errno));
+ log_error("poll failed: ", strerror(errno));
throw std::runtime_error("Poll failed");
}
// We cannot possibly have more ready events than the number of fds we are
@@ -205,7 +205,7 @@ int Poller::poll(const std::chrono::milliseconds& timeout)
{
if (errno == EINTR)
return 0;
- log_error("epoll wait: " << strerror(errno));
+ log_error("epoll wait: ", strerror(errno));
throw std::runtime_error("Epoll_wait failed");
}
for (int i = 0; i < nb_events; ++i)
diff --git a/louloulibs/network/tcp_socket_handler.cpp b/louloulibs/network/tcp_socket_handler.cpp
index 81369dd..5420b1c 100644
--- a/louloulibs/network/tcp_socket_handler.cpp
+++ b/louloulibs/network/tcp_socket_handler.cpp
@@ -64,8 +64,8 @@ void TCPSocketHandler::init_socket(const struct addrinfo* rp)
struct addrinfo* result;
int err = ::getaddrinfo(this->bind_addr.data(), nullptr, nullptr, &result);
if (err != 0 || !result)
- log_error("Failed to bind socket to " << this->bind_addr << ": "
- << gai_strerror(err));
+ log_error("Failed to bind socket to ", this->bind_addr, ": ",
+ gai_strerror(err));
else
{
utils::ScopeGuard sg([result](){ freeaddrinfo(result); });
@@ -79,15 +79,15 @@ void TCPSocketHandler::init_socket(const struct addrinfo* rp)
break;
}
if (!rp)
- log_error("Failed to bind socket to " << this->bind_addr << ": "
- << strerror(bind_error));
+ log_error("Failed to bind socket to ", this->bind_addr, ": ",
+ strerror(bind_error));
else
- log_info("Socket successfully bound to " << this->bind_addr);
+ log_info("Socket successfully bound to ", this->bind_addr);
}
}
int optval = 1;
if (::setsockopt(this->socket, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) == -1)
- log_warning("Failed to enable TCP keepalive on socket: " << strerror(errno));
+ log_warning("Failed to enable TCP keepalive on socket: ", strerror(errno));
// Set the socket on non-blocking mode. This is useful to receive a EAGAIN
// error when connect() would block, to not block the whole process if a
// remote is not responsive.
@@ -113,7 +113,7 @@ void TCPSocketHandler::connect(const std::string& address, const std::string& po
// this is the first call of this function.
if (!this->resolver.is_resolved())
{
- log_info("Trying to connect to " << address << ":" << port);
+ log_info("Trying to connect to ", address, ":", port);
// Start the asynchronous process of resolving the hostname. Once
// the addresses have been found and `resolved` has been set to true
// (but connecting will still be false), TCPSocketHandler::connect()
@@ -161,7 +161,7 @@ void TCPSocketHandler::connect(const std::string& address, const std::string& po
this->init_socket(rp);
}
catch (const std::runtime_error& error) {
- log_error("Failed to init socket: " << error.what());
+ log_error("Failed to init socket: ", error.what());
break;
}
}
@@ -204,7 +204,7 @@ void TCPSocketHandler::connect(const std::string& address, const std::string& po
"connection_timeout"s + std::to_string(this->socket)));
return ;
}
- log_info("Connection failed:" << strerror(errno));
+ log_info("Connection failed:", strerror(errno));
}
log_error("All connection attempts failed.");
this->close();
@@ -268,9 +268,9 @@ ssize_t TCPSocketHandler::do_recv(void* recv_buf, const size_t buf_size)
else if (-1 == size)
{
if (this->connecting)
- log_warning("Error connecting: " << strerror(errno));
+ log_warning("Error connecting: ", strerror(errno));
else
- log_warning("Error while reading from socket: " << strerror(errno));
+ log_warning("Error while reading from socket: ", strerror(errno));
// Remember if we were connecting, or already connected when this
// happened, because close() sets this->connecting to false
const auto were_connecting = this->connecting;
@@ -300,7 +300,7 @@ void TCPSocketHandler::on_send()
ssize_t res = ::sendmsg(this->socket, &msg, MSG_NOSIGNAL);
if (res < 0)
{
- log_error("sendmsg failed: " << strerror(errno));
+ log_error("sendmsg failed: ", strerror(errno));
this->on_connection_close(strerror(errno));
this->close();
}
@@ -351,9 +351,9 @@ void TCPSocketHandler::close()
void TCPSocketHandler::display_resolved_ip(struct addrinfo* rp) const
{
if (rp->ai_family == AF_INET)
- log_debug("Trying IPv4 address " << addr_to_string(rp));
+ log_debug("Trying IPv4 address ", addr_to_string(rp));
else if (rp->ai_family == AF_INET6)
- log_debug("Trying IPv6 address " << addr_to_string(rp));
+ log_debug("Trying IPv6 address ", addr_to_string(rp));
}
void TCPSocketHandler::send_data(std::string&& data)
@@ -478,18 +478,18 @@ void TCPSocketHandler::tls_output_fn(const Botan::byte* data, size_t size)
void TCPSocketHandler::tls_alert_cb(Botan::TLS::Alert alert, const Botan::byte*, size_t)
{
- log_debug("tls_alert: " << alert.type_string());
+ log_debug("tls_alert: ", alert.type_string());
}
bool TCPSocketHandler::tls_handshake_cb(const Botan::TLS::Session& session)
{
- log_debug("Handshake with " << session.server_info().hostname() << " complete."
- << " Version: " << session.version().to_string()
- << " using " << session.ciphersuite().to_string());
+ log_debug("Handshake with ", session.server_info().hostname(), " complete.",
+ " Version: ", session.version().to_string(),
+ " using ", session.ciphersuite().to_string());
if (!session.session_id().empty())
- log_debug("Session ID " << Botan::hex_encode(session.session_id()));
+ log_debug("Session ID ", Botan::hex_encode(session.session_id()));
if (!session.session_ticket().empty())
- log_debug("Session ticket " << Botan::hex_encode(session.session_ticket()));
+ log_debug("Session ticket ", Botan::hex_encode(session.session_ticket()));
return true;
}