Hi, I am @rustonbsd and I have been working with iroh, the p2p lib quite a bit. I have as of late been experimenting with integrating iroh and its ability to dial by ed25519 pub key into libp2p. I first wrote a go package with an ffi go<>rust bridge to add iroh connections as a transport layer in go-libp2p. If you are interested it is on github at rustonbsd/go-libp2p-iroh-transport
What i just got done with is a much cleaner rust-libp2p Transport and StreamMuxer implementation of iroh QUIC connections as a libp2p transport layer.
see GitHub - rustonbsd/libp2p-iroh: iroh QUIC connections as Libp2p Transport
The cool thing is that libp2p’s PeerId is directly translatable to Iroh’s EndpointId (renamed from NodeId in yesterday iroh release ^^).
This enables dialing by pure PeerId like this:
let peer_addr = “/p2p/12D3KooWE6XdeHWQkJADPNBLeKb42y5XTHwuY1qPqnKDwjt8XfrZ”.parse::()?;
swarm.dial(peer_addr)?;
If libp2p-iroh is used as transport, this works even when of you only have two peers and both of them sit behind different run of the mill routers with no open ports, or any other scenarios where usually an open port isn’t feasible.
The transport uses iroh’s built-in relay network and NAT traversal. When you dial a peer, iroh handles:
- Direct connections when possible
- Relay routing as fallback if (immediate) direct connections fail
- Automatic hole punching
- Connection upgrades from relayed to direct
You don’t configure any of this. It just works with the magic of iroh: GitHub - n0-computer/iroh: peer-2-peer that just works
I am looking for some example projects that have to fight with non reachable peers where I can implement libp2p-iroh and cut out some NAT traversal logic etc on an experimental branch.
If you should try it and have some feedback I would love to hear what you think!