feat: enhance packet logging by including source address and port in received domain packet logs

This commit is contained in:
MayaTheShy
2025-11-09 23:04:54 -05:00
parent a727af0f8a
commit 391b760db5
2 changed files with 11 additions and 1 deletions

View File

@@ -363,7 +363,16 @@ void OverteClient::poll() {
sockaddr_storage from{}; socklen_t fromlen = sizeof(from);
ssize_t r = ::recvfrom(m_udpFd, buf, sizeof(buf), 0, reinterpret_cast<sockaddr*>(&from), &fromlen);
if (r > 0) {
std::cout << "[OverteClient] <<< Received domain packet (" << r << " bytes)" << std::endl;
// Log source address
char fromIP[INET_ADDRSTRLEN];
uint16_t fromPort = 0;
if (from.ss_family == AF_INET) {
sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(&from);
inet_ntop(AF_INET, &sin->sin_addr, fromIP, sizeof(fromIP));
fromPort = ntohs(sin->sin_port);
}
std::cout << "[OverteClient] <<< Received packet (" << r << " bytes) from " << fromIP << ":" << fromPort << std::endl;
// Hex dump first 32 bytes for debugging
std::cout << "[OverteClient] Hex: ";
for (int i = 0; i < std::min(32, (int)r); ++i) {