Skip to content

magic_endpoint: allow dialing with just PeerId #1248

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
flub opened this issue Jul 17, 2023 · 6 comments · Fixed by #2045
Closed

magic_endpoint: allow dialing with just PeerId #1248

flub opened this issue Jul 17, 2023 · 6 comments · Fixed by #2045
Labels
c-iroh feat New feature or request

Comments

@flub
Copy link
Contributor

flub commented Jul 17, 2023

The magic endpoint stores known addresses of peers in the PeerMap. This should allows it to keep state across dials and allows successful dials with just a PeerId. We should allow this.

See #1222 (comment)

@flub flub added the c-iroh label Jul 17, 2023
@flub flub added this to iroh Jul 17, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog - unassigned issues in iroh Jul 17, 2023
@dignifiedquire dignifiedquire added this to the v0.5.1 milestone Jul 18, 2023
@dignifiedquire dignifiedquire added the feat New feature or request label Jul 18, 2023
@Frando Frando mentioned this issue Jul 26, 2023
2 tasks
@rklaehn
Copy link
Contributor

rklaehn commented Jul 28, 2023

I think it is very important that we enable this somehow, soon.

For me this is one of the main selling points of iroh-net. It is very simple to explain: you get all of QUIC, but you can dial by identity (peer id) instead of location (addr). Basically QUIC but p2p, very good and short elevator pitch.

So why can't we have some (non-persisted) information exchange between the derpers that allow them to figure out a peer => current derp region mapping?

A peer knows or at least can find out its own region id. So when it connects to its derp region, this information could be distributed between the derpers, no?

At least for me this is extremely valuable to make iroh-net a compelling product that people might be willing to pay for.

@rklaehn
Copy link
Contributor

rklaehn commented Jul 28, 2023

Can't we just hack dial by peer in the most non decentralized way possible? Have a single central database that stores peer -> region, that gets updated every time a peer connects to a derper, and gets queried every time we need to know where a peer is?

Once we go via the relays we are in a somewhat centralized world anyway. So I say let's just hack it for now and then come up with something more pure/decentralized later...

@b5 b5 modified the milestones: v0.6.0-alpha: Sync!, v0.6.1 Aug 24, 2023
@b5 b5 modified the milestones: v0.6.0, v0.7.0 Sep 14, 2023
@b5 b5 removed this from the v0.7.0 milestone Sep 26, 2023
@rklaehn
Copy link
Contributor

rklaehn commented Oct 13, 2023

This: #1636 would solve this.

@rklaehn
Copy link
Contributor

rklaehn commented Oct 13, 2023

@b5 and @dignifiedquire it would be nice to have a decision whether this is happening soon or not.

I think we should do this as soon as possible, definitely before the end of the year. This to me is the missing item to be able to consider iroh-net complete in terms of API.

When using iroh-net as a library this is the one thing you will have to build stuff around. See what david had to do write his p2p thing: https://github.com/dvc94ch/p2p/blob/master/src/discovery.rs

@b5
Copy link
Member

b5 commented Oct 13, 2023

be the change @rklaehn. If you want this to happen design a workable solution we can debate. (for the record, I very much want to be able to dial without derp region as well)

@rklaehn
Copy link
Contributor

rklaehn commented Oct 13, 2023

be the change @rklaehn. If you want this to happen design a workable solution we can debate. (for the record, I very much want to be able to dial without derp region as well)

I take this as a confirmation that I can spend some time on it. Currently discussing with @Nuhvi ...

@b5 b5 mentioned this issue Mar 6, 2024
3 tasks
github-merge-queue bot pushed a commit that referenced this issue Apr 15, 2024
## 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 <kasey@n0.computer>
Co-authored-by: Asmir Avdicevic <asmir.avdicevic64@gmail.com>
Co-authored-by: Ruediger Klaehn <rklaehn@protonmail.com>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in iroh Apr 15, 2024
ppodolsky pushed a commit to izihawa/iroh that referenced this issue Apr 20, 2024
## 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 n0-computer#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 n0-computer#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 n0-computer#1248

---------

Co-authored-by: Kasey <kasey@n0.computer>
Co-authored-by: Asmir Avdicevic <asmir.avdicevic64@gmail.com>
Co-authored-by: Ruediger Klaehn <rklaehn@protonmail.com>
matheus23 pushed a commit that referenced this issue Nov 14, 2024
## 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 <kasey@n0.computer>
Co-authored-by: Asmir Avdicevic <asmir.avdicevic64@gmail.com>
Co-authored-by: Ruediger Klaehn <rklaehn@protonmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
c-iroh feat New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants