fix dnsClient
This commit is contained in:
parent
dde40ceb68
commit
968b86755b
@ -327,7 +327,6 @@ actor SDLContextActor {
|
||||
let nePacket = NEPacket(data: packet, protocolFamily: 2)
|
||||
self.provider.packetFlow.writePacketObjects([nePacket])
|
||||
}
|
||||
throw SDLContextError.dnsClientClosed
|
||||
} onCancel: {
|
||||
dnsClient.stop()
|
||||
}
|
||||
@ -342,8 +341,10 @@ actor SDLContextActor {
|
||||
self.dnsLocalClient = dnsLocalClient
|
||||
|
||||
defer {
|
||||
Task {
|
||||
self.dnsLocalClient = nil
|
||||
//dnsLocalClient.stop()
|
||||
await dnsLocalClient.stop()
|
||||
}
|
||||
}
|
||||
|
||||
try await withTaskCancellationHandler {
|
||||
@ -354,7 +355,6 @@ actor SDLContextActor {
|
||||
let nePacket = NEPacket(data: packet, protocolFamily: 2)
|
||||
self.provider.packetFlow.writePacketObjects([nePacket])
|
||||
}
|
||||
throw SDLContextError.dnsLocalClientClosed
|
||||
} onCancel: {
|
||||
Task {
|
||||
await dnsLocalClient.stop()
|
||||
|
||||
@ -37,7 +37,6 @@ actor DNSLocalClient {
|
||||
private let timeoutInterval: TimeInterval = 3.0
|
||||
|
||||
nonisolated let packetFlow: AsyncThrowingStream<Data, Error>
|
||||
@ObservationIgnored
|
||||
private let packetContinuation: AsyncThrowingStream<Data, Error>.Continuation
|
||||
private var isPacketContinuationFinished: Bool = false
|
||||
|
||||
@ -87,10 +86,6 @@ actor DNSLocalClient {
|
||||
}
|
||||
|
||||
func query(tracker: DNSTracker, dnsPayload: Data) {
|
||||
let transactionID: UInt16
|
||||
let connection: NWConnection
|
||||
let rewrittenPayload: Data
|
||||
|
||||
guard self.state != .stopped,
|
||||
let connection = self.connection, connection.state == .ready, dnsPayload.count >= 2 else {
|
||||
return
|
||||
@ -101,9 +96,9 @@ actor DNSLocalClient {
|
||||
return
|
||||
}
|
||||
|
||||
transactionID = allocatedTransactionID
|
||||
let transactionID = allocatedTransactionID
|
||||
self.pendingRequests[transactionID] = PendingRequest(tracker: tracker)
|
||||
rewrittenPayload = Self.rewriteTransactionID(in: dnsPayload, to: transactionID)
|
||||
let rewrittenPayload = Self.rewriteTransactionID(in: dnsPayload, to: transactionID)
|
||||
|
||||
connection.send(content: rewrittenPayload, completion: .contentProcessed { [weak self] error in
|
||||
if let error {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user