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) {