mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-21 13:55:58 +00:00
Ignore duplicate sequence numbers
This commit is contained in:
1 parent
cffaabc076
commit
7fbe254118
2 files changed
+13
-4
No files matched your search
@@ -389,9 +389,17 @@ class NearbyConnection {
|
|||||||
let d2dMsg = try Securegcm_DeviceToDeviceMessage(serializedBytes: decryptedData)
|
let d2dMsg = try Securegcm_DeviceToDeviceMessage(serializedBytes: decryptedData)
|
||||||
|
|
||||||
guard d2dMsg.hasMessage, d2dMsg.hasSequenceNumber else { throw NearbyError.requiredFieldMissing("d2dMessage.message|sequenceNumber") }
|
guard d2dMsg.hasMessage, d2dMsg.hasSequenceNumber else { throw NearbyError.requiredFieldMissing("d2dMessage.message|sequenceNumber") }
|
||||||
clientSeq += 1
|
let receivedSeq = d2dMsg.sequenceNumber
|
||||||
|
let expectedSeq = clientSeq + 1
|
||||||
|
|
||||||
guard d2dMsg.sequenceNumber == clientSeq else { throw NearbyError.protocolError("Wrong sequence number. Expected \(clientSeq), got \(d2dMsg.sequenceNumber)") }
|
if receivedSeq == expectedSeq {
|
||||||
|
clientSeq = receivedSeq
|
||||||
|
} else if receivedSeq <= clientSeq {
|
||||||
|
log("[NearbyConnection \(self.id)] Ignoring duplicate/stale frame sequence \(receivedSeq). Current sequence is \(clientSeq)")
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
throw NearbyError.protocolError("Wrong sequence number. Expected \(expectedSeq), got \(receivedSeq)")
|
||||||
|
}
|
||||||
let offlineFrame = try Location_Nearby_Connections_OfflineFrame(serializedBytes: d2dMsg.message)
|
let offlineFrame = try Location_Nearby_Connections_OfflineFrame(serializedBytes: d2dMsg.message)
|
||||||
|
|
||||||
if offlineFrame.hasV1, offlineFrame.v1.hasType, case .payloadTransfer = offlineFrame.v1.type {
|
if offlineFrame.hasV1, offlineFrame.v1.hasType, case .payloadTransfer = offlineFrame.v1.type {
|
||||||
|
|||||||
@@ -273,13 +273,14 @@ class ShareViewController: NSViewController, OutboundAppDelegate {
|
|||||||
if #available(macOS 15.0, *) {
|
if #available(macOS 15.0, *) {
|
||||||
alert.informativeText = "TimeoutDescription".localized()
|
alert.informativeText = "TimeoutDescription".localized()
|
||||||
alert.addButton(withTitle: "TimeoutButton".localized())
|
alert.addButton(withTitle: "TimeoutButton".localized())
|
||||||
|
alert.addButton(withTitle: "CloseAlert".localized())
|
||||||
} else {
|
} else {
|
||||||
alert.informativeText = "TimeoutDescriptionLegacy".localized()
|
alert.informativeText = "TimeoutDescriptionLegacy".localized()
|
||||||
alert.addButton(withTitle: "TimeoutButtonLegacy".localized())
|
alert.addButton(withTitle: "TimeoutButtonLegacy".localized())
|
||||||
}
|
}
|
||||||
|
|
||||||
alert.beginSheetModal(for: self.view.window!) { _ in
|
alert.beginSheetModal(for: self.view.window!) { response in
|
||||||
if #available(macOS 15.0, *) {
|
if #available(macOS 15.0, *), response == .alertFirstButtonReturn {
|
||||||
openPrivacyAndSecuritySettings()
|
openPrivacyAndSecuritySettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user