Replies: 2 comments 1 reply
-
I don't think we've quite agreed that iroh wants to provide this functionality, but personally I find it rather tempting too. However I think we're going to concentrate on getting the base protocol reliable and fast before we start adding other things. With those caveats out of the way, here are my current thoughts:
|
Beta Was this translation helpful? Give feedback.
-
So I like the idea of using separate connections via the same magic socket. That way we would not have to walk on eggshells in our own protocol evolution, but would still share the hole punching mechanism. Regarding identifiers, I am also not fond of some dynamic string - id mapping. Maybe just have a table somewhere in this repo where people can reserve an integer for their extension. |
Beta Was this translation helpful? Give feedback.
-
I wanted to open a discussion on reusing Iroh connections for application-level protocols. I'll outline some usecases, and to get a discussion started I'll also add some very preliminary thoughts on a potential implementation that came to mind when reading the Iroh source code and thinking about existing multistream implementations (libp2p, hypercore protocol).
background and usecases
At the moment Iroh owns a QUIC connection, as in: The provide server treats each stream as an Iroh protocol stream. Especially with the holepunching features getting in, it will be very attractive to reuse the Iroh connection establishment setup, and run both the Iroh protocol and other application-specific protocols over the same quic connection.
Use cases are wide:
ideas for implementation
In libp2p land, this is solved by always sending a multistream protocol identifier on each substream first.
To reduce the overhead of sending a protocol string identifier for each request (if there are to be many), this could be optimized quite easily by assigning an integer ID to the protocol on first use. So the string identifier is only sent once per connection, subsequent streams use the int id. Hypercore Protocol uses the same technique for protocol extensions.
The current Iroh protocol currently requires a Handshake message as first message on each new stream. Which likely is to be optimized anyways once Iroh starts to use many requests / streams to not resend the 32 byte auth token on each request. So possibly this could be combined quite nicely:
The current Iroh handshake with protocol version and auth token could live in the opaque
handshake
of such a new multi-protocol handshake. Subsequent requests would use theid
that the client assigned on the first request and skip the protocol name and handshake bytes. For non-Iroh protocols, the raw quinn(SendStream, RecvStream)
could be passed on to the application after decoding the handshake message.For the library use case, exposing the streams that are not handled in Iroh I could see working in two ways:
register_protocol(name: &str, on_stream: impl Fn(stream: (quinn::SendStream, quinn::RecvStream), handshake: Option<Bytes>)
In the binary, unknown protocols could just be ignored.
Beta Was this translation helpful? Give feedback.
All reactions