X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fprotocol_key.c;h=25dbc55e5c04b7533e9eb0f6c5eeb62214cc648e;hb=325d837df2ec867c668b6a911b97e719f196ba0e;hp=6a2946eb8d6ca22be39d3cbcea42fcb0a9c181d3;hpb=42c2dd52c43dceb72127e3a02103ea8338c8dae2;p=meshlink diff --git a/src/protocol_key.c b/src/protocol_key.c index 6a2946eb..25dbc55e 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -275,16 +275,15 @@ static bool req_key_ext_h(meshlink_handle_t *mesh, connection_t *c, const char * return true; } - strncat(host, " ", MAX_STRING_SIZE - 1); - strncat(host, port, MAX_STRING_SIZE - 1); + char *canonical_address; + xasprintf(&canonical_address, "%s %s", host, port); - if(from->canonical_address && !strcmp(from->canonical_address, host)) { - return true; + if(mesh->log_level <= MESHLINK_DEBUG && (!from->canonical_address || strcmp(from->canonical_address, canonical_address))) { + logger(mesh, MESHLINK_DEBUG, "Updating canonical address of %s to %s", from->name, canonical_address); } - logger(mesh, MESHLINK_DEBUG, "Updating canonical address of %s to %s", from->name, host); free(from->canonical_address); - from->canonical_address = xstrdup(host); + from->canonical_address = canonical_address; return true; }