mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 08:25:21 +00:00
Clear handshake coordinator state during panic mode
When panic mode is triggered (triple tap on logo), it now properly clears: - All handshake coordinator states - Handshake attempt times - Notifies UI that all peers are disconnected This fixes the issue where handshake states would persist after clearing identity, causing confusion when the device showed "zero peers connected" but still had established handshake states in logs. Also ensures UI is properly notified to update the peer list to empty.
This commit is contained in:
@@ -254,4 +254,13 @@ class NoiseHandshakeCoordinator {
|
|||||||
SecureLogger.log("========================", category: SecureLogger.handshake, level: .debug)
|
SecureLogger.log("========================", category: SecureLogger.handshake, level: .debug)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clear all handshake states - used during panic mode
|
||||||
|
func clearAllHandshakeStates() {
|
||||||
|
handshakeQueue.async(flags: .barrier) {
|
||||||
|
SecureLogger.log("Clearing all handshake states for panic mode", category: SecureLogger.handshake, level: .warning)
|
||||||
|
self.handshakeStates.removeAll()
|
||||||
|
self.processedHandshakeMessages.removeAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1159,6 +1159,16 @@ class BluetoothMeshService: NSObject {
|
|||||||
// Clear persistent identity
|
// Clear persistent identity
|
||||||
noiseService.clearPersistentIdentity()
|
noiseService.clearPersistentIdentity()
|
||||||
|
|
||||||
|
// Clear all handshake coordinator states
|
||||||
|
handshakeCoordinator.clearAllHandshakeStates()
|
||||||
|
|
||||||
|
// Clear handshake attempt times
|
||||||
|
handshakeAttemptTimes.removeAll()
|
||||||
|
|
||||||
|
// Notify UI that all peers are disconnected
|
||||||
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
self?.delegate?.didUpdatePeerList([])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getAllConnectedPeerIDs() -> [String] {
|
private func getAllConnectedPeerIDs() -> [String] {
|
||||||
|
|||||||
Reference in New Issue
Block a user