Skip to content

Commit

Permalink
Merge pull request #135 from swhitty/remove-AnySocketAddress
Browse files Browse the repository at this point in the history
remove AnySocketAddress
  • Loading branch information
swhitty authored Nov 23, 2024
2 parents 5653d61 + 08267e0 commit 13778ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 2 additions & 10 deletions FlyingSocks/Sources/AsyncSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public struct AsyncSocket: Sendable {
message: [UInt8],
to peerAddress: some SocketAddress,
interfaceIndex: UInt32? = nil,
from localAddress: (some SocketAddress)? = nil
from localAddress: (any SocketAddress)? = nil
) async throws {
let sent = try await pool.loopUntilReady(for: .write, on: socket) {
try socket.send(message: message, to: peerAddress, interfaceIndex: interfaceIndex, from: localAddress)
Expand All @@ -251,19 +251,11 @@ public struct AsyncSocket: Sendable {
}

public func send(message: Message) async throws {
let localAddress: AnySocketAddress?

if let unwrappedLocalAddress = message.localAddress {
localAddress = AnySocketAddress(unwrappedLocalAddress)
} else {
localAddress = nil
}

try await send(
message: message.bytes,
to: AnySocketAddress(message.peerAddress),
interfaceIndex: message.interfaceIndex,
from: localAddress
from: message.localAddress
)
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions FlyingSocks/Sources/Socket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public struct Socket: Sendable, Hashable {
message: [UInt8],
to peerAddress: some SocketAddress,
interfaceIndex: UInt32? = nil,
from localAddress: (some SocketAddress)? = nil
from localAddress: (any SocketAddress)? = nil
) throws -> Int {
try message.withUnsafeBytes { buffer in
try send(
Expand All @@ -417,7 +417,7 @@ public struct Socket: Sendable, Hashable {
flags: Int32,
to peerAddress: some SocketAddress,
interfaceIndex: UInt32? = nil,
from localAddress: (some SocketAddress)? = nil
from localAddress: (any SocketAddress)? = nil
) throws -> Int {
var iov = iovec()
var msg = msghdr()
Expand Down Expand Up @@ -685,7 +685,7 @@ fileprivate extension Socket {
static func withPacketInfoControl<T>(
family: sa_family_t,
interfaceIndex: UInt32?,
address: (some SocketAddress)?,
address: (any SocketAddress)?,
_ body: (UnsafePointer<cmsghdr>?, ControlMessageHeaderLengthType) -> T
) -> T {
switch Int32(family) {
Expand Down

0 comments on commit 13778ca

Please sign in to comment.