## Description
This allows to set `hostname = ["relay.foo.org", "relay.bar.org"]` in
the iroh-relay TOML config.
Setting a single string like previously, `hostname = "relay.foo.org"` ,
is still accepted as well, so this is not a breaking change to config
formats.
It also adds enviroment variables to override the ACME directory URL to
allow using the ACME adaptor with other servers than letsencrypt.
Finally, this adds a test script that tests the setup with a
locally-running `pebble` ACME server. I confirmed locally that it works.
Not sure if we want to run it in CI as well.
## 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. -->
- [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
The [README of the iroh
crate](https://github.com/n0-computer/iroh/tree/main/iroh) is the first
thing people see on https://crates.io/crates/iroh or
https://lib.rs/iroh, and we should improve it.
Right now it mostly talks about structured events, which is a very minor
thing in the grand scheme of things. And it has no code example.
This PR improves the README. Happy to discuss or iterate.
## Description
Updates to the latest noq main, especially due to this bug fix:
https://github.com/n0-computer/noq/pull/695
That fix makes `switch_client_dual_to_v4` non-flaky.
## Breaking Changes
None
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
## Description
This is a cleanup pass over all docs of public items. Fixes typos, odd
grammar, non-adherence to doc guidelines, and other minor things.
## Description
This PR adds a new `AccessConfig::SharedToken(Vec<String>)` variant to
the `iroh-relay` configuration,
allowing self-hosted relays to require a shared bearer token from
connecting
clients, without using an external auth service.
- Clients authenticate via `Authorization: Bearer <token>` header or
`?token=` query param,
using the existing `RelayConfig::with_auth_token()` /
`RelayMap::with_auth_token()` API;
- Token can be set via config file (`access.shared_token = ["token-a",
"token-b"]`) or the
`IROH_RELAY_ACCESS_TOKEN` environment variable (**the env var takes
precedence**);
- Empty token is rejected at startup;
- A token set to the empty string, will make the server fail to start.
[See related
discussion](https://github.com/n0-computer/iroh/discussions/4316)
## Breaking Changes
None.
## Notes & open questions
- As we stated in the discussion, using an external service should
always be considered the best choice for production. The static token
variant is still useful for simpler deployments.
- Supported the token list in config, as suggested by fokx
## Change checklist
- [x] Self-review
- [x] Documentation updates
- [x] Tests
Co-authored-by: fokx <36614441+fokx@users.noreply.github.com>
---------
Co-authored-by: Franz Heinzmann <frando@unbiskant.org>
## Description
This test is flaky because QAD fails to establish a connection within
3s due to the packet loss. At that point there's not relay server
until at least the next net-report which only runs after about 30s.
The right fix for this is for net-report to be more streaming instead
of running on a schedule. So iroh can respond to events from changed
network conditions properly.
## Breaking Changes
n/a
## Notes & open questions
See #4321 to track this.
## Change checklist
- [x] Self-review.
---------
Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com>
## Description
Updates `ed25519-dalek` to `=3.0.0-rc.0` and `curve25519-dalek` to
`=5.0.0-rc.0`. Not sure if the final release will be made in time. We
can do a minor release though once the final version comes out. It will
be "semi-breaking" but there's nothing we can do about it then (builds
will break for people who have `=3.0.0-rc.0` in their *own* Cargo.toml).
## Description
This makes the validation token store global for the endpoint. Before it
was recreated on each connection, which defeats the purpose of the
mechanism.
I had to do this to make the example in my blog post (
https://github.com/n0-computer/iroh.computer/pull/464 ) work at all.
For context: This is the client side store for NEW_TOKEN address
validation tokens that need to be presented on new connections for the
mechanism to work.
The mechanism is currently disabled on the **server side** because we
don't set the "bloom" feature flag on noq-proto ( noq-proto = { version
= "=1.0.0-rc.1", default-features = false } ). So if we connect to iroh
nodes with default features we *never* store any tokens because we never
get any.
## Breaking Changes
None
## Notes & open questions
Note: this whole thing feels weird. Since NEW_TOKEN tokens are of very
little utility for iroh connections (reason see blog post) I would
prefer if we would really disable the mechanism both on the client side
and the server side.
To do that I would like to move from the current approach of `Arc<dyn
TokenStore>` with a noop impl `NoneTokenStore` to an `Option<Arc<dyn
TokenStore>>` which is just `None` if the mechanism is disabled. The
same for the server side where we have `Arc<dyn TokenLog>` and
`NoneTokenLog`.
Note: we *can* change this without breaking the public API, but that
means that we still keep the NoneXXX impls around. See
https://github.com/n0-computer/noq/tree/rklaehn/refactor-token-log-2 .
But then ideally you would want to remove them and also provide an
option via the builder to disable them, which would be a public API
change.
Disabling it by default would mean that we would need a new public API
to enable it on the client side. This would be used rarely, only in
cases where you care about 0-rtt *and* payloads for 0-rtt that are big
enough to exceed the 3x amplification limit. I got some real world use
cases for this that I personally care about, involving a DHT, but most
iroh users would never have to touch this.
Note: when I say we should disable this by default I mean in iroh. In
noq as a generic QUIC impl this makes more sense to enable since normal
client server QUIC connections frequently have long cert chains that
exceed the amplification limit. Again, for context see the blog post
draft.
## 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 was an oversight. In general we should prefer potable_atomic since
it falls back to normal atomics on 64 bit but also works on 32 bit
platforms.
I think this should be uncontroversial since we already use portable
atomics elsewhere.
Needed to get iroh to work on esp32 and other 32 bit platforms.
## Breaking Changes
None
## Notes & open questions
Note: this is not a breaking change and does not need to go in before
1.0
## 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 changes iroh's implementation of `AsyncUdpSocket::poll_recv` to not
forward transport recv errors unconditionally.
When `AsyncUdpSocket::poll_recv` returns an error, noq aborts the
`EndpointDriver` (unless the error is `io::ErrorKind::ConnectionReset`,
in which case the driver continues). Aborting the `EndpointDriver` is
final, there is no recovery path from that in noq. An endpoint with a
dead driver will silently fail on most operations thereafter.
In iroh, we have multiple transports. Before this change, a single error
in any transport would kill the `noq::Endpoint`. We do not want this:
Even if the failure of a transport is real and final, there might still
be other transports. Additionally, our IP transports can recover from
errors, e.g. when a major network change notification triggers a rebind.
Finally, error semantics and whether they are final or transient are
obscure and platform-specific, see e.g. #4297.
Instead, we swallow and warn-log errors by default. If *all* configured
transports produce an error, we increment a counter. If the counter
reaches 8, we give up and return an error from `poll_recv`. We'll have
to see in practice if the number 8 is a good compromise here. The idea
is to not die on transient errors right away, but also not keep polling
a dead system forever.
In any case, with this change the noq Endpoint will survive as long as
*any* transport does not produce errors. Whereas before, we would kill
the endpoint even if there are healthy transports.
## 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
This adds a new mode to fully customize the `rustls::ServerCertVerifier`
used for non-iroh TLS requests throughout iroh, and renames
`CaRootsConifg` to `CaTlsConfig` (with a deprecated alias to keep
backwards compat). A new mode `CaTlsConfig::custom_server_cert_verifier`
allows to supply a callback that gets passed a `CryptoProvider` and
returns a `Arc<dyn ServerCertVerifier>`.
It is indended for advanced usecases like those described in #2901.
Fixes#2901
cc @link2xt
## Breaking Changes
None.
The following items have been deprecated:
- `iroh_relay::tls::CaRootsConfig` (also re-exported as
`iroh::tls::CaRootsConfig`), use `iroh_relay::tls::CaTlsConfig` instead
(also re-exported as `iroh::tls::CaTlsConfig`).
- `iroh_relay::tls::CaRootsConfig::custom`, use
`CaTlsConfig::custom_roots` instead
- `iroh::endpoint::Builder::ca_roots_config`,
use`iroh::endpoint::Builder::ca_tls_config` instead
## 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.
- [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
Don't log at warn level if the address lookup isn't configured.
This is a conscious choice that you don't want to be nagged about all
the time.
## Breaking Changes
<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->
## Notes & open questions
Note: another option would be to remove the
AddressLookupFailed::NoServiceConfigured entirely, but that would be
breaking a public API. So I just log that particular error at less than
warn to get rid of the log spam.
## 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
Did a quick pass over tracing logs when running the transfer example
with `RUST_LOG=iroh=debug`.
* Remove some nearly-duplicate lines by demoting one of the duplicates
to `trace`
* Remove duplicate `iroh::_event` for relay connections
* Remove duplicate span qualifier for pkarr publish
## Change checklist
<!-- Remove any that are not relevant. -->
- [x] Self-review.
## Description
Minor cleanups to the reqwest client builder util function:
* use non-deprecated `tls_backend_preconfigured` instead of
`use_preconfigured_tls` (change in reqwest 0.13)
* no need to wrap the DNS resolver in an Arc (change in reqwest 0.13)
* improve docs
## Change checklist
- [x] Self-review.
## Description
We upstreamed `MaybeFuture` to `n0-future`, so let's use it and remove
our own version in iroh's util module.
## Change checklist
- [x] Self-review.
## Description
Currently the relay client resolves a relay's hostname to a single
address and dials
only that one. A `prefer_ipv6` flag decides whether we query for an A or
AAAA record.
If the DNS query returns an unreachable AAAA record for whatever reason,
or we somehow
end in a state where `prefer_ipv6` is true but the machine does not
actually support IPv6,
then dialing the relay fails.
This PR fixes this by resolving both A and AAAA records and racing them
happy-eyeballs style: the addresses are tried in preference order, each
dial starting a short delay after the previous, and the
first connection to succeed wins while the rest are cancelled. The same
race
covers both direct and proxied relay connections.
Fixes#4069
## Notes & open questions
Also fixes a unrelated doc comment that was very weirdly written and
referred to, I think, some configuration from a very long time ago.
## 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
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>