This commit is contained in:
anlicheng 2026-03-27 13:35:02 +08:00
parent 5358d9a2b7
commit 2e311cbf9e

View File

@ -41,7 +41,7 @@ actor SDLPuncherActor {
return
}
pendingRequests[dstMac] = .init(expireAt: Date().addingTimeInterval(cooldownInterval), request: request)
self.pendingRequests[dstMac] = .init(expireAt: Date().addingTimeInterval(cooldownInterval), request: request)
//
var queryInfo = SDLQueryInfo()
queryInfo.dstMac = request.dstMac
@ -51,11 +51,17 @@ actor SDLPuncherActor {
}
func handlePeerInfo(using udpHole: SDLUDPHole?, peerInfo: SDLPeerInfo) async {
guard let udpHole, let requestContext = pendingRequests.removeValue(forKey: peerInfo.dstMac),
let remoteAddress = try? await peerInfo.v4Info.socketAddress() else {
// ;
guard let requestContext = pendingRequests.removeValue(forKey: peerInfo.dstMac) else {
return
}
//
guard let udpHole, peerInfo.hasV4Info else {
return
}
if let remoteAddress = try? await peerInfo.v4Info.socketAddress() {
SDLLogger.shared.log("[SDLContext] hole sock address: \(remoteAddress)", level: .debug)
// register
var register = SDLRegister()
@ -67,6 +73,7 @@ actor SDLPuncherActor {
udpHole.send(type: .register, data: registerData, remoteAddress: remoteAddress)
}
}
}
//
func isRequestExpired(dstMac: Data) -> Bool {