You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fbc2961
Browse filesBrowse the repository at this point in the historyBrowse files
Address review: optional JNA, scoped nativeDnssd, drop dead tests.
Make JNA optional, catch LinkageError when it is absent, let callers force
JmDNS or pass InetAddress to scope DNS-SD interface/host, deprecate auto(),
and replace the non-running live IT with fuller TXT/JmDNS unit coverage.
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy file name to clipboardExpand all lines: CHANGES.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# HAP-Java 2.0.10
2
2
* Add optional Mute characteristic to Doorbell service
3
3
* Add pluggable `HomekitAdvertiser` with native DNS-SD / Bonjour implementation (`DnssdHomekitAdvertiser`) so macOS can advertise `_hap._tcp` without binding UDP 5353 [#212](https://github.com/hap-java/HAP-Java/issues/212) (see [docs/NATIVE_DNSSD.md](docs/NATIVE_DNSSD.md))
4
-
* Extract shared HAP TXT helpers (`HapDnsTxt`)
5
-
*Add optional runtime dependency on JNA (`net.java.dev.jna:jna`) for native `DNSServiceRegister` (macOS `libSystem` / Avahi `libdns_sd`); JmDNS path unchanged when native DNS-SD is not used
4
+
* Extract shared HAP TXT helpers (`HapDnsTxt`) with stable key order; JmDNS and native advertisers publish the same property set
5
+
* JNA (`net.java.dev.jna:jna`) is **optional** for `nativeDnssd()`; JmDNS-only consumers do not need it. Applications should choose `jmdns(...)` or `nativeDnssd(InetAddress)` explicitly (`auto(...)` is deprecated)
6
6
7
7
# HAP-Java 2.0.9
8
8
* Fix Set Duration and Remaining Duration characteristics to advertise format `uint32` instead of `int`[#202](https://github.com/hap-java/HAP-Java/issues/202)
Copy file name to clipboardExpand all lines: README.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,19 +28,20 @@ read the [Javadoc](https://hap-java.github.io/HAP-Java/apidocs/index.html)
28
28
Native DNS-SD / Bonjour (macOS)
29
29
=========
30
30
31
-
JmDNS binds UDP **5353**. On macOS that port is owned by `mDNSResponder`, so dedicated JmDNS advertising fails with “Address already in use” and Home never sees `_hap._tcp`.
31
+
JmDNS binds UDP **5353**. On macOS that port is owned by `mDNSResponder`, so dedicated JmDNS advertising can fail with “Address already in use” and Home never sees `_hap._tcp`.
32
32
33
-
This build adds a native advertiser that registers through Bonjour without binding 5353:
33
+
This build adds a native advertiser that registers through Bonjour without binding 5353. Choose the advertiser explicitly in your application (e.g. openHAB); declare optional JNA when using the native path:
Copy file name to clipboardExpand all lines: docs/NATIVE_DNSSD.md
+40-25Lines changed: 40 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Typical symptoms on macOS: empty `dns-sd -B _hap._tcp` results while `lsof -iUDP
10
10
11
11
## Solution
12
12
13
-
This fork adds a pluggable **`HomekitAdvertiser`** and a native implementation **`DnssdHomekitAdvertiser`** that calls Apple’s DNS-SD API (`DNSServiceRegister`) via JNA:
13
+
This library adds a pluggable **`HomekitAdvertiser`** and a native implementation **`DnssdHomekitAdvertiser`** that calls Apple’s DNS-SD API (`DNSServiceRegister`) via JNA:
Check whether the native library **loads** (does not prove registration will succeed on the LAN):
39
53
40
54
```java
41
55
if (HomekitAdvertisers.isNativeDnssdSupported()) {
42
-
// safe to call nativeDnssd()
56
+
// safe to construct nativeDnssd(...)
43
57
}
44
58
```
45
59
46
60
Existing constructors that take only `InetAddress` / `JmDNS` keep the previous JmDNS behaviour (backward compatible).
47
61
48
-
## Verifying on macOS
62
+
## Verifying on macOS (manual)
49
63
50
-
After starting a server with `HomekitAdvertisers.nativeDnssd()` (or `auto(...)`):
64
+
There is no automated live IT in CI (ubuntu runners lack `libdns_sd` / Bonjour). After starting a server with `HomekitAdvertisers.nativeDnssd(bind)`:
51
65
52
66
```bash
53
67
dns-sd -B _hap._tcp local.
68
+
dns-sd -L "<instance name>" _hap._tcp local.
54
69
# or
55
70
dns-sd -Z _hap._tcp local.
56
71
```
57
72
58
-
You should see the bridge/accessory instance. No Java process should be listening on UDP 5353 (`lsof -iUDP:5353` should only show `mDNSResponder`).
73
+
You should see the bridge/accessory instance and HAP TXT keys. No Java process should be listening on UDP 5353 (`lsof -iUDP:5353` should only show `mDNSResponder`).
59
74
60
75
## API surface
61
76
@@ -73,11 +88,12 @@ setConfigurationIndex(int)
73
88
74
89
| Factory | Behaviour |
75
90
| --- | --- |
76
-
|`jmdns(JmDNS)`| Wrap an existing JmDNS |
77
-
|`jmdns(InetAddress)`| Create JmDNS on that address |
78
-
|`nativeDnssd()`| Native Bonjour / dns_sd (throws if unsupported) |
79
-
|`auto(InetAddress)`| Native if supported, else JmDNS |
80
-
|`isNativeDnssdSupported()`| Probe without constructing |
|`nativeDnssd(InetAddress)`| Native Bonjour scoped to that address’s interface index + SRV host |
95
+
|`isNativeDnssdSupported()`| Whether JNA + dns_sd **load** (not a live register probe) |
96
+
|`auto(InetAddress)`|**Deprecated** — prefer an explicit `jmdns` / `nativeDnssd` choice |
81
97
82
98
### `HomekitServer` constructors
83
99
@@ -90,21 +106,20 @@ When an advertiser is supplied, `createBridge` / `createStandaloneAccessory` use
90
106
91
107
## Implementation notes
92
108
93
-
***JNA** loads `System` on macOS/Darwin and `dns_sd` elsewhere (Avahi Bonjour compatibility).
109
+
***JNA**is an **optional** dependency. It loads `System` on macOS/Darwin and `dns_sd` elsewhere (Avahi Bonjour compatibility). Missing JNA surfaces as `LinkageError` and `isNativeDnssdSupported()` returns `false`.
94
110
*`DNSServiceRegister` receives the TCP port in **network byte order**.
95
-
* TXT is RFC 6763 length-prefixed `key=value` bytes (`HapDnsTxt.encodeTxt`).
111
+
* Default `nativeDnssd()` uses `interfaceIndex = 0` (all interfaces) and `host = null` (system hostname). Prefer `nativeDnssd(InetAddress)` when the HAP TCP listener is bound to one LAN address.
112
+
* TXT is RFC 6763 length-prefixed `key=value` bytes (`HapDnsTxt.encodeTxt`). Key insertion order is stable (`LinkedHashMap`); RFC 6763 does not require a particular pair order.
96
113
* A daemon thread runs `DNSServiceProcessResult` until `DNSServiceRefDeallocate` on `stop()` / re-register.
97
114
* Re-registration (discoverability, MAC, `c#`) deallocates and registers again — same pattern as the JmDNS advertiser.
|`HomekitAdvertisersTest`| Factory / support probe |
107
-
|`DnssdLiveAdvertiserIT`| Real register+stop when native DNS-SD is present |
120
+
|`HapDnsTxtTest`| Full TXT key set, stable order, wire encoding |
121
+
|`DnssdHomekitAdvertiserTest`| Mocked JNA register / interface+host / re-register / stop / port endianness |
122
+
|`JmdnsHomekitAdvertiserTest`| JmDNS register including full HAP property set |
108
123
109
124
```bash
110
125
mvn test
@@ -114,10 +129,10 @@ mvn test
114
129
115
130
| Symptom | Likely cause |
116
131
| --- | --- |
117
-
|`Address already in use` / “no suitable mDNS” | Still using JmDNS against mDNSResponder — switch to `nativeDnssd()`|
118
-
|`UnsupportedOperationException: Native DNS-SD`| No `libSystem`/`libdns_sd` on this JVM/OS |
132
+
|`Address already in use` / “no suitable mDNS” | Still using dedicated JmDNS against mDNSResponder — switch to `nativeDnssd(bind)` or share an existing JmDNS|
133
+
|`UnsupportedOperationException: Native DNS-SD`| No JNA on classpath, or no `libSystem`/`libdns_sd` on this JVM/OS |
119
134
|`DNSServiceRegister failed with error code …`| Bad name/type, permissions, or daemon unavailable — check Console / `mDNSResponder`|
120
-
| Browse empty after register | Wrong interface, firewall, or advertiser stopped; confirm with `dns-sd -B _hap._tcp`|
135
+
| Browse empty after register / too many interfaces | Prefer `nativeDnssd(localAddress)` instead of all-interfaces `nativeDnssd()`|
0 commit comments