fix: update handleDomainListReply to correctly read node local ID in big-endian format and enhance debug output
Some checks failed
CI / build-and-test (push) Has been cancelled

This commit is contained in:
MayaTheShy
2025-11-10 00:52:08 -05:00
parent 8fe7925d68
commit b5e061a9bc

View File

@@ -967,23 +967,21 @@ void OverteClient::handleDomainListReply(const char* data, size_t len) {
std::cout << "[OverteClient] Node UUID (our session): " << nodeUUID << std::endl; std::cout << "[OverteClient] Node UUID (our session): " << nodeUUID << std::endl;
// Read domain local ID (16-bit) - this is in LITTLE-ENDIAN, not big-endian! // Read node local ID (16-bit, BIG-ENDIAN / network byte order)
// Do NOT use ntohs() - just read directly on x86
if (offset + 2 > len) return; if (offset + 2 > len) return;
// Debug: show the exact bytes at this position // Debug: show the exact bytes at this position
std::cout << "[OverteClient] LocalID bytes at offset " << offset << ": " std::cout << "[OverteClient] Node LocalID bytes at offset " << offset << ": "
<< std::hex << std::setfill('0') << std::setw(2) << (int)(unsigned char)data[offset] << " " << std::hex << std::setfill('0') << std::setw(2) << (int)(unsigned char)data[offset] << " "
<< std::setw(2) << (int)(unsigned char)data[offset+1] << std::dec << std::endl; << std::setw(2) << (int)(unsigned char)data[offset+1] << std::dec << std::endl;
uint16_t localID; uint16_t localID = ntohs(*reinterpret_cast<const uint16_t*>(data + offset)); // Big-endian!
std::memcpy(&localID, data + offset, sizeof(uint16_t)); // Direct read, little-endian
offset += 2; offset += 2;
// Store our local ID for use in sourced packets // Store our local ID for use in sourced packets
m_localID = localID; m_localID = localID;
std::cout << "[OverteClient] Local ID: " << localID << " (0x" << std::hex << localID << std::dec << ")" << std::endl; std::cout << "[OverteClient] Node Local ID (ours!): " << localID << " (0x" << std::hex << localID << std::dec << ")" << std::endl;
// Read permissions (32-bit) // Read permissions (32-bit)
if (offset + 4 > len) return; if (offset + 4 > len) return;