This commit is contained in:
anlicheng 2026-02-03 13:44:24 +08:00
parent 478969d99d
commit d964eb6e27

View File

@ -139,8 +139,7 @@ actor SDLContextActor {
group.addTask { group.addTask {
while true { while true {
try Task.checkCancellation() try Task.checkCancellation()
try await Task.sleep(nanoseconds: 5 * 1_000_000_000) try await Task.sleep(for: .seconds(5))
try Task.checkCancellation()
await self.sendStunRequest() await self.sendStunRequest()
} }
} }
@ -236,6 +235,8 @@ actor SDLContextActor {
stunRequest.mac = self.config.networkAddress.mac stunRequest.mac = self.config.networkAddress.mac
stunRequest.natType = UInt32(self.natType.rawValue) stunRequest.natType = UInt32(self.natType.rawValue)
self.logger.log("[SDLContext] will send stun request")
if let stunData = try? stunRequest.serializedData() { if let stunData = try? stunRequest.serializedData() {
let remoteAddress = self.config.stunSocketAddress let remoteAddress = self.config.stunSocketAddress
self.udpHole?.send(type: .stunRequest, data: stunData, remoteAddress: remoteAddress) self.udpHole?.send(type: .stunRequest, data: stunData, remoteAddress: remoteAddress)