mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 20:54:23 +01:00
common: add logging for peer packets, with status_io.
We log the plaintext, not the encrypted ones. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -15,9 +15,12 @@ bool sync_crypto_write(struct crypto_state *cs, int fd, const void *msg TAKES)
|
||||
bool post_sabotage = false;
|
||||
int type = fromwire_peektype(msg);
|
||||
#endif
|
||||
u8 *enc = cryptomsg_encrypt_msg(NULL, cs, msg);
|
||||
u8 *enc;
|
||||
bool ret;
|
||||
|
||||
status_io(LOG_IO_OUT, msg);
|
||||
enc = cryptomsg_encrypt_msg(NULL, cs, msg);
|
||||
|
||||
#if DEVELOPER
|
||||
switch (dev_disconnect(type)) {
|
||||
case DEV_DISCONNECT_BEFORE:
|
||||
@@ -71,6 +74,7 @@ u8 *sync_crypto_read(const tal_t *ctx, struct crypto_state *cs, int fd)
|
||||
if (!dec)
|
||||
status_trace("Failed body decrypt with rn=%"PRIu64, cs->rn-2);
|
||||
else
|
||||
status_trace("Read decrypt %s", tal_hex(trc, dec));
|
||||
status_io(LOG_IO_IN, dec);
|
||||
|
||||
return dec;
|
||||
}
|
||||
|
||||
@@ -138,6 +138,8 @@ static struct io_plan *peer_decrypt_body(struct io_conn *conn,
|
||||
if (!decrypted)
|
||||
return io_close(conn);
|
||||
|
||||
status_io(LOG_IO_IN, decrypted);
|
||||
|
||||
/* BOLT #1:
|
||||
*
|
||||
* A node MUST ignore a received message of unknown type, if that type
|
||||
@@ -349,6 +351,8 @@ struct io_plan *peer_write_message(struct io_conn *conn,
|
||||
|
||||
assert(!pcs->out);
|
||||
|
||||
/* Important: this doesn't take msg! */
|
||||
status_io(LOG_IO_OUT, msg);
|
||||
pcs->out = cryptomsg_encrypt_msg(conn, &pcs->cs, msg);
|
||||
pcs->next_out = next;
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@ void status_fmt(enum log_level level, const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void status_io(enum log_level dir, const u8 *msg)
|
||||
{
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
/* AUTOGENERATED MOCKS START */
|
||||
/* Generated stub for dev_blackhole_fd */
|
||||
|
||||
Reference in New Issue
Block a user