Commit Graph

5065 Commits

Author SHA1 Message Date
Thomas Eizinger
ab8d6dca1e fix(connlib): only send DNS through tunnel if upstream DNS is configured (#5819)
Extracted out of #5797.

This is a problem that becomes evident as
https://github.com/firezone/firezone/issues/2667 is implemented:

Whenever connlib sees a DNS packet where the sentinel DNS is a resource,
it's forwarded to the resource instead of requests being resolved
locally. This doesn't work well with system's DNS servers since many
times those are provided by the DHCP to be a local resolver which can't
be reached from a gateway. Meaning that with full route this request
will be just dropped. Preventing all internet connections outside of
Firezone.

Most of the times when an administrator actually wants to forward all
DNS request they will add explicitly an upstream DNS server which makes
sense since depending on what the local DHCP configures isn't a good
idea if you want to tunnel DNS requests.

This makes this behavior explicit and docs and UI should be updated
accordingly.

Co-authored-by: Gabi <gabrielalejandro7@gmail.com>

---------

Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2024-07-20 17:14:18 +00:00
Jamil
dd19563c41 chore: Update FAQs (#5926)
Fixes #5762
2024-07-20 08:59:36 -07:00
dependabot[bot]
6fa6c08bf9 build(deps): Bump pnet_packet from 0.34.0 to 0.35.0 in /rust (#5396)
Bumps [pnet_packet](https://github.com/libpnet/libpnet) from 0.34.0 to
0.35.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/libpnet/libpnet/releases">pnet_packet's
releases</a>.</em></p>
<blockquote>
<h2>v0.35.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Update license field following SPDX 2.1 license expression standard
by <a href="https://github.com/frisoft"><code>@​frisoft</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/633">libpnet/libpnet#633</a></li>
<li>transport: Add option to set ECN on the TransportSender socket. by
<a href="https://github.com/hawkinsw"><code>@​hawkinsw</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/685">libpnet/libpnet#685</a></li>
<li>Fix failing tests by <a
href="https://github.com/Paul-weqe"><code>@​Paul-weqe</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/676">libpnet/libpnet#676</a></li>
<li>remove the repetitive word by <a
href="https://github.com/cuishuang"><code>@​cuishuang</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/672">libpnet/libpnet#672</a></li>
<li>Add apple tvos support by <a
href="https://github.com/lcruz99"><code>@​lcruz99</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/652">libpnet/libpnet#652</a></li>
<li>Adding vxlan to pnet_packet by <a
href="https://github.com/stevedoyle"><code>@​stevedoyle</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/654">libpnet/libpnet#654</a></li>
<li>Add ICMP Destination unreachable Next-hop MTU by <a
href="https://github.com/fabi321"><code>@​fabi321</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/662">libpnet/libpnet#662</a></li>
<li>Update ARP example to also support IPv6 via NDP by <a
href="https://github.com/tgross35"><code>@​tgross35</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/642">libpnet/libpnet#642</a></li>
<li>Ensure BPF read is 4-byte aligned by <a
href="https://github.com/frankplow"><code>@​frankplow</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/655">libpnet/libpnet#655</a></li>
<li>Expose the various values in the TcpOption structure for external
program access by <a
href="https://github.com/rikonaka"><code>@​rikonaka</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/640">libpnet/libpnet#640</a></li>
<li>Definition for ethernet flow control packets. by <a
href="https://github.com/AJMansfield"><code>@​AJMansfield</code></a> in
<a
href="https://redirect.github.com/libpnet/libpnet/pull/649">libpnet/libpnet#649</a></li>
<li>Expose set_ecn on unix only by <a
href="https://github.com/mrmonday"><code>@​mrmonday</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/689">libpnet/libpnet#689</a></li>
<li>datalink(linux): add feature to pass the fd (socket) to ::channel()
by <a href="https://github.com/Martichou"><code>@​Martichou</code></a>
in <a
href="https://redirect.github.com/libpnet/libpnet/pull/584">libpnet/libpnet#584</a></li>
<li>Added DNS protocol support by <a
href="https://github.com/tomDev5"><code>@​tomDev5</code></a> in <a
href="https://redirect.github.com/libpnet/libpnet/pull/678">libpnet/libpnet#678</a></li>
<li>linux: use poll api instead of select inorder to support fd &gt;
1024. Fixes <a
href="https://redirect.github.com/libpnet/libpnet/issues/612">#612</a>
and <a
href="https://redirect.github.com/libpnet/libpnet/issues/639">#639</a>
by <a
href="https://github.com/nemosupremo"><code>@​nemosupremo</code></a> in
<a
href="https://redirect.github.com/libpnet/libpnet/pull/681">libpnet/libpnet#681</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/frisoft"><code>@​frisoft</code></a> made
their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/633">libpnet/libpnet#633</a></li>
<li><a href="https://github.com/hawkinsw"><code>@​hawkinsw</code></a>
made their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/685">libpnet/libpnet#685</a></li>
<li><a href="https://github.com/Paul-weqe"><code>@​Paul-weqe</code></a>
made their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/676">libpnet/libpnet#676</a></li>
<li><a href="https://github.com/cuishuang"><code>@​cuishuang</code></a>
made their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/672">libpnet/libpnet#672</a></li>
<li><a href="https://github.com/lcruz99"><code>@​lcruz99</code></a> made
their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/652">libpnet/libpnet#652</a></li>
<li><a
href="https://github.com/stevedoyle"><code>@​stevedoyle</code></a> made
their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/654">libpnet/libpnet#654</a></li>
<li><a href="https://github.com/fabi321"><code>@​fabi321</code></a> made
their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/662">libpnet/libpnet#662</a></li>
<li><a href="https://github.com/tgross35"><code>@​tgross35</code></a>
made their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/642">libpnet/libpnet#642</a></li>
<li><a href="https://github.com/frankplow"><code>@​frankplow</code></a>
made their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/655">libpnet/libpnet#655</a></li>
<li><a
href="https://github.com/AJMansfield"><code>@​AJMansfield</code></a>
made their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/649">libpnet/libpnet#649</a></li>
<li><a href="https://github.com/tomDev5"><code>@​tomDev5</code></a> made
their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/678">libpnet/libpnet#678</a></li>
<li><a
href="https://github.com/nemosupremo"><code>@​nemosupremo</code></a>
made their first contribution in <a
href="https://redirect.github.com/libpnet/libpnet/pull/681">libpnet/libpnet#681</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/libpnet/libpnet/compare/v0.34.0...v0.35.0">https://github.com/libpnet/libpnet/compare/v0.34.0...v0.35.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="97ece70e2f"><code>97ece70</code></a>
Release v0.35.0</li>
<li><a
href="49c8c683f9"><code>49c8c68</code></a>
Merge pull request <a
href="https://redirect.github.com/libpnet/libpnet/issues/681">#681</a>
from ionosnetworks/feat/linux-poll-api</li>
<li><a
href="07526a7f6f"><code>07526a7</code></a>
Merge pull request <a
href="https://redirect.github.com/libpnet/libpnet/issues/678">#678</a>
from tomDev5/dns</li>
<li><a
href="b319ca2f64"><code>b319ca2</code></a>
fixed dns code</li>
<li><a
href="a3a46e6fb2"><code>a3a46e6</code></a>
removed BooleanField for u1</li>
<li><a
href="7086ed22a6"><code>7086ed2</code></a>
dns layer in pnet</li>
<li><a
href="14a01ffc37"><code>14a01ff</code></a>
Merge pull request <a
href="https://redirect.github.com/libpnet/libpnet/issues/584">#584</a>
from Martichou/raw_socket</li>
<li><a
href="bd4c8b0e32"><code>bd4c8b0</code></a>
datalink(linux): add feature to pass the fd (socket) to ::channel()</li>
<li><a
href="28e9de4b8c"><code>28e9de4</code></a>
Merge pull request <a
href="https://redirect.github.com/libpnet/libpnet/issues/689">#689</a>
from mrmonday/ecn-unix-only</li>
<li><a
href="01eee253ba"><code>01eee25</code></a>
Expose set_ecn on unix only.</li>
<li>Additional commits viewable in <a
href="https://github.com/libpnet/libpnet/compare/v0.34.0...v0.35.0">compare
view</a></li>
</ul>
</details>
<br />


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

You can trigger a rebase of this PR 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>

> **Note**
> Automatic rebases have been disabled on this pull request as it has
been open for over 30 days.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-20 04:38:45 +00:00
Thomas Eizinger
5e021a235c test(connlib): proactively force connections through relay (#5917)
Currently, the relay path in `tunnel_test` is only hit accidentally
because we don't run the gateways in dual-stack mode and thus, some
testcases have a client and gateways that can't talk to each other (and
thus fall back to the relay).

This requires us to filter out certain resources because we can't route
to an IPv6 CIDR resource from an IPv4-only gateway. This causes quite a
lot of rejections which creates problems when one attempts up the number
of test cases (i.e. 10_000).

To fix this, we run the gateways always in dual-stack mode and introduce
a dedicated flag that sometimes drop all direct traffic between the
client and the gateways.
2024-07-20 04:38:20 +00:00
Brian Manifold
79c815fbbc feat(portal): Add REST API (#5579)
Why:

* In order to manage a large number of Firezone Sites, Resources,
Policies, etc... a REST API is needed as clicking through the UI is too
time consuming, as well as prone to error. By providing a REST API
Firezone customers will be able to manage things within their Firezone
accounts with code.
2024-07-20 04:20:43 +00:00
Gabi
18394e3dcb fix(connlib): send dns proxy ips even with overlapping internet resource (#5902)
To determine whether we send proxy IPs we depend on the `allowed_ips`,
since that's where we track what resources we have sent to a given
gateway.

However, the way we were matching if a given resource destination was
sent was using `longest_match` and with overlapping DNS this no longer
works, since this will match for internet resources even if the proxy IP
wasn't sent.

So we check that it's a DNS resource and if it's we exactly match on the
allowed ip table.

Alternatively, we could keep track of `sent_ips` for a gateway, though
this is a bit of a redundant state that we need to keep in sync but has
the benefit of being more explicit, so I'm open to do that in a follow
up PR. But I'd like to merge this to get ready for internet resources.
2024-07-20 00:26:36 +00:00
Thomas Eizinger
5db0424032 test(connlib): generate all resources ahead of time (#5916)
Currently, `tunnel_test` is broken as a result of #5871. In particular,
adding a resource requires that the resource is assigned to a gateway
which can only be done after it is being added. As a result, no
resources are ever added in the test.

With this patch, we align the test even closer with how Firezone works
in production: We generate all resources ahead of time and selectively
activate / deactivate them on the client. Unfortunately, this requires
quite a few changes but overall, is a net-positive change.

Replaces: #5914.
2024-07-19 23:38:54 +00:00
Reactor Scram
75529ea799 chore(rust): bump nightly version used for checking unused deps (#5918)
This version was a few months old and started throwing errors about
features that stabilized since then.

e.g.
https://github.com/firezone/firezone/actions/runs/10011089436/job/27673759249

```
error[E0658]: use of unstable library feature 'proc_macro_byte_character'
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.86/src/wrapper.rs:871:21
    |
871 |                     proc_macro::Literal::byte_character(byte)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #115268 <https://github.com/rust-lang/rust/issues/115268> for more information
    = help: add `#![feature(proc_macro_byte_character)]` to the crate attributes to enable
    = note: this compiler was built on 2024-03-25; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'proc_macro_c_str_literals'
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.86/src/wrapper.rs:898:21
    |
898 |                     proc_macro::Literal::c_string(string)
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #119750 <https://github.com/rust-lang/rust/issues/119750> for more information
    = help: add `#![feature(proc_macro_c_str_literals)]` to the crate attributes to enable
    = note: this compiler was built on 2024-03-25; consider upgrading it if it is out of date

For more information about this error, try `rustc --explain E0658`.
error: could not compile `proc-macro2` (lib) due to 2 previous errors
```
2024-07-19 22:32:51 +00:00
Andrew Dryga
4f1a17b0e1 fix(infra): Use highcpu instances for relays (#5922) 2024-07-19 15:19:16 -06:00
Andrew Dryga
0b6e3564f3 chore(infra): Deploy relay and portal to more zones and use more modern CPU arch (#5921) 2024-07-19 15:15:28 -06:00
Thomas Eizinger
1bac0e0f0e test(connlib): ensure portal init doesn't interrupt data plane (#5899)
The connection to the portal could be interrupted at any point, most
notably when it is being re-deployed. Doing so results in a new `init`
message being pushed to all clients and gateways. This must not
interrupt the data plane.

To ensure this, we add a new `ReconnectPortal` transition to
`tunnel_test` where we simulate receiving a new `init` message with the
same values as we already have locally, i.e. same set of relays and
resources.

This resolves an existing TODO where the logic of performing
non-destructive updates to resources in `set_resources` wasn't tested.
2024-07-19 09:28:44 +00:00
Jamil
bf693ad83f chore(website): Add hero texture, adjust copy (#5909) 2024-07-18 13:22:48 -07:00
Jamil
f0b4ce45a2 fix(portal): Disable submit button for synchronous forms upon submit (#5882)
https://github.com/user-attachments/assets/3b7153c5-4c08-470b-9258-fadc08a12be8


The `cursor-wait` graphic is corrupted due to a Quicktime recording bug,
but it's working live.

Fixes #5881
2024-07-18 18:19:20 +00:00
Jamil
42c7480156 feat(website): link to probe in footer (#5907)
fixes #5898
2024-07-18 09:03:13 -07:00
Jamil
e8c832fe73 feat(website): Add Clipboard component and inject into <code> blocks (#5904)
Fixes #3866 
<img width="948" alt="Screenshot 2024-07-18 at 1 05 43 AM"
src="https://github.com/user-attachments/assets/4ad3b742-ea4e-4202-a7f8-a016914ef308">
2024-07-18 15:14:26 +00:00
Reactor Scram
32014eafbf docs(maintainers): fix (#5894)
Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-07-18 15:10:15 +00:00
Thomas Eizinger
4937291d23 refactor(connlib): deal with resources one at a time (#5886)
The two primary users of the `add_resources` and `remove_resources` are
the client's eventloop and the `tunnel_test`. Both of them only ever
pass a single resource at a time.

It is thus simpler to remove the inner loop from within `ClientState`
and simply process a single resource at a time.
2024-07-18 04:59:12 +00:00
Thomas Eizinger
5268756b60 feat(connlib): add placeholder for Internet Resource (#5900)
In preparation for #2667, we add an `internet` variant to our list of
possible resource types. This is backwards-compatible with existing
clients and ensures that, once the portal starts sending Internet
resources to clients, they won't fail to deserialise these messages.

The portal will have a version check to not send this to older clients
anyway but the sooner we can land this, the better. It simplifies the
initial development as we start preparing for the next client release.

Adding new fields to a JSON message is always backwards-compatible so we
can extend this later with whatever we need.
2024-07-18 04:28:02 +00:00
Thomas Eizinger
066270051b test(connlib): always run all assertions (#5892)
Currently, `tunnel_test` aborts a `Transition` as soon as one assertion
fails. This often makes it hard to debug a problem as it can be useful
to see which assertions pass and which fail to figure out, what went
wrong.

To resolve this, we replace all `assert` macros with either `info!` or
`error!` trace events. All "failed assertions" must be logged as
`error!`.

Before running these assertions, we temporarily install a custom tracing
layer that keeps track of how many `error!` events are emitted. If we
emit at least one `error!` event, the layer pancis upon `Drop` which
happens at the end of the `check_invariants` function.
2024-07-18 02:16:17 +00:00
Thomas Eizinger
da52c66023 refactor(clients): init PhoenixChannel in upper layers (#5884)
This represents a step towards #3837. Eventually, we'd like the
abstractions of `Session` and `Eventloop` to go away entirely. For that,
we need to thin them out.

The introduction of `ConnectArgs` was already a hint that we are passing
a lot of data across layers that we shouldn't. To avoid that, we can
simply initialise `PhoenixChannel` earlier and thus each callsite can
specify the desired configuration directly.

I've left `ConnectArgs` intact to keep the diff small.
2024-07-18 02:08:38 +00:00
Gabi
5c1f5e1ece fix(connlib): prioritize dns resources to CIDR ones in case of an overlap (#5840)
For full route this happens always and if we don't prioritize DNS
resources any packet for DNS IPs will get routed to the full route
gateway which might not have the correct resource.

TODO: this still needs unit tests
TODO: Waiting on #5891
2024-07-18 01:27:07 +00:00
Reactor Scram
7397656637 docs(user-guide/windows): fix incorrect service name (#5895)
Somehow I had put the debug service there not the prod one

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-07-18 01:18:04 +00:00
Thomas Eizinger
4f4134b000 test(connlib): model gateway <> site <> resource relationship (#5871)
Currently, the relationship between gateways, sites and resources is
modeled in an ad-hoc fashion within `tunnel_test`. The correct
relationship is:

- The portal knows about all sites.
- A resource can only be added for an existing site.
- One or more gateways belong to a single site.

To express this relationship in `tunnel_test`, we first sample between 1
and 3 sites. Then we sample between 1 and 3 gateways and assign them a
site each. When adding new resources, we sample a site that the resource
belongs to. Upon a connection intent, we sample a gateway from all
gateways that belong to the site that the resource is defined in.

In addition, this patch-set removes multi-site resources from the
`tunnel_test`. As far as connlib's routing logic is concerned, we route
packets to a resource on a selected gateway. How the portal selected the
site of the gateway doesn't matter to connlib and thus doesn't need to
be covered in these tests.
2024-07-17 22:41:47 +00:00
Reactor Scram
6b1b14dc2c chore(gui-client): release GUI Client 1.1.7 (#5897)
Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-07-17 22:23:43 +00:00
Thomas Eizinger
aa279d7731 ci: never tolerate warnings in Rust code (#5893)
Our Rust CI runs various jobs in different configurations of packages
and / or features. Currently, only the clippy job denies warnings which
makes it possible that some code still generates warnings under
particular configurations.

To ensure we always fail on warnings, we set a global env var to deny
warnings for all Rust CI jobs.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-07-17 22:22:12 +00:00
Reactor Scram
cfab7579b6 ci(rust): fix stale entries in Cargo.lock (#5896)
I think this is because there was a force-push in the `proptest` repo,
which caused the locked revision to no longer belong to the branch
specified by `Cargo.toml`

It happened to affect macOS and not Linux or Windows, nor local builds,
maybe because they have different caching setups.

<img width="326" alt="image"
src="https://github.com/user-attachments/assets/4c8f8ba5-d2f1-4f89-8895-e533178b6348">
2024-07-17 20:33:04 +00:00
Gabi
7e963f74ca chore(connlib): performance improvement for picking cidr resources (#5891)
Extracted from  #5840

Some cleanup on generating IPs and improve performance of picking a host
within an IP range by doing some math instead of iterating through the
ip range.
2024-07-17 06:24:34 +00:00
Thomas Eizinger
93651d483c build(deps): bump quinn-udp dependency (#5872)
In the new version, `quinn-udp` no longer supports sending multiple
`Transmit`s at once via `sendmmsg`. We made use of that to send all
buffered packets in one go.

In reality, these buffered packets can only be control messages like
STUN requests to relays or something like that. For the hot-patch of
routing packets, we only ever read a single IP packet from the TUN
device and attempt to send it out right away. At most, we may buffer one
packet at a time here in case the socket is busy.

Getting these wake-ups right is quite tricky. I think we should
prioritise #3837 soon. Once that is integrated, we can use `async/await`
for the high-level integration between `Io` and the state which allows
us to simply suspend until we can send the message, avoiding the need
for a dedicated buffer.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-07-16 22:46:18 +00:00
Reactor Scram
63623346b9 fix(headless-client/windows): improve Client startup times on Windows (#5375)
Closes #5026
Closes #5879 

On the resource-constrained Windows Server 2022 test VM, the median
sign-in time dropped from 5.0 seconds to 2.2 seconds.

# Changes

- Measure end-to-end connection time in the GUI process
- Use `ipconfig` instead of Powershell to flush DNS faster
- Activate DNS control by manipulating the Windows Registry directly
instead of calling Powershell
- Remove deactivate step when changing DNS servers (seals a DNS leak
when roaming networks)
- Remove completely redundant `Set-DnsClientServerAddress` step from
activating DNS control
- Remove `Remove-NetRoute` powershell cmdlet that seems to do nothing

# Benchmark 7

- Optimized release builds
- x86-64 constrained VM (1 CPU thread, 2 GB RAM)

Main with measurement added, `c1c99197e` from #5864 

- 6.0 s
- 5.5 s
- 4.1 s
- 5.0 s
- 4.1 s
- (Median = 5.0 s)

Main with speedups added, `2128329f9` from #5375, this PR

- 3.7 s
- 2.2 s
- 1.9 s
- 2.3 s
- 2.0 s
- (Median = 2.2 s)

```[tasklist]
### Next steps
- [x] Benchmark on the resource-constrained VM
- [x] Move raw benchmark data to a comment and summarize in the description
- [x] Clean up tasks that don't need to be in the commit
- [x] Merge
```

# Hypothetical further optimizations

- Ditch the `netsh` subprocess in `set_ips`

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-07-16 21:55:29 +00:00
Thomas Eizinger
58db5f0639 refactor(connlib): remove Callbacks from Tunnel (#5885)
Following the removal of the return type from the callback functions in
#5839, we can now move the use of the `Callbacks` one layer up the stack
and decouple them entirely from the `Tunnel`.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2024-07-16 21:00:40 +00:00
Jamil
0e2a13148f fix(portal): redirect back to resources / sites after edit (#5870)
- Updates `new` and `edit` flows to redirect back to sites or resources
after save
- Adds flash message pertaining to the above

Fixes #5776
2024-07-16 16:10:21 +00:00
Reactor Scram
c0ebb98ec9 chore(gui-client): measure startup time (#5864)
Refs #5026
2024-07-16 14:49:12 +00:00
Reactor Scram
03089c0bde docs(gui-client): update dev docs (#5858)
The docs for DNS control and process splitting no longer have any
information more useful, accurate, or fresh than the code itself
2024-07-16 14:49:00 +00:00
Gabi
8a76f2b870 fix(connlib): use 120 prefix for macos address (#5853)
Otherwise with full route when we try to create the default route for
ipv6 it just removes the previous default route and never adds ours,
completely breaking ipv6 [this seems to be the
reason](2fec12a6e1/Sources/WireGuardKit/PacketTunnelSettingsGenerator.swift (L137-L141))
2024-07-16 03:24:04 +00:00
Adrián Baena García
7acba5a3e9 docs(docker-compose) Duplicated sysctls src_valid_mark (#5865)
One of the lines at sysctls section in docker-compose.yml example file
is duplicated:

- net.ipv4.conf.all.src_valid_mark=1

So I deleted it to make it clearer.

Signed-off-by: Adrián Baena García <adrianbaenagarcia@gmail.com>
2024-07-15 20:22:54 -07:00
Gabi
5b0aaa6f81 fix(connlib): protect all sockets from routing loops (#5797)
Currently, only connlib's UDP sockets for sending and receiving STUN &
WireGuard traffic are protected from routing loops. This is was done via
the `Sockets::with_protect` function. Connlib has additional sockets
though:

- A TCP socket to the portal.
- UDP & TCP sockets for DNS resolution via hickory.

Both of these can incur routing loops on certain platforms which becomes
evident as we try to implement #2667.

To fix this, we generalise the idea of "protecting" a socket via a
`SocketFactory` abstraction. By allowing the different platforms to
provide a specialised `SocketFactory`, anything Linux-based can give
special treatment to the socket before handing it to connlib.

As an additional benefit, this allows us to remove the `Sockets`
abstraction from connlib's API again because we can now initialise it
internally via the provided `SocketFactory` for UDP sockets.

---------

Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-07-16 00:40:05 +00:00
Thomas Eizinger
14abda01fd refactor(connlib): polish DNS resource matching (#5866)
In preparation for implementing #5056, I familiarized myself with the
current code and ended up implementing a couple of refactorings.
2024-07-15 23:56:48 +00:00
Thomas Eizinger
92a2a7852b ci(kotlin): don't be verbose in building Rust (#5856)
Additional verbosity doesn't give us a lot more useful information but
spams the log a lot. We don't compile with `cargo --verbose` anywhere
else either.
2024-07-15 21:54:16 +00:00
Gabi
7436f86332 chore(connlib): remove warnings for non-proptest tests (#5883)
Extracted from #5797
2024-07-15 21:52:22 +00:00
Thomas Eizinger
847e7801f6 test(connlib): remove Tick transition (#5867)
When the property-based state machine test was first created, I
envisioned that we could also easily test advancing time. Unfortunately,
the tricky part of advancing time is to correctly encode the _expected_
behaviour as it requires knowledge of all timeouts etc.

Thus, the `Tick` transition has been left lingering and doesn't actually
test much. It is obviously still sampled by the test runner and thus
"wastes" test cases that don't end up exercising anything meaningful
because the time advancements are < 1000ms.

There are plans to more roughly test time-related things by implementing
delays between applying `Transmit`s. Until then, we can remove the
`Tick` transition.
2024-07-15 21:08:22 +00:00
Reactor Scram
b539c01cab fix(gui-client/linux): show a specific error message in the GUI when updating (#5848)
Closes #5790 (we could do more, but this might be sufficient)

<img width="892" alt="image"
src="https://github.com/firezone/firezone/assets/13400041/5ce84a05-2f6c-4ffd-ba21-19d3087c8c7f">
<img width="641" alt="image"
src="https://github.com/firezone/firezone/assets/13400041/2da7ff36-a969-444e-885c-ae0919577f56">


The code is cross-platform, but this is unlikely to happen on Windows
because the MSI refuses to update if the GUI process is running. On
Linux `apt-get` will update and restart the IPC service without touching
the GUI process.

```[tasklist]
- [x] Test on Linux with `apt-get install`
- [x] Update changelog
- [x] Run a 5-minute smoke test on Linux
- [x] Run a 5-minute smoke test on Windows
- [x] Open for review
- [ ] Merge
```

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-07-15 17:53:24 +00:00
Jamil
16c24c2024 fix(website): update battlecard (#5868)
Google Workspace (ts)
2024-07-14 18:08:10 -07:00
Thomas Eizinger
a4a8221b8b refactor(connlib): explicitly initialise Tun (#5839)
Connlib's routing logic and networking code is entirely platform
agnostic. The only platform-specific bit is how we interact with the TUN
device. From connlib's perspective though, all it needs is an interface
for reading and writing. How the device gets initialised and updated is
client-business.

For the most part, this is the same on all platforms: We call callbacks
and the client updates the state accordingly. The only annoying bit here
is that Android recreates the TUN interface on every update and thus our
old file descriptor is invalid. The current design works around this by
returning the new file descriptor on Android. This is a problematic
design for several reasons:

- It forces the callback handler to finish synchronously, and halting
connlib until this is complete.
- The synchronous nature also means we cannot replace the callbacks with
events as events don't have a return value.

To fix this, we introduce a new `set_tun` method on `Tunnel`. This moves
the business of how the `Tun` device is created up to the client. The
clients are already platform-specific so this makes sense. In a future
iteration, we can move all the various `Tun` implementations all the way
up to the client-specific crates, thus co-locating the platform-specific
code.

Initialising `Tun` from the outside surfaces another issue: The routes
are still set via the `Tun` handle on Windows. To fix this, we introduce
a `make_tun` function on `TunDeviceManager` in order for it to remember
the interface index on Windows and being able to move the setting of
routes to `TunDeviceManager`.

This simplifies several of connlib's APIs which are now infallible.

Resolves: #4473.

---------

Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: conectado <gabrielalejandro7@gmail.com>
2024-07-12 23:54:15 +00:00
Jamil
478229e605 docs: update release playbook (#5863)
Update MAINTAINERS.md with most recent release playbook.

```[tasklist]
### Tasks
- [x] Merge `publish_release.md` into `MAINTAINERS.md`
- [ ] Merge PR
```

---------

Co-authored-by: Not Applicable <ReactorScram@users.noreply.github.com>
2024-07-12 21:19:36 +00:00
Reactor Scram
a8ece49d9e chore: bump GUI to 1.1.6 (#5862)
I started a playbook for publishing GUI releases, I didn't see any other
one around.

I think there's a middle step I'm not clear on:

1. Open this PR and get it approved
2. Do something? Publish the draft release maybe? Run a special CI
workflow?
3. Merge this PR to update the changelog and bump the versions in Git

```[tasklist]
### Tasks
```
2024-07-12 18:45:56 +00:00
Reactor Scram
1cbb1e14ea docs(gui-client): update known issues lists (#5849) 2024-07-12 15:02:25 +00:00
Thomas Eizinger
a4714d6de3 chore(connlib): print error after panicking (#5854) 2024-07-12 14:30:11 +00:00
Thomas Eizinger
f21e9116e2 chore(nix): install android-tools in dev-shell (#5855)
This contains `adb` which is useful for Android development.
2024-07-12 14:27:39 +00:00
Jamil
db9512f213 fix(website): Fix broken docs link (#5857) 2024-07-12 06:41:25 -07:00
Thomas Eizinger
c92dd559f7 chore(rust): format Cargo.toml using cargo-sort (#5851) 2024-07-12 04:57:22 +00:00