Skip to content

working node discovery example using the iroh-gossip-discovery crate #116

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ target/
*iroh-data
*/.sendme*
/deploy-out
.envrc
.direnv
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Use iroh through [extism]

Experiment with [FROST] threshold signatures for iroh.

### [gossip-node-discover](gossip-node-discover)

Discover nodes via [iroh-gossip-discovery](https://crates.io/crates/iroh-gossip-discovery).

### [iroh-automerge](iroh-automerge)

Iroh integration with [automerge]
Expand Down
96 changes: 96 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
description = "A devShell example";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
in
with pkgs;
{
devShells.default = mkShell {
nativeBuildInputs = [
openssl
pkg-config
rust-bin.nightly.latest.default
rust-analyzer
];
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
};
}
);
}
38 changes: 38 additions & 0 deletions gossip-node-discover/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# gossip-node-discovery

Discover nodes via [iroh-gossip-discovery](https://crates.io/crates/iroh-gossip-discovery).

## node

This binary will start an iroh endpoint and listen for NodeIds on the
mDNS local discovery stream and also make an http request to a known
server for it's NodeId. Once it gets one of these NodeId's it will
subscribe to the [0u8; 32] topic Id and begin to send it's NodeId
every 2 seconds. It also has a task that will listen for NodeId's that
come on the gossip receiver stream and update a hashtable of known
nodes.

## whoami

This is a simple http server that also subscribed to the gossip
topic. `node` can hit this server if it can't find any seed NodeIds
via mDNS.

## Running the Demo

If you are running locally and want to test via mDNS then just do:
```
cd node
cargo run -- <name-of-node>
```

If you also want to test discovery using the `whoami` server do:
```
cd whoami
cargo run
```
in another terminal
```
cd node
cargo run -- <name-of-node>
```
Loading
Loading