Skip to content

Commit d6a2586

Browse files
committed
update
1 parent 678be99 commit d6a2586

File tree

7 files changed

+98
-89
lines changed

7 files changed

+98
-89
lines changed

connecting/creating-endpoint.mdx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
---
2-
title: "Creating an endpoint"
2+
title: "Creating an Endpoint"
33
---
44

5+
An endpoint is the core building block of an iroh node. It manages network
6+
connections, handles incoming and outgoing traffic, and provides the necessary
7+
infrastructure for implementing protocols.
8+
59
To create an endpoint in Iroh, you can use the `Endpoint::bind` method. This
610
method initializes a new endpoint and binds it to a local address, allowing it
711
to listen for incoming connections.
@@ -17,10 +21,9 @@ async fn main() {
1721
```
1822

1923

20-
Breaking that down, `bind` creates the endpoint and starts listening for
21-
incoming connections, while the `await` keyword is used to wait for the endpoint
24+
1. `bind` creates the endpoint and starts listening for
25+
incoming connections
26+
2. `await` keyword is used to wait for the endpoint
2227
to be created in an asynchronous context.
23-
24-
25-
Once you have an endpoint, you can use it to create connections to other
26-
endpoints, or accept incoming connections from other endpoints.
28+
3. Once you have an endpoint, you can use it to create connections to other
29+
endpoints, or accept incoming connections from other endpoints.

connecting/dht-discovery.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: "DHT"
3+
---
4+
5+
Discovery via DHT in iroh uses the [BitTorrent Mainline](https://en.wikipedia.org/wiki/Mainline_DHT) distributed hash table (DHT) to publish & resolve EndpointIds.
6+
7+
DHT Discovery is _not_ enabled by default, and must be enabled by the user. You'll need to add the `discovery-pkarr-dht` feature flag to your `Cargo.toml` to use it.
8+
9+
```toml
10+
[dependencies]
11+
# Make sure to use the most recent version here instead of nn. (at the time of writing: 0.32)
12+
iroh = { version = "0.nn", features = ["discovery-pkarr-dht"] }
13+
```
14+
15+
Then configure your endpoint to use DHT discovery concurrently with mDNS discovery, but not with the default DNS discovery, use the `Endpoint::empty_builder` method. This requires specifying a `RelayMode`, which in this example we will keep default.
16+
17+
```rust
18+
use iroh::Endpoint;
19+
20+
let dht_discovery = iroh::discovery::dht::DhtDiscovery::builder();
21+
let mdns = iroh::discovery::mdns::MdnsDiscovery::builder();
22+
let ep = Endpoint::empty_builder(iroh::RelayMode::Default)
23+
.discovery(dnt_discovery)
24+
.bind()
25+
.await?;
26+
```

connecting/dns-discovery.mdx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: "DNS"
3+
---
4+
5+
By Default, iroh uses the DNS discovery system to find other peers with a given EndpointId.
6+
7+
iroh will use a standard DNS server to publish and resolve EndpointIds to their
8+
home relay addresses. This allows any iroh endpoint to be discoverable globally,
9+
as long as they are connected to the same relay that is reachable from the public
10+
internet.
11+
12+
```rust
13+
use iroh::Endpoint;
14+
15+
#[tokio::main]
16+
async fn main() -> anyhow::Result<()> {
17+
let endpoint = Endpoint::bind().await?;
18+
19+
println!("endpoint id: {:?}", endpoint.id());
20+
Ok(())
21+
}
22+
```
23+
24+
TODO: example of looking up another endpoint via dns
25+
26+
## Dedicated DNS Server
27+
28+
By default, iroh will look up the endpoint on a public shared instance of the
29+
DNS discovery server. If you'd like to run your own private DNS discovery server
30+
for more guaranteed privacy and uptime guarantees, you can configure iroh to use
31+
it.
32+
33+
34+
TODO: rust code for custom dns server
35+
36+
## Important notes
37+
38+
1. DNS discovery is the default discovery mechanism in iroh, so you don't need
39+
to do anything special to enable it.
40+
2. DNS discovery only publishes the home relay of an endpoint, not its direct
41+
addresses.
42+
3. DNS discovery is opt-out, so if you don't want your endpoint to be
43+
discoverable via DNS, you can disable it by using the
44+
`Endpoint::empty_builder` method instead of `Endpoint::builder`.
45+
4. Two nodes must connect to the same DNS discovery server to find each other using DNS discovery.
46+
47+
48+

connecting/global-discovery.mdx

Lines changed: 0 additions & 72 deletions
This file was deleted.

connecting/gossip.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Broadcast via gossip topics"
2+
title: "Gossip Broadcast"
33
---
44

55
Gossip protocols let peers broadcast messages to subscribers of a topic

connecting/local-discovery.mdx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
---
2-
title: "Local discovery"
2+
title: "mDNS and Bluetooth"
33
---
44

5-
Placeholder: Using mDNS for local peer discovery and network config notes.
5+
Local discovery adds the ability to use physical radios to discover other iroh
6+
endpoints. This is useful for local networks where the internet may not be available or reliable.
67

8+
Local connections can be faster and more reliable than internet-based connections, especially in
9+
environments with poor connectivity. They also enhance privacy by keeping communications within a local area.
710

811
## mDNS
912

10-
Local discovery adds the ability to scan local networks for other iroh
11-
endpoints, using Local Swarm Discovery. This is useful for local networks, or
12-
for bootstrapping a network before a relay is available.
13-
1413
Local Discovery is _not_ enabled by default, and must be enabled by the user.
1514
You'll need to add the `discovery-local-network` feature flag to your
1615
`Cargo.toml` to use it.
@@ -34,4 +33,7 @@ let ep = Endpoint::builder()
3433
```
3534

3635

37-
## Bluetooth, and P2P WiFi
36+
## Bluetooth
37+
38+
Bluetooth discovery is currently under development and will be available in a
39+
future release of iroh. For more information, please [contact us](https://cal.com/team/number-0/n0-protocol-services).

docs.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"quickstart",
2121
{
2222
"group": "Concepts",
23+
"expanded": true,
2324
"pages": [
2425
"concepts/endpoints",
2526
"concepts/discovery",
@@ -31,10 +32,11 @@
3132
]
3233
},
3334
{
34-
"group": "Connecting Peers",
35+
"group": "Forming a Network",
3536
"pages": [
3637
"connecting/creating-endpoint",
37-
"connecting/global-discovery",
38+
"connecting/dns-discovery",
39+
"connecting/dht-discovery",
3840
"connecting/local-discovery",
3941
"connecting/gossip"
4042
]

0 commit comments

Comments
 (0)