This commit is contained in:
callebtc
2025-07-22 01:22:43 +02:00
parent 4d2a84077d
commit 7417c651e3
@@ -526,21 +526,30 @@ class BluetoothMeshService(private val context: Context) {
) )
try { try {
// TODO: THIS FORMAT FOR DELIVERY ACKS SHOULD BE DEPRECATED
val ackData = ack.encode() ?: return val ackData = ack.encode() ?: return
val typeMarker = MessageType.DELIVERY_ACK.value.toByte()
val payloadWithMarker = byteArrayOf(typeMarker) + ackData
val encryptedPayload = securityManager.encryptForPeer(payloadWithMarker, senderPeerID)
if (encryptedPayload == null) {
Log.w(TAG, "Failed to encrypt delivery ACK for $senderPeerID")
return
}
// Create inner packet with the delivery ACK data // Create inner packet with the delivery ACK data
val innerPacket = BitchatPacket( val packet = BitchatPacket(
type = MessageType.DELIVERY_ACK.value, type = MessageType.NOISE_ENCRYPTED.value,
senderID = hexStringToByteArray(myPeerID), senderID = hexStringToByteArray(myPeerID),
recipientID = hexStringToByteArray(senderPeerID), recipientID = hexStringToByteArray(senderPeerID),
timestamp = System.currentTimeMillis().toULong(), timestamp = System.currentTimeMillis().toULong(),
payload = ackData, payload = encryptedPayload,
signature = null, signature = null,
ttl = 3u ttl = 3u
) )
// Use the new encrypt and broadcast function // Use the new encrypt and broadcast function
encryptAndBroadcastNoisePacket(innerPacket, senderPeerID) connectionManager.broadcastPacket(RoutedPacket(packet))
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "Failed to send delivery ACK: ${e.message}") Log.e(TAG, "Failed to send delivery ACK: ${e.message}")