From 884d0f180a59349d5b8771ae6d8d669b4886a726 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 5 Sep 2021 20:20:28 +0200 Subject: [PATCH] TCP server: log IP addresses in more places --- src/p2p_server.cpp | 2 +- src/tcp_server.inl | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index 60be525..21f1dd9 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -1121,7 +1121,7 @@ bool P2PServer::P2PClient::on_handshake_challenge(const uint8_t* buf) memcpy(&peer_id, buf + CHALLENGE_SIZE, sizeof(uint64_t)); if (peer_id == server->get_peerId()) { - LOGWARN(5, "tried to connect to self"); + LOGWARN(5, "tried to connect to self at " << static_cast(m_addrString)); return false; } diff --git a/src/tcp_server.inl b/src/tcp_server.inl index 2e2022e..d9c6640 100644 --- a/src/tcp_server.inl +++ b/src/tcp_server.inl @@ -419,7 +419,7 @@ void TCPServer::shutdown_tcp() using namespace std::chrono; const system_clock::time_point start_time = system_clock::now(); - uint32_t counter = 0; + int64_t counter = 0; uv_async_t asy; constexpr uint32_t timeout_seconds = 30; @@ -524,7 +524,7 @@ bool TCPServer::send_internal(Client* client, Sen MutexLock lock(client->m_writeBuffersLock); client->m_writeBuffers.push_back(buf); } - LOGWARN(1, "failed to start writing data to client connection, error " << uv_err_name(err)); + LOGWARN(1, "failed to start writing data to client connection " << static_cast(client->m_addrString) << ", error " << uv_err_name(err)); return false; } @@ -800,14 +800,14 @@ void TCPServer::Client::on_alloc(uv_handle_t* han Client* pThis = static_cast(handle->data); if (pThis->m_readBufInUse) { - LOGWARN(4, "client: read buffer is already in use"); + LOGWARN(4, "client " << static_cast(pThis->m_addrString) << " read buffer is already in use"); buf->len = 0; buf->base = nullptr; return; } if (pThis->m_numRead >= sizeof(pThis->m_readBuf)) { - LOGWARN(4, "client: read buffer is full"); + LOGWARN(4, "client " << static_cast(pThis->m_addrString) << " read buffer is full"); buf->len = 0; buf->base = nullptr; return; @@ -833,7 +833,7 @@ void TCPServer::Client::on_read(uv_stream_t* stre } else if (nread < 0) { if (nread != UV_EOF) { - LOGWARN(5, "client: failed to read response, err = " << uv_err_name(static_cast(nread))); + LOGWARN(5, "client " << static_cast(pThis->m_addrString) << " failed to read response, err = " << uv_err_name(static_cast(nread))); } pThis->close(); } @@ -851,7 +851,7 @@ void TCPServer::Client::on_write(uv_write_t* req, } if (status != 0) { - LOGWARN(5, "client: failed to write data to client connection, error " << uv_err_name(status)); + LOGWARN(5, "client " << static_cast(client->m_addrString) << " failed to write data to client connection, error " << uv_err_name(status)); client->close(); } }