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
feat(iroh): publish and resolve user-defined data in discovery (#3176)
## Description
**Based on #3175**
Adds support for publishing and resolving a string of user-defined data
through Iroh's discovery services.
This gives applications a way to add additional information to the
records published and resolved through discovery, in addition to the
addressing information (relay URL and direct addresses). Iroh itself
does not parse or use this user-defined data string in any way.
All existing discovery services are updated to support the user data.
All DNS-based discovery services encode the user-defined data in a TXT
record, in the same way as the DNS/pkarr services already encode the
relay URL and direct addresses. Therefore, the length of the
`user-data=<user-data>` string is limited to 255 bytes, which is the max
length for a single character string in DNS messages. Thus, the length
of the actual user-defined data string is limited to 245 bytes (255
minux `user-data=`). This limit is enforced when constructing a
`UserData` (which is just a wrapper around a `String` otherwise).
The local swarm discovery uses `swarm-discovery` under the hood, for
which I added support for TXT records in
rkuhn/swarm-discovery#12. This was released as
`swarm-discovery@0.3.0-alpha.2`.
## Breaking Changes
<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->
## Notes & open questions
Note that currently the `DiscoveryItem` which contains the user-defined
data is only accessible when directly calling the methods on the
`Discovery` trait. For discoveries initiated by the endpoint, both
active from `Endpoint::connect` and passive from the magicsock's
subscription to `Discovery::subscribe`, the `DiscoveryItem`s are
currently not exposed in any way, thus there's no way for an app to
access the user data of nodes discovered by the endpoint. However, with
#3181, there will be a way to watch for all `DiscoveryItem`s found by
the endpoint.
## Change checklist
- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
---------
Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com>
0 commit comments