fix udpHole

This commit is contained in:
anlicheng 2026-05-04 20:21:59 +08:00
parent 55701085e3
commit dcbaffe70e
2 changed files with 5 additions and 5 deletions

View File

@ -172,7 +172,8 @@ actor SDLContextActor {
quicClient.start() quicClient.start()
defer { defer {
quicClient.stop() self.quicClient?.stop()
self.quicClient = nil
SDLLogger.log("[SDLContext] quicClient: stop") SDLLogger.log("[SDLContext] quicClient: stop")
} }

View File

@ -67,15 +67,14 @@ final class SDLUDPHole: ChannelInboundHandler {
} }
// --MARK: ChannelInboundHandler delegate // --MARK: ChannelInboundHandler delegate
func channelRead(context: ChannelHandlerContext, data: NIOAny) { func channelRead(context: ChannelHandlerContext, data: NIOAny) {
let envelope = unwrapInboundIn(data) let envelope = unwrapInboundIn(data)
var buffer = envelope.data var buffer = envelope.data
let remoteAddress = envelope.remoteAddress let remoteAddress = envelope.remoteAddress
if let rawBytes = buffer.getBytes(at: buffer.readerIndex, length: buffer.readableBytes) { let byteCount = buffer.readableBytes - buffer.readerIndex
SDLLogger.log("[SDLUDPHole] get raw bytes: \(rawBytes.count), from: \(remoteAddress)", for: .debug) SDLLogger.log("[SDLUDPHole] get raw bytes: \(byteCount), from: \(remoteAddress)", for: .debug)
}
do { do {
if let message = try SDLHoleMessage.decode(buffer: &buffer) { if let message = try SDLHoleMessage.decode(buffer: &buffer) {