Skip to content

Commit da14cc6

Browse files
feat!: add iroh-relay crate (#2873)
## Description Adds a new crate `iroh-relay`. It's structured as follows: - protos: protocols the server is able to handle, this includes the relay protocol, stun, and partially disco. - server: the server code, as it was already in the og mod - client: the client code, as it was already in the og mod - server binary (bin `iroh-relay`) as it was previously in iroh-net's bin. This moves the code around in the least disruptive possible way to give us a starting point over which to improve this. Check the notes and open questions for future work ## Breaking Changes - `iroh_net::relay` is removed. `RelayUrl`, `RelayMode`, `RelayNode` and `RelayMap` are moved to the top (`iroh_net`). All other members of this module are now moved to the new crate `iroh-relay` ## Notes & open questions - Disco includes a transaction id defined in terms of stun's transaction id. Every use of this is now directly from `stun_rs` to make it clear this is not defined in terms of the relay's stun server. The relay can't read the contents of disco packages so I consider this the right thing to do, even if the types are actually the same. - The relay needs to identify Disco packages to queue them separately. Disco is not yet its own crate because we do not know its future. Based on this I chose to duplicate the code that does the identification. But just this signals we should start the work on deciding what disco looks like in a post ts world to de-duplicate this code and use it from a single source. The code as it stands is highly unlikely to change; however, any change to the protocol's wrapper would now need to be changed in two places, which is ofc not ideal. - The relay's "protocol" includes quite a lot of non protocol code, that probably belongs more to the server. I was really tempted to try to move this code to better places but in reality this is not the time. The purpose of this PR is among many others, to allow for future work like this. - What used to be called the relay module had a lot of relay-related code without a clear objective or offering. This includes for example, all the relay map related code. The relay as a protocol, server, and client, has absolutely no need for these types. Relay topology is entirely a `iroh`/`iroh-net` topic. On the same page is the infra-related code. Nothing in the protocol, server or client is different depending on the infra values. This is entirely a `iroh`/`iroh-net` topic. Based on these arguments, these types, functions, etc that were part of the relay module have actually stayed in `iroh-net` instead. - I did a couple passes of `udeps`, but it's messy. Optional dependencies are their own feature so they aren't flagged as unused. There are (in general, not in the relay) dependencies that differ in targets, and the features combinations also affect this as well. So the deps that remain are a "reasonable best effort" in accordance with our CI checks. In reality, - and in particular when checking feature combinations with `fc` - there's a lot of work left to do on that front. - The crate's version is 0.29 because there's no point in setting the version to 0.28, which will never be released, to then later be changed to 0.29. This might be unexpected but it's the option that reduces senseless future work. - dns code is duplicated. This is unfortunate but since it's only used in tests to configure the client there's really not much to do here. Most of what this does are fixes we should try to upstream ## Change checklist - [x] Self-review. - [x] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] ~~Tests if relevant.~~ - [x] All breaking changes documented.
1 parent 88e2b01 commit da14cc6

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jobs:
190190
# uses: obi1kenobi/cargo-semver-checks-action@v2
191191
uses: n0-computer/cargo-semver-checks-action@feat-baseline
192192
with:
193-
package: iroh, iroh-base, iroh-cli, iroh-dns-server, iroh-metrics, iroh-net, iroh-net-bench, iroh-router, netwatch, portmapper
193+
package: iroh, iroh-base, iroh-cli, iroh-dns-server, iroh-metrics, iroh-net, iroh-net-bench, iroh-router, netwatch, portmapper, iroh-relay
194194
baseline-rev: ${{ env.HEAD_COMMIT_SHA }}
195195
use-cache: false
196196

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env:
2323
RUSTFLAGS: -Dwarnings
2424
RUSTDOCFLAGS: -Dwarnings
2525
SCCACHE_CACHE_SIZE: "50G"
26-
CRATES_LIST: "iroh,iroh-metrics,iroh-net,iroh-net-bench,iroh-test,iroh-cli,iroh-dns-server,iroh-router,netwatch,portmapper"
26+
CRATES_LIST: "iroh,iroh-metrics,iroh-net,iroh-net-bench,iroh-test,iroh-cli,iroh-dns-server,iroh-router,netwatch,portmapper,iroh-relay"
2727
IROH_FORCE_STAGING_RELAYS: "1"
2828

2929
jobs:

Cargo.lock

Lines changed: 65 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"iroh-test",
99
"iroh-net/bench",
1010
"iroh-cli",
11+
"iroh-relay",
1112
"iroh-router",
1213
"net-tools/netwatch",
1314
"net-tools/portmapper",

0 commit comments

Comments
 (0)