mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 21:05:18 +00:00
Fix Noise session persistence during peer ID rotation
- Add session migration when peer IDs rotate - Sessions now follow peers across ID changes via fingerprint - Add migratePeerSession to NoiseEncryptionService - Add migrateSession to NoiseSessionManager - Integrate migration in BluetoothMeshService updatePeerBinding This fixes the issue where established Noise sessions were lost when peer IDs rotated, causing "No Noise session" errors and requiring re-handshake.
This commit is contained in:
@@ -259,6 +259,19 @@ class NoiseSessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
func migrateSession(from oldPeerID: String, to newPeerID: String) {
|
||||
_ = managerQueue.sync(flags: .barrier) {
|
||||
// Check if we have a session for the old peer ID
|
||||
if let session = sessions[oldPeerID] {
|
||||
// Move the session to the new peer ID
|
||||
sessions[newPeerID] = session
|
||||
sessions.removeValue(forKey: oldPeerID)
|
||||
|
||||
SecurityLogger.log("Migrated Noise session from \(oldPeerID) to \(newPeerID)", category: SecurityLogger.noise, level: .info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getEstablishedSessions() -> [String: NoiseSession] {
|
||||
return managerQueue.sync {
|
||||
return sessions.filter { $0.value.isEstablished() }
|
||||
|
||||
Reference in New Issue
Block a user