Commit Graph

566 Commits

Author SHA1 Message Date
dependabot[bot]
97eb506bb3 build(deps): Bump tokio from 1.35.1 to 1.36.0 in /rust (#3561)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.35.1 to 1.36.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.36.0</h2>
<h1>1.36.0 (February 2nd, 2024)</h1>
<h3>Added</h3>
<ul>
<li>io: add <code>tokio::io::Join</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6220">#6220</a>)</li>
<li>io: implement <code>AsyncWrite</code> for <code>Empty</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6235">#6235</a>)</li>
<li>net: add support for anonymous unix pipes (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6127">#6127</a>)</li>
<li>net: add <code>UnixSocket</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6290">#6290</a>)</li>
<li>net: expose keepalive option on <code>TcpSocket</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6311">#6311</a>)</li>
<li>sync: add <code>{Receiver,UnboundedReceiver}::poll_recv_many</code>
(<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6236">#6236</a>)</li>
<li>sync: add <code>Sender::{try_,}reserve_many</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6205">#6205</a>)</li>
<li>sync: add <code>watch::Receiver::mark_unchanged</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6252">#6252</a>)</li>
<li>task: add <code>JoinSet::try_join_next</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6280">#6280</a>)</li>
</ul>
<h3>Changed</h3>
<ul>
<li>io: make <code>copy</code> cooperative (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6265">#6265</a>)</li>
<li>io: make <code>repeat</code> and <code>sink</code> cooperative (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6254">#6254</a>)</li>
<li>io: simplify check for empty slice (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6293">#6293</a>)</li>
<li>process: use pidfd on Linux when available (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6152">#6152</a>)</li>
<li>sync: use AtomicBool in broadcast channel future (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6298">#6298</a>)</li>
</ul>
<h3>Documented</h3>
<ul>
<li>io: clarify <code>clear_ready</code> docs (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6304">#6304</a>)</li>
<li>net: document that <code>*Fd</code> traits on <code>TcpSocket</code>
are unix-only (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6294">#6294</a>)</li>
<li>sync: document FIFO behavior of <code>tokio::sync::Mutex</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6279">#6279</a>)</li>
<li>chore: typographic improvements (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6262">#6262</a>)</li>
<li>runtime: remove obsolete comment (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6303">#6303</a>)</li>
<li>task: fix typo (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6261">#6261</a>)</li>
</ul>
<p><a
href="https://redirect.github.com/tokio-rs/tokio/issues/6220">#6220</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6220">tokio-rs/tokio#6220</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6235">#6235</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6235">tokio-rs/tokio#6235</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6127">#6127</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6127">tokio-rs/tokio#6127</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6290">#6290</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6290">tokio-rs/tokio#6290</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6311">#6311</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6311">tokio-rs/tokio#6311</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6236">#6236</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6236">tokio-rs/tokio#6236</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6205">#6205</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6205">tokio-rs/tokio#6205</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6252">#6252</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6252">tokio-rs/tokio#6252</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6280">#6280</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6280">tokio-rs/tokio#6280</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6265">#6265</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6265">tokio-rs/tokio#6265</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6254">#6254</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6254">tokio-rs/tokio#6254</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6293">#6293</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6293">tokio-rs/tokio#6293</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6238">#6238</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6238">tokio-rs/tokio#6238</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6152">#6152</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6152">tokio-rs/tokio#6152</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6298">#6298</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6298">tokio-rs/tokio#6298</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6262">#6262</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6262">tokio-rs/tokio#6262</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6303">#6303</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6303">tokio-rs/tokio#6303</a>
<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6261">#6261</a>:
<a
href="https://redirect.github.com/tokio-rs/tokio/pull/6261">tokio-rs/tokio#6261</a></p>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="eaf81ed324"><code>eaf81ed</code></a>
chore: prepare Tokio v1.36.0 (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6312">#6312</a>)</li>
<li><a
href="53f9e5a357"><code>53f9e5a</code></a>
ci: make sure dictionary words are sorted and unique (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6316">#6316</a>)</li>
<li><a
href="9077762545"><code>9077762</code></a>
net: expose keepalive option on <code>TcpSocket</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6311">#6311</a>)</li>
<li><a
href="131e7b4e49"><code>131e7b4</code></a>
ci: add spellchecking (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6297">#6297</a>)</li>
<li><a
href="e53b92a993"><code>e53b92a</code></a>
io: clarify <code>clear_ready</code> docs (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6304">#6304</a>)</li>
<li><a
href="7536132065"><code>7536132</code></a>
sync: use AtomicBool in broadcast channel future (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6298">#6298</a>)</li>
<li><a
href="b6d0c9091d"><code>b6d0c90</code></a>
macros: fix trait_method breaking change detection (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6308">#6308</a>)</li>
<li><a
href="4846959e8a"><code>4846959</code></a>
runtime: remove obsolete comment (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6303">#6303</a>)</li>
<li><a
href="ec3038357f"><code>ec30383</code></a>
net: add <code>UnixSocket</code> (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6290">#6290</a>)</li>
<li><a
href="f80bbec28f"><code>f80bbec</code></a>
io: simplify check for empty slice (<a
href="https://redirect.github.com/tokio-rs/tokio/issues/6293">#6293</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/tokio-rs/tokio/compare/tokio-1.35.1...tokio-1.36.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.35.1&new-version=1.36.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 <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-15 23:25:36 +00:00
Gabi
55e4fb100f fix(gateway): re-implement resource address resolution in eventloop (#3656)
Reimplements what #3654 reverted with a fix

---------

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-02-15 20:51:59 +00:00
Reactor Scram
0fbd40fcb2 feat(linux): Notify systemd when we've started (#3628)
Regardless of `FIREZONE_DNS_CONTROL`, always try to notify systemd that
we've started.

I had accidentally conflated the idea of running as a systemd service
with the idea of using systemd to control DNS. They're separate, but
I'll keep the service unit in here and always use `sd-notify` since it
should be harmless to use even in Alpine.

~~If `FIREZONE_DNS_CONTROL` is `systemd-resolved`, try to notify systemd
that we've finished startup and the tunnel is ready.~~

Also adds a CI test, including a systemd service file that is **not**
ready for general use.
Ready for review once it's green.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-02-15 20:12:37 +00:00
Reactor Scram
085351f455 revert: 3622 to fix failing DNS CI test (#3654)
Reverts #3622 I don't know why, but that change seemed to cause the
`/etc/resolv.conf` test to fail in CI and I was thinking of the "roll
back first" principle
https://cloud.google.com/blog/products/gcp/reliable-releases-and-rollbacks-cre-life-lessons

~~I also change one `ping` in CI to `until ping`. This was an earlier
attempt before I did the revert, and it seems safe to leave it in.~~
2024-02-15 19:26:34 +00:00
Thomas Eizinger
c53553cd26 feat(snownet): timeout connections without a handshake after 20 seconds (#3633)
It was discovered by @conectado that this timeout needs to be longer
than 10 seconds.
2024-02-15 01:55:46 +00:00
Thomas Eizinger
23e89c7290 feat(snownet): attempt to make new allocation when refresh fails (#3631)
Initially, we thought that we need to replace the entire `Allocation` if
the credentials to the relay change. However, during testing it turned
out that the credentials will change every time the portal sends us new
credentials. Likely, the portal hashes some kind of nonce into the
password as well.

Consequently, throwing away the entire state of the `Allocation` is
wrong. Instead, we will simply try to refresh the allocation using the
new credentials. If the refresh fails, we will try to make a new
allocation. If that also fails unrecoverably, then we "suspend" the
allocation, i.e. the `Allocation` will not perform any further action by
itself.

In case we get a new `refresh` call (which happens every time we want to
use the `Allocation` for a connection), we restart things and try to
make a new one.
2024-02-15 01:41:10 +00:00
Thomas Eizinger
f42aa862a8 refactor(gateway): perform DNS resolution of resources in eventloop (#3622)
With #3391, constructing a new tunnel will no longer be `async` which
makes DNS resolution the only `async` component of
`set_peer_connection_request`. In general, adding resources as part of
setting up a connection is a duplicated of the logic within
`allow_access`.

We solve both of these problems at once by moving the DNS resolution out
of `connlib` into the `gateway` binary and perform it as part of the
eventloop during a connection setup.
2024-02-15 01:40:44 +00:00
Thomas Eizinger
890217a1ff feat(snownet): invalidate candidates (#3604)
Invalidating candidates should give `str0m` a hint that it may have to
switch to a different candidate pair.
2024-02-15 00:26:14 +00:00
Reactor Scram
00f6fcdd09 feat(linux): If FIREZONE_DNS_CONTROL is etc-resolv-conf, modify '/etc/resolv.conf' (#3639)
Only user-facing if users are using the Docker image for the Linux
client.

I split off a module for `/etc/resolv.conf` since the code and unit
tests are about 300 lines and aren't related to the rest of the
`tun_linux.rs` code.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-02-14 23:50:01 +00:00
Thomas Eizinger
29ef4d7769 chore(snownet): better logging (#3646)
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-02-14 21:31:27 +00:00
Jamil
724a487a02 fix(android): prevent null pointer segfault on 32-bit platforms (#3619)
Without this alignment, accessing the `name` field reliably produces a
segfault:

```
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1d in tid 13835 (Thread-7), pid 13757 (irezone.android)
```

Interestingly, this only happens in release builds on 32-bit platforms.
Logging the returned name fixes it too which hints at some kind of
optimisation issue. Adding a padding is the most reliable fix.

Fixes: #3637.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-02-14 06:22:46 +00:00
Reactor Scram
1056af4020 feat(linux): Add FIREZONE_DNS_CONTROL env var to choose which DNS control method to use (#3629)
The Docker image for the client is opted in to this new feature. The
bare `linux-client-x64` exe is not. I don't know if users are using the
Docker images?

I wanted to use CLI args, but the DNS control code ("config" or
"control"? Or "SplitDNS"?) has to run at the end of `set_iface_config`,
which on Linux runs in a worker, so I couldn't figure out how to move it
into `on_set_interface_config` in the callbacks. Maybe there is a way,
but the env var results in a small diff.
2024-02-14 02:54:16 +00:00
Thomas Eizinger
8b2cf37722 fix(snownet): remove debug_assert! for timed-out connections (#3635) 2024-02-14 02:41:51 +00:00
Thomas Eizinger
37ee760849 feat(snownet): only emit ConnectionEstablished upon the first connection (#3634) 2024-02-14 02:39:35 +00:00
Thomas Eizinger
6b4f1a02a7 feat(snownet): remove wireguard keep-alives (#3630)
`str0m` sends its own STUN keep-alives and @conectado has already
removed the logic that uses the wireguard keep-alives to detect stale
connections in
8234529cdf
as part of the integration of `snownet`.

We don't need two keep-alive mechanisms at once.
2024-02-14 02:34:44 +00:00
Jamil
02171189a8 chore(connlib): Make request ioctl mutable (#3644)
Technically, the data held by the ioctl request is changing, so make
them mutable.
2024-02-14 02:23:51 +00:00
Jamil
cde1c50f95 refactor(android): Simplify tunnel implementation and fix tunnel lifecycle (#3583)
Fixes #3578 
Fixes #3551 

The issue turned out to be a bunk Repository. Upon unraveling that ball
of yarn, I decided to clean up the Tunnel implementation altogether. It
uses the existing tunnel in-memory store for pushing updates to a
connected SessionActivity.

This PR includes many bug fixes as well.
2024-02-13 21:10:51 +00:00
dependabot[bot]
9d0af9a811 build(deps): Bump crash-handler from 0.6.0 to 0.6.1 in /rust (#3623)
Bumps [crash-handler](https://github.com/EmbarkStudios/crash-handling)
from 0.6.0 to 0.6.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/EmbarkStudios/crash-handling/releases">crash-handler's
releases</a>.</em></p>
<blockquote>
<h2>crash-handler-0.6.1</h2>
<h3>Added</h3>
<ul>
<li><a
href="https://redirect.github.com/EmbarkStudios/crash-handling/pull/81">PR#81</a>
resolved <a
href="https://redirect.github.com/EmbarkStudios/crash-handling/issues/79">#79</a>
by adding <code>make_single_crash_event</code>.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="d34d00bc51"><code>d34d00b</code></a>
chore: Release</li>
<li><a
href="789c99498c"><code>789c994</code></a>
Update CHANGELOGs</li>
<li><a
href="addf1486f8"><code>addf148</code></a>
Update (<a
href="https://redirect.github.com/EmbarkStudios/crash-handling/issues/81">#81</a>)</li>
<li><a
href="16c2545f2a"><code>16c2545</code></a>
chore: Release</li>
<li><a
href="955629bab9"><code>955629b</code></a>
Update CHANGELOG</li>
<li><a
href="5e907ff389"><code>5e907ff</code></a>
Add Android support for the i686 and x86-64 targets (<a
href="https://redirect.github.com/EmbarkStudios/crash-handling/issues/76">#76</a>)</li>
<li><a
href="14bba1b81e"><code>14bba1b</code></a>
Fix using <code>crash-handler</code> under Miri (<a
href="https://redirect.github.com/EmbarkStudios/crash-handling/issues/75">#75</a>)</li>
<li><a
href="1db8fca031"><code>1db8fca</code></a>
chore: Release</li>
<li>See full diff in <a
href="https://github.com/EmbarkStudios/crash-handling/compare/crash-handler-0.6.0...crash-handler-0.6.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=crash-handler&package-manager=cargo&previous-version=0.6.0&new-version=0.6.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 <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</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-02-13 17:55:19 +00:00
Reactor Scram
bd5b5d9c5f ci(windows): test crash handling as part of smoke test (#3624)
If this passes I'll use it to approve #3623
2024-02-13 17:12:57 +00:00
Thomas Eizinger
6c2fdcfd0a chore: bump Rust version to 1.76 (#3632) 2024-02-13 17:01:22 +00:00
Reactor Scram
830302af43 test(linux): Low-risk changes to prepare for Linux DNS support (#3625)
This splits off the easy parts from #3605.

- Add quotes around `PHOENIX_SECURE_COOKIES` because my local
`docker-compose` considers unquoted 'false' to be a schema error - Env
vars are strings or numbers, not bools, it says
- Create `test.httpbin.docker.local` container in a new subnet so it can
be used as a DNS resource without the existing CIDR resource picking it
up
- Add resources and policies to `seeds.exs` per #3342
- Fix warning about `CONNLIB_LOG_UPLOAD_INTERVAL_SECS` not being set
- Add `resolv-conf` dep and unit tests to `firezone-tunnel` and
`firezone-linux-client`
- Impl `on_disconnect` in the Linux client with `tracing::error!`
- Add comments

```[tasklist]
- [x] (failed) Confirm that the client container actually does stop faster this way
- [x] Wait for tests to pass
- [x] Mark as ready for review
```
2024-02-12 19:04:51 +00:00
dependabot[bot]
46efc84834 build(deps): Bump time from 0.3.32 to 0.3.34 in /rust (#3559)
Bumps [time](https://github.com/time-rs/time) from 0.3.32 to 0.3.34.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/time-rs/time/releases">time's
releases</a>.</em></p>
<blockquote>
<h2>v0.3.34</h2>
<p>See the <a
href="https://github.com/time-rs/time/blob/main/CHANGELOG.md">changelog</a>
for details.</p>
<h2>v0.3.33</h2>
<p>See the <a
href="https://github.com/time-rs/time/blob/main/CHANGELOG.md">changelog</a>
for details.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/time-rs/time/blob/main/CHANGELOG.md">time's
changelog</a>.</em></p>
<blockquote>
<h2>0.3.34 [2024-12-03]</h2>
<h3>Fixed</h3>
<p>Computing the local offset on Windows works again. It was broken in
some cases in v0.3.32 and
v0.3.33.</p>
<h2>0.3.33 [2024-02-03]</h2>
<h3>Fixed</h3>
<p>Builds targeting <code>wasm32-unknown-unknown</code> now work
again.</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="f11f9b2a0c"><code>f11f9b2</code></a>
v0.3.34 release</li>
<li><a
href="ef7bfbd638"><code>ef7bfbd</code></a>
fix unsigned to signed conversion bug (<a
href="https://redirect.github.com/time-rs/time/issues/656">#656</a>)</li>
<li><a
href="76468cb651"><code>76468cb</code></a>
v0.3.33 release</li>
<li><a
href="6c2b602a41"><code>6c2b602</code></a>
Fix wasm32-unknown-unknown build (<a
href="https://redirect.github.com/time-rs/time/issues/655">#655</a>)</li>
<li>See full diff in <a
href="https://github.com/time-rs/time/compare/v0.3.32...v0.3.34">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=time&package-manager=cargo&previous-version=0.3.32&new-version=0.3.34)](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 <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 18:11:41 +00:00
Reactor Scram
ce79d020c1 ci(windows): add 'firezone' to the MSI names (#3610)
Since `windows-client-x64.msi` could be any other product.

I also split up the build steps similar to how the smoke test does.
2024-02-09 17:14:13 +00:00
Thomas Eizinger
45b1e3cda4 feat(connlib): remove duplication from logs (#3596)
Currently, we log messages from the portal several times via different
ways. For one, the message is included in the span via
`tracing::instrument`. Then it is also logged on `trace!` level twice
(this PR removes one of them). Plus, the fields of the
`request_connection` span are not printed in a very human-readable way
(bytes arrays). This makes the logs super noisy, see here for the latest
run on `main`:
https://github.com/firezone/firezone/actions/runs/7808301643/job/21298585685#step:13:13

Compare this with the logs from the run in this PR:
https://github.com/firezone/firezone/actions/runs/7813774334/job/21313812863?pr=3596#step:13:13

Some of these improvements were made as part of debugging #3391.
Extracting them here in a separate PR to reduce the diff of #3391.
2024-02-08 00:43:09 +00:00
Thomas Eizinger
22760e86c5 feat(snownet): refresh allocation upon each new connection (#3591)
Currently, a `REFRESH` for an allocation is only triggered after half
its lifetime (which defaults to 10 minutes). A refresh is the only way
for us to check whether an allocation is still active. If the relay
restarted or the allocation was somehow invalidated otherwise,
attempting to refresh it will fail.

By triggering a refresh for each allocation every time we get a new
connection, we immediately check whether that allocation (and thus its
candidates) are still valid. What to do with invalidated candidates is
left to a future iteration.
2024-02-08 00:43:06 +00:00
Thomas Eizinger
4f4f374a18 fix(snownet): replace Allocation if credentials to relay change (#3590)
When a relay restarts, its credentials change but the socket we use to
connect to it might not. Because we upsert `Allocation`s within a
`snownet::Node` based on the socket, such a change is currently not
picked up.

Instead, we now check whether an existing allocation uses the same
credentials and if it doesn't we throw the old one away and use the new
one instead.
2024-02-07 21:31:36 +00:00
Thomas Eizinger
459a79a528 refactor(snownet): introduce CandidateEvent (#3592)
Candidates, especially relay candidates can become invalid. For example,
a relay might be shut down, change its credentials or now be unreachable
due to network changes. In order to signal these changes in network
connections to a `snownet::Node`, we introduce a `CandidateEvent`.

Right now, `CandidateEvent` does not yet have an `Invalid` variant
because it would be dead code (it is not yet emitted by anything). This
PR is just the scaffolding to make that easier to introduce later.
2024-02-07 21:26:14 +00:00
Thomas Eizinger
5ebb4cfd57 feat(snownet): instrument the handle_input function with tracing (#3594)
This improves the logs because it adds a bunch of context to them that
we'd otherwise have to repeat everywhere.

Extracted from: #3391.
2024-02-07 19:54:32 +00:00
Thomas Eizinger
d550c9da89 refactor(connlib): remove unnecessary Serialize derive (#3595)
These messages are only deserialized, never serialized. The `derive` can
thus be removed.

Extracted from: #3391.
2024-02-07 19:54:25 +00:00
Thomas Eizinger
b343e133fe fix(snownet): don't try to re-authorize forever (#3589)
If we receive a 401 or a 438, we should re-authenticate the request with
the new nonce sent from the server. Except if we had sent a nonce and
receive a 401, then it means our credentials are completely invalid and
retrying to authenticate will not solve it.
2024-02-07 18:43:53 +00:00
Reactor Scram
00205646c0 feat(windows): split up signing-in state, closes #3597 (#3599)
Closes #3597


![image](https://github.com/firezone/firezone/assets/13400041/e74b6ac1-7f89-4093-bb30-33f776ddd872)

![image](https://github.com/firezone/firezone/assets/13400041/e5f614e4-16f3-43da-9df8-54ec857505d2)
2024-02-07 18:04:56 +00:00
Reactor Scram
0573098b98 fix(windows): improve logging around smoke test / log export (#3600)
This should help narrow down #3598
2024-02-07 18:00:08 +00:00
Thomas Eizinger
a6ba31ac81 chore(snownet): remove obsolete TODO (#3593)
This has been resolved and we are depending on the latest version.
2024-02-07 14:05:23 +00:00
Thomas Eizinger
61acb23345 fix(snownet): don't mangle source IP to determine use of relay (#3556)
Mangling the source IP is not correct, we actually need to search for
the allocated socket within our list of allocations, otherwise we cannot
translate between IPv4 and IPv6 as we e.g. wouldn't find an IPv6
allocation on an IPv4 relay.
2024-02-07 00:37:21 +00:00
Gabi
e486339523 fix(snownet): properly cleanup connections before adding a new one (#3587)
This was causing some problems in my tests with connlib, when the client
re-created the connection and recieved the candidates before the offer
response, this *seems* like it made the client hang waiting for the
connection to happen, without failing it.

I couldn't find out why exactly the hang happens since it seems like the
remote candidates are added to the new connection and stun packets are
directed to the new connection, so it may be unrelated but I think it's
still right to clean this hashmap up.

---------

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-02-06 23:18:49 +00:00
Reactor Scram
2ee6eb5d88 fix(windows): Ensure crashes, errors, and panics are all logged to file (#3572)
Closes #3567 

This doesn't feel complete, but there isn't much more I can do without
changing lots of code and doing more research, and I don't want to hold
up the Windows beta for error handling that may not be used.

I'm only handling crashes, errors, and panics in the `Controller` task
since it's hard to simulate them elsewhere. Everything else like the
wintun worker thread will have to be best-effort or tested by modifying
the code temporarily.

Crashes go to stderr and and the log file, and we can get a line number
from the crash dump:

![image](https://github.com/firezone/firezone/assets/13400041/bbabcdb5-9d59-40b8-9b2f-bff2c88d8a88)

Errors go to stderr and the log file, but we don't get a line number,
because we aren't capturing the backtrace:

![image](https://github.com/firezone/firezone/assets/13400041/31e13b5a-aec7-4b3c-91e0-d0f230f4dfd3)

Panics go to stderr and the log file, but we don't even get the panic
message. I don't think I can do much about that. Tokio doesn't give us
the full `PanicInfo`, which contains the message and location (line
number). If we end up debugging a panic in prod we could bisect by
putting tighter bounds until we narrow it down.

![image](https://github.com/firezone/firezone/assets/13400041/20337dde-911a-4edf-8d68-829ed9aebc27)

The panic hook ends up not triggered because:
- If I don't catch the panic, the app won't close, because Tokio will
catch the panic
- If I do catch the panic, I can't call the panic hook manually, because
Tokio doesn't give me a `PanicInfo` struct. And I can't resume the
panic, because I'm still inside a Tokio task.

I don't think there's any point capturing a crash dump on panic, because
Tokio will have already stopped the panicked thread, and the backtrace
will only show the catch location.

Maybe the message would print if I changed the controller task to a
controller thread, so that panicking that thread will trigger
`tracing_panic` and then abort the process? But that's a bigger change.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2024-02-06 20:30:05 +00:00
Reactor Scram
a822238205 fix(windows): keep the main loop running even if a request has an error (#3569)
Closes #3521 because now almost all of the `?` in the main loop will log
an error and not bail. This is nice for trivial things like copying a
resource when we're not signed in. (e.g. User opens the menu, the token
expires, user clicks something, it should just do nothing instead of
crashing)

Closes a long-standing TODO for moving more of the request handling code
inside `impl Controller`
2024-02-06 16:24:11 +00:00
Reactor Scram
9365a61513 fix(windows): Wrap deep link URLs in SecureUrl, don't log them (#3574)
Previously the whole URL was logged, which includes half of the secret
token. Now it just says "Got deep link"
2024-02-06 16:21:36 +00:00
Thomas Eizinger
0d5b230020 fix(snownet): don't attempt to bind a channel if we don't have a matching allocation (#3575)
In order to bind a channel to an IPv4 peer, the client must have
previously made an IPv4 allocation. The same applies to IPv6. The relay
will enforce this and reject the channel binding if that isn't the case
but we shouldn't rely on this in the client code. Instead, we should not
attempt to bind a channel if we haven't previously made an allocation
for that IP family.

We always try to make an allocation for both IPv4 and IPv6 but not every
relay may operate in a dual-socket mode. Thus, it may only return an
IPv4 or an IPv6 address.
2024-02-06 10:17:39 +00:00
Thomas Eizinger
18b9a783d2 fix(snownet): always clear state of failed connections (#3581)
Initially, I thought it could be useful to keep the connection around in
case we want to do an ICE restart. We don't do that (yet) so for now,
the safer option is to just clean up all the state and let the upper
layers deal with reestablishing it.

This should hopefully fix the repeated emitting of the
`ConnectionFailed` event.
2024-02-06 09:02:48 +00:00
Thomas Eizinger
75732ca56a feat(snownet): retry TURN allocations using exponential backoffs (#3530)
Similar to https://github.com/firezone/firezone/pull/3529.
2024-02-06 07:12:23 +00:00
Reactor Scram
5943a95b6f fix(windows): vt100 seems to panic in CI, just print a warning instead (#3573)
Fixes the Windows smoke test failing in CI currently.
The CI already has coloring enabled.
2024-02-05 22:56:32 +00:00
Gabi
8a31a532b6 fix(connlib): Enable ansi colors for the windows client debug console (#3552)
This adds colors to the debug console in the windows client


![image](https://github.com/firezone/firezone/assets/3310803/dfb5b119-9db3-40b8-acf9-3485a2268597)
2024-02-05 21:37:54 +00:00
dependabot[bot]
0c05d853bb build(deps): Bump minidumper from 0.8.0 to 0.8.1 in /rust (#3560)
Bumps [minidumper](https://github.com/EmbarkStudios/crash-handling) from
0.8.0 to 0.8.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/EmbarkStudios/crash-handling/releases">minidumper's
releases</a>.</em></p>
<blockquote>
<h2>minidumper-0.8.1</h2>
<h3>Changed</h3>
<ul>
<li><a
href="https://redirect.github.com/EmbarkStudios/crash-handling/pull/81">PR#81</a>
resolved <a
href="https://redirect.github.com/EmbarkStudios/crash-handling/issues/80">#80</a>
by updating <code>polling</code> to 0.3.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="3b77c9b00d"><code>3b77c9b</code></a>
chore: Release</li>
<li><a
href="d34d00bc51"><code>d34d00b</code></a>
chore: Release</li>
<li><a
href="789c99498c"><code>789c994</code></a>
Update CHANGELOGs</li>
<li><a
href="addf1486f8"><code>addf148</code></a>
Update (<a
href="https://redirect.github.com/EmbarkStudios/crash-handling/issues/81">#81</a>)</li>
<li><a
href="16c2545f2a"><code>16c2545</code></a>
chore: Release</li>
<li><a
href="955629bab9"><code>955629b</code></a>
Update CHANGELOG</li>
<li><a
href="5e907ff389"><code>5e907ff</code></a>
Add Android support for the i686 and x86-64 targets (<a
href="https://redirect.github.com/EmbarkStudios/crash-handling/issues/76">#76</a>)</li>
<li><a
href="14bba1b81e"><code>14bba1b</code></a>
Fix using <code>crash-handler</code> under Miri (<a
href="https://redirect.github.com/EmbarkStudios/crash-handling/issues/75">#75</a>)</li>
<li>See full diff in <a
href="https://github.com/EmbarkStudios/crash-handling/compare/minidumper-0.8.0...minidumper-0.8.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=minidumper&package-manager=cargo&previous-version=0.8.0&new-version=0.8.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 <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-05 21:37:27 +00:00
Reactor Scram
e0f54784b4 fix(windows): save actor name to disk and reload it on startup (#3546)
Closes #3519 

The actor name is saved in plain text in our AppData folder.

I did simple manual tests on my dev laptop:
- Restart the app, it reloads the actor name from disk
- Sign out of the app, the file is deleted from the disk

Caveats:
- If you un-install the app while signed in, the actor name will still
be there until something cleans up AppData. I don't think the MSI cleans
it up.
- If the token is present but the actor name is missing, I just treat it
as if the token was missing and make the app be signed-out, since this
will happen on dev systems until this PR has been merged for some time.
- If we try to delete the file and the file is NotFound, I just ignore
it.
2024-02-05 21:27:43 +00:00
Reactor Scram
ed2cae122e feat(windows): add smoke test subcommand (#3541)
Part of #3534
This PR creates the subcommand, which you can run locally, but it
doesn't run it in `ci.yml` yet. That's in #3542

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2024-02-05 18:49:28 +00:00
Thomas Eizinger
b73b0cf2b7 feat(snownet): return MutableIpPacket from decapsulate (#3555)
The user is already passing us a mutable buffer so we might as well give
them a `MutableIpPacket` to allow them to further mutate it.

Extracted out of #3391.
2024-02-05 10:55:23 +00:00
Thomas Eizinger
394e9e8cc3 chore(snownet): fix bad caching base after rename (#3557)
This is an oversight from
https://github.com/firezone/firezone/pull/3435.
2024-02-05 10:55:05 +00:00
Thomas Eizinger
e0af229901 feat(snownet): retry STUN bindings using exponential backoff (#3529)
Currently, we retry STUN bindings at a fixed interval if we don't
receive a response. This results in very noise logs if we attempt to
contact an IPv6 STUN server but don't have an IPv6 interface.
2024-02-05 05:50:50 +00:00
Thomas Eizinger
fa3775a125 deps: update to latest upstream version of str0m (#3554)
Necessary contributions have (once again) been merged so we can switch
back to the upstream repo again! :)
2024-02-05 03:40:41 +00:00