Skip to content

Commit

Permalink
add support for host name resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
krzemin committed Jun 12, 2024
1 parent bc0cb57 commit 442dd81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/DNSServiceDiscovery/DNSServiceInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public struct DNSServiceInstance: Hashable {
public var domain: Domain
/// The interface index on which the service was discovered.
public var interfaceIndex: UInt32
/// The host name of discovered instance machine.
public var host: String?
/// The port on which the instance is running.
public var port: UInt16? = nil
/// The TXT record key-value pairs. Only provided during resolution.
Expand Down
2 changes: 2 additions & 0 deletions Sources/DNSServiceDiscovery/Internal/DNSService+Resolve.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ extension DNSService {
var flags = Flags(rawValue: rawFlags)
flags.insert(.add) // We always consider resolved instances "added" so we can deal with them in a uniform way on a higher level

let hostName = rawHostTarget.map { String(cString: $0) }
let txtRecord = rawTxtRecord.map { parse(rawTxtRecord: $0, txtLen: Int(txtLen)) } ?? [:]
let instance = DNSServiceInstance(
name: resolveQuery.name,
type: resolveQuery.serviceType,
domain: resolveQuery.domain,
interfaceIndex: interfaceIndex,
host: hostName,
port: UInt16(bigEndian: port), // Convert from network byte order
txtRecord: txtRecord
)
Expand Down

0 comments on commit 442dd81

Please sign in to comment.