Skip to content

Commit 6336d80

Browse files
rustyrussellt-bast
andauthored
Follow BOLT1 handling for "no reply" pings: ignore, don't warn. (#3278)
These "oversize ping replies" are how we ask for no replies, such as when we're sending dummy traffic. From the rationale: This allows a convenient cutoff for `num_pong_bytes` to indicate that no reply should be sent. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Co-authored-by: t-bast <bastien@acinq.fr>
1 parent e6c3d6e commit 6336d80

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,9 @@ class PeerConnection(keyPair: KeyPair, conf: PeerConnection.Conf, switchboard: A
243243
case Event(ping@Ping(pongLength, _, _), d: ConnectedData) =>
244244
d.transport ! TransportHandler.ReadAck(ping)
245245
if (pongLength <= 65532) {
246-
// see BOLT 1: we reply only if requested pong length is acceptable
246+
// See BOLT 1: we reply only if requested pong length is acceptable.
247+
// Senders may use unacceptable pong length when they don't want a response (to generate cover traffic).
247248
d.transport ! Pong(ByteVector.fill(pongLength)(0.toByte))
248-
} else {
249-
log.warning(s"ignoring invalid ping with pongLength=${ping.pongLength}")
250-
d.transport ! Warning(s"invalid pong length (${ping.pongLength})")
251249
}
252250
stay()
253251

eclair-core/src/test/scala/fr/acinq/eclair/io/PeerConnectionSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi
250250
test("ignore malicious ping") { f =>
251251
import f._
252252
connect(nodeParams, remoteNodeId, switchboard, router, connection, transport, peerConnection, peer)
253-
// huge requested pong length
253+
// Huge requested pong length.
254254
val ping = Ping(Int.MaxValue, randomBytes(127))
255255
transport.send(peerConnection, ping)
256256
transport.expectMsg(TransportHandler.ReadAck(ping))
257-
assert(transport.expectMsgType[Warning].channelId == Peer.CHANNELID_ZERO)
257+
// We simply ignore the message without sending pong back.
258258
transport.expectNoMessage()
259259
}
260260

0 commit comments

Comments
 (0)