Skip to content

Commit d79e5d1

Browse files
committed
Update README.md
1 parent a8ea670 commit d79e5d1

File tree

1 file changed

+86
-1
lines changed

1 file changed

+86
-1
lines changed

README.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,13 @@ Response:
163163

164164
#### 4. mDNS Service Discovery
165165

166-
Blox devices advertise both peerIDs via mDNS TXT records on the local network (service type `_fulatower._tcp`).
166+
Blox devices advertise themselves on the local network via mDNS (multicast DNS), allowing mobile apps and other clients to discover devices without knowing their IP addresses.
167+
168+
**Service type:** `_fulatower._tcp`
169+
170+
**Instance naming:** Each device registers with a unique instance name derived from its kubo peerID: `fulatower_<last 5 chars of peerID>`. For example, a device with kubo peerID `12D3KooWAbCdEfGh12345` registers as `fulatower_12345`. If the peerID is not yet available (e.g. first boot before configuration), the device registers as `fulatower_NEW`. This ensures multiple blox devices on the same LAN are all discoverable without overwriting each other.
171+
172+
**TXT records:**
167173

168174
| TXT Key | Value | Description |
169175
|---------|-------|-------------|
@@ -175,6 +181,85 @@ Blox devices advertise both peerIDs via mDNS TXT records on the local network (s
175181

176182
If the config file is missing or identity derivation fails, `bloxPeerIdString` falls back to reading from kubo's config file via `GetKuboPeerID()`. Fields default to `"NA"` when unavailable.
177183

184+
**Discovering devices from the command line:**
185+
186+
Using `dns-sd` (macOS):
187+
```bash
188+
dns-sd -B _fulatower._tcp local.
189+
```
190+
191+
Example output:
192+
```
193+
Browsing for _fulatower._tcp.local.
194+
DATE: ---Mon 17 Feb 2026---
195+
Timestamp A/R Flags if Domain Service Type Instance Name
196+
10:23:45.123 Add 2 4 local. _fulatower._tcp. fulatower_12345
197+
10:23:45.456 Add 2 4 local. _fulatower._tcp. fulatower_67890
198+
```
199+
200+
To get full details (IP, port, TXT records) for a specific device:
201+
```bash
202+
dns-sd -L "fulatower_12345" _fulatower._tcp local.
203+
```
204+
205+
Example output:
206+
```
207+
Lookup fulatower_12345._fulatower._tcp.local.
208+
DATE: ---Mon 17 Feb 2026---
209+
fulatower_12345._fulatower._tcp.local. can be reached at blox-device.local.:40001
210+
bloxPeerIdString=12D3KooWAbCdEfGh12345
211+
ipfsClusterID=12D3KooWXyZaBcDe67890
212+
poolName=my-pool
213+
authorizer=...
214+
hardwareID=a1b2c3d4e5
215+
```
216+
217+
Using `avahi-browse` (Linux):
218+
```bash
219+
avahi-browse -r _fulatower._tcp
220+
```
221+
222+
Example output:
223+
```
224+
+ eth0 IPv4 fulatower_12345 _fulatower._tcp local
225+
= eth0 IPv4 fulatower_12345 _fulatower._tcp local
226+
hostname = [blox-device.local]
227+
address = [192.168.1.100]
228+
port = [40001]
229+
txt = ["bloxPeerIdString=12D3KooWAbCdEfGh12345" "ipfsClusterID=12D3KooWXyZaBcDe67890" "poolName=my-pool" "authorizer=..." "hardwareID=a1b2c3d4e5"]
230+
+ eth0 IPv4 fulatower_67890 _fulatower._tcp local
231+
= eth0 IPv4 fulatower_67890 _fulatower._tcp local
232+
hostname = [blox-device-2.local]
233+
address = [192.168.1.101]
234+
port = [40001]
235+
txt = ["bloxPeerIdString=12D3KooWZzYyXxWw67890" "ipfsClusterID=12D3KooWQqRrSsTt11111" "poolName=my-pool" "authorizer=..." "hardwareID=f6g7h8i9j0"]
236+
```
237+
238+
**Programmatic discovery (Go):**
239+
240+
```go
241+
import "github.com/grandcat/zeroconf"
242+
243+
resolver, _ := zeroconf.NewResolver(nil)
244+
entries := make(chan *zeroconf.ServiceEntry)
245+
246+
go func() {
247+
for entry := range entries {
248+
fmt.Printf("Found: %s at %s:%d\n", entry.Instance, entry.AddrIPv4, entry.Port)
249+
for _, txt := range entry.Text {
250+
fmt.Printf(" %s\n", txt)
251+
}
252+
}
253+
}()
254+
255+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
256+
defer cancel()
257+
resolver.Browse(ctx, "_fulatower._tcp", "local.", entries)
258+
<-ctx.Done()
259+
```
260+
261+
**Multi-device coexistence:** When multiple blox devices are on the same network, each registers with its own unique instance name. A browsing client will see all devices and can identify them by their TXT records (peerID, hardwareID, pool name). The service type `_fulatower._tcp` remains the same across all devices for compatibility — only the instance name varies.
262+
178263
#### 5. Go Code (`wifi.GetKuboPeerID()`)
179264

180265
For internal Go code that needs the kubo peerID, use the standalone utility function:

0 commit comments

Comments
 (0)