mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 14:25:20 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d487e5bdb | ||
|
|
4acb2cf540 |
@@ -60,23 +60,24 @@ final class NoiseSessionManager {
|
|||||||
throw NoiseSessionError.alreadyEstablished
|
throw NoiseSessionError.alreadyEstablished
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any existing non-established session
|
let session: NoiseSession
|
||||||
if let existingSession = sessions[peerID], !existingSession.isEstablished() {
|
|
||||||
_ = sessions.removeValue(forKey: peerID)
|
if let existingSession = sessions[peerID] {
|
||||||
|
session = existingSession
|
||||||
|
session.reset()
|
||||||
|
} else {
|
||||||
|
// Create new initiator session
|
||||||
|
session = SecureNoiseSession(
|
||||||
|
peerID: peerID,
|
||||||
|
role: .initiator,
|
||||||
|
keychain: keychain,
|
||||||
|
localStaticKey: localStaticKey
|
||||||
|
)
|
||||||
|
sessions[peerID] = session
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new initiator session
|
|
||||||
let session = SecureNoiseSession(
|
|
||||||
peerID: peerID,
|
|
||||||
role: .initiator,
|
|
||||||
keychain: keychain,
|
|
||||||
localStaticKey: localStaticKey
|
|
||||||
)
|
|
||||||
sessions[peerID] = session
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let handshakeData = try session.startHandshake()
|
return try session.startHandshake()
|
||||||
return handshakeData
|
|
||||||
} catch {
|
} catch {
|
||||||
// Clean up failed session
|
// Clean up failed session
|
||||||
_ = sessions.removeValue(forKey: peerID)
|
_ = sessions.removeValue(forKey: peerID)
|
||||||
|
|||||||
Reference in New Issue
Block a user