Share connection completion code

Across hard and soft reset.
This commit is contained in:
Davide De Rosa 2018-09-02 00:42:14 +02:00
parent c930cda065
commit e900454504
1 changed files with 10 additions and 9 deletions

View File

@ -701,10 +701,7 @@ public class SessionProxy {
enqueueControlPackets(code: .controlV1, key: negotiationKey.id, payload: cipherTextOut)
if negotiationKey.softReset {
authenticator = nil
negotiationKey.controlState = .connected
connectedDate = Date()
transitionKeys()
completeConnection()
}
nextPushRequestDate = Date().addingTimeInterval(CoreConfiguration.retransmissionLimit)
}
@ -724,6 +721,14 @@ public class SessionProxy {
}
}
private func completeConnection() {
setupEncryption()
authenticator = nil
negotiationKey.controlState = .connected
connectedDate = Date()
transitionKeys()
}
// MARK: Control
// Ruby: handle_ctrl_pkt
@ -888,11 +893,7 @@ public class SessionProxy {
return
}
setupEncryption()
authenticator = nil
negotiationKey.controlState = .connected
connectedDate = Date()
transitionKeys()
completeConnection()
guard let remoteAddress = link?.remoteAddress else {
fatalError("Could not resolve link remote address")