Skip to content

Commit

Permalink
Log the version of a node when it replies to a ping.
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb James DeLisle committed Feb 22, 2013
1 parent b41484a commit d27739e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dht/dhtcore/RouterModule.c
Expand Up @@ -737,10 +737,16 @@ static inline int handleReply(struct DHTMessage* message, struct RouterModule* m
if (nodes == NULL && tid && tid->len == 2 && tid->bytes[0] == 'p') {
uint8_t index = tid->bytes[1];
if (index < RouterModule_MAX_CONCURRENT_PINGS && module->pings[index] != NULL) {
String* versionBin = Dict_getString(message->asDict, CJDHTConstants_VERSION);
#ifdef Log_DEBUG
uint8_t printedAddr[60];
Address_print(printedAddr, message->address);
Log_debug(module->logger, "Got pong! %s\n", printedAddr);

uint8_t versionStr[41] = "old";
if (versionBin && versionBin->len == 20) {
Hex_encode(versionStr, 41, (uint8_t*) versionBin->bytes, 20);
}
Log_debug(module->logger, "Got pong! [%s] ver[%s]\n", printedAddr, versionStr);
#endif

Timeout_clearTimeout(module->pings[index]->timeout);
Expand All @@ -750,8 +756,7 @@ static inline int handleReply(struct DHTMessage* message, struct RouterModule* m
responseFromNode(node, lag, module);

if (module->pings[index]->isFromAdmin) {
String* version = Dict_getString(message->asDict, CJDHTConstants_VERSION);
pingResponse(module->pings[index], false, lag, version, module);
pingResponse(module->pings[index], false, lag, versionBin, module);
}

struct Allocator* pa = module->pings[index]->allocator;
Expand Down

0 comments on commit d27739e

Please sign in to comment.