Skip to content

Commit 08267e0

Browse files
committed
remove AnySocketAddress
1 parent 5653d61 commit 08267e0

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

FlyingSocks/Sources/AsyncSocket.swift

+2-10
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public struct AsyncSocket: Sendable {
231231
message: [UInt8],
232232
to peerAddress: some SocketAddress,
233233
interfaceIndex: UInt32? = nil,
234-
from localAddress: (some SocketAddress)? = nil
234+
from localAddress: (any SocketAddress)? = nil
235235
) async throws {
236236
let sent = try await pool.loopUntilReady(for: .write, on: socket) {
237237
try socket.send(message: message, to: peerAddress, interfaceIndex: interfaceIndex, from: localAddress)
@@ -251,19 +251,11 @@ public struct AsyncSocket: Sendable {
251251
}
252252

253253
public func send(message: Message) async throws {
254-
let localAddress: AnySocketAddress?
255-
256-
if let unwrappedLocalAddress = message.localAddress {
257-
localAddress = AnySocketAddress(unwrappedLocalAddress)
258-
} else {
259-
localAddress = nil
260-
}
261-
262254
try await send(
263255
message: message.bytes,
264256
to: AnySocketAddress(message.peerAddress),
265257
interfaceIndex: message.interfaceIndex,
266-
from: localAddress
258+
from: message.localAddress
267259
)
268260
}
269261
#endif

FlyingSocks/Sources/Socket.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public struct Socket: Sendable, Hashable {
397397
message: [UInt8],
398398
to peerAddress: some SocketAddress,
399399
interfaceIndex: UInt32? = nil,
400-
from localAddress: (some SocketAddress)? = nil
400+
from localAddress: (any SocketAddress)? = nil
401401
) throws -> Int {
402402
try message.withUnsafeBytes { buffer in
403403
try send(
@@ -417,7 +417,7 @@ public struct Socket: Sendable, Hashable {
417417
flags: Int32,
418418
to peerAddress: some SocketAddress,
419419
interfaceIndex: UInt32? = nil,
420-
from localAddress: (some SocketAddress)? = nil
420+
from localAddress: (any SocketAddress)? = nil
421421
) throws -> Int {
422422
var iov = iovec()
423423
var msg = msghdr()
@@ -685,7 +685,7 @@ fileprivate extension Socket {
685685
static func withPacketInfoControl<T>(
686686
family: sa_family_t,
687687
interfaceIndex: UInt32?,
688-
address: (some SocketAddress)?,
688+
address: (any SocketAddress)?,
689689
_ body: (UnsafePointer<cmsghdr>?, ControlMessageHeaderLengthType) -> T
690690
) -> T {
691691
switch Int32(family) {

0 commit comments

Comments
 (0)