daemon: handle receipt of error packets.

If it's all printable, print it, otherwise dump hex.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-05-06 11:55:52 +09:30
parent e1c6f2d630
commit 1be98d860f
1 changed files with 14 additions and 1 deletions

View File

@ -1504,7 +1504,20 @@ void peer_calculate_close_fee(struct peer *peer)
void peer_unexpected_pkt(struct peer *peer, const Pkt *pkt)
{
FIXME_STUB(peer);
const char *p;
/* Check packet for weird chars. */
for (p = pkt->error->problem; *p; p++) {
if (cisprint(*p))
continue;
p = tal_hexstr(peer, pkt->error->problem,
strlen(pkt->error->problem));
log_unusual(peer->log, "Error pkt (hex) %s", p);
tal_free(p);
return;
}
log_unusual(peer->log, "Error pkt '%s'", pkt->error->problem);
}
void peer_watch_htlcs_cleared(struct peer *peer,