iroh 0.33.0 - Browsers and Discovery and 0-RTT, oh my!
by ramfox, matheus23Welcome to a new release of iroh
, a library for building on direct connections between devices, putting more control in the hands of your users.
We’ve got some exciting features for you this round! Iroh v0.33
compiles to Wasm and can be used in the browser, Discovery
now includes a way to pass in user-defined data, iroh::Endpoint
’s now allow you to subscribe to a stream that updates with every newly discovered node, and we’ve enabled 0-RTT QUIC connections.
🖥️ Browsers, now in iroh
Iroh v0.33
compiles to Wasm and can be used in the browser!
Not only that, but iroh-gossip
, too!
Can’t believe it? See these two examples we’ve cooked up:
- An iroh echo server in the browser. Check it out in action!
- An browser chat room UI based on the iroh gossip chat example. Check it out in action!
We’ve had this on the roadmap for some time and are extremely excited to have reached this milestone. Keep in mind there are some limitations for iroh
in the browser, such as not being able to establish direct connections right now.
There is a lot to cover here, so for further info take a look at the new page on our website that describes the features, limitations, and future plans for browser/Wasm work in iroh
. Also, take a look at the troubleshooting discussion on our github for fixes to typical issues that come up when compiling iroh
to WebAssembly.
🌐 Discovery Changes
We’ve implemented two new features involving Discovery
for this release! First, allowing users to publish and discover user-defined data. Second, creating easier APIs for users to track all of the nodes that have been discovered by iroh
.
🦾 User-Defined Data
Folks have been asking for this feature for a while and we are thrilled to finally have it: you can now add user-defined data to be published and resolved during Discovery
!
The original ask from our users was to be able to receive information about what ALPNs the nodes they have discovered speak. Or, to be able to put in a special “application specific” string, that would help the app developer understand if a node they have discovered is useful in their network. But you can use it any way you want.
This data is totally opaque and never read by iroh
. As long as it can be encoded/represented by UTF-8 string of 245 bytes (so it can fit into a DNS TXT record), you can put in whatever you need!
Check out PR https://github.com/n0-computer/iroh/pull/3176 for more details.
🌊 subscription stream
We do not maintain or keep around any sort of address book in iroh
. If an iroh
node is shutdown, it doesn’t contain any records of the nodes it discovered or communicated with once it has been spun back up.
We give ways for folks to export any connection information for themselves (iroh::Endpoint::remote_info_iter
) before shutting down, but this specifically does not include the user-defined data that we discover during Discovery
(since iroh
does not read or store this information). We now offer a new method iroh::Endpoint::discovery_stream
that returns a stream of DiscoveryItem
s. All information that iroh
has discovered will be passed along on that stream, that way our users can build up their own address books if that information is important for them to keep around!
Check out PR https://github.com/n0-computer/iroh/pull/3181 for more details!
⚡ 0-RTT
0-RTT allows you to skip a round-trip if you have connected to the given endpoint before and and stored the TLS session ticket from the previous session.
Iroh v0.33
, by default, will cache up to 8 session tickets per endpoint you connect to, and remember up to 32 endpoints maximum.
This cache only lives in-memory. We might add customization to the EndpointBuilder
in the future to allow for customizing this cache (allowing you to persist it), but that obviously has security implications, so will need careful consideration.
You can enable 0-RTT via the Endpoint::connect_with_opts
function, which - unlike Endpoint::connect
- returns a Connecting
, a state prior to a full Connection
. By calling Connecting::into_0rtt
you can attempt to turn this connection into a full 0-RTT connection. However, security caveats apply. See that function's documentation for details.
Checkout PR https://github.com/n0-computer/iroh/pull/3163 for more!
⚠️ Breaking Changes
- iroh
- removed
iroh::test_utils::create_dns_resolver
is removed, useiroh::dns::DnsResolver::new
insteadiroh::dns::resolver
andiroh::dns::default_resolver
are removed. There is no static, global DNS resolver anymore. If you want to share a DNS resolver between endpoints, create the resolver yourself withiroh::dns::DnsResolver::new
and clone it into the endpoint builders (inEndpointBuilder::dns_resolver
). If you want to reuse the DNS resolver from an endpoint, you can access it withEndpoint::dns_resolver
and clone it to wherever you need it.iroh::dns::node_info::{IrohAttr, TxtAttrs, node_id_from_hickory_name}
are no longer public. Useiroh::dns::DnsResolver::lookup_node_by_id
oriroh::dns::DnsResolver::lookup_node_by_domain_name
to lookup node info from DNS.iroh::dns::node_info::{to_z32, from_z32}
are removed. Use the methods oniroh::dns::node_info::NodeIdExt
trait instead.iroh::dns::ResolverExt
is removed. Use the methods oniroh::dns::DnsResolver
instead.iroh::discovery::Discovery::publish
now takesdata: &NodeData
as its single argument.iroh::discovery::NodeData
is a re-export ofiroh_relay::dns::node_info::NodeData
, and contains relay URL and direct addresses. See docs forNodeData
for details.iroh::Endpoint::connect_with
was removed, useiroh::Endpoint::connect_with_opts
instead
- changed
iroh::dns::DnsResolver
used to be a type alias and now is a reexport ofiroh_relay::dns::DnsResolver
structiroh::dns::node_info
module is now a reexport ofiroh_relay::dns::node_info
iroh::discovery::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING}
are now reexports ofiroh_relay::dns::{N0_DNS_NODE_ORIGIN_PROD, N0_DNS_NODE_ORIGIN_STAGING}
- The methods in
iroh::dns::DnsResolver
now take animpl ToString
instead ofimpl hickory_proto::rr::domain::IntoName
for theirhost
argument iroh::discovery::DiscoveryItem
no longer has any public fields. There are now getters for the contained data, and constructors for createing aDiscoveryItem
from aNodeInfo
.iroh_relay::dns::node_info::NodeInfo
is changed.NodeInfo::new
now has a singleNodeId
argument. UseNodeInfo::with_direct_addresses
andNodeInfo::with_relay_url
to set addresses and relay URL. Alternatively, useNodeInfo::from_parts
and pass aNodeData
struct.NodeInfo
now has two public fieldsnode_id: NodeId
anddata: NodeData
, and setter and getter methods for the relay URL and direct addresses.
iroh::discovery::pkarr::PkarrPublisher::update_addr_info
now takes aNodeData
argumentiroh::endpoint::Connection::into_0rtt
now returnsiroh::endpoint::ZeroRttAccepted
, instead ofiroh_quinn::ZeroRttAccepted
- removed
But wait, there's more!
Many bugs were squashed, and smaller features were added. For all those details, check out the full changelog: https://github.com/n0-computer/iroh/releases/tag/v0.33.0.
If you want to know what is coming up, check out the v0.34.0 milestone, and if you have any wishes, let us know about the issues! If you need help using iroh or just want to chat, please join us on discord! And to keep up with all things iroh, check out our Twitter.
To get started, take a look at our docs, dive directly into the code, or chat with us in our discord channel.