mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-26 08:45:22 +00:00
wip ack
This commit is contained in:
@@ -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}")
|
||||||
|
|||||||
Reference in New Issue
Block a user