Files
iroh/deny.toml
Franz Heinzmann c23446ce2e feat(relay): allow updating the per-client rate limit live (#4381)
## Description

Currently, in the relay server, the per-client receive rate limit is
fixed when a connection was accepted: `RelayService` stores the rate
limit config immutably, so changing the rate limit is only possible
through rebuilding the service and dropping its live connections.

This PR puts the rate behind a `watch` channel instead. Each accepted
connection subscribes a receiver, and `RateLimited` reconfigures its
bucket on the next read whenever the value changes.
`RelayService::set_client_rate_limit` is a new public function to change
the rate limit for this `RelayService`.

It uses `tokio:::sync::watch` and not `n0_watcher`, because checking
whether the rate limit changed is on the hot path (on each `poll_read`
of the underlying socket), and in tokio's watch channel, checking wether
the value changed is a single atomic load, whereas in n0_watcher,
checking if changed aquires a ReadLock.

## Breaking Changes

None. One API addition:
`iroh_relay::server::RelayService::set_client_rate_limit`.

## Notes & open questions

We need this in iroh services to update the rate limit for a project
once it reaches its spend cap. This will work because each tenant in the
multitenant relays is a `RelayService` each internally.

## 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.
- [x] This PR was created by a human that thought critically about the
      proposed change and wrote an as clear and concise description as
      they could.
- [x] This PR isn't slop, and is carefully crafted to do have the
      intented effect.
2026-07-03 11:26:44 +02:00

32 lines
1.0 KiB
TOML

[bans]
multiple-versions = "allow"
deny = ["native-tls", "openssl"]
[licenses]
allow = [
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"BSD-2-Clause",
"BSD-3-Clause",
"BSL-1.0", # BOSL license
"CDLA-Permissive-2.0", # Community Data License Agreement Permissive 2.0 due to webpki-root-certs
"ISC",
"MIT",
"Zlib",
"MPL-2.0", # https://fossa.com/blog/open-source-software-licenses-101-mozilla-public-license-2-0/
"Unicode-3.0",
"Unlicense", # https://unlicense.org/
]
[advisories]
ignore = [
"RUSTSEC-2024-0436", # paste -> netlink-packet-core
"RUSTSEC-2023-0089", # unmaintained: postcard -> heapless -> atomic-polyfill
"RUSTSEC-2026-0194", # netwatch -> netdev -> plist -> quick-xml: remove once https://github.com/ebarnard/rust-plist/pull/191 is released
"RUSTSEC-2026-0195", # netwatch -> netdev -> plist -> quick-xml: remove once https://github.com/ebarnard/rust-plist/pull/191 is released
]
[sources]
allow-git = []