Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: node discovery via DNS (#2045)
## Description This enables global node discovery over DNS, i.e. dialing nodes by just their node id. Current setup is as follows: * When dialing a node only by its NodeId, the new `DnsDiscovery` service is invoked. It will lookup a TXT record at (by default) `_iroh_node.b32encodednodeid.testdns.iroh.link` over regular DNS or DNS-over-http. Right now the Cloudflare DNS servers are configured. At `testdns.iroh.link` we run a custom [DNS server](https://github.com/n0-computer/iroh-dns-server/tree/main) * Nodes publish their Derp address to this DNS server through Pkarr signed packets. This is an intermediate step, we decided that the publishing by default should not happen by the nodes directly but mediated through the Derp servers. Work for the latter happens in #2052 This PR thus allows for the following: ```sh # terminal/computer 1 $ iroh console --start Iroh is running Node ID: qp2znfedwdij4llc5noizwfemfgba7bzxozvr4bp7hfsdmwqbpua $ blob add ./myfile ... Blob: o5uanh5s2zwn2sucy47puqidsfx2advxos7kajq3ajwitcwobhba ... # terminal/computer 2 iroh console --start blob get o5uanh5s2zwn2sucy47puqidsfx2advxos7kajq3ajwitcwobhba --node qp2znfedwdij4llc5noizwfemfgba7bzxozvr4bp7hfsdmwqbpua ``` <!-- A summary of what this pull request achieves and a rough list of changes. --> ## Notes & open questions * Misses node configuration in the CLI for the node origin domain (right now hardcoded to `testdns.iroh.link`). How do we want to expose this - CLI flag? Or in the config file? I'd say the latter. * Offload publishing to the Derpers - see #2052 * Right now the records published via pkarr have a TTL of 30s - the iroh-dns-server will use that TTL as-is when serving the records over DNS. both can/should change? * We can also *very* easily allow to lookup nodes not only by NodeId, but by any domain name. In the `iroh-dns` crate I included an example `resolve` that does just that. By setting a `CNAME` record you can even use any domain and simply point to the record hosted at the `testdns.iroh.link` server. So if, on your custom domain, you added a record like this ``` _iroh_node.frando.n0.computer CNAME _iroh_node.qp2znfedwdij4llc5noizwfemfgba7bzxozvr4bp7hfsdmwqbpua.iroh.link. ``` You can use this with the example to resolve to the node id and derp addresses: ``` cargo run --example resolve -- domain frando.n0.computer ``` <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [x] Tests if relevant. Closes #1248 --------- Co-authored-by: Kasey <[email protected]> Co-authored-by: Asmir Avdicevic <[email protected]> Co-authored-by: Ruediger Klaehn <[email protected]>
- Loading branch information