Skip to content

Commit

Permalink
fix(darwin): Fixed some encoding problems with attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyost authored Apr 27, 2024
2 parents 67d6ea3 + f89e3c0 commit a5fb3c1
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class BonsoirServiceBroadcast: BonsoirAction {
var txtRecord = TXTRecordRef()
TXTRecordCreate(&txtRecord, 0, nil)
for (key, value) in service.attributes {
TXTRecordSetValue(&txtRecord, key, UInt8(value.count), value)
guard let valueData = value.data(using: .utf8) else { continue }
TXTRecordSetValue(&txtRecord, key, UInt8(valueData.count), [UInt8](valueData))
}
let error = DNSServiceRegister(&sdRef, 0, 0, service.name, service.type, "local.", service.host, CFSwapInt16HostToBig(UInt16(service.port)), TXTRecordGetLength(&txtRecord), TXTRecordGetBytesPtr(&txtRecord), BonsoirServiceBroadcast.registerCallback as DNSServiceRegisterReply, Unmanaged.passUnretained(self).toOpaque())
if error == kDNSServiceErr_NoError {
Expand Down

0 comments on commit a5fb3c1

Please sign in to comment.