This commit is contained in:
anlicheng 2025-08-01 12:03:26 +08:00
parent d1452ce0b7
commit 1f629a58a0
4 changed files with 10 additions and 10 deletions

View File

@ -47,8 +47,8 @@ public class SDLContext: @unchecked Sendable {
let rsaCipher: RSACipher
//
var udpHoleActor: SDLUDPHoleActor?
var superClientActor: SDLSuperClientActor?
var udpHoleActor: SDLUDPHole?
var superClientActor: SDLSuperClient?
//
private var readTask: Task<(), Never>?
@ -93,8 +93,8 @@ public class SDLContext: @unchecked Sendable {
}
public func start() async throws {
self.udpHoleActor = try await SDLUDPHoleActor()
self.superClientActor = try await SDLSuperClientActor(host: self.config.superHost, port: self.config.superPort)
self.udpHoleActor = try await SDLUDPHole()
self.superClientActor = try await SDLSuperClient(host: self.config.superHost, port: self.config.superPort)
self.noticeClient = try await SDLNoticeClient()
try await withThrowingTaskGroup(of: Void.self) { group in
@ -160,7 +160,7 @@ public class SDLContext: @unchecked Sendable {
self.readTask?.cancel()
}
private func handleSuperEvent(event: SDLSuperClientActor.SuperEvent) async throws {
private func handleSuperEvent(event: SDLSuperClient.SuperEvent) async throws {
switch event {
case .ready:
NSLog("[SDLContext] get registerSuper, mac address: \(Self.formatMacAddress(mac: self.devAddr.mac))")
@ -273,7 +273,7 @@ public class SDLContext: @unchecked Sendable {
// try await self.udpHole?.start()
}
private func handleUDPEvent(event: SDLUDPHoleActor.UDPEvent) async throws {
private func handleUDPEvent(event: SDLUDPHole.UDPEvent) async throws {
switch event {
case .ready:
//

View File

@ -22,7 +22,7 @@ struct SDLNatProber {
}
// nat
static func getNatType(udpHole: SDLUDPHoleActor?, config: SDLConfiguration) async -> NatType {
static func getNatType(udpHole: SDLUDPHole?, config: SDLConfiguration) async -> NatType {
guard let udpHole else {
return .blocked
}
@ -67,7 +67,7 @@ struct SDLNatProber {
}
}
private static func getNatAddress(_ udpHole: SDLUDPHoleActor, remoteAddress: SocketAddress, attr: SDLProbeAttr) async -> SocketAddress? {
private static func getNatAddress(_ udpHole: SDLUDPHole, remoteAddress: SocketAddress, attr: SDLProbeAttr) async -> SocketAddress? {
let stunProbeReply = try? await udpHole.stunProbe(remoteAddress: remoteAddress, attr: attr, timeout: 5)
return stunProbeReply?.socketAddress()

View File

@ -10,7 +10,7 @@ import NIOCore
import NIOPosix
// --MARK: SuperNode
actor SDLSuperClientActor {
actor SDLSuperClient {
private let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
private let asyncChannel: NIOAsyncChannel<ByteBuffer,ByteBuffer>
private let (writeStream, writeContinuation) = AsyncStream.makeStream(of: TcpMessage.self, bufferingPolicy: .unbounded)

View File

@ -16,7 +16,7 @@ struct UDPMessage {
}
// sn-server
actor SDLUDPHoleActor {
actor SDLUDPHole {
private let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
private let asyncChannel: NIOAsyncChannel<AddressedEnvelope<ByteBuffer>, AddressedEnvelope<ByteBuffer>>
private let (writeStream, continuation) = AsyncStream.makeStream(of: UDPMessage.self, bufferingPolicy: .unbounded)