Limit direct payload hops

This commit is contained in:
Janez T
2026-03-05 08:30:06 +01:00
parent 5beac70644
commit c83eaa4d98
7 changed files with 172 additions and 11 deletions

View File

@@ -36,6 +36,7 @@ class ImageSession {
class ImageProvider with ChangeNotifier {
static const String _storageKey = 'stored_image_sessions_v1';
static const Duration _outgoingTtl = Duration(minutes: 15);
static const int maxDirectPayloadHops = 3;
/// Incoming sessions keyed by sessionId.
final Map<String, ImageSession> _sessions = {};
@@ -190,6 +191,12 @@ class ImageProvider with ChangeNotifier {
debugPrint('⚠️ [ImageProvider] ${requester.advName} has no direct path');
return false;
}
if (requester.outPathLen > maxDirectPayloadHops) {
debugPrint(
'⚠️ [ImageProvider] ${requester.advName} is too far: ${requester.outPathLen} hops (max $maxDirectPayloadHops)',
);
return false;
}
for (final fragment in cached.fragments) {
if (requestedIndices != null &&