bool send_meta(connection_t *c, const char *buffer, int length) {
cp();
- ifdebug(META) logger(LOG_DEBUG, _("Sending %d bytes of metadata to %s (%s)"), length, c->name, c->hostname);
+ ifdebug(META) logger(LOG_DEBUG, _("Sending %d bytes of metadata to %s (%s)"), length,
+ c->name, c->hostname);
/* Add our data to buffer */
if(c->status.encryptout) {
size_t outlen = length;
if(!cipher_encrypt(&c->outcipher, buffer, length, outbuf, &outlen, false) || outlen != length) {
- logger(LOG_ERR, _("Error while encrypting metadata to %s (%s)"), c->name, c->hostname);
+ logger(LOG_ERR, _("Error while encrypting metadata to %s (%s)"),
+ c->name, c->hostname);
return false;
}
+ ifdebug(META) logger(LOG_DEBUG, _("Encrypted write %p %p %p %d"), c, c->buffer, outbuf, length);
bufferevent_write(c->buffer, (void *)outbuf, length);
+ ifdebug(META) logger(LOG_DEBUG, _("Done."));
} else {
+ ifdebug(META) logger(LOG_DEBUG, _("Unencrypted write %p %p %p %d"), c, c->buffer, buffer, length);
bufferevent_write(c->buffer, (void *)buffer, length);
+ ifdebug(META) logger(LOG_DEBUG, _("Done."));
}
return true;
bufp = endp;
} else {
size_t outlen = inlen;
+ ifdebug(META) logger(LOG_DEBUG, _("Received encrypted %d bytes"), inlen);
evbuffer_expand(c->buffer->input, c->buffer->input->off + inlen);
if(!cipher_decrypt(&c->incipher, bufp, inlen, c->buffer->input->buffer + c->buffer->input->off, &outlen, false) || inlen != outlen) {
- logger(LOG_ERR, _("Error while decrypting metadata from %s (%s)"), c->name, c->hostname);
+ logger(LOG_ERR, _("Error while decrypting metadata from %s (%s)"),
+ c->name, c->hostname);
return false;
}
-
c->buffer->input->off += inlen;
+
inlen = 0;
}