352 Commits

Author SHA1 Message Date
Thomas Eizinger
00a3940717 chore(rust): introduce tokio workspace dependency (#5821)
We are referencing the `tokio` dependency a lot and it makes sense to
ensure that version is tracked only once across the whole workspace.

Extracted out of #5797.

---------

Co-authored-by: Not Applicable <ReactorScram@users.noreply.github.com>
2024-07-10 23:40:34 +00:00
Thomas Eizinger
0c2648dae2 test(connlib): correctly scope state within tunnel_test (#5809)
Currently, the type hierarchy within `tunnel_test` is already quite
nested: We have a `Host` that wraps a `SimNode` which wraps a
`ClientState` or `GatewayState`. Additionally, a lot of state that is
actually _per_ client or _per_ gateway is tracked in the root of
`ReferenceState` and `TunnelTest`. That makes it difficult to introduce
multiple gateways / clients to this test.

To fix this, we introduce dedicated `RefClient` and `RefGateway` states.
Those track the expected state of a particular client / gateway.
Similarly, we introduce dedicated `SimClient` and `SimGateway` structs
that track the simulation state by wrapping the corresponding
system-under-test: `ClientState` a `GatewayState`.

This ends up moving a lot of code around but has the great benefit that
all the state is now scoped to a particular instance of a client or a
gateway, paving the way for creating multiple clients & gateways in a
single test.
2024-07-10 23:22:19 +00:00
Thomas Eizinger
9caca475dc test(connlib): introduce routing table to tunnel_test (#5786)
Currently, `tunnel_test` uses a rather naive approach when dispatching
`Transmit`s. In particular, it checks client, gateway and relay
separately whether they "want" a certain packet. In a real network,
these packets are routed based on their IP.

To mimic something similar, we introduce a `Host` abstraction that wraps
each component: client, gateway and relay. Additionally, we introduce a
`RoutingTable` where we can add and remove hosts. With these things in
place, routing a `Transmit` is as easy as looking up the destination IP
in the routing table and dispatching to the corresponding host.

Our hosts are type-safe: client, gateway and relay have different types.
Thus, we abstract over them using a `HostId` in order to know, which
host a certain message is for. Following these patches, we can easily
introduce multiple gateways and relays to this test by simply making
more entries in this routing table. This will increase the test coverage
of connlib.

Lastly, this patch massively increases the performance of `tunnel_test`.
It turns out that previously, we spent a lot of CPU cycles accessing
"random" IPs from very large iterators. With this patch, we take a
limited range of 100 IPs that we sample from, thus drastically
increasing performance of this test. The configured 1000 testcases
execute in 3s on my machine now (with opt-level 1 which is what we use
in CI).

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
2024-07-09 01:48:54 +00:00
Thomas Eizinger
28d5b8574c chore(connlib): minor logging tweaks (#5746)
Noticed a few things that caused unnecessary verbosity in the logs.
2024-07-05 14:45:32 +00:00
Jamil
60d2a2befd fix(infra): relay listens on UDP only (#5718)
I don't believe we use/need TCP for the Relays. Better to keep the ports
closed if so.

Also, the docker-compose.yml is updated to allow the `relay-1` service
to respond to all its ports, since we don't need those mapped typically.
2024-07-04 16:53:08 +00:00
Thomas Eizinger
b5fd980fb2 fix(relay): don't log all request failures on the same level (#5622)
Currently, the relay logs all failed requests on WARN. This is a bit
excessive because during normal operation, clients are expected to hit
several 401s due to stale or missing nonces.

In order to not flood the logs with these, we introduce a new type,
`ResponseErrorLevel` that represents the subset of `tracing::Level` that
`make_error_response` can log:

- `Warn`
- `Debug`

Both variants mapping to the variants in `tracing::Level` with the same
name, and the function will log accordingly.

So now the caller can pick what level of error is meant to be used and
reduce the noise on the logs when it's meant to be part of normal
operation.

Fixes: #5490.

---------

Co-authored-by: conectado <gabrielalejandro7@gmail.com>
2024-06-29 02:38:55 +00:00
dependabot[bot]
fb5bda81e8 build(deps): Bump derive_more from 0.99.17 to 0.99.18 in /rust (#5395)
Bumps [derive_more](https://github.com/JelteF/derive_more) from 0.99.17
to 0.99.18.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/JelteF/derive_more/blob/v0.99.18/CHANGELOG.md">derive_more's
changelog</a>.</em></p>
<blockquote>
<h2>0.99.18 - 2024-06-15</h2>
<ul>
<li>Update syn to version 2.x</li>
<li>Bump minimum supported rust version to 1.65</li>
</ul>
<h2>0.99.10 - 2020-09-11</h2>
<h3>Improvements</h3>
<ul>
<li><code>From</code> supports additional types for conversion:
<code>#[from(types(u8, u16))]</code>.</li>
</ul>
<h2>0.99.7 - 2020-05-16</h2>
<h3>Fixes</h3>
<ul>
<li>Fix generic derives for <code>MulAssign</code></li>
</ul>
<h3>Improvements</h3>
<ul>
<li>When specifying specific features of the crate to only enable
specific
derives, the <code>extra-traits</code> feature of <code>syn</code> is
not always enabled
when those the specified features do not require it. This should speed
up
compile time of <code>syn</code> when this feature is not needed.</li>
</ul>
<h2>0.99.6 - 2020-05-13</h2>
<h3>Improvements</h3>
<ul>
<li>Make sure output of derives is deterministic, for better support in
rust-analyzer</li>
</ul>
<h2>0.99.5 - 2020-03-28</h2>
<h3>New features</h3>
<ul>
<li>Support for deriving <code>Error</code>!!! (many thanks to <a
href="https://github.com/ffuugoo"><code>@​ffuugoo</code></a> and <a
href="https://github.com/tyranron"><code>@​tyranron</code></a>)</li>
</ul>
<h3>Fixes</h3>
<ul>
<li>
<p>Fix generic bounds for <code>Deref</code> and <code>DerefMut</code>
with <code>forward</code>, i.e. put <code>Deref</code>
bound on whole type, so on <code>where Box&lt;T&gt;: Deref</code>
instead of on <code>T: Deref</code>.
(<a
href="https://redirect.github.com/JelteF/derive_more/issues/114">#107</a>)</p>
</li>
<li>
<p>The <code>tests</code> directory is now correctly included in the
crate (requested by
Debian package maintainers)</p>
</li>
</ul>
<h2>0.99.4 - 2020-03-28</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="678a4735bc"><code>678a473</code></a>
chore: Release derive_more version 0.99.18</li>
<li><a
href="fcde5568cb"><code>fcde556</code></a>
Include example published package</li>
<li><a
href="89cbd82959"><code>89cbd82</code></a>
Remove track_caller feature detection because msrv was bumped</li>
<li><a
href="db36f6dade"><code>db36f6d</code></a>
Fix question marks</li>
<li><a
href="f0c2530255"><code>f0c2530</code></a>
fmt</li>
<li><a
href="461db95716"><code>461db95</code></a>
Fix issue when compiling on 1.65</li>
<li><a
href="39ad36fd71"><code>39ad36f</code></a>
Update changelog for v0.99.18</li>
<li><a
href="57b6e1746e"><code>57b6e17</code></a>
Update to syn 2</li>
<li><a
href="ea4fa94003"><code>ea4fa94</code></a>
Fix tests</li>
<li><a
href="ab82aef0bf"><code>ab82aef</code></a>
Ignore error doctests as it still contains old backtrace logic</li>
<li>Additional commits viewable in <a
href="https://github.com/JelteF/derive_more/compare/v0.99.17...v0.99.18">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=derive_more&package-manager=cargo&previous-version=0.99.17&new-version=0.99.18)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-24 21:39:08 +00:00
Thomas Eizinger
cf9f7504ce chore(relay): be more lenient with debug-assertions (#5367)
Some of the debug-assertions in the relay are a bit too strict.
Specifically, if an allocation times out because it is not refreshed, we
also clean-up all channel bindings associated with that allocation. Yet,
if an existing channel binding has already been removed earlier, it will
no longer be present in the respective map.

This isn't an issue at all. We can simply change the debug-assertion to
only compare what used to be present in the map. What really matters is
that the item we just removed does in fact point to the data that we are
expecting.

Related: #5355.
2024-06-14 06:07:15 +00:00
Jamil
7e533c42f8 refactor: Split releases for Clients and Gateways (#5287)
- Removes version numbers from infra components (elixir/relay)
- Removes version bumping from Rust workspace members that don't get
published
- Splits release publishing into `gateway-`, `headless-client-`, and
`gui-client-`
- Removes auto-deploying new infrastructure when a release is published.
Use the Deploy Production workflow instead.

Fixes #4397
2024-06-10 16:47:49 +00:00
dependabot[bot]
dfbfbbe8c9 build(deps): Bump tokio from 1.37.0 to 1.38.0 in /rust (#5193)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.37.0 to 1.38.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/tokio-rs/tokio/releases">tokio's
releases</a>.</em></p>
<blockquote>
<h2>Tokio v1.38.0</h2>
<p>This release marks the beginning of stabilization for runtime
metrics. It
stabilizes <code>RuntimeMetrics::worker_count</code>. Future releases
will continue to
stabilize more metrics.</p>
<h3>Added</h3>
<ul>
<li>fs: add <code>File::create_new</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6573">#6573</a>)</li>
<li>io: add <code>copy_bidirectional_with_sizes</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6500">#6500</a>)</li>
<li>io: implement <code>AsyncBufRead</code> for <code>Join</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6449">#6449</a>)</li>
<li>net: add Apple visionOS support (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6465">#6465</a>)</li>
<li>net: implement <code>Clone</code> for <code>NamedPipeInfo</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6586">#6586</a>)</li>
<li>net: support QNX OS (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6421">#6421</a>)</li>
<li>sync: add <code>Notify::notify_last</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6520">#6520</a>)</li>
<li>sync: add <code>mpsc::Receiver::{capacity,max_capacity}</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6511">#6511</a>)</li>
<li>sync: add <code>split</code> method to the semaphore permit (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6472">#6472</a>,
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6478">#6478</a>)</li>
<li>task: add
<code>tokio::task::join_set::Builder::spawn_blocking</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6578">#6578</a>)</li>
<li>wasm: support rt-multi-thread with wasm32-wasi-preview1-threads (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6510">#6510</a>)</li>
</ul>
<h3>Changed</h3>
<ul>
<li>macros: make <code>#[tokio::test]</code> append <code>#[test]</code>
at the end of the attribute list (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6497">#6497</a>)</li>
<li>metrics: fix <code>blocking_threads</code> count (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6551">#6551</a>)</li>
<li>metrics: stabilize <code>RuntimeMetrics::worker_count</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6556">#6556</a>)</li>
<li>runtime: move task out of the <code>lifo_slot</code> in
<code>block_in_place</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6596">#6596</a>)</li>
<li>runtime: panic if <code>global_queue_interval</code> is zero (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6445">#6445</a>)</li>
<li>sync: always drop message in destructor for oneshot receiver (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6558">#6558</a>)</li>
<li>sync: instrument <code>Semaphore</code> for task dumps (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6499">#6499</a>)</li>
<li>sync: use FIFO ordering when waking batches of wakers (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6521">#6521</a>)</li>
<li>task: make <code>LocalKey::get</code> work with Clone types (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6433">#6433</a>)</li>
<li>tests: update nix and mio-aio dev-dependencies (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6552">#6552</a>)</li>
<li>time: clean up implementation (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6517">#6517</a>)</li>
<li>time: lazily init timers on first poll (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6512">#6512</a>)</li>
<li>time: remove the <code>true_when</code> field in
<code>TimerShared</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6563">#6563</a>)</li>
<li>time: use sharding for timer implementation (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6534">#6534</a>)</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>taskdump: allow building taskdump docs on non-unix machines (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6564">#6564</a>)</li>
<li>time: check for overflow in <code>Interval::poll_tick</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6487">#6487</a>)</li>
<li>sync: fix incorrect <code>is_empty</code> on mpsc block boundaries
(<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6603">#6603</a>)</li>
</ul>
<h3>Documented</h3>
<ul>
<li>fs: rewrite file system docs (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6467">#6467</a>)</li>
<li>io: fix <code>stdin</code> documentation (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6581">#6581</a>)</li>
<li>io: fix obsolete reference in <code>ReadHalf::unsplit()</code>
documentation (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6498">#6498</a>)</li>
<li>macros: render more comprehensible documentation for
<code>select!</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6468">#6468</a>)</li>
<li>net: add missing types to module docs (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6482">#6482</a>)</li>
<li>net: fix misleading <code>NamedPipeServer</code> example (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6590">#6590</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="14c17fc096"><code>14c17fc</code></a>
chore: prepare Tokio v1.38.0 (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6601">#6601</a>)</li>
<li><a
href="65cbf730de"><code>65cbf73</code></a>
chore: prepare tokio-macros v2.3.0 (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6600">#6600</a>)</li>
<li><a
href="dbf93c7184"><code>dbf93c7</code></a>
sync: fix incorrect is_empty on mpsc block boundaries (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6603">#6603</a>)</li>
<li><a
href="873cb8ae2f"><code>873cb8a</code></a>
runtime: move task out of the <code>lifo_slot</code> in
<code>block_in_place</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6596">#6596</a>)</li>
<li><a
href="97bb47b480"><code>97bb47b</code></a>
task: fix a typo in doc of <code>LocalSet::run_until</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6599">#6599</a>)</li>
<li><a
href="86658bd87d"><code>86658bd</code></a>
metrics: stabilize <code>RuntimeMetrics::worker_count</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6556">#6556</a>)</li>
<li><a
href="9e00b266e0"><code>9e00b26</code></a>
sync: add <code>Notify::notify_last</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6520">#6520</a>)</li>
<li><a
href="6c42d286b3"><code>6c42d28</code></a>
net: fix misleading <code>NamedPipeServer</code> example (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6590">#6590</a>)</li>
<li><a
href="3a6fdc0568"><code>3a6fdc0</code></a>
license: fix formatting and remove year in licenses (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6451">#6451</a>)</li>
<li><a
href="2890d0c3db"><code>2890d0c</code></a>
metrics: fix blocking_threads count (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6551">#6551</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/tokio-rs/tokio/compare/tokio-1.37.0...tokio-1.38.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tokio&package-manager=cargo&previous-version=1.37.0&new-version=1.38.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-05 07:45:38 +00:00
Thomas Eizinger
d27a7a3083 feat(relay): support custom turn port (#5208)
Original PR: #5130.

Co-authored-by: Antoine <antoinelabarussias@gmail.com>
2024-06-05 04:04:17 +00:00
dependabot[bot]
c7b95b8fc0 build(deps): Bump serde from 1.0.197 to 1.0.203 in /rust (#5135)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.197 to
1.0.203.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/serde-rs/serde/releases">serde's
releases</a>.</em></p>
<blockquote>
<h2>v1.0.203</h2>
<ul>
<li>Documentation improvements (<a
href="https://redirect.github.com/serde-rs/serde/issues/2747">#2747</a>)</li>
</ul>
<h2>v1.0.202</h2>
<ul>
<li>Provide public access to RenameAllRules in serde_derive_internals
(<a
href="https://redirect.github.com/serde-rs/serde/issues/2743">#2743</a>)</li>
</ul>
<h2>v1.0.201</h2>
<ul>
<li>Resolve unexpected_cfgs warning (<a
href="https://redirect.github.com/serde-rs/serde/issues/2737">#2737</a>)</li>
</ul>
<h2>v1.0.200</h2>
<ul>
<li>Fix formatting of &quot;invalid type&quot; and &quot;invalid
value&quot; deserialization error messages containing NaN or infinite
floats (<a
href="https://redirect.github.com/serde-rs/serde/issues/2733">#2733</a>,
thanks <a
href="https://github.com/jamessan"><code>@​jamessan</code></a>)</li>
</ul>
<h2>v1.0.199</h2>
<ul>
<li>Fix ambiguous associated item when
<code>forward_to_deserialize_any!</code> is used on an enum with
<code>Error</code> variant (<a
href="https://redirect.github.com/serde-rs/serde/issues/2732">#2732</a>,
thanks <a
href="https://github.com/aatifsyed"><code>@​aatifsyed</code></a>)</li>
</ul>
<h2>v1.0.198</h2>
<ul>
<li>Support serializing and deserializing
<code>Saturating&lt;T&gt;</code> (<a
href="https://redirect.github.com/serde-rs/serde/issues/2709">#2709</a>,
thanks <a
href="https://github.com/jbethune"><code>@​jbethune</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="d5bc546ca5"><code>d5bc546</code></a>
Release 1.0.203</li>
<li><a
href="45ae217728"><code>45ae217</code></a>
Merge pull request <a
href="https://redirect.github.com/serde-rs/serde/issues/2747">#2747</a>
from dtolnay/variadic</li>
<li><a
href="b7b97dda73"><code>b7b97dd</code></a>
Unindent implementation inside tuple_impl_body macro</li>
<li><a
href="5d3c563d46"><code>5d3c563</code></a>
Document tuple impls as fake variadic</li>
<li><a
href="376185458b"><code>3761854</code></a>
Merge pull request <a
href="https://redirect.github.com/serde-rs/serde/issues/2745">#2745</a>
from dtolnay/docsrs</li>
<li><a
href="a8f14840ab"><code>a8f1484</code></a>
Rely on docs.rs to define --cfg=docsrs by default</li>
<li><a
href="9e32a40b1c"><code>9e32a40</code></a>
Release 1.0.202</li>
<li><a
href="87f635e54d"><code>87f635e</code></a>
Release serde_derive_internals 0.29.1</li>
<li><a
href="d4b2dfbde2"><code>d4b2dfb</code></a>
Merge pull request <a
href="https://redirect.github.com/serde-rs/serde/issues/2743">#2743</a>
from dtolnay/renameallrules</li>
<li><a
href="f6ab0bc56f"><code>f6ab0bc</code></a>
Provide public access to RenameAllRules in serde_derive_internals</li>
<li>Additional commits viewable in <a
href="https://github.com/serde-rs/serde/compare/v1.0.197...v1.0.203">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=serde&package-manager=cargo&previous-version=1.0.197&new-version=1.0.203)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-27 21:16:16 +00:00
Thomas Eizinger
92676f0f53 test(connlib): simulate IO in state machine tests (#4728)
This is similar to #4097 and #4585 but for the entire `ClientState` and
`GatewayState`. We also do it in the context of a property-based test
with the vision that we can deterministically explore a large space of
state transitions and see where our main property breaks: Being able to
send an ICMP packet from the client to the gateway.

In other words, we now correctly pass all the `Transmit`s back and forth
between the components as if they would receive it from the network. Due
to the nature of property-based tests, this already exercises a very
large input space. For example, if the client does not have an IPv6
socket and the gateway doesn't have an IPv4 socket, this test already
checks whether we then correctly fall back to using a relay (because the
allocation we make on the relay is the only network path where the STUN
requests pass through).

What this does not (yet) do is set up a proper network topology. The
`dispatch_transmit` function will happily "route" a `Transmit` from e.g.
the client to the gateway even if they are in different subnets. In
other words, these tests assume that the actual network itself works and
we can exchange UDP packets between the components.

For now, we only send ICMPs to CIDR resources. As a next step, we can
extend this to DNS resources by sending DNS queries for our DNS
resources and then sending an ICMP to the resolved IP.
2024-05-22 23:10:58 +00:00
Jamil
7c5669ef51 chore: bump version to 1.0.5 for linux/windows (#5093)
Just need a rubberstamp. This was generated with `make -f
scripts/Makefile version`
2024-05-22 18:25:12 +00:00
Thomas Eizinger
99c600f558 chore(relay): allow domains in --otel-grpc-endpoint (#5059)
Replaces #4932.

---------

Co-authored-by: Antoine Labarussias <antoinelabarussias@gmail.com>
2024-05-22 01:43:17 +00:00
Jamil
e50b3bd865 chore: bump versions for 1.0.4 release (#4985)
Update download links etc for the 1.0.4 release
2024-05-14 16:11:12 +00:00
dependabot[bot]
6dd7b4cfec build(deps): Bump base64 from 0.22.0 to 0.22.1 in /rust (#4969)
Bumps [base64](https://github.com/marshallpierce/rust-base64) from
0.22.0 to 0.22.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/marshallpierce/rust-base64/blob/master/RELEASE-NOTES.md">base64's
changelog</a>.</em></p>
<blockquote>
<h1>0.22.1</h1>
<ul>
<li>Correct the symbols used for the predefined
<code>alphabet::BIN_HEX</code>.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="e144006974"><code>e144006</code></a>
v0.22.1</li>
<li><a
href="64cca59ddb"><code>64cca59</code></a>
Merge pull request <a
href="https://redirect.github.com/marshallpierce/rust-base64/issues/271">#271</a>
from JobanSD/patch-1</li>
<li><a
href="838355e0ac"><code>838355e</code></a>
Correct BinHex 4.0 alphabet according to specifications</li>
<li><a
href="bf15ccf30a"><code>bf15ccf</code></a>
Merge pull request <a
href="https://redirect.github.com/marshallpierce/rust-base64/issues/270">#270</a>
from marshallpierce/mp/clippy</li>
<li><a
href="fc6aabee8a"><code>fc6aabe</code></a>
Appease clippy</li>
<li><a
href="9a518a2d5d"><code>9a518a2</code></a>
Merge pull request <a
href="https://redirect.github.com/marshallpierce/rust-base64/issues/267">#267</a>
from bdura/patch-1</li>
<li><a
href="d96c80f242"><code>d96c80f</code></a>
Merge branch 'marshallpierce:master' into patch-1</li>
<li><a
href="e8e4a22761"><code>e8e4a22</code></a>
docs: fix trailing ``` in mod.rs example</li>
<li>See full diff in <a
href="https://github.com/marshallpierce/rust-base64/compare/v0.22.0...v0.22.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=base64&package-manager=cargo&previous-version=0.22.0&new-version=0.22.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-13 19:38:38 +00:00
Jamil
1be77d4e2d chore: Bump versions to link 1.0.3 packages (#4924)
Link to latest binaries

Generated with `make -f scripts/Makefile`.

Just need a rubber-stamp, changes should be GTG
2024-05-08 21:09:50 +00:00
dependabot[bot]
785b829c7a build(deps): Bump socket2 from 0.5.6 to 0.5.7 in /rust (#4863)
Bumps [socket2](https://github.com/rust-lang/socket2) from 0.5.6 to
0.5.7.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/rust-lang/socket2/blob/master/CHANGELOG.md">socket2's
changelog</a>.</em></p>
<blockquote>
<h1>0.5.7</h1>
<ul>
<li>Added <code>Socket::(set_)passcred</code>
(<a
href="https://redirect.github.com/rust-lang/socket2/pull/506">rust-lang/socket2#506</a>).</li>
<li>Added <code>RecvFlags::is_confirm</code> and
<code>RecvFlags::is_dontroute</code>
(<a
href="https://redirect.github.com/rust-lang/socket2/pull/499">rust-lang/socket2#499</a>).</li>
<li>Added <code>MsgHdrMut::control_len</code>
(<a
href="https://redirect.github.com/rust-lang/socket2/pull/505">rust-lang/socket2#505</a>).</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="c8146aa5bb"><code>c8146aa</code></a>
Release v0.5.7</li>
<li><a
href="8685db561c"><code>8685db5</code></a>
Use consistent language in change log</li>
<li><a
href="6923954ce0"><code>6923954</code></a>
Add test for Socket::passcred/set_passcred and fix formatting.</li>
<li><a
href="630c8a7370"><code>630c8a7</code></a>
Add Socket::passcred/set_passcred for working with SO_PASSCRED.</li>
<li><a
href="21ba6609ef"><code>21ba660</code></a>
Add MsgHdrMut::control_len to get how much of control buffer was
filled.</li>
<li><a
href="c93cdcc25f"><code>c93cdcc</code></a>
Add MSG_CONFIRM and MSG_DONTROUTE to RecvFlags</li>
<li>See full diff in <a
href="https://github.com/rust-lang/socket2/compare/v0.5.6...v0.5.7">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=socket2&package-manager=cargo&previous-version=0.5.6&new-version=0.5.7)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-05 14:08:29 +00:00
dependabot[bot]
740aebc831 build(deps): Bump anyhow from 1.0.81 to 1.0.82 in /rust (#4810)
Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.81 to 1.0.82.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/dtolnay/anyhow/releases">anyhow's
releases</a>.</em></p>
<blockquote>
<h2>1.0.82</h2>
<ul>
<li>Documentation improvements</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="074bdea1c7"><code>074bdea</code></a>
Release 1.0.82</li>
<li><a
href="47a4fbfa36"><code>47a4fbf</code></a>
Merge pull request <a
href="https://redirect.github.com/dtolnay/anyhow/issues/360">#360</a>
from dtolnay/docensure</li>
<li><a
href="c5af1db020"><code>c5af1db</code></a>
Make ensure's doc comment apply to the cfg(not(doc)) macro too</li>
<li><a
href="bebc7a2fe4"><code>bebc7a2</code></a>
Revert &quot;Temporarily disable miri on doctests&quot;</li>
<li><a
href="f2c4db9b47"><code>f2c4db9</code></a>
Update ui test suite to nightly-2024-03-31</li>
<li><a
href="028cbeedf5"><code>028cbee</code></a>
Explicitly install a Rust toolchain for cargo-outdated job</li>
<li><a
href="7a4cac5192"><code>7a4cac5</code></a>
Merge pull request <a
href="https://redirect.github.com/dtolnay/anyhow/issues/358">#358</a>
from dtolnay/workspacewrapper</li>
<li><a
href="939db012c2"><code>939db01</code></a>
Apply RUSTC_WORKSPACE_WRAPPER</li>
<li><a
href="9f84a37551"><code>9f84a37</code></a>
Temporarily disable miri on doctests</li>
<li><a
href="45e5a589e9"><code>45e5a58</code></a>
Ignore dead code lint in test</li>
<li>Additional commits viewable in <a
href="https://github.com/dtolnay/anyhow/compare/1.0.81...1.0.82">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=anyhow&package-manager=cargo&previous-version=1.0.81&new-version=1.0.82)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2024-05-03 23:35:02 +00:00
Jamil
4dc656c90a chore(ci): bump versions (#4840) 2024-04-30 16:31:20 -07:00
Jamil
b79ce96bc6 chore(website): Bump versions (#4821)
- Bump versions to point to latest binaries
- Stage versions for next release
2024-04-29 22:06:00 +00:00
Jamil
5dc52edecc ci: Bump versions and fix release overwrites (#4769) 2024-04-24 11:43:19 -07:00
Thomas Eizinger
53c7bd8201 fix(relay): clear channel bindings when allocation is deleted (#4705)
As suspected, there was a bug in the relay where channel bindings were
not cleared if the client freed the allocation early by sending a
REFRESH request with a lifetime of 0.

Resolves: #4588.
2024-04-19 13:25:38 +00:00
Thomas Eizinger
c4db5736d7 chore(relay): restore request metadata for control messages (#4699)
Previously, we would have a single span that was activated for all
messages, including channel-data messages. That was great for
de-duplication but shit for performance, so we turned it down to `debug`
level. That lost us a lot of context for messages like "Successfully
bound channel" or any other state change in the relay.

To restore this, we remove the span from `handle_client_input` and start
a new span on `info` level for each control message. For channel data
messages, the span is however on `debug` level to not affect performance
in production.

Resolves: #4496.
2024-04-19 05:32:00 +00:00
Thomas Eizinger
d9dc94eca3 chore(relay): log all failed requests on warn (#4700)
This was discussed with @AndrewDryga to allow us detecting potential
attacks. Some amount of authentication failures are expected during
normal operation because TURN has this system of nonces which can only
be used a certain number of times.

Resolves: #4550.
2024-04-19 05:17:38 +00:00
Thomas Eizinger
a3cc56f5df chore(relay): parse init message (#4672)
Actually parsing this got lost as part of introducing graceful shutdown
where we re-ordered when to connect to the portal. This removes a
warning from the logs which might otherwise be misleading of a problem.
2024-04-18 02:11:40 +00:00
Thomas Eizinger
be1a719e2c chore(relay): perform graceful shutdown upon receiving SIGTERM (#4552)
Upon receiving a SIGTERM, we immediately disconnect from the websocket
connection to the portal and set a flag that we are shutting down.

Once we are disconnected from the portal and no longer have an active
allocations, we exit with 0. A repeated SIGTERM signal will interrupt
this process and force the relay to shutdown.

Disconnecting from the portal will (eventually) trigger a message to
clients and gateways that this relay should no longer be used. Thus,
depending on the timeout our supervisor has configured after sending
SIGTERM, the relay will continue all TURN operations until the number of
allocations drops to 0.

Currently, we also allow clients to make new allocations and refreshing
existing allocations. In the future, it may make sense to implement a
dedicated status code and refuse `ALLOCATE` and `REFRESH` messages
whilst we are shutting down.

Related: #4548.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-04-12 08:45:08 +00:00
Thomas Eizinger
31eec1aac7 chore(relay): connect to portal in the background during startup (#4594)
In a prior design of the relay and the `phoenix-channel`, connecting to
the portal was a blocking operation, i.e. we weren't meant to start the
relaying operations before the portal connection succeeded.

Since then, `phoenix-channel` got refactored to have an internal
(re)-connection mechanism, meaning we don't actually need to `.await`
anything to obtain a `PhoenixChannel` instance that we can use to
initialize the `Server`. Furthermore, we changed the health-check to
return 200 OK prior to the portal connection being established in #4553.

Taking both of these into account, there is no more need to block on the
portal connection being established, which allows us to remove the use
of `phoenix_channel::init` and connect in the background whilst we
already accept STUN & TURN traffic.
2024-04-12 03:48:09 +00:00
Thomas Eizinger
fb68e90829 chore(snownet): add unit-test for relayed connection (#4570)
This PR adds a unit-test to `snownet` that exercises all code paths that
are required for a relayed connection to work. This includes:

- Nodes make an allocation with real credentials, nonces etc
- Nodes exchange their ICE candidates
- Nodes bind data channels on the relay
- str0m performs ICE over these data channels
- Nodes handshake a wireguard tunnel on the nominated socket

I consider this a baseline. Once merged, I want to attempt writing a
test in #4568 that asserts migration of a connection to a new relay
without the connection expiring. At some point, we can even go further
and move these tests to `firezone-tunnel` and unit-test even more things
like connection intents etc.
2024-04-10 21:31:00 +00:00
Thomas Eizinger
03d89fec50 chore(relay): fail health-check with 400 on being partitioned for > 15min (#4553)
During the latest relay outage, we failed to send heartbeats to the
portal because we were busy-looping and never got to handle messages or
timers for the portal.

To mitigate this or similar bugs, we update an `Instant` every time we
send a heartbeat to the portal. In case we are actually
network-partitioned, this will cause the health-check to fail after 15
minutes. This value is the same as the partition timeout for the portal
connection itself[^1]. Very likely, we will never see a relay being
shutdown because of a failing health check in this case as it would have
already shut itself down.

An exception to this are bugs in the eventloop where we fail to interact
with the portal at all.

Resolves: #4510.

[^1]: Previously, this was unlimited.
2024-04-10 02:05:59 +00:00
Thomas Eizinger
d92eaa30e2 chore(relay): remove stale arg (#4554)
This one slipped in as part of #4426. Originally, I intended to allow
for on-demand profiling of the relay but it didn't turn out to be
necessary.
2024-04-09 16:04:59 +00:00
Thomas Eizinger
8900e263ca refactor(relay): favor Instant over SystemTime (#4468)
This one is a bit tricky. Our auth scheme requires me to know the
current time as a UNIX timestamp and that I can only get from
`SystemTime` but not `Instant`. The `Server` is meant to be SANS-IO,
including the current time so technically, I would have to pass that in
as a parameter.

I ended up settling on a compromise of making the auth verification
impure and internally calling `SystemTime::now`. That results in a much
nicer API and allows us to use `Instant` for everything else, e.g.
expiry of channel bindings, allocations etc.

Resolves: #4464.
2024-04-08 23:37:19 +00:00
Thomas Eizinger
a1a7d925b1 chore(rust): enforce no wildcard matching (#4491)
A wildcard match was the underlying bug fixed in #4486. Despite being a
bit annoying in some cases, I think it is worth having this lint turned
on to ensure we don't wildcard match in situations where it can have bad
consequences, like `poll` functions.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
2024-04-08 12:06:37 +00:00
Thomas Eizinger
4ca3a68253 Bump dependency 2024-04-08 20:26:54 +10:00
Thomas Eizinger
c036d1abe5 refactor(relay): remove heap-allocations from hotpath (#4457)
This required a mid-sized refactor of the relay's eventloop. The idea is
that we can use [`mio`](https://docs.rs/mio/latest/mio/) to do the
actual IO handling instead of `tokio`. `tokio` depends on `mio`
internally but doesn't expose its primitives. Most importantly, we don't
get access to the API where we can dynamically register file descriptors
to watch for readiness.

In order to avoid allocations on the relaying hotpath, we need to listen
on a dynamic number of sockets:

1. Our client-facing socket on port 3478
2. All sockets allocated by clients

`mio` is the building block of the async tokio runtime, hence it does
not provide an async primitives. Instead, it blocks the current thread
that it is running on and feeds you events that you need to deal with.
We still need our `tokio` runtime to register timers and for
communication with the portal. To integrate the two, we spawn a
dedicated thread for `mio::Poll` and communicate with it via channels
within the `Sockets` abstraction. Thus, the `Eventloop` itself has no
idea that `mio` is used for all the network communication.

Whenever `mio` sends us an event that a socket is ready, we try to read
from that specific socket. We must read from this socket until it
returns `WouldBlock` at which point we move on to the next event.

We only register for read-readiness. If a socket is not ready for
writing, we just drop the packet.

With this design in place, we can now have a single buffer that we read
incoming packets into and dispatch it to `Server`, depending on which
port is what received on. A future refactoring could maybe even unify
these functions and let the `Server` deal with the ports internally.

Resolves: #4366.
2024-04-04 18:53:59 +00:00
Thomas Eizinger
283bf8271f fix(relay): don't busy-loop on poll_timeout (#4497)
The value returned from `poll_timeout` needs to only reset the `Sleep`
but don't need to go back to the top of the loop. Instead, we move its
polling to below the resetting of `Sleep`. This will correctly register
a waker in case we did change `Sleep`.

This `continue` causes a busy-loop and stops the relay from dealing with
the `phoenix-channel` which means the portal will eventually consider it
offline.

This was first introduced in #4455.
2024-04-03 19:33:09 -06:00
Thomas Eizinger
ddd0a3b986 fix(relay): always continue after ready events (#4494)
This is a similar fix as to #4486. I am not sure if this is / was
actively causing problems but using `continue` after _any_ ready event
is definitely more correct.

This is a low-risk change.
2024-04-04 01:10:30 +00:00
Thomas Eizinger
285249a384 fix(relay): only unbind a channel if it is actually bound (#4495)
Currently, we are emitting the "Channel is now expired" message multiple
times because we don't filter for the ones we have already unbound.
2024-04-04 01:09:58 +00:00
Thomas Eizinger
97e6a92e39 chore(rust): remove unused dependencies (#4475)
These were all found by `cargo-udeps`.

Resolves: #4403.
2024-04-03 14:11:02 +00:00
Thomas Eizinger
b668f8944b chore(rust): lint against redundant async (#4466)
I came across a redundant `async` within the relay code and thought:
"Hey, I know there is a lint against this, let's turn it on".
2024-04-03 02:43:49 +00:00
Thomas Eizinger
1b11d75a91 refactor(relay): replace Command::Wake with poll_timeout (#4455)
This is much more robust than the previous implementation because we now
go through all allocations and channels every time we get a
`handle_timeout` and clean up everything that is expired.

Resolves: #4095.
2024-04-02 23:09:46 +00:00
Thomas Eizinger
5f718ad982 refactor(relay): reduce allocations during relaying (#4453)
Previously, we would allocate each message twice:

1. When receiving the original packet.
2. When forming the resulting channel-data message.

We can optimise this to only one allocation each by:

1. Carrying around the original `ChannelData` message for traffic from
clients to peers.
2. Pre-allocating enough space for the channel-data header for traffic
from peers to clients.

Local flamegraphing still shows most of user-space activity as
allocations. I did occasionally see a throughput of ~10GBps with these
patches. I'd like to still work towards #4095 to ensure we handle
anything time-sensitive better.
2024-04-02 22:00:36 +00:00
dependabot[bot]
33fdbd960c build(deps): Bump clap from 4.5.3 to 4.5.4 in /rust (#4433)
Bumps [clap](https://github.com/clap-rs/clap) from 4.5.3 to 4.5.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/clap-rs/clap/releases">clap's
releases</a>.</em></p>
<blockquote>
<h2>v4.5.4</h2>
<h2>[4.5.4] - 2024-03-25</h2>
<h3>Fixes</h3>
<ul>
<li><em>(derive)</em> Allow non-literal <code>#[arg(id)]</code>
attributes again</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/clap-rs/clap/blob/master/CHANGELOG.md">clap's
changelog</a>.</em></p>
<blockquote>
<h2>[4.5.4] - 2024-03-25</h2>
<h3>Fixes</h3>
<ul>
<li><em>(derive)</em> Allow non-literal <code>#[arg(id)]</code>
attributes again</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="5e4facf76f"><code>5e4facf</code></a>
chore: Release</li>
<li><a
href="8880b0a5da"><code>8880b0a</code></a>
docs: Update changelog</li>
<li><a
href="132b5dded5"><code>132b5dd</code></a>
Merge pull request <a
href="https://redirect.github.com/clap-rs/clap/issues/5425">#5425</a>
from epage/lit</li>
<li><a
href="df915fefef"><code>df915fe</code></a>
fix(derive): Re-allow expressions for id's</li>
<li><a
href="8eab48fa3c"><code>8eab48f</code></a>
refactor(derive): Make it easier to work with 'Name'</li>
<li><a
href="be73195ecf"><code>be73195</code></a>
refactor(derive): Clarify tests</li>
<li><a
href="024089bb60"><code>024089b</code></a>
Merge pull request <a
href="https://redirect.github.com/clap-rs/clap/issues/5415">#5415</a>
from Pi-Cla/patch-1</li>
<li><a
href="3b35dba160"><code>3b35dba</code></a>
docs: Add mention of nushell to clap_complete README</li>
<li><a
href="58469d1669"><code>58469d1</code></a>
Merge pull request <a
href="https://redirect.github.com/clap-rs/clap/issues/5405">#5405</a>
from epage/docs</li>
<li><a
href="655d8295a7"><code>655d829</code></a>
docs(derive): Fix ToC links within tutorial chapters</li>
<li>See full diff in <a
href="https://github.com/clap-rs/clap/compare/v4.5.3...v4.5.4">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=clap&package-manager=cargo&previous-version=4.5.3&new-version=4.5.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-02 18:31:17 +00:00
Thomas Eizinger
a1bd9248d0 chore(relay): reduce instrumentation overhead (#4426)
Previously, we were creating a lot of spans because they were all set to
`level = error`. We now reduce those spans to `debug` which should help
with the CPU utilization.

Related: #4366.
2024-04-01 23:02:59 +00:00
Thomas Eizinger
a2a86703e7 chore(relay): make profiling in release build possible (#4441)
Currently, controlling the RNG seed is gated for debug builds only. This
makes profiling the release build impossible because we cannot generate
credentials upfront.

Additionally, for flamegraphs to be useful, we need to enable debug
symbols for the relay.
2024-04-01 21:37:11 +00:00
Thomas Eizinger
c96f32105c chore(relay): remove per-packet logs on debug level (#4439)
This follows the same policy as we applied in connlib: Anything that
happens on a per-packet basis is on `trace` level.

Resolves: #4333.
2024-04-01 21:35:11 +00:00
Thomas Eizinger
6efce31a94 chore(relay): apply log target consistently (#4440)
The main relay component uses the `relay` target to be more concise
whilst emitting logs. This PR fixes a few logs that were missing that.
2024-04-01 20:54:24 +00:00
Thomas Eizinger
fb7f7c0b9a chore: apply lints consistently across workspace (#4357)
Motivated by: #4340.

I also activated
[`clippy::unnnecessary_wraps`](https://rust-lang.github.io/rust-clippy/master/#/unnecessary_wraps)
which does create some false-positives for the platform-specific code
but is IMO overall a net-positive. With the amount of Rust code and
crates increasing, it is good to have tools point out simplifications
like these as they are otherwise hard to spot, especially across crate
boundaries.
2024-03-28 06:09:22 +00:00
dependabot[bot]
baa2831664 build(deps): Bump clap from 4.5.2 to 4.5.3 in /rust (#4191)
Bumps [clap](https://github.com/clap-rs/clap) from 4.5.2 to 4.5.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/clap-rs/clap/releases">clap's
releases</a>.</em></p>
<blockquote>
<h2>v4.5.3</h2>
<h2>[4.5.3] - 2024-03-15</h2>
<h3>Internal</h3>
<ul>
<li><em>(derive)</em> Update <code>heck</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/clap-rs/clap/blob/master/CHANGELOG.md">clap's
changelog</a>.</em></p>
<blockquote>
<h2>[4.5.3] - 2024-03-15</h2>
<h3>Internal</h3>
<ul>
<li><em>(derive)</em> Update <code>heck</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="4e07b43858"><code>4e07b43</code></a>
chore: Release</li>
<li><a
href="8247c7ddf0"><code>8247c7d</code></a>
docs: Update changelog</li>
<li><a
href="677c52ce08"><code>677c52c</code></a>
chore: Update <code>heck</code> requirement (<a
href="https://redirect.github.com/clap-rs/clap/issues/5396">#5396</a>)</li>
<li>See full diff in <a
href="https://github.com/clap-rs/clap/compare/v4.5.2...v4.5.3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=clap&package-manager=cargo&previous-version=4.5.2&new-version=4.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-03-19 22:49:06 +00:00