## Description
Locally, `test_paths_watcher` and `endpoint_two_direct_add_relay` fairly
consistently failed for me.
I dug into `test_paths_watcher`, this was what was going on:
1. A new connection is established via IP path
2. The test waits for both relay and IP path to be established with a 1s
timeout
3. The connection immediately tries to add a relay path after it was
established via IP path, but it can't yet because of missing remote
CIDs, so it schedules a later path open for the relay path.
4. <lots and lots of path open events, many many new paths opened and
immedaitely closed>
5. Scheduled path open for the relay path triggers, but it fails because
MaxPathIdReached. Unlike RemoteCidsExhausted, it doesn't re-schedule
this path open.
6. 1s timeout triggers
The weird thing was that the max path ID limit wasn't increased. This
was because the hole-punched paths that were opened were never cleaned
up - no path was ever abandoned.
Digging deeper I found out that our logic for abandoning redundant IP
paths wasn't triggered when the newly hole-punched path wasn't better
than our current paths.
This PR fixes that.
During investigation I also found out that we would never re-try opening
the relay path in case you get a `MaxPathIdReached` error, which seems
bad, so now we explicitly handle this case as well.
## Breaking Changes
None
## Notes & open questions
Arguably, we could also decide to not match on the particular error that
causes us to not be able to open a path and always re-schedule path
opening on error?
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
## Description
If a path is abandoned on one connection we now leave it alone, if the
path is unusable other connections will abandon it in their own time.
Any scheduling on a bad path should be handled better inside
noq. Adding this complexity to iroh does not buy us much.
Supercedes #4245 and #4257.
## Breaking Changes
n/a
## Notes & open questions
n/a
## Change checklist
- [x] Self-review.
## Description
Previously noq always allowed the server to migrate during the
handshake. So now we just always override that setting.
## Breaking Changes
n/a
## Notes & open questions
Some tests manually create noq::TransportConfig, they have been manually
adjusted. From the public API this isn't possible.
## Change checklist
- [ ] Self-review.
## Description
Patches noq to https://github.com/n0-computer/noq/pull/672
Makes iroh successfully holepunch when the server is behind a hard NAT
and the client is behind an easy NAT. The reverse aready worked before.
## Breaking Changes
n/a
## Notes & open questions
(@flub hijacked this PR)
Once https://github.com/n0-computer/noq/pull/672 is merged I'll update
this PR to point to noq main again before merging.
## Change checklist
- [x] Self-review.
- [x] Tests if relevant.
---------
Co-authored-by: Floris Bruynooghe <flub@n0.computer>
## Description
An attempt to make path selection more flexible for complex custom
transport use cases.
Path selection is now via a dynable trait `PathSelector`. The only fn
select takes a `PathSelectionContext` that has the current path as well
as a way to iterate over a flat list of `PathSelectionData` structs.
`PathSelectionData` currently just has the address and the stats, but in
the future could be extended to contain more detailed information such
as the congestion controller metrics `noq_proto::ControllerMetrics` etc.
I think cc metrics would be quite helpful to make good decisions about
path selection.
`select` returns a PathSelection struct that is at this time a newtype
over an Option<Addr>. add is first writer wins, all subsequent calls
will ignore the addr and emit a warning. But we can change this in the
future to allow multiple addrs.
The entire mechanism is only pub under the `unstable-custom-transports`
flag, so we can change it in the future. But there are some additive
changes we could do without breakage. For example we could allow
PathSelection to also keep track of paths to be closed.
## Breaking Changes
Removes some public methods on the endpoint builder that are too
opinionated if you want to make path selection fully generic:
`endpoint::Builder::transport_bias(kind, bias)`: removed
`endpoint::transports::TransportBias`: removed
And some changes involving the unstable_custom_transport API.
## Notes & open questions
Note: the new signature tries to anticipate that in the future we might
want to select multiple transports, but as of now it will just ignore
these.
## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] 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.
- [ ] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
- [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
- [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
- [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
- [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
- [ ] [`sendme`](https://github.com/n0-computer/sendme)
---------
Co-authored-by: Frando <frando@unbiskant.org>
Co-authored-by: Floris Bruynooghe <flub@n0.computer>
Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com>
## Description
Replaces the `AccessConfig` with a new trait `AccessControl` with
`on_connect` and `on_disconnect` functions. `on_connect` returns the
`Access::Allow/Deny` enum, like the callback did previously.
To allow to revoke access dynamically, this now assigns each connection
a `ConnectionId` early on, and includes this id in the `on_connect` hook
(through `ClientRequest:::connection_id`). When the connection closes,
`on_disconnect` is called with the same id. This allows AccessControl
impls to maintain a map of active connections and their tokens, so that
when revoking a token no-longer permitted clients can be disconnected.
## Breaking Changes
Breaking Changes
- removed: `iroh_relay::server::AccessConfig` (enum) and
`iroh_relay::server::AccessCheck` (type alias), replaced by the new
`AccessControl` trait.
- changed: `iroh_relay::server::client::Client` is no longer public. It
had no public methods and could not be used from outside of the crate.
- changed: `iroh_relay::server::RelayConfig::access` is `Arc<dyn
DynAccessControl>` instead of `AccessConfig`.
`iroh_relay::server::http_server::RelayService::new` and
`iroh::test_utils::run_relay_server_with_access` take `Arc<dyn
DynAccessControl>` instead of `AccessConfig`.
- changed: `iroh_relay::server::Access::Deny` is now a struct variant
`Deny { reason: Option<String> }`; `Access` is no longer `Copy`.
- changed: `iroh_relay::server::ClientRequest::new` takes `(EndpointId,
ProtocolVersion, http::request::Parts)` instead of `(EndpointId,
http::request::Parts)`, i.e. it now also takes the negotiated protocol
version.
- changed:
`iroh_relay::protos::handshake::SuccessfulAuthentication::authorize_if`
takes `Access` instead of `bool`.
- changed: `iroh_relay::server::client::Config::new` takes
`(OnDisconnectGuard, RelayedStream, ProtocolVersion)` instead of
`(EndpointId, RelayedStream, ProtocolVersion)`, and the public
`Config::endpoint_id` field is replaced by `Config::guard`. Build the
guard with `OnDisconnectGuard::empty`, or use the value returned by
`SuccessfulAuthentication::authorize_with`.
- added: `iroh_relay::server::AccessControl`,
`iroh_relay::server::DynAccessControl`, `iroh_relay::server::AllowAll`,
`iroh_relay::server::ConnectionId`,
`iroh_relay::server::OnDisconnectGuard`.
## Notes & open questions
This is another alternative to #4274 and #4275
In contrast to 4275, this allows the AccessControl to close connections
by itself without requiring network roundtrips. However, for such
AccessControl impls it comes with the cost to maintain a connection
index.
See the `runtime_auth` test for how this looks in practice.
## Change checklist
<!-- Remove any that are not relevant. -->
- [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.
- [x] Tests if relevant.
- [x] All breaking changes documented.
## Description
Use a new `transport::FourTuple` throughout the send path. Adds a src
argument to CustomSender::poll_send. Replaces the recently added
`TransportFourTuple` with the new `transports::FourTuple`.
Motivations:
* We noted that it would be nicer if the TransportFourTuple introduced
in #4273 would be an enum, so that we cannot have mismatches between the
transport kinds of local and remote addresses. I agree. What prevented
it was that we had to convert to `transports::Addr` many times, which is
not free.
* I noticed that custom transports don't get a `src: Option<CustomAddr>`
in their `poll_send`. I think it should be there, because custom
transports *can* set a CustomAddr on which incoming packets were
received, so to mirror the features of the IP transport they should be
able to pin to an interface when replying as well, if the transport has
a notion of multiple interfaces
This PR fixes both by replacing the `remote_state::TransportFourTuple`
with a `transports::FourTuple` that is used throughout the send path,
including custom transports.
## Breaking Changes
* `iroh::endpoint::transports::CustomSender::poll_send` now has an
additional arg `src: Option<&CustomAddr>`
## Notes & open questions
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
- [ ] 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.
- [x] Tests if relevant.
- [x] All breaking changes documented.
## Description
Track the selected path in the RemoteStateActor by FourTuple.
Handling and exposing the local address is .. weird:
* For IP transports, it is the address of the local socket, if known
* For relay transports, we never set the local_ip in the recv meta.
* For custom transports, the custom transport implementation can set a
`CustomAddr` in `RecvMeta`, which we convert to a mapped addr with port
0 internally in the recv path
The address we get back from noq for a path is this address. We don't
want to ever expose mapped addresses, so we need to convert this address
into something else. We have a precedent: We recently introduced a
`IncomingLocalAddr` which is basically this.
So I decided to reuse this type and renam eit to `LocalTransportAddr`,
which mirrors `TransportAddr` nicely.
The conversions are nothing to be happy about, but I don't see a solid
alternative right now without larger refactors.
## Breaking Changes
* changed: The variants of `iroh::endpoint::PathEvent` are now marked
`#[non_exhaustive]`
* renamed: `iroh::endpoint::IncomingLocalAddr` ->
`iroh::endpoint::LocalTransportAddr`, and the `Relay` variant is now a
tuple variant
## Notes & open questions
Instead of reusing and renaming the exisitng `IncomingLocalAddr`, we
could also expose local_addr as `Option<LocalTransportAddr>`, with `enum
LocalTransportAddr { Ip(IpAddr), Custom(CustomAddr) }`, i.e. remove the
`Relay` case. I had this in an earlier version but then found yet
another public address type a bit too much so instead went for the
existing `IncomingLocalAddr`.
## Change checklist
<!-- Remove any that are not relevant. -->
- [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.
- [x] Tests if relevant.
- [x] All breaking changes documented.
## Description
Updates to the latest main, including `#[non_exhaustive]` changes to
`PathEvent`: https://github.com/n0-computer/noq/pull/648
## Notes & open questions
Adding a `#[cfg(test)] panic!()` to ensure we keep the versions in noq
and iroh in sync and see iroh tests failing when we add more path
events.
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
## Description
This makes `Endpoint::close` in most cases (no packet loss) much faster:
- It is basically instant (or rather - its performance independent of
the network) when all connections that were open were already closed
remotely (we waited for `connection.closed().await` before calling
`Endpoint::close`).
- It takes ~1 RTT (the worst RTT among all connections that is), when we
initiated the close locally immediately before calling
`Endpoint::close`. The round trip is the CONNECTION_CLOSE frame going
one way and coming back. This only works if we didn't experience any
packet loss.
Fixes https://github.com/n0-computer/iroh/issues/4201
This is a sort of "batch" of work to make this happen:
- It depends on the noq feature to only wait for *entering* the draining
state, not exiting it, allowing us to close the socket earlier:
https://github.com/n0-computer/noq/pull/651
- It fixes [a
bug](https://github.com/n0-computer/iroh/blob/main/iroh/src/socket/transports.rs#L252-L254)
where we cut off all packet receiving after *entering* `Endpoint::close`
(this is too early! it doesn't allow `noq::Endpoint::wait_idle` to do
its job!)
- It fixes another bug in `Runtime::close` where that would always wait
for all `EndpointDriver` and `ConnectionDriver`s to run to completion,
even if we know we can short-circuit (because we know we've waited for
`wait_idle`!).
It also contains some small logging impovements (I was able to remove
`Socket::public_key` because it was only used for logging in a redundant
way).
## Breaking Changes
None.
## Notes & open questions
- [x] Depends on one noq PR to be merged.
## Change checklist
<!-- Remove any that are not relevant. -->
- [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.
## Description
Adds a regression test and fix for this bug:
When a RemoteStateActor is terminating, and a new message to the actor
is sent *before* `poll_cleanup` is called, we would check if the sender
is closed and, if so, spawn a new RemoteStateActor. When `poll_cleanup`
then processes the task of the terminated actor, it would
unconditionally remove the sender of the just-spawned actor.
## Notes & open questions
I am pretty sure my solution is fine, but would like an additional set
of eyes. I'm also thinking if we can add a small abstraction to make
this more foolproof, but not sure. Let's get the fix in first.
## 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.
- [x] Tests if relevant.
- [x] All breaking changes documented.
---------
Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com>
## Description
Define the list of allowed types per crate instead of globally, and add
a `cargo make` task to run the checks locally.
## Change checklist
- [x] Self-review.
## Description
`Endpoint::connect` starts a RemoteStateActor with a `ResolveRemote`
message that contains a oneshot sender as reply channel. The
RemoteStateActor starts address lookup, and triggers the reply channel
when the first result arrives. The RemoteStateActor has an idle timeout
of 60s. Before this fix, we did not check for pending resolve requests
when the idle timeout expires: The actor stopped and the reply channel
sender are dropped, which propagated as `InternalConsistencyError` back
to the caller.
This PR fixes it such that we only consider a RemoteStateActor to be
idle when there are no outstanding `ResolveRemote` requests.
Fixes#4265 and comes with a regression test.
## Notes & open questions
With this change, `Endpoint::connect` will hang forever if the
configured AddressLookup services remain pending forever (i.e. don't
return any results and don't close their result stream). Will address
this in a followup.
## 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.
- [x] Tests if relevant.
## Description
By splitting the `RemoteStateActor` struct into `connections` and
`state`, we can write and use util methods on `state` while also mutably
borrowing into `connections`. This e.g. allows us to have
`open_path_on_conn` to repeat less code.
## 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.
## Description
We currently pass a `WeakConnectionHandle` to the `RemoteStateActor`
when a connection's handshake completed, but then await until the actor
confirms the registration, to then resolve to user code with the
connection. So we *always* keep the connection alive until the actor
confirms, which means there's no benefit to downgrading and upgrading
here. The change saves us one fallible upgrade and a level of
indentation in the RemoteStateActor with no downsides.
## Change checklist
- [x] Self-review.
Fixes https://github.com/n0-computer/iroh/issues/4252
`musl-gcc -static` produces an `ET_EXEC` binary using musl's `Scrt1.o`,
but `rustc` with `+crt-static` was linking its bundled `rcrt1.o` (the
static-PIE startup) into the same image. The PIE startup code then
treats the absent `.dynamic` section as `_DYNAMIC == 0` and segfaults in
`_start_c` before reaching `main`.
Adding `-C relocation-model=static` makes rustc pick the non-PIE
`crt1.o`, which matches the ET_EXEC output and yields a fully static,
truly portable binary. Verified on the x86_64 musl CI runner against
Alpine, Ubuntu 22.04, Ubuntu 24.04, and Debian bookworm.
## Description
<!-- A summary of what this pull request achieves and a rough list of
changes. -->
## Breaking Changes
<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->
## Notes & open questions
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] 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.
- [ ] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
- [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
- [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
- [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
- [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
- [ ] [`sendme`](https://github.com/n0-computer/sendme)
## Description
Waiting for stopped when the peer is about to shutdown is flaky and
not the recommended shutdown protocol. The CONNECTION_CLOSE could be
sent before all packets have been acked. And if the close arrives
before some acks then stopped (on the server) will fail with an
error.
CONNECTION_CLOSE is supposed to include any un-acked packets, but this
is only a best-effort and not a guarantee. This may not include all
packets if an ACK was already considered in-flight.
## Breaking Changes
n/a
## Notes & open questions
QUIC shutdown, it still gets us...
## Change checklist
- [x] Self-review.
- [x] Tests if relevant.
> Updated version of #4231
Embedders that mount the relay protocol via custom HTTP servers (e.g.
axum integration in holochain/kitsune2) cannot use the existing
RateLimited<S: AsyncRead> wrapper because their stream layer is already
WS-framed by the time the relay handler runs. Exposing Bucket lets these
embedders apply iroh's bucket semantics at the frame layer.
Visibility-only change: Bucket struct, Bucket::new and Bucket::consume
become pub. Fields stay private. InvalidBucketConfig was already pub.
Adds rustdocs to satisfy deny(missing_docs).
No behavior change.
Co-authored-by: Christian Visintin <christian.visintin@veeso.dev>
## Description
This replaces the current `PathWatcher` with a new combination of primitives.
- `Connection::paths` returns `PathList<'conn>`, a list of the currently-open paths. Iteration yields `Path<'conn>` with access to the remote address, selection state, and path stats. The `PathList` is a snapshot in time (ie., once returned from `Connection::paths` won't change for changes in the path list). It is also lifetime-bound to the `Connection` (which gives us unconditional access to path stats right out of the noq state).
- `Connection::path_events()` returns a `PathEventStream` of path events. This stream is lifetime-free, can be sent to other tasks, and does not keep the `Connection` alive. The subscription is registered immediately at call time so pairing it with a subsequent `paths()` read produces a race-free check-then-wait loop.
- `Connection::paths_stream` returns a stream that yields `PathList<'conn>` whenever the path list changes (ie. on path open/close or selection change)
`PathEvent` has four variants: `Opened`, `Closed` (with `last_stats` inline), `Selected`, and a `Lagged` (with the missed count) to account for the (rare) case of a broadcast stream lag.
Closed paths are no longer retained in `Paths`. Consumers that need totals over the connection's lifetime accumulate from `PathEvent:: Closed`; the `transfer.rs` example's `spawn_stats_collector` demonstrates this pattern.
Internally, the path store splits into two handles sharing an `Mutex<State>`, containing a `SmallVec` of `(PathId, TransportAddr)` plus the selected path id. `PathStateSender`, owned by the `RemoteStateActor`, is the sole mutator and holds the broadcast `Sender`. `PathStateReceiver`, held by the `Connection`, reads via `ArcSwap` and subscribes via a `WeakSender`. When the `ConnectionState` is dropped, the broadcast `Sender` is dropped with it and outstanding event streams end naturally; new subscriptions on a closed connection where the remote state actor already dropped its state then yield an already-closed stream.
Final per-path statistics now come from `noq::Closed::path_stats` at connection close time, via https://github.com/n0-computer/noq/pull/617.
## Breaking Changes
- removed: `iroh::endpoint::PathWatcher`, `iroh::endpoint::PathInfo`, `iroh::endpoint::PathInfoList`, `iroh::endpoint::PathInfoListIter`.
- changed: `Connection::paths` returns `PathList<'_>` instead of `PathWatcher`. `Path<'_>` replaces `PathInfo`; `Path::stats` is now infallible
- changed: `ConnectionInfo::paths` is removed in favour of `ConnectionInfo::path_events`. `ConnectionInfo::selected_path` now returns `Option<TransportAddr>` instead of `Option<PathInfo>`.
- added: `iroh::endpoint::Path`, `iroh::endpoint::Paths`, `iroh::endpoint::PathEvent` (with `Opened`, `Closed`, `Selected`, `Lagged` variants), `iroh::endpoint::PathEventStream`, `Connection::path_events`, `ConnectionInfo::path_events`.
## 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).
- [x] Tests updated.
- [x] All breaking changes documented.
## Description
Makes the `iroh::endpoint::transports` module gated behind the
`custom-transports` feature.
## Breaking Changes
- changed: `iroh::endpoint::transports` is now gated on the
`unstable-custom-transports` feature
## Change checklist
- [x] Self-review.
- [x] All breaking changes documented.
## Description
This changes the logic how we apply a change in path selection. We now
consistently set the selected path to `PathStatus::Available`, and all
non-selected paths to `PathStatus::Backup`. It also unifies the
application of the path status and the closing of redundant IP paths
into a single loop over all connections and paths.
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
## Description
Removes the `portmapper` crate from the public API of `iroh`. The
`portmapper::Metrics` were re-exported as
`iroh::metrics::PortmapMetrics` and held in
`EndpointMetrics::portmapper`, which forced the `portmapper` crate into
our public API and our `external-types.toml` allow-list.
In its place, `iroh::metrics::NetReportMetrics` gains two minimal
counters: `portmap_attempts` and `portmap_external_address_updated`.
These are incremented from the socket actor when a port mapping is
requested and when the watcher reports a new external address. The
internal `portmapper` module no longer takes an `EndpointMetrics` and
constructs the underlying portmapper client with its default metrics.
The `metrics` feature no longer toggles the `portmapper/metrics`
feature, since portmapper's own metrics are no longer exposed.
## Breaking changes
- removed: `iroh::metrics::PortmapMetrics` re-export.
- removed: `iroh::metrics::EndpointMetrics::portmapper` field.
- added: `iroh::metrics::NetReportMetrics::portmap_attempts` counter.
- added:
`iroh::metrics::NetReportMetrics::portmap_external_address_updated`
counter.
- changed: the `metrics` feature no longer enables `portmapper/metrics`.
## Change checklist
- [x] Self-review.
- [x] All breaking changes documented.
## Description
This is the part of https://github.com/n0-computer/iroh/pull/4232 that
removes something from the non feature gated public API.
If (as seems likely) we won't get
https://github.com/n0-computer/iroh/pull/4232 in for this release, this
would prevent having to break the stable (non feature gated) public API
when adding https://github.com/n0-computer/iroh/pull/4232 in the next
release.
## Breaking Changes
Removes some public methods on the endpoint builder that are too
opinionated if you want to make path selection fully generic:
endpoint::Builder::transport_bias: removed from the public api
endpoint::transports::TransportBias: removed from the public api
## Notes & open questions
Note: I did a quick check in all notable custom transports I am aware
of:
n0-computer/iroh-tor-transport
n0-computer/iroh-nym-transport
mcginty/iroh-ble-transport
None of them does use transport_bias, not even in examples. Most of them
just remove the ip transport. So this won't break any downstream crate I
am aware of.
## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] 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.
- [ ] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
- [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
- [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
- [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
- [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
- [ ] [`sendme`](https://github.com/n0-computer/sendme)
## Description
This adds an `auth_token` field to `RelayConfig`. The client sends the
token to the relay so the relay can decide whether to admit the
connection.
On native targets the token is sent as an `Authorization: Bearer TOKEN`
header on the WebSocket upgrade request. In browsers, where you can't
set headers on WebSocket requests, it is sent as a `?token=TOKEN` query
parameter instead.
On the server side, `ClientRequest::auth_token()` (passed to the
`AccessConfig::Restricted` hook) returns the token regardless of which
path the client used. It accepts the `Bearer` scheme case-insensitively,
walks all `Authorization` headers, and falls back to the `token` query
parameter if no header carries one.
## Breaking Changes
None against 0.98. Against main:
* removed: `iroh_relay::client::ClientBuilder::query_param(key, value)`
(was added in #4207). Replaced by [`ClientBuilder::auth_token`] for the
currently intended use case; arbitrary URL query parameters on the
upgrade request are no longer settable on the client for now.
* changed: `iroh_relay::server::AccessCheck` type alias. The returned
future may now borrow from the `&ClientRequest` argument: `for<'a>
Fn(&'a ClientRequest) -> Pin<Box<dyn Future<Output = Access> + Send +
'a>>` instead of `Fn(&ClientRequest) ->
n0_future::future::Boxed<Access>`. Closures that build the future with
`async move { ... }.boxed()` keep compiling.
## Notes & open questions
* How do we want people to set a relay auth token in iroh? This PR does
it via a new field in `RelayConfig` (plus `RelayMap::with_auth_token` to
apply one token across all entries). That works for entries in the relay
map, but there's no way to set a token for a relay URL that wasn't in
the map (e.g. one that comes back from address lookup).
* There's no way to surface a failed authentication to the user
currently, all you get is warn logs.
## 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.
## Description
Adds two integration tests that demonstrate embedding the relay inside
an external HTTP server:
- `tests/relay_hyper.rs`: serves a `RelayServiceWithNotify` directly via
hyper.
- `tests/relay_axum.rs`: uses axum, its `Router` and its
`WebSocketUpgrade` for the `/relay` route. Then passes the client stream
to the relay `Clients`. Does not use `RelayServeWthNotfy`.
Also exports the type aliases
`iroh_relay::server::http_server::BytesBody`, `HyperError`, and
`HyperResult` so that external code can name the response and error
types of `RelayServiceWithNotify`'s hyper service.
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
## Description
Updates `noq` and adapts iroh to the changes in
https://github.com/n0-computer/noq/pull/617 by reexporting
`noq::Closed`.
## Breaking Changes
* changed: The `OnClosed` future returned from
`iroh::endpoint::WeakConnectionHandle::closed` now resolves to
`iroh::endpoint::Closed`, a struct with public fields for the close
reason, connection stats, and path stats.
## Notes & open questions
It would be nice to have the `TransportAddr` available for the path
stats, but we don't have that info available for paths that were already
closed earlier. Use the new APIs in #4188 instead if this needed.
## Change checklist
<!-- Remove any that are not relevant. -->
- [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.
- [x] Tests if relevant.
- [x] All breaking changes documented.
## Description
When constructing our DnsResolver we call into
`hickory_resolver::read_system_conf`, which on Android uses JNI by going
through `ndk_context` to call `LinkProperties.getDnsServers()`. This
works fine when `ndk_context` has been initialized with a real `JavaVM`
and `Application` context but panics unconditionally if `ndk_context`
has not been initialized. The initialization can either be done manually
or, usually, through a glue crate like `android-activity` or `ndk-glue`.
This means that constructing an iroh endpoint on Android panics if
`ndk_context` hasn't been initialized.
This PR documents the Android requirement and adds an init helper. Using
iroh on Android requires `ndk_context` to be initialized before the
resolver is constructed, otherwise the build panics at the JNI boundary.
The PR adds docs around that on `DnsResolver`,
`Builder::with_system_defaults`, and `Endpoint`, and re-exports the
`ndk_context` init function as `iroh_dns::install_android_jni_context`
so that consumers can init manually. The system-DNS fallback log was
also bumped from `debug` to `warn` so the silent-fallback path actually
surfaces.
Finally, this PR adds CI to run the full iroh test suite in the Android
emulator. When running unit tests in the emulator, we don't have a Java
context. To bypass the panic in debug builds (which is what the test
suite runs as) we wrap the JNI call in `std::panic::catch_unwind` and
let the resolver fall back to public DNS if the ndk_context call panics
(which it does). Release builds let the panic propagate, since
uninitialized `ndk_context` in production is a programming error and
should surface loudly. This is a little ugly I admit, but I have not
found another way around this. Very open to suggestions. But - the test
suite passes! Had to do a couple of tricks to properly wait for
networking on the GitHub-hosted emulator. One regression test in
`iroh/src/socket.rs` is ignored on Android because the emulator's
network stack flakes on rapid rebinds. Will open an issue for that.
## Breaking Changes
## Notes & open questions
Follow-up PRs:
* #4209 adds an APK-based smoke test that exercises the JNI path through
a real `NativeActivity` against `ConnectivityService`.
## 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.
- [x] Tests if relevant.
- [x] All breaking changes documented.
## Description
We see those as hex in the logs because that is how you display an
IPv6 address. So write them in hex, it's easier to recognise things
that way.
## Breaking Changes
none
## Notes & open questions
Please double check I didn't make any mistakes converting decimal to
hex.
## 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.
## Description
- Updates to latest noq main & applies fixes
- Renames `QuicTransportConfig::set_max_remote_nat_traversal_addresses`
to `QuicTransportConfig::max_remote_nat_traversal_addresses` for
consistency with noq & other configuration function names
- Changes the defaults for maximum number of QNT addresses and multipath
paths according to discussions in
https://github.com/n0-computer/noq/issues/613 and
[here](https://github.com/n0-computer/noq/pull/620#pullrequestreview-4196031518)
## Breaking Changes
- Renamed `QuicTransportConfig::set_max_remote_nat_traversal_addresses`
to `QuicTransportConfig::max_remote_nat_traversal_addresses`
## Change checklist
<!-- Remove any that are not relevant. -->
- [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.
- [x] All breaking changes documented.
- [x] List all breaking changes in the above "Breaking Changes" section.
---------
Co-authored-by: dignifiedquire <me@dignifiedquire.com>
Co-authored-by: Floris Bruynooghe <flub@n0.computer>
## Description
Adds `#[non_exhaustive]` to more public structs and enums, so that
fields and variants can be added without a breaking change.
For each struct that has at least one field without a reasonable default
a `new()` constructor is added that takes those required values and
leaves the rest at their defaults. Remaining fields are then assigned
through their public field directly. Structs that already had a
`Default` impl keep it.
Internal callers (the `iroh-relay` binary, `iroh::test_utils`, and the
patchbay integration tests) are updated to use the new constructors and
field assignment instead of struct literals.
## Breaking changes
`iroh-base`:
- `iroh_base::endpoint_addr::CustomAddrParseError` is now
`#[non_exhaustive]`.
`iroh`:
- `iroh::endpoint::BeforeConnectOutcome` is now `#[non_exhaustive]`.
- `iroh::endpoint::AfterHandshakeOutcome` is now `#[non_exhaustive]`.
`iroh-relay`:
- `iroh_relay::server::ServerConfig` is now `#[non_exhaustive]`. Already
had a `Default` impl; construct via `ServerConfig::default()` and assign
fields, e.g. `let mut c = ServerConfig::default(); c.relay =
Some(...);`.
- `iroh_relay::server::RelayConfig` is now `#[non_exhaustive]`. Added
`RelayConfig::new(http_bind_addr: impl Into<SocketAddr>) -> Self`, which
leaves `tls = None`, `limits = Limits::default()`, `key_cache_capacity =
None`, and `access = AccessConfig::Everyone`.
- `iroh_relay::server::AccessConfig` is now `#[non_exhaustive]`.
- `iroh_relay::server::QuicConfig` is now `#[non_exhaustive]`. Added
`QuicConfig::new(bind_addr: impl Into<SocketAddr>) -> Self`.
- `iroh_relay::server::TlsConfig` is now `#[non_exhaustive]`. Added
`TlsConfig::new(https_bind_addr: impl Into<SocketAddr>, cert:
CertConfig) -> Self`.
- `iroh_relay::server::Limits` is now `#[non_exhaustive]`. Use the
`Default` impl and then set fields as needed.
- `iroh_relay::server::ClientRateLimit` is now `#[non_exhaustive]`.
Added `ClientRateLimit::new(bytes_per_second: NonZeroU32) -> Self`,
which leaves `max_burst_bytes = None`.
- `iroh_relay::server::CertConfig` is now `#[non_exhaustive]`.
- `iroh_relay::server::client::Config<S>` is now `#[non_exhaustive]`.
Added `Config::new(endpoint_id: EndpointId, stream: RelayedStream<S>,
protocol_version: ProtocolVersion) -> Self`, which fills `write_timeout`
from `defaults::timeouts::SERVER_WRITE_TIMEOUT` and `channel_capacity`
from `protos::relay::PER_CLIENT_SEND_QUEUE_DEPTH`.
- `iroh_relay::http::ProtocolVersion` is now `#[non_exhaustive]`.
- `iroh_relay::protos::handshake::Mechanism` (cfg `server`) is now
`#[non_exhaustive]`.
`iroh-dns-server`:
- `iroh_dns_server::config::DnsConfig` is now `#[non_exhaustive]`. Added
`DnsConfig::new(port: u16, default_soa: String, default_ttl: u32,
origins: Vec<String>) -> Self`, which leaves `bind_addr = None` and the
apex `rr_a`, `rr_aaaa`, `rr_ns` records at `None`. There is no `Default`
impl: SOA, origins and port are deployment-specific and have no neutral
default.
## 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.
- [x] All breaking changes documented.
## Description
`iroh::endpoint::Source` wasn't used in any public API anymore, so this
makes the enum `pub(crate)`. We also had many unused variants, those are
removed. The `_0: Private` marker is removed as well now that the enum
is not public anymore.
Also removes the `IpPort` type from `socket::remote_map`, which was
`pub` but neither re-exported nor used anywhere.
## Breaking changes
- removed: `iroh::endpoint::Source`. The type is now `pub(crate)` in
`iroh::socket::remote_map` and is not part of the public API.
## 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.
- [x] Tests if relevant.
- [x] All breaking changes documented.
## Description
Foreign types in our public API block semver-breaking updates of those
crates during 1.0. #3177 tracks reducing that surface to a curated
allow list.
This adds a `check_external_types` CI job that runs
[`cargo-check-external-types`] against all workspace crates against a
shared `external-types.toml` at the workspace root.
Closes#3177.
[`cargo-check-external-types`]:
https://github.com/awslabs/cargo-check-external-types
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
- [ ] 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.
- [ ] All breaking changes documented.
## Description
Zip is slow, so we already prefer a manual loop in one place. This makes
loop use consistent over all similar places.
Possibly more notably there is a semantic change. Functions will now
always panic early when given buffers of different size, whereas zip
just ignores the extra items in the second and third buffer.
## Breaking Changes
None
## Notes & open questions
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] 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.
- [ ] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
- [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
- [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
- [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
- [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
- [ ] [`sendme`](https://github.com/n0-computer/sendme)
## Description
Prefer release assert for locations where a bounds check follows. The
compiler has to insert a bounds check in release mode for the array
access if the bounds check is not present, so there is no runtime cost
for this.
Also it gives better panic messages in case of a buggy noq_udp UDP
socket impl or a very broken custom transport impl.
## Breaking Changes
None
## Notes & open questions
<!-- Any notes, remarks or open questions you have to make about the PR.
-->
## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] 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.
- [ ] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
- [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
- [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
- [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
- [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
- [ ] [`sendme`](https://github.com/n0-computer/sendme)