mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Fail fast on outbound rejection
This commit is contained in:
1 parent
3736605509
commit
cffaabc076
1 file changed
+22
-2
@@ -157,10 +157,20 @@ class OutboundNearbyConnection: NearbyConnection {
|
||||
return
|
||||
}
|
||||
if frame.hasV1, frame.v1.hasType {
|
||||
if frame.v1.type == .progressUpdate || frame.v1.type == .response {
|
||||
if frame.v1.type == .progressUpdate {
|
||||
log("[OutboundNearbyConnection \(self.id)] Ignoring duplicate/intermediate transfer setup frame \(frame.v1.type) while waiting for pairedKeyEncryption.")
|
||||
return
|
||||
}
|
||||
if frame.v1.type == .response {
|
||||
let status = frame.v1.connectionResponse.status
|
||||
if status == .accept {
|
||||
log("[OutboundNearbyConnection \(self.id)] Ignoring out-of-order accept response while waiting for pairedKeyEncryption.")
|
||||
return
|
||||
}
|
||||
log("[OutboundNearbyConnection \(self.id)] Received terminal response \(status) while waiting for pairedKeyEncryption.")
|
||||
try processConsent(frame: frame)
|
||||
return
|
||||
}
|
||||
}
|
||||
throw NearbyError.requiredFieldMissing("sharingNearbyFrame.v1.pairedKeyEncryption")
|
||||
case .sentPairedKeyResult:
|
||||
@@ -169,10 +179,20 @@ class OutboundNearbyConnection: NearbyConnection {
|
||||
return
|
||||
}
|
||||
if frame.hasV1, frame.v1.hasType {
|
||||
if frame.v1.type == .pairedKeyEncryption || frame.v1.type == .progressUpdate || frame.v1.type == .response {
|
||||
if frame.v1.type == .pairedKeyEncryption || frame.v1.type == .progressUpdate {
|
||||
log("[OutboundNearbyConnection \(self.id)] Ignoring duplicate/intermediate transfer setup frame \(frame.v1.type) while waiting for pairedKeyResult.")
|
||||
return
|
||||
}
|
||||
if frame.v1.type == .response {
|
||||
let status = frame.v1.connectionResponse.status
|
||||
if status == .accept {
|
||||
log("[OutboundNearbyConnection \(self.id)] Ignoring out-of-order accept response while waiting for pairedKeyResult.")
|
||||
return
|
||||
}
|
||||
log("[OutboundNearbyConnection \(self.id)] Received terminal response \(status) while waiting for pairedKeyResult.")
|
||||
try processConsent(frame: frame)
|
||||
return
|
||||
}
|
||||
}
|
||||
throw NearbyError.requiredFieldMissing("sharingNearbyFrame.v1.pairedKeyResult")
|
||||
case .sentIntroduction:
|
||||
|
||||
Reference in new issue
Block a user