From f00ee00fd862091a646099470bb4686195a3336c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 9 Aug 2016 13:11:10 +0930 Subject: [PATCH] peer: log unexpected packets properly. And only try to print the contents if they're PKT_ERR. Signed-off-by: Rusty Russell --- daemon/peer.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/daemon/peer.c b/daemon/peer.c index 3af06eb8b..cce45c38b 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -2365,6 +2365,12 @@ void peer_unexpected_pkt(struct peer *peer, const Pkt *pkt) { const char *p; + log_unusual(peer->log, "Received unexpected pkt %u (%s)", + pkt->pkt_case, pkt_name(pkt->pkt_case)); + + if (pkt->pkt_case != PKT__PKT_ERROR) + return; + /* Check packet for weird chars. */ for (p = pkt->error->problem; *p; p++) { if (cisprint(*p)) @@ -2372,11 +2378,11 @@ void peer_unexpected_pkt(struct peer *peer, const Pkt *pkt) p = tal_hexstr(peer, pkt->error->problem, strlen(pkt->error->problem)); - log_unusual(peer->log, "Error pkt (hex) %s", p); + log_add(peer->log, "hex: %s", p); tal_free(p); return; } - log_unusual(peer->log, "Error pkt '%s'", pkt->error->problem); + log_add(peer->log, "'%s'", pkt->error->problem); } /* Create a bitcoin close tx, using last signature they sent. */