Skip to content

Commit

Permalink
(Minor) Truncate onion message payload when logging (#669)
Browse files Browse the repository at this point in the history
The payload may be very large (32kB) which is spammy and non informative
anyway.
  • Loading branch information
pm47 authored Jun 18, 2024
1 parent 4897222 commit f115021
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/commonMain/kotlin/fr/acinq/lightning/io/Peer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,12 @@ class Peer(
suspend fun sendLoop() {
try {
for (msg in peerConnection.output) {
// Avoids polluting the logs with pings/pongs
if (msg !is Ping && msg !is Pong) logger.info { "sending $msg" }
when (msg) {
is Ping -> {} // Avoids polluting the logs with pings/pongs
is Pong -> {}
is OnionMessage -> logger.info { "sending ${msg.copy(onionRoutingPacket = msg.onionRoutingPacket.copy(payload = ByteVector.empty))} (truncated payload)" } // Not printing the payload, which can be very large
else -> logger.info { "sending $msg" }
}
val encoded = LightningMessage.encode(msg)
session.send(encoded) { data, flush -> socket.send(data, flush) }
}
Expand Down

0 comments on commit f115021

Please sign in to comment.