From dcbaffe70ead8b5d666b62a0f0b482ef8a0a76fa Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 4 May 2026 20:21:59 +0800 Subject: [PATCH] fix udpHole --- Tun/Punchnet/Actors/SDLContextActor.swift | 3 ++- Tun/Punchnet/UDPHole/SDLUDPHole.swift | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tun/Punchnet/Actors/SDLContextActor.swift b/Tun/Punchnet/Actors/SDLContextActor.swift index a59fdb9..346b2e3 100644 --- a/Tun/Punchnet/Actors/SDLContextActor.swift +++ b/Tun/Punchnet/Actors/SDLContextActor.swift @@ -172,7 +172,8 @@ actor SDLContextActor { quicClient.start() defer { - quicClient.stop() + self.quicClient?.stop() + self.quicClient = nil SDLLogger.log("[SDLContext] quicClient: stop") } diff --git a/Tun/Punchnet/UDPHole/SDLUDPHole.swift b/Tun/Punchnet/UDPHole/SDLUDPHole.swift index d258202..ea0f895 100644 --- a/Tun/Punchnet/UDPHole/SDLUDPHole.swift +++ b/Tun/Punchnet/UDPHole/SDLUDPHole.swift @@ -67,15 +67,14 @@ final class SDLUDPHole: ChannelInboundHandler { } // --MARK: ChannelInboundHandler delegate - + func channelRead(context: ChannelHandlerContext, data: NIOAny) { let envelope = unwrapInboundIn(data) var buffer = envelope.data let remoteAddress = envelope.remoteAddress - if let rawBytes = buffer.getBytes(at: buffer.readerIndex, length: buffer.readableBytes) { - SDLLogger.log("[SDLUDPHole] get raw bytes: \(rawBytes.count), from: \(remoteAddress)", for: .debug) - } + let byteCount = buffer.readableBytes - buffer.readerIndex + SDLLogger.log("[SDLUDPHole] get raw bytes: \(byteCount), from: \(remoteAddress)", for: .debug) do { if let message = try SDLHoleMessage.decode(buffer: &buffer) {