From 94a9baefeba174fbebe42a12053866c631b849eb Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Wed, 15 May 2024 12:15:54 -0700 Subject: [PATCH] peer: reduce upper bound of pong bytes to ease bandwidth load --- peer/brontide.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/peer/brontide.go b/peer/brontide.go index 1fa6c1311..3cb682235 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -76,6 +76,12 @@ const ( // ErrorBufferSize is the number of historic peer errors that we store. ErrorBufferSize = 10 + + // pongSizeCeiling is the upper bound on a uniformly distributed random + // variable that we use for requesting pong responses. We don't use the + // MaxPongBytes (upper bound accepted by the protocol) because it is + // needlessly wasteful of precious Tor bandwidth for little to no gain. + pongSizeCeiling = 4096 ) var ( @@ -558,17 +564,16 @@ func NewBrontide(cfg Config) *Brontide { return lastSerializedBlockHeader[:] } - // TODO(roasbeef): make dynamic in order to - // create fake cover traffic - // NOTE(proofofkeags): this was changed to be - // dynamic to allow better pong identification, - // however, more thought is needed to make this - // actually usable as a traffic decoy + // TODO(roasbeef): make dynamic in order to create fake cover traffic. + // + // NOTE(proofofkeags): this was changed to be dynamic to allow better + // pong identification, however, more thought is needed to make this + // actually usable as a traffic decoy. randPongSize := func() uint16 { return uint16( // We don't need cryptographic randomness here. /* #nosec */ - rand.Intn(lnwire.MaxPongBytes + 1), + rand.Intn(pongSizeCeiling) + 1, ) }