From 74864472c7ee8cba59f0d5daee53a135ed9fc0f1 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Mon, 12 Jan 2026 17:04:17 +0700 Subject: [PATCH] fix relay --- bitchat/Services/NotificationStreamAssembler.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bitchat/Services/NotificationStreamAssembler.swift b/bitchat/Services/NotificationStreamAssembler.swift index 39948dc6..cbef4506 100644 --- a/bitchat/Services/NotificationStreamAssembler.swift +++ b/bitchat/Services/NotificationStreamAssembler.swift @@ -62,6 +62,7 @@ struct NotificationStreamAssembler { let hasRecipient = (flags & BinaryProtocol.Flags.hasRecipient) != 0 let hasSignature = (flags & BinaryProtocol.Flags.hasSignature) != 0 let isCompressed = (flags & BinaryProtocol.Flags.isCompressed) != 0 + let hasRoute = (version >= 2) && (flags & BinaryProtocol.Flags.hasRoute) != 0 let lengthOffset = 12 let payloadLength: Int @@ -80,6 +81,15 @@ struct NotificationStreamAssembler { var frameLength = framePrefix + payloadLength if hasRecipient { frameLength += BinaryProtocol.recipientIDSize } if hasSignature { frameLength += BinaryProtocol.signatureSize } + + if hasRoute { + let routeCountOffset = framePrefix + (hasRecipient ? BinaryProtocol.recipientIDSize : 0) + let routeCountIndex = buffer.startIndex + routeCountOffset + guard buffer.count > routeCountOffset else { break } + let routeCount = Int(buffer[routeCountIndex]) + frameLength += 1 + (routeCount * BinaryProtocol.senderIDSize) + } + if isCompressed { let rawLengthFieldBytes = (version == 2) ? 4 : 2 if payloadLength < rawLengthFieldBytes {