Commit Graph

1332 Commits

Author SHA1 Message Date
Thomas Eizinger
128d0eb407 feat(connlib): transparently forward non-resources DNS queries (#6181)
Currently, `connlib` depends on `hickory-resolver` to perform DNS
queries for non-resources. This is unnecessary. Instead of buffering the
original UDP DNS query, consulting hickory to resolve the name and
mapping the response back, we can simply take the UDP payload and send
it via our protected socket directly to the original upstream DNS
server.

This ensures `connlib` is as transparent as possible for DNS queries for
non-resources. Additionally, it removes a lot of error handling and
other cruft that we currently have to perform because we are using
hickory. For example, hickory will automatically retry a DNS query after
a certain timeout. However, the OS / client talking to `connlib` will
also retry after a certain timeout because it is making DNS queries over
an unreliable transport (UDP). It is thus unnecessary for us to do that
internally.

To correctly test this change, our test-suite needed some refactoring.
Specifically, DNS servers are now modelled as dedicated `Host`s that can
receive (UDP) traffic.

Lastly, we can remove our dependency on `hickory-proto` and
`hickory-resolver` everywhere and only use `domain` for parsing DNS
messages.

Resolves: #6141.
Related: #6033.
Related: #4800. (Impossible to happen with this design)
2024-08-07 08:54:49 +00:00
Thomas Eizinger
376900ca4e refactor(connlib): simplify sampling of initial state (#6194)
Instead of having one giant, composed strategy, we introduce a dedicated
`stub_portal` strategy. That one samples what is defined in the portal
in production: sites, gateways and resources.

Based on a sampled portal, we can then sample gateways, a client and DNS
records for our resources.
2024-08-07 06:07:39 +00:00
Thomas Eizinger
423d70854b chore(connlib): fix clippy warnings (#6190) 2024-08-07 05:46:11 +00:00
Thomas Eizinger
a282208f0b chore(connlib): minimize debug print of DnsServer (#6191)
The `DnsServer` struct is quite nested. All it really contains
(currently) is a `SocketAddr`. To make logs containing this structure
easier to use, only print the inner address on debug.
2024-08-07 05:46:04 +00:00
Thomas Eizinger
dda6adecf2 chore(connlib): log when we are updating DNS servers (#6192) 2024-08-07 04:27:35 +00:00
Thomas Eizinger
a81f5128e5 refactor(connlib): don't manually build DNS responses (#6193)
Resolves: #5540.
2024-08-07 04:27:27 +00:00
Thomas Eizinger
622fa63535 fix(ci): always install curl (#6189)
CI on `main` runs against the `release` images which had `curl` removed
in #6169.
2024-08-07 04:15:30 +00:00
Thomas Eizinger
94527f9fa1 fix(gateway): always masquerade for docker-deployed gateways (#6169)
Without masquerading, packets sent by the gateway through the TUN
interface use the wrong source address (the TUN device's address)
instead of the gateway's actual network interface.

We set this env variable in all our uses of the gateway, thus we might
as well remove it and always perform unconditionally.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-08-07 03:00:50 +00:00
Reactor Scram
0cb96d5e37 chore(gui-client/windows): throw an error if the GUI runs as admin (#6176)
Closes #5878

It won't work properly as admin (deep links will all fail), and this
improves UX by making it obvious that admin powers are no longer needed
for the GUI.

```[tasklist]
- [x] Write up `SAFETY` comments
```
2024-08-07 01:22:59 +00:00
Reactor Scram
5b75e8714a feat(client/tauri): allow users to favorite specific Resources and hide the rest (#5923)
Refs #5123

Looking at a Resource when nothing is favorited
<img width="504" alt="image"
src="https://github.com/user-attachments/assets/4c3bc1da-4645-40c1-84a4-3e3425a0fea3">

Looking at a favorited Resource
<img width="515" alt="image"
src="https://github.com/user-attachments/assets/22140f81-5453-41fd-9071-9c999b3151b1">

Looking at a non-favorited Resource
<img width="497" alt="image"
src="https://github.com/user-attachments/assets/84deddb1-8a05-4b78-9dfa-a8a60ca86831">


```[tasklist]
- [x] Double-check that the Resources are sorted alphabetically (or whatever) and leave a comment where they're sorted
- [x] String changes
- [x] Move "Add" and "Remove" down to a different section
- [x] Fix empty favorites menu
- [ ] Wait for other Clients to sync
- [ ] Merge
```

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-08-06 22:36:52 +00:00
Shantanu Gadgil
22c7414cd1 environmentfile optional to suppress warning in logs (#6151)
environmentfile optional to suppress warning in logs

---------

Signed-off-by: Shantanu Gadgil <shantanugadgil@users.noreply.github.com>
2024-08-06 12:55:51 -07:00
Reactor Scram
5eb2bba47b feat(headless-client): use systemd-resolved DNS control by default (#6163)
Closes #5063, supersedes #5850 

Other refactors and changes made as part of this:

- Adds the ability to disable DNS control on Windows
- Removes the spooky-action-at-a-distance `from_env` functions that used
to be buried in `tunnel`
- `FIREZONE_DNS_CONTROL` is now a regular `clap` argument again

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-08-06 18:16:51 +00:00
Reactor Scram
30622da24f fix(client): increase mpsc channel size (#6184)
Mitigates #5880.

This should fix the issue for all practical purposes, but we don't need
a channel there, so it does not close the ticket. A more permanent fix
would involve factoring out the callbacks or cheating and using a Mutex
inside the callbacks to do a swap-and-notify thing.

This affects both the Headless Client and the GUI Client's IPC service,
on both Linux and Windows.
2024-08-06 17:18:37 +00:00
Gabi
a2d849087a feat(android): add setDisabledResources FFI (#6166)
Builds on top of  #6164

Part of the effor towards
https://github.com/firezone/firezone/issues/6074

Prepares connlib to call `setDisableResource` from android.

Furthermore, we add a `disablable` parameter for resources which default
to false for now, in the future the portal will set it for the internet
resource, and further in the future it may be used for other resources.

The `disablable` parameter only affect UI.
2024-08-05 22:43:27 +00:00
dependabot[bot]
f4429cf6ec build(deps): Bump domain from 0.10.0 to 0.10.1 in /rust (#6080)
Bumps [domain](https://github.com/nlnetlabs/domain) from 0.10.0 to
0.10.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/nlnetlabs/domain/releases">domain's
releases</a>.</em></p>
<blockquote>
<h2>0.10.1</h2>
<p>New</p>
<ul>
<li>Allow AllRecordData’s parsing impls to accept an unsized [u8] as the
source octets. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/310">#310</a>
by [<a
href="https://github.com/xofyarg"><code>@​xofyarg</code></a>])</li>
<li>Made <code>sign::records::FamilyName</code> public. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/312">#312</a>
by [<a
href="https://github.com/achow101"><code>@​achow101</code></a>])</li>
<li>Added an impl of <code>FromStr</code> for <code>Question</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/317">#317</a>)</li>
</ul>
<p>Bug fixes</p>
<ul>
<li>Accept an empty record type bitmap when scanning NSEC/NSEC3 data.
(<a
href="https://redirect.github.com/nlnetlabs/domain/issues/310">#310</a>
by [<a
href="https://github.com/xofyarg"><code>@​xofyarg</code></a>])</li>
<li>Fix serialization of ProtoRrsig to conform with RFC 4034. ([#313 by
[<a
href="https://github.com/achow101"><code>@​achow101</code></a>])</li>
<li>Add <code>?Sized</code> bounds to <code>Message::is_answer</code>
and <code>ParsedRecord::to_record</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>
by [<a href="https://github.com/xofyarg"><code>@​xofyarg</code></a>], <a
href="https://redirect.github.com/nlnetlabs/domain/issues/325">#325</a>
by [<a href="https://github.com/hunts"><code>@​hunts</code></a>])</li>
<li>Bring back <code>MessageBuilder::as_target</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>
by [<a
href="https://github.com/xofyarg"><code>@​xofyarg</code></a>])</li>
<li>Bring back <code>impl FreezeBuilder for StaticCompressor</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>
by [<a
href="https://github.com/xofyarg"><code>@​xofyarg</code></a>])</li>
<li><code>sign::records::RecordsIter::skip_before</code> now stops at
the first name in zone even if the apex itself doesn’t appear. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/314">#314</a>
by [<a
href="https://github.com/achow101"><code>@​achow101</code></a>])</li>
<li>Fix a counting error in <code>SliceLabelsIter::next</code> that
broke compression via <code>StaticCompressor</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/321">#321</a>
by [<a href="https://github.com/hunts"><code>@​hunts</code></a>])</li>
</ul>
<p>Unstable features</p>
<ul>
<li>New unstable feature <code>unstable-stelline</code> for the Stelline
testing framework as a “normal” module of <em>domain.</em> (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/315">#315</a>)</li>
<li>Renamed the domain name types in <code>zonetree</code> from
<code>Dname</code> to <code>Name</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/308">#308</a>)</li>
</ul>
<p>Other changes</p>
<ul>
<li>The minimum Rust version is now 1.78. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/320">#320</a>)</li>
</ul>
<p><a
href="https://redirect.github.com/nlnetlabs/domain/issues/308">#308</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/308">NLnetLabs/domain#308</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/310">#310</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/310">NLnetLabs/domain#310</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/312">#312</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/312">NLnetLabs/domain#312</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/314">#314</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/314">NLnetLabs/domain#314</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/315">#315</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/315">NLnetLabs/domain#315</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/317">#317</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/317">NLnetLabs/domain#317</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/318">NLnetLabs/domain#318</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/320">#320</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/320">NLnetLabs/domain#320</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/321">#321</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/321">NLnetLabs/domain#321</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/325">#325</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/325">NLnetLabs/domain#325</a>
[<a href="https://github.com/achow101"><code>@​achow101</code></a>]: <a
href="https://github.com/achow101">https://github.com/achow101</a>
[<a href="https://github.com/hunts"><code>@​hunts</code></a>]: <a
href="https://github.com/hunts">https://github.com/hunts</a>
[<a href="https://github.com/xofyarg"><code>@​xofyarg</code></a>]: <a
href="https://github.com/xofyarg">https://github.com/xofyarg</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/NLnetLabs/domain/blob/main/Changelog.md">domain's
changelog</a>.</em></p>
<blockquote>
<h2>0.10.1</h2>
<p>Release 2024-06-03.</p>
<p>New</p>
<ul>
<li>Allow AllRecordData’s parsing impls to accept an unsized [u8] as the
source octets. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/310">#310</a>
by [<a
href="https://github.com/xofyarg"><code>@​xofyarg</code></a>])</li>
<li>Made <code>sign::records::FamilyName</code> public. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/312">#312</a>
by [<a
href="https://github.com/achow101"><code>@​achow101</code></a>])</li>
<li>Added an impl of <code>FromStr</code> for <code>Question</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/317">#317</a>)</li>
</ul>
<p>Bug fixes</p>
<ul>
<li>Accept an empty record type bitmap when scanning NSEC/NSEC3 data.
(<a
href="https://redirect.github.com/nlnetlabs/domain/issues/310">#310</a>
by [<a
href="https://github.com/xofyarg"><code>@​xofyarg</code></a>])</li>
<li>Fix serialization of ProtoRrsig to conform with RFC 4034. ([#313 by
[<a
href="https://github.com/achow101"><code>@​achow101</code></a>])</li>
<li>Add <code>?Sized</code> bounds to <code>Message::is_answer</code>
and <code>ParsedRecord::to_record</code>.
(<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>
by [<a href="https://github.com/xofyarg"><code>@​xofyarg</code></a>], <a
href="https://redirect.github.com/nlnetlabs/domain/issues/325">#325</a>
by [<a href="https://github.com/hunts"><code>@​hunts</code></a>])</li>
<li>Bring back <code>MessageBuilder::as_target</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>
by [<a
href="https://github.com/xofyarg"><code>@​xofyarg</code></a>])</li>
<li>Bring back <code>impl FreezeBuilder for StaticCompressor</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>
by [<a
href="https://github.com/xofyarg"><code>@​xofyarg</code></a>])</li>
<li><code>sign::records::RecordsIter::skip_before</code> now stops at
the first name in
zone even if the apex itself doesn’t appear. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/314">#314</a>
by [<a
href="https://github.com/achow101"><code>@​achow101</code></a>])</li>
<li>Fix a counting error in <code>SliceLabelsIter::next</code> that
broke compression
via <code>StaticCompressor</code>. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/321">#321</a>
by [<a href="https://github.com/hunts"><code>@​hunts</code></a>])</li>
</ul>
<p>Unstable features</p>
<ul>
<li>New unstable feature <code>unstable-stelline</code> for the Stelline
testing
framework as a “normal” module of <em>domain.</em> (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/315">#315</a>)</li>
<li>Renamed the domain name types in <code>zonetree</code> from
<code>Dname</code> to <code>Name</code>.
(<a
href="https://redirect.github.com/nlnetlabs/domain/issues/308">#308</a>)</li>
</ul>
<p>Other changes</p>
<ul>
<li>The minimum Rust version is now 1.78. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/320">#320</a>)</li>
</ul>
<p><a
href="https://redirect.github.com/nlnetlabs/domain/issues/308">#308</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/308">NLnetLabs/domain#308</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/310">#310</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/310">NLnetLabs/domain#310</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/312">#312</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/312">NLnetLabs/domain#312</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/314">#314</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/314">NLnetLabs/domain#314</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/315">#315</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/315">NLnetLabs/domain#315</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/317">#317</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/317">NLnetLabs/domain#317</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/318">NLnetLabs/domain#318</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/320">#320</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/320">NLnetLabs/domain#320</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/321">#321</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/321">NLnetLabs/domain#321</a>
<a
href="https://redirect.github.com/nlnetlabs/domain/issues/325">#325</a>:
<a
href="https://redirect.github.com/NLnetLabs/domain/pull/325">NLnetLabs/domain#325</a>
[<a href="https://github.com/achow101"><code>@​achow101</code></a>]: <a
href="https://github.com/achow101">https://github.com/achow101</a>
[<a href="https://github.com/hunts"><code>@​hunts</code></a>]: <a
href="https://github.com/hunts">https://github.com/hunts</a>
[<a href="https://github.com/xofyarg"><code>@​xofyarg</code></a>]: <a
href="https://github.com/xofyarg">https://github.com/xofyarg</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="b65cc98d7f"><code>b65cc98</code></a>
Release 0.10.1. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/326">#326</a>)</li>
<li><a
href="161339b76f"><code>161339b</code></a>
Update README (a bit).</li>
<li><a
href="5f96282389"><code>5f96282</code></a>
Update changelog.</li>
<li><a
href="dab2a90563"><code>dab2a90</code></a>
Refactor pointer casts to transmutes and annotate with repr(transparent)
(<a
href="https://redirect.github.com/nlnetlabs/domain/issues/324">#324</a>)</li>
<li><a
href="d4f120a205"><code>d4f120a</code></a>
allow create real resource record from unsized data (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/325">#325</a>)</li>
<li><a
href="ac63ab239b"><code>ac63ab2</code></a>
Impl FromStr for Question and use it in Stelline. (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/317">#317</a>)</li>
<li><a
href="c72f07eb47"><code>c72f07e</code></a>
Remove (direct) dependency on <code>hex</code> and
<code>pin-project-lite</code> (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/323">#323</a>)</li>
<li><a
href="7c399fcb56"><code>7c399fc</code></a>
Update changelog.</li>
<li><a
href="42c0d4495e"><code>42c0d44</code></a>
Don't skip children of apex in SortedRecords (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/314">#314</a>)</li>
<li><a
href="57f3475b3f"><code>57f3475</code></a>
add some missing methods/trait bounds (<a
href="https://redirect.github.com/nlnetlabs/domain/issues/318">#318</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/nlnetlabs/domain/compare/v0.10.0...v0.10.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=domain&package-manager=cargo&previous-version=0.10.0&new-version=0.10.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-08-05 22:40:49 +00:00
Gabi
181b81d24a feat(connlib): allow users to disable resources (#6164)
This is just the API part for #6074

We expose a new API `set_disabled_resources` which given a set of
resource ids it does the following:
* Disconnect any active connection depending only on this resource
* Prevent any new connection with that resource id being established

The `set_disabled_resources` API is purposely not stateful. In other
words, resources cannot be incrementally enabled or disabled. Instead,
clients always need to send the latest state, i.e. all resources that
should be disabled. `connlib` will figure out the diff and correctly
enable / disable resources as necessary. Thus, enabling a resource is
done by calling `set_disabled_resources` without the previously disabled
resource ID.

Initially, this will only be used for the internet resource but the use
can be expanded for any other resource.
2024-08-05 21:13:04 +00:00
dependabot[bot]
8352255499 build(deps): Bump serde from 1.0.203 to 1.0.204 in /rust (#6173)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.203 to
1.0.204.
<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.204</h2>
<ul>
<li>Apply #[diagnostic::on_unimplemented] attribute on Rust 1.78+ to
suggest adding serde derive or enabling a &quot;serde&quot; feature flag
in dependencies (<a
href="https://redirect.github.com/serde-rs/serde/issues/2767">#2767</a>,
thanks <a
href="https://github.com/weiznich"><code>@​weiznich</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="18dcae0a77"><code>18dcae0</code></a>
Release 1.0.204</li>
<li><a
href="58c307f9cc"><code>58c307f</code></a>
Alphabetize list of rustc-check-cfg</li>
<li><a
href="8cc4809414"><code>8cc4809</code></a>
Merge pull request <a
href="https://redirect.github.com/serde-rs/serde/issues/2769">#2769</a>
from dtolnay/onunimpl</li>
<li><a
href="1179158def"><code>1179158</code></a>
Update ui test with diagnostic::on_unimplemented from PR 2767</li>
<li><a
href="91aa40e749"><code>91aa40e</code></a>
Add ui test of unsatisfied serde trait bound</li>
<li><a
href="595019e979"><code>595019e</code></a>
Cut test_suite from workspace members in old toolchain CI jobs</li>
<li><a
href="b0d7917f88"><code>b0d7917</code></a>
Pull in trybuild 'following types implement trait' fix</li>
<li><a
href="8e6637a1e4"><code>8e6637a</code></a>
Merge pull request <a
href="https://redirect.github.com/serde-rs/serde/issues/2767">#2767</a>
from weiznich/feature/diagnostic_on_unimplemented</li>
<li><a
href="694fe05953"><code>694fe05</code></a>
Use the <code>#[diagnostic::on_unimplemented]</code> attribute when
possible</li>
<li><a
href="f3dfd2a237"><code>f3dfd2a</code></a>
Suppress dead code warning in test of unit struct remote derive</li>
<li>Additional commits viewable in <a
href="https://github.com/serde-rs/serde/compare/v1.0.203...v1.0.204">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.203&new-version=1.0.204)](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-08-05 11:05:11 +00:00
Thomas Eizinger
aea399de14 build(deps): use upstream str0m (#5745)
With the adoption of #5080, connlib is now resilient against temporarily
failed connections as they'll be immediately re-established. Thus, we no
longer need any of the patches that we are currently maintaining in our
str0m fork.

The only difference is an adjustment of the ICE timeout parameters but
those can be made configurable in str0m.

Related: https://github.com/algesten/str0m/pull/537.
2024-08-02 22:42:58 +00:00
Reactor Scram
2ee64b782e chore(gui-client): reduce "building tray menu" logs to DEBUG (#6150)
I don't remember why I had this at INFO but with the new status stuff it
results in a lot of noise in the logs.
2024-08-02 20:43:35 +00:00
Jamil
51e0b61c9c chore: Bump all clients and gateway versions (#6149)
Includes major fixes https://github.com/firezone/firezone/pull/6143 and
https://github.com/firezone/firezone/pull/6117
2024-08-02 01:12:49 -07:00
Gabi
abfd378fe9 fix(connlib): Disable hickory cache (#6143)
This seems to fix #6033 

What **seems** to be happening is that sometimes responses are delayed
and hickory cache the negative response.

We disable the cache, and the multiple attempts to be as transparent as
possible until #6141 is implemented.

Furthermore, the lack of recursion available in responses can cause
issues in some clients and enabling it shouldn't cause any problems.
2024-08-01 23:59:24 -07:00
Thomas Eizinger
226389a25a fix(connlib): be resilient against network-partitioned relays (#6117)
When a relay disconnects from the portal, either during deployment or
because of a network partition, the portal sends us a `relays_presence`
event. This allows us to discontinue use of a relay. Any connections
that currently use that relay get cut and the next packet reestablishes
a new one.

In the case of relays being re-deployed, their state is gone entirely
and we will receive new relays to use. In the case of a network
partition, the relay would have retained its state but we have already
discarded ours locally. Only one allocation per client (identified by
its 3-tuple) is allowed, so making a new allocation on that relay would
fail.

In order to sync up this inconsistency, we delete our current allocation
and make a new one if we detect this case. To test this, we introduce a
new state transition to `tunnel_test` that simulates such a network
partition.

In addition, we also remove the "upsert" behaviour of relays. The
credentials of a relay can only change if it reboots. Rebooting would
trigger a `relays_presence` event and tell us to disconnect from that
relay. Thus, receiving a relay that we already know is guaranteed to use
the same credentials.

Removal of this upserting behaviour is essentially the fix for #6067.
Due to a portal bug (#6099), we may receive a relay as connected that is
in fact shutting down. In case a channel needs to be refreshed on
exactly that relay - whilst we are trying to refresh the allocation it
as part of upserting - causes a busy loop of attempting to queue a
message but failing to do so because we haven't chosen an
`active_socket` yet for that relay.

Fixes: #6067.
2024-08-02 05:21:37 +00:00
Reactor Scram
23161ec840 chore(gui-client): release 1.1.8 (#6136)
Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-08-01 21:58:18 +00:00
dependabot[bot]
8f17ef933b build(deps-dev): Bump tailwindcss from 3.4.6 to 3.4.7 in /rust/gui-client (#6125)
Bumps [tailwindcss](https://github.com/tailwindlabs/tailwindcss) from
3.4.6 to 3.4.7.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/tailwindlabs/tailwindcss/releases">tailwindcss's
releases</a>.</em></p>
<blockquote>
<h2>v3.4.7</h2>
<h3>Fixed</h3>
<ul>
<li>Fix class detection in Slim templates with attached attributes and
ID (<a
href="https://redirect.github.com/tailwindlabs/tailwindcss/pull/14019">#14019</a>)</li>
<li>Ensure attribute values in <code>data-*</code> and
<code>aria-*</code> modifiers are always quoted in the generated CSS (<a
href="https://redirect.github.com/tailwindlabs/tailwindcss/pull/14037">#14037</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/tailwindlabs/tailwindcss/blob/v3.4.7/CHANGELOG.md">tailwindcss's
changelog</a>.</em></p>
<blockquote>
<h2>[3.4.7] - 2024-07-25</h2>
<h3>Fixed</h3>
<ul>
<li>Fix class detection in Slim templates with attached attributes and
ID (<a
href="https://redirect.github.com/tailwindlabs/tailwindcss/pull/14019">#14019</a>)</li>
<li>Ensure attribute values in <code>data-*</code> and
<code>aria-*</code> modifiers are always quoted in the generated CSS (<a
href="https://redirect.github.com/tailwindlabs/tailwindcss/pull/14037">#14037</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="9824cb64a0"><code>9824cb6</code></a>
Update version in package.json</li>
<li><a
href="aa6c10f67f"><code>aa6c10f</code></a>
Add missing heading to changelog</li>
<li><a
href="245058c7fd"><code>245058c</code></a>
Update changelog for v3.4.7</li>
<li><a
href="605d8cd5eb"><code>605d8cd</code></a>
Update CHANGELOG.md</li>
<li><a
href="680c55c11c"><code>680c55c</code></a>
Normalize attribute selector for <code>data-*</code> and
<code>aria-*</code> modifiers (<a
href="https://redirect.github.com/tailwindlabs/tailwindcss/issues/14037">#14037</a>)</li>
<li><a
href="866860e6a6"><code>866860e</code></a>
Print eventual lightning CSS parsing errors when the CSS matcher fail
(<a
href="https://redirect.github.com/tailwindlabs/tailwindcss/issues/14034">#14034</a>)</li>
<li><a
href="bdc87ae1d7"><code>bdc87ae</code></a>
Fix class detection in Slim templates with attached attributes and IDs
(<a
href="https://redirect.github.com/tailwindlabs/tailwindcss/issues/14019">#14019</a>)</li>
<li>See full diff in <a
href="https://github.com/tailwindlabs/tailwindcss/compare/v3.4.6...v3.4.7">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tailwindcss&package-manager=npm_and_yarn&previous-version=3.4.6&new-version=3.4.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-08-01 14:52:47 +00:00
dependabot[bot]
122f11892c build(deps-dev): Bump @types/node from 20.14.12 to 22.0.2 in /rust/gui-client (#6124)
Bumps
[@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)
from 20.14.12 to 22.0.2.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@types/node&package-manager=npm_and_yarn&previous-version=20.14.12&new-version=22.0.2)](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-08-01 14:15:15 +00:00
Jamil
09c108cd20 fix(connlib): make Relay connectivity error log at ERROR level (#6105)
This almost always indicate a user-impacting connectivity error. For
customers troubleshooting their Gateways by greping for `ERROR`, this
will make these much easier to find.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2024-08-01 01:07:45 +00:00
Gabi
5841f297a5 fix(gateway): prevent routing loops (#6096)
In some weird conditions there might be routing loops in the gateway
too, so this fixes it and it doesn't do any harm.

Could be the cause behind [these
logs](https://github.com/firezone/firezone/issues/6067#issuecomment-2259081958)
2024-07-30 22:29:38 +00:00
Thomas Eizinger
64d2d89542 test(connlib): add coverage for the Internet Resource (#6089)
With the upcoming feature of full-route tunneling aka an "Internet
Resource", we need to expand the reference state machine in
`tunnel_test`. In particular, packets to non-resources will now be
routed the gateway if we have previously activated the Internet
resource.

This is reasonably easy to model as we can see from the small diff.

Because `connlib` doesn't actually support the Internet resource yet,
the code snippet for where it is added to the list of all possible
resources to sample from is commented out.
2024-07-30 22:04:38 +00:00
Thomas Eizinger
a25e1d10f0 chore: optimise tunnel_test debug output (#6088)
When `tunnel_test` fails, it prints the initial state in verbose debug
formatting. Most of the fields in `RefClient` track state _during_ the
runtime of the test and are all empty initially. The same thing applies
to `Host`.

To make this output easier to read and scroll, we ignore some of these
fields in the debug output.
2024-07-30 21:15:48 +00:00
Thomas Eizinger
308d49865d build(deps): remove proptest fork (#6084)
The bugfix we have been waiting on has been merged and thus we no longer
need to rely on our fork.

Related: https://github.com/proptest-rs/proptest/pull/482.
2024-07-30 21:14:13 +00:00
dependabot[bot]
bd49298240 build(deps): Bump tokio from 1.38.0 to 1.39.2 in /rust (#6082)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.38.0 to 1.39.2.
<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.39.2</h2>
<h1>1.39.2 (July 27th, 2024)</h1>
<p>This release fixes a regression where the <code>select!</code> macro
stopped accepting expressions that make use of temporary lifetime
extension. (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6722">#6722</a>)</p>
<p><a
href="https://redirect.github.com/tokio-rs/tokio/issues/6722">#6722</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6722">tokio-rs/tokio#6722</a></p>
<h2>Tokio v1.39.1</h2>
<h1>1.39.1 (July 23rd, 2024)</h1>
<p>This release reverts &quot;time: avoid traversing entries in the time
wheel twice&quot; because it contains a bug. (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6715">#6715</a>)</p>
<p><a
href="https://redirect.github.com/tokio-rs/tokio/issues/6715">#6715</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6715">tokio-rs/tokio#6715</a></p>
<h2>Tokio v1.39.0</h2>
<h1>1.39.0 (July 23rd, 2024)</h1>
<ul>
<li>This release bumps the MSRV to 1.70. (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6645">#6645</a>)</li>
<li>This release upgrades to mio v1. (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6635">#6635</a>)</li>
<li>This release upgrades to windows-sys v0.52 (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6154">#6154</a>)</li>
</ul>
<h3>Added</h3>
<ul>
<li>io: implement <code>AsyncSeek</code> for <code>Empty</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6663">#6663</a>)</li>
<li>metrics: stabilize <code>num_alive_tasks</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6619">#6619</a>,
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6667">#6667</a>)</li>
<li>process: add <code>Command::as_std_mut</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6608">#6608</a>)</li>
<li>sync: add <code>watch::Sender::same_channel</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6637">#6637</a>)</li>
<li>sync: add
<code>{Receiver,UnboundedReceiver}::{sender_strong_count,sender_weak_count}</code>
(<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6661">#6661</a>)</li>
<li>sync: implement <code>Default</code> for <code>watch::Sender</code>
(<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6626">#6626</a>)</li>
<li>task: implement <code>Clone</code> for <code>AbortHandle</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6621">#6621</a>)</li>
<li>task: stabilize <code>consume_budget</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6622">#6622</a>)</li>
</ul>
<h3>Changed</h3>
<ul>
<li>io: improve panic message of <code>ReadBuf::put_slice()</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6629">#6629</a>)</li>
<li>io: read during write in <code>copy_bidirectional</code> and
<code>copy</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6532">#6532</a>)</li>
<li>runtime: replace <code>num_cpus</code> with
<code>available_parallelism</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6709">#6709</a>)</li>
<li>task: avoid stack overflow when passing large future to
<code>block_on</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6692">#6692</a>)</li>
<li>time: avoid traversing entries in the time wheel twice (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6584">#6584</a>)</li>
<li>time: support <code>IntoFuture</code> with <code>timeout</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6666">#6666</a>)</li>
<li>macros: support <code>IntoFuture</code> with <code>join!</code> and
<code>select!</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6710">#6710</a>)</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>docs: fix docsrs builds with the fs feature enabled (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6585">#6585</a>)</li>
<li>io: only use short-read optimization on known-to-be-compatible
platforms (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6668">#6668</a>)</li>
<li>time: fix overflow panic when using large durations with
<code>Interval</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6612">#6612</a>)</li>
</ul>
<h3>Added (unstable)</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="f602eae499"><code>f602eae</code></a>
chore: prepare Tokio v1.39.2 (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6730">#6730</a>)</li>
<li><a
href="438def7957"><code>438def7</code></a>
macros: allow temporary lifetime extension in select (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6722">#6722</a>)</li>
<li><a
href="ee8d4d1b05"><code>ee8d4d1</code></a>
chore: fix ci failures (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6725">#6725</a>)</li>
<li><a
href="3297052763"><code>3297052</code></a>
ci: test Quinn in CI (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6719">#6719</a>)</li>
<li><a
href="f8fe0ffb23"><code>f8fe0ff</code></a>
chore: prepare Tokio v1.39.1 (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6716">#6716</a>)</li>
<li><a
href="47210a8e6e"><code>47210a8</code></a>
time: revert &quot;avoid traversing entries in the time wheel
twice&quot; (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6715">#6715</a>)</li>
<li><a
href="29545d9037"><code>29545d9</code></a>
runtime: ignore many_oneshot_futures test for alt scheduler (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6712">#6712</a>)</li>
<li><a
href="48e35c11d9"><code>48e35c1</code></a>
chore: release Tokio v1.39.0 (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6711">#6711</a>)</li>
<li><a
href="dd1d37167d"><code>dd1d371</code></a>
macros: accept <code>IntoFuture</code> args for macros (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6710">#6710</a>)</li>
<li><a
href="6a1a7b1591"><code>6a1a7b1</code></a>
chore: prepare tokio-macros v2.4.0 (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6707">#6707</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/tokio-rs/tokio/compare/tokio-1.38.0...tokio-1.39.2">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.38.0&new-version=1.39.2)](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: Thomas Eizinger <thomas@eizinger.io>
2024-07-30 20:45:35 +00:00
Reactor Scram
1c4a85ff40 chore(gui-client): make links more obvious in the menu (#6071)
Closes https://github.com/firezone/firezone/issues/5954

After:
<img width="552" alt="image"
src="https://github.com/user-attachments/assets/2f923e5a-091e-49ec-8b55-07cacb87e0a7">

Before:

![image](https://github.com/user-attachments/assets/aff2fa59-13d3-492d-843c-5749bdc5ad14)

Puts angle brackets around links, e.g. `example.com` will copy that
text,
but `<https://example.com>` will open `https://example.com`/ in the
browser.

The Tauri menu is a least-common-denominator of Linux and Windows, so it
doesn't have nice features like blue underlines for hyperlinks.
2024-07-30 16:55:42 +00:00
Reactor Scram
e6cbb5fa8a feat(gui-client/linux): network roaming (#5978)
Closes #5846 

Will be moved down to the IPC service eventually.

The goal for connection roaming is not for totally transparent "Change
Wi-Fi networks without dropping SSH" handoffs, but just for Firezone to
re-connect itself as quickly as possible so that everything above us can
re-connect as quickly as it times out, and won't be hung up with a
broken tunnel.
2024-07-30 16:01:45 +00:00
Reactor Scram
7d1fa247c5 refactor(gui-client): refactor menu so it's testable (#6070)
Extracted from #5923
2024-07-30 15:51:40 +00:00
Thomas Eizinger
c6b576d1b1 fix(gateway): ignore non-client packets (#6086)
On the gateway, the only packets we are interested in receiving on the
TUN device are the ones destined for clients. To achieve this, we
specifically set routes for the reserved IP ranges on our interface.

Multicast packets as such as MLDV2 get sent to all packets and cause
unnecessary noise in our logs. Thus, as a defense-in-depth measure, we
drop all packets outside of the IP ranges reserved for our clients.
2024-07-30 06:34:36 +00:00
Thomas Eizinger
0230708182 feat(connlib): pick a single relay for each connection (#6060)
Currently, each connection always uses all relays. That is pretty
wasteful in terms of bandwidth usage and processing power because we
only ever need a a single relay for a connection. When we re-deploy
relays, we actively invalidate them, meaning the connection gets cut
instantly without waiting for an ICE timeout and the next packet will
establish a new one.

This is now also asserted with a dedicated transition in `tunnel_test`.

To correctly simulate this in `tunnel_test`, we always cut the
connection to all relays. This frees us from modelling `connlib`'s
internal strategy for picking a relay which keeps the reference state
simple.

Resolves: #6014.
2024-07-30 03:44:40 +00:00
dependabot[bot]
026feefc2c build(deps): Bump log from 0.4.21 to 0.4.22 in /rust (#6081)
Bumps [log](https://github.com/rust-lang/log) from 0.4.21 to 0.4.22.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/rust-lang/log/blob/master/CHANGELOG.md">log's
changelog</a>.</em></p>
<blockquote>
<h2>[0.4.22] - 2024-06-27</h2>
<h2>What's Changed</h2>
<ul>
<li>Add some clarifications to the library docs by <a
href="https://github.com/KodrAus"><code>@​KodrAus</code></a> in <a
href="https://redirect.github.com/rust-lang/log/pull/620">rust-lang/log#620</a></li>
<li>Add links to <code>colog</code> crate by <a
href="https://github.com/chrivers"><code>@​chrivers</code></a> in <a
href="https://redirect.github.com/rust-lang/log/pull/621">rust-lang/log#621</a></li>
<li>adding line_number test + updating some testing infrastructure by <a
href="https://github.com/DIvkov575"><code>@​DIvkov575</code></a> in <a
href="https://redirect.github.com/rust-lang/log/pull/619">rust-lang/log#619</a></li>
<li>Clarify the actual set of functions that can race in _racy variants
by <a href="https://github.com/KodrAus"><code>@​KodrAus</code></a> in <a
href="https://redirect.github.com/rust-lang/log/pull/623">rust-lang/log#623</a></li>
<li>Replace deprecated std::sync::atomic::spin_loop_hint() by <a
href="https://github.com/Catamantaloedis"><code>@​Catamantaloedis</code></a>
in <a
href="https://redirect.github.com/rust-lang/log/pull/625">rust-lang/log#625</a></li>
<li>Check usage of max_level features by <a
href="https://github.com/Thomasdezeeuw"><code>@​Thomasdezeeuw</code></a>
in <a
href="https://redirect.github.com/rust-lang/log/pull/627">rust-lang/log#627</a></li>
<li>Remove unneeded import by <a
href="https://github.com/Thomasdezeeuw"><code>@​Thomasdezeeuw</code></a>
in <a
href="https://redirect.github.com/rust-lang/log/pull/628">rust-lang/log#628</a></li>
<li>Loosen orderings for logger initialization in <a
href="https://redirect.github.com/rust-lang/log/pull/632">rust-lang/log#632</a>.
Originally by <a
href="https://github.com/pwoolcoc"><code>@​pwoolcoc</code></a> in <a
href="https://redirect.github.com/rust-lang/log/pull/599">rust-lang/log#599</a></li>
<li>Use Location::caller() for file and line info in <a
href="https://redirect.github.com/rust-lang/log/pull/633">rust-lang/log#633</a>.
Originally by <a
href="https://github.com/Cassy343"><code>@​Cassy343</code></a> in <a
href="https://redirect.github.com/rust-lang/log/pull/520">rust-lang/log#520</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/chrivers"><code>@​chrivers</code></a>
made their first contribution in <a
href="https://redirect.github.com/rust-lang/log/pull/621">rust-lang/log#621</a></li>
<li><a href="https://github.com/DIvkov575"><code>@​DIvkov575</code></a>
made their first contribution in <a
href="https://redirect.github.com/rust-lang/log/pull/619">rust-lang/log#619</a></li>
<li><a
href="https://github.com/Catamantaloedis"><code>@​Catamantaloedis</code></a>
made their first contribution in <a
href="https://redirect.github.com/rust-lang/log/pull/625">rust-lang/log#625</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/rust-lang/log/compare/0.4.21...0.4.22">https://github.com/rust-lang/log/compare/0.4.21...0.4.22</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="d5ba2cfee9"><code>d5ba2cf</code></a>
Merge pull request <a
href="https://redirect.github.com/rust-lang/log/issues/634">#634</a>
from rust-lang/cargo/0.4.22</li>
<li><a
href="d1a8306aad"><code>d1a8306</code></a>
prepare for 0.4.22 release</li>
<li><a
href="46894ef229"><code>46894ef</code></a>
Merge pull request <a
href="https://redirect.github.com/rust-lang/log/issues/633">#633</a>
from rust-lang/feat/panic-info</li>
<li><a
href="e0d389c9ca"><code>e0d389c</code></a>
Merge pull request <a
href="https://redirect.github.com/rust-lang/log/issues/632">#632</a>
from rust-lang/feat/loosen-atomics</li>
<li><a
href="c9e5e13e9b"><code>c9e5e13</code></a>
use Location::caller() for file and line info</li>
<li><a
href="507b672660"><code>507b672</code></a>
loosen orderings for logger initialization</li>
<li><a
href="c879b011a8"><code>c879b01</code></a>
Merge pull request <a
href="https://redirect.github.com/rust-lang/log/issues/628">#628</a>
from Thomasdezeeuw/fix-warnings</li>
<li><a
href="405fdb4d9f"><code>405fdb4</code></a>
Merge pull request <a
href="https://redirect.github.com/rust-lang/log/issues/627">#627</a>
from Thomasdezeeuw/check-features</li>
<li><a
href="1307ade112"><code>1307ade</code></a>
Remove unneeded import</li>
<li><a
href="710560ecb7"><code>710560e</code></a>
Don't use --all-features in CI</li>
<li>Additional commits viewable in <a
href="https://github.com/rust-lang/log/compare/0.4.21...0.4.22">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=log&package-manager=cargo&previous-version=0.4.21&new-version=0.4.22)](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-07-30 02:04:01 +00:00
Thomas Eizinger
14a93e0d4d refactor(connlib): use const ctors for IpNetwork (#6085) 2024-07-30 00:31:32 +00:00
dependabot[bot]
509f7ab6c4 build(deps): Bump zip from 2.1.3 to 2.1.5 in /rust (#6079)
Bumps [zip](https://github.com/zip-rs/zip2) from 2.1.3 to 2.1.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/zip-rs/zip2/releases">zip's
releases</a>.</em></p>
<blockquote>
<h2>v2.1.5</h2>
<h3><!-- raw HTML omitted -->🚜 Refactor</h3>
<ul>
<li>change invalid_state() return type to io::Result<!-- raw HTML
omitted --></li>
</ul>
<h2>v2.1.4</h2>
<h3><!-- raw HTML omitted -->🐛 Bug Fixes</h3>
<ul>
<li>fix(<a
href="https://redirect.github.com/zip-rs/zip2/pull/215">#215</a>):
Upgrade to deflate64 0.1.9</li>
<li>Panic when reading a file truncated in the middle of an XZ block
header</li>
<li>Some archives with over u16::MAX files were handled incorrectly or
slowly (<a
href="https://redirect.github.com/zip-rs/zip2/pull/189">#189</a>)</li>
<li>Check number of files when deciding whether a CDE is the real
one</li>
<li>Could still select a fake CDE over a real one in some cases</li>
<li>May have to consider multiple CDEs before filtering for
validity</li>
<li>We now keep searching for a real CDE header after read an invalid
one from the file comment</li>
<li>Always search for data start when opening an archive for append, and
reject the header if data appears to start after central directory</li>
<li><code>deep_copy_file</code> no longer allows overwriting an existing
file, to match the behavior of <code>shallow_copy_file</code></li>
<li>File start position was wrong when extra data was present</li>
<li>Abort file if central extra data is too large</li>
<li>Overflow panic when central directory extra data is too large</li>
<li>ZIP64 header was being written twice when copying a file</li>
<li>ZIP64 header was being written to central header twice</li>
<li>Start position was incorrect when file had no extra data</li>
<li>Allow all reserved headers we can create</li>
<li>Fix a bug where alignment padding interacts with other extra-data
fields</li>
<li>Fix bugs involving alignment padding and Unicode extra fields</li>
<li>Incorrect header when adding AES-encrypted files</li>
<li>Parse the extra field and reject it if invalid</li>
<li>Incorrect behavior following a rare combination of
<code>merge_archive</code>, <code>abort_file</code> and
<code>deep_copy_file</code>. As well, we now return an error when a file
is being copied to itself.</li>
<li>path_to_string now properly handles the case of an empty path</li>
<li>Implement <code>Debug</code> for <code>ZipWriter</code> even when
it's not implemented for the inner writer's type</li>
<li>Fix an issue where the central directory could be incorrectly
detected</li>
<li><code>finish_into_readable()</code> would corrupt the archive if the
central directory had moved</li>
</ul>
<h3><!-- raw HTML omitted -->🚜 Refactor</h3>
<ul>
<li>Verify with debug assertions that no FixedSizeBlock expects a
multi-byte alignment (<a
href="https://redirect.github.com/zip-rs/zip2/pull/198">#198</a>)</li>
<li>Use new do_or_abort_file method</li>
</ul>
<h3><!-- raw HTML omitted --> Performance</h3>
<ul>
<li>Speed up CRC when encrypting small files</li>
<li>Limit the number of extra fields</li>
<li>Refactor extra-data validation</li>
<li>Store extra data in plain vectors until after validation</li>
<li>Only build one IndexMap after choosing among the possible valid
headers</li>
<li>Simplify validation of empty extra-data fields</li>
<li>Validate automatic extra-data fields only once, even if several are
present</li>
<li>Remove redundant <code>validate_extra_data()</code> call</li>
<li>Skip searching for the ZIP32 header if a valid ZIP64 header is
present (<a
href="https://redirect.github.com/zip-rs/zip2/pull/189">#189</a>)</li>
</ul>
<h3><!-- raw HTML omitted -->⚙️ Miscellaneous Tasks</h3>
<ul>
<li>Fix a bug introduced by c934c824</li>
<li>Fix a failing unit test</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/zip-rs/zip2/blob/master/CHANGELOG.md">zip's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="https://github.com/zip-rs/zip2/compare/v2.1.4...v2.1.5">2.1.5</a>
- 2024-07-20</h2>
<h3><!-- raw HTML omitted -->🚜 Refactor</h3>
<ul>
<li>change invalid_state() return type to io::Result<!-- raw HTML
omitted --></li>
</ul>
<h2><a
href="https://github.com/zip-rs/zip2/compare/v2.1.3...v2.1.4">2.1.4</a>
- 2024-07-18</h2>
<h3><!-- raw HTML omitted -->🐛 Bug Fixes</h3>
<ul>
<li>fix(<a
href="https://redirect.github.com/zip-rs/zip2/pull/215">#215</a>):
Upgrade to deflate64 0.1.9</li>
<li>Panic when reading a file truncated in the middle of an XZ block
header</li>
<li>Some archives with over u16::MAX files were handled incorrectly or
slowly (<a
href="https://redirect.github.com/zip-rs/zip2/pull/189">#189</a>)</li>
<li>Check number of files when deciding whether a CDE is the real
one</li>
<li>Could still select a fake CDE over a real one in some cases</li>
<li>May have to consider multiple CDEs before filtering for
validity</li>
<li>We now keep searching for a real CDE header after read an invalid
one from the file comment</li>
<li>Always search for data start when opening an archive for append, and
reject the header if data appears to start after central directory</li>
<li><code>deep_copy_file</code> no longer allows overwriting an existing
file, to match the behavior of <code>shallow_copy_file</code></li>
<li>File start position was wrong when extra data was present</li>
<li>Abort file if central extra data is too large</li>
<li>Overflow panic when central directory extra data is too large</li>
<li>ZIP64 header was being written twice when copying a file</li>
<li>ZIP64 header was being written to central header twice</li>
<li>Start position was incorrect when file had no extra data</li>
<li>Allow all reserved headers we can create</li>
<li>Fix a bug where alignment padding interacts with other extra-data
fields</li>
<li>Fix bugs involving alignment padding and Unicode extra fields</li>
<li>Incorrect header when adding AES-encrypted files</li>
<li>Parse the extra field and reject it if invalid</li>
<li>Incorrect behavior following a rare combination of
<code>merge_archive</code>, <code>abort_file</code> and
<code>deep_copy_file</code>. As well, we now return an error when a file
is being copied to itself.</li>
<li>path_to_string now properly handles the case of an empty path</li>
<li>Implement <code>Debug</code> for <code>ZipWriter</code> even when
it's not implemented for the inner writer's type</li>
<li>Fix an issue where the central directory could be incorrectly
detected</li>
<li><code>finish_into_readable()</code> would corrupt the archive if the
central directory had moved</li>
</ul>
<h3><!-- raw HTML omitted -->🚜 Refactor</h3>
<ul>
<li>Verify with debug assertions that no FixedSizeBlock expects a
multi-byte alignment (<a
href="https://redirect.github.com/zip-rs/zip2/pull/198">#198</a>)</li>
<li>Use new do_or_abort_file method</li>
</ul>
<h3><!-- raw HTML omitted --> Performance</h3>
<ul>
<li>Speed up CRC when encrypting small files</li>
<li>Limit the number of extra fields</li>
<li>Refactor extra-data validation</li>
<li>Store extra data in plain vectors until after validation</li>
<li>Only build one IndexMap after choosing among the possible valid
headers</li>
<li>Simplify validation of empty extra-data fields</li>
<li>Validate automatic extra-data fields only once, even if several are
present</li>
<li>Remove redundant <code>validate_extra_data()</code> call</li>
<li>Skip searching for the ZIP32 header if a valid ZIP64 header is
present (<a
href="https://redirect.github.com/zip-rs/zip2/pull/189">#189</a>)</li>
</ul>
<h3><!-- raw HTML omitted -->⚙️ Miscellaneous Tasks</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="8fb107ad5e"><code>8fb107a</code></a>
chore: release (<a
href="https://redirect.github.com/zip-rs/zip2/issues/222">#222</a>)</li>
<li><a
href="a7c1230dfa"><code>a7c1230</code></a>
publicly export and document the zip64 threshold constants (<a
href="https://redirect.github.com/zip-rs/zip2/issues/79">#79</a>)</li>
<li><a
href="a60bd79826"><code>a60bd79</code></a>
Merge pull request <a
href="https://redirect.github.com/zip-rs/zip2/issues/210">#210</a> from
a1phyr/multiple_refactors</li>
<li><a
href="7471cf526f"><code>7471cf5</code></a>
refactor: change invalid_state() return type to io::Result&lt;T&gt;</li>
<li><a
href="9caa3b678f"><code>9caa3b6</code></a>
Merge pull request <a
href="https://redirect.github.com/zip-rs/zip2/issues/194">#194</a> from
zip-rs/release-plz-2024-06-15T04-17-17Z</li>
<li><a
href="8b11361b9e"><code>8b11361</code></a>
chore: release</li>
<li><a
href="55c2c64249"><code>55c2c64</code></a>
ci(fuzz): Set max length closer to current corpus entries' length</li>
<li><a
href="193bbe125b"><code>193bbe1</code></a>
fix(<a
href="https://redirect.github.com/zip-rs/zip2/issues/215">#215</a>):
Upgrade to deflate64 0.1.9</li>
<li><a
href="4e971d07ab"><code>4e971d0</code></a>
Commit unfinished corpus</li>
<li><a
href="c14986806a"><code>c149868</code></a>
Fix divergence from origin/master</li>
<li>Additional commits viewable in <a
href="https://github.com/zip-rs/zip2/compare/v2.1.3...v2.1.5">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=zip&package-manager=cargo&previous-version=2.1.3&new-version=2.1.5)](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-07-29 23:46:48 +00:00
Gabi
c3a45f53df fix(connlib): prevent routing loops on windows (#6032)
In `connlib`, traffic is sent through sockets via one of three ways:

1. Direct p2p traffic between clients and gateways: For these, we always
explicitly set the source IP (and thus interface).
2. UDP traffic to the relays: For these, we let the OS pick an
appropriate source interface.
3. WebSocket traffic over TCP to the portal: For this too, we let the OS
pick the source interface.

For (2) and (3), it is possible to run into routing loops, depending on
the routes that we have configured on the TUN device.

In Linux, we can prevent routing loops by marking a socket [0] and
repeating the mark when we add routes [1]. Packets sent via a marked
socket won't be routed by a rule that contains this mark. On Android, we
can do something similar by "protecting" a socket via a syscall on the
Java side [2].

On Windows, routing works slightly different. There, the source
interface is determined based on a computed metric [3] [4]. To prevent
routing loops on Windows, we thus need to find the "next best" interface
after our TUN interface. We can achieve this with a combination of
several syscalls:

1. List all interfaces on the machine
2. Ask Windows for the best route on each interface, except our TUN
interface.
3. Sort by Windows' routing metric and pick the lowest one (lower is
better).

Thanks to the abstraction of `SocketFactory` that we already previously
introduced, Integrating this into `connlib` isn't too difficult:

1. For TCP sockets, we simply resolve the best route after creating the
socket and then bind it to that local interface. That way, all packets
will always going via that interface, regardless of which routes are
present on our TUN interface.
2. UDP is connection-less so we need to decide per-packet, which
interface to use. "Pick the best interface for me" is modelled in
`connlib` via the `DatagramOut::src` field being `None`.
- To ensure those packets don't cause a routing loop, we introduce a
"source IP resolver" for our `UdpSocket`. This function gets called
every time we need to send a packet without a source IP.
- For improved performance, we cache these results. The Windows client
uses this source IP resolver to use the above devised strategy to find a
suitable source IP.
- In case the source IP resolution fails, we don't send the packet. This
is important, otherwise, the kernel might choose our TUN interface again
and trigger a routing loop.

The last remark to make here is that this also works for connection
roaming. The TCP socket gets thrown away when we reconnect to the
portal. Thus, the new socket will pick the new best interface as it is
re-created. The UDP sockets also get thrown away as part of roaming.
That clears the above cache which is what we want: Upon roaming, the
best interface for a given destination IP will likely have changed.

[0]:
59014a9622/rust/headless-client/src/linux.rs (L19-L29)
[1]:
59014a9622/rust/bin-shared/src/tun_device_manager/linux.rs (L204-L224)
[2]:
59014a9622/rust/connlib/clients/android/src/lib.rs (L535-L549)
[3]:
https://learn.microsoft.com/en-us/previous-versions/technet-magazine/cc137807(v=msdn.10)?redirectedfrom=MSDN
[4]:
https://learn.microsoft.com/en-us/windows-server/networking/technologies/network-subsystem/net-sub-interface-metric

Fixes: #5955.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-07-29 22:25:42 +00:00
Thomas Eizinger
194eebd164 fix(connlib): de-prioritise timeout handling (#6077)
`connlib`'s event loop performs work in a very particular order:

1. Local buffers like IP, UDP and DNS packets are emptied.
2. Time-sensitive tasks, if any, are performed.
3. New UDP packets are processed.
4. New IP packets (from the TUN device) are processed.

This priority ensures we don't accept more work (i.e. new packets) until
we have finished processing existing work. As a result, we can keep
local buffers small and processing latencies low.

I am not completely confident on the issue of #6067 but if the busy-loop
originates from a bad timer, then the above priority means we never get
to the part where we read new UDP or IP packets and components such a
`PhoenixChannel` - which operate outside of `connlib'`s event loop -
don't get any CPU time.

A naive fix for this problem is to just de-prioritise the polling of the
timer within `Io::poll`. I say naive because without additional changes,
this could delay the processing of time-sensitive tasks on a very busy
client / gateway where packets are constantly arriving and thus we
never[^1] reach the part where the timer gets polled.

To fix this, we make two distinct changes:

1. We pro-actively break from `connlib'`s event loop every 5000
iterations. This ensures that even on a very busy system, other
components like the `PhoenixChannel` get a chance to do _some_ work once
in a while.
2. In case we force-yield from the event loop, we call `handle_timeout`
and immediately schedule a new wake-up. This ensures time does advance
in regular intervals as well and we don't get wrongly suspended by the
runtime.

These changes don't prevent any timer-loops by themselves. With a
timer-loop, we still busy-loop for 5000 iterations and thus
unnecessarily burn through some CPU cycles. The important bit however is
that we stay operational and can accept packets and portal messages. Any
of them might change the state such that the timer value changes, thus
allowing `connlib` to self-heal from this loop.

Fixes: #6067.

[^1]: This is an assumption based on the possible control flow. In
practise, I believe that reading from the sockets or the TUN device is a
much slower operation than processing the packets. Thus, we should
eventually hit the the timer path too.
2024-07-29 22:16:10 +00:00
Reactor Scram
6e24e0201e chore(rust): bump Rust to 1.80 (#6065)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-07-29 14:16:22 +00:00
Thomas Eizinger
b29341be62 fix(connlib): clear timeout after it fired (#6076)
We don't want the timer to fire multiple times at the same `Instant`
unless it has been specifically set to that `Instant` again. Thus, clear
the timer after it fired.

I don't think this fixed #6067 but it can't hurt.
2024-07-28 21:24:17 +00:00
Thomas Eizinger
fc4b8c7b46 refactor: rename reconnect to reset (#6057)
Connection roaming within `connlib` has changed a fair-bit since we
introduced the `reconnect` function. The new implementation is basically
a hard-reset of all state within `connlib`. Renaming this function
across all layers makes this more obvious.

Resolves: #6038.
2024-07-28 07:41:45 +00:00
Thomas Eizinger
356dd12e7f chore(connlib): remove duplicate Device::poll_read function (#6072)
The `Device` implementation is no longer platform-specific so we can
delete the duplicated `poll_read` function.
2024-07-28 06:05:37 +00:00
Reactor Scram
05e3a38701 refactor(bin-shared): remove CommonArgs (#6068)
Closes #6025

It was only used in the Gateway, so we inline it there and remove `clap`
as a dep for ~~that crate~~ `bin-shared`
2024-07-26 21:48:09 +00:00
Thomas Eizinger
90f74aa35e test(snownet): minor tidy-up (#6056)
Came across this while looking into #6014.
2024-07-26 19:51:24 +00:00
Reactor Scram
6862213cc2 fix(headless-client/linux): only notify systemd that we're up after Resources are available (#6026)
Closes #5912

Before this, I had the `--exit` CLI flag and the `sd_notify` call
hanging off the wrong callback.
2024-07-26 18:53:08 +00:00
Gabi
a39b853bc1 fix(windows,linux): ensure set_routes is idempotent (#6051)
Windows may delete the default route during roaming. To prevent this
from causing problems, we make `set_routes` add all routes regardless of
the previously stored ones. The known routes are only used to compute,
what routes are to be removed.

For Linux we do the same to make it consistent across platforms.

This also give us the chance to not clear the cache when ips are set,
since now all routes are always added, meaning they will be always
re-added when roaming.

Overall, this more closely aligns Linux and Windows with how Firezone
works on Apple and Android. There, we always remove all routes and set
new ones. Removing routes happens very rarely (only when CIDR resources
are deactivated), thus, not removing all and re-adding the routes is
still deemed to be worth it.

With the new implementation, this is guaranteed to always make the new
routes take effect and at the same time be idempotent.

---------

Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-07-26 05:13:58 +00:00
Thomas Eizinger
f800875aff fix(relay): don't hang when connecting to OTLP exporter (#6034)
The dependency update in #6003 introduced a regression: Connecting to
the OTLP exporter was hanging forever and thus the relay failed to start
up.

The hang seems to be related to _dropping_ the `meter_provider`. Looking
at the changelog update, this change was actually called out:
https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/CHANGELOG.md#v0170.

By setting these providers globally, the relay starts up just fine.

To ensure this doesn't regress again, we add an OTEL collector to our
`docker-compose.yml` and configure the `relay-1` to connect to it.
2024-07-25 10:36:42 -06:00