Structure
HostPort
Immutable host + port pair representing a TCP network endpoint.
struct HostPort
Overview
swift-tor uses HostPort wherever the library crosses a TCP boundary: the SOCKS5 proxy surfaced by socksEndpoint, the optional control port accepted by TorControlClient(host:port:), and the forwarding target on an OnionPortTarget.tcp(host:port:) mapping. It is a deliberately minimal value type — a String + Int pair with printable formatting — rather than a validating type. Address families, DNS resolution, and port-range enforcement are deferred to the POSIX socket layer in ControlSocket and to Apple’s CFNetwork proxy resolver; a HostPort is simply a typed seat at those APIs.
The shape aligns with RFC 3986 authority components (RFC 3986 §3.2.2) and with SOCKS5’s host-plus-port addressing model (RFC 1928 §4).
Note
HostPort conforms to Sendable (value type, all fields Sendable) and to Hashable (synthesised — both fields are Hashable). Equality is case- and digit-exact; "LocalHost" and "localhost" are distinct instances.
Important
No validation is performed. Out-of-range ports, malformed IPv6 literals, and unresolvable hostnames surface as TorError.ioError(_:) at connection time — not at construction.
Topics
Initializers
Instance Properties
Type Methods
See Also
Related Documentation