Commit Graph

3903 Commits

Author SHA1 Message Date
Reactor Scram
a10d76c525 chore(linux): revert /etc/resolv.conf on exit if we changed it to control DNS (#4148)
This isn't really user-facing, so I marked it down from `feat` to
`chore`. Closes #3817

- If we exit gracefully, `/etc/resolv.conf` is reverted
- We always keep the `.before-firezone` backup in case we lose power and
the revert transaction is corrupted or rolled back
- We use a magic header to detect whether the last run was a crash or
not. If Firezone crashes and the user wants to modify their default DNS,
they need to delete that header so that Firezone won't accidentally
revert its backup and trash their change.
- All error variants for this module replaced with `anyhow::Error` since
they were never matched by callers.

I ran `cargo mutants` locally and it helped me validate the unit tests
and it picked up a `match` branch that I forgot to delete.

```[tasklist]
- [x] (Failed: Integration tests didn't like it) ~~Add the system default resolvers below Firezone's sentinels~~
- [x] `tracing::info` "Last run crashed" if we have to revert the file at startup
```

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-03-18 16:29:25 +00:00
Reactor Scram
8bad6a39d0 chore: propose process splitting for Linux (#4153) 2024-03-18 16:24:19 +00:00
Andrew Dryga
62df3fb89c Stop using Finch as Swoosh http client 2024-03-18 08:56:05 -06:00
Andrew Dryga
7e3271c205 fix(portal): Start finch pool for swoosh 2024-03-18 08:28:20 -06:00
Jamil
de687f4c59 chore(ci): Lock AzureSignTool to version 4 (#4190)
Fixes #4185
2024-03-18 13:42:24 +00:00
Brian Manifold
2c7f45cc99 feat(portal): Add sign up override in portal (#3739)
Why:

* In order to allow easy testing of billing / Stripe integration, the
staging environment needs to allow members of the Firezone team access
to create new accounts, while disallowing the general public to create
accounts. The account creation override functionality allows for
multiple domains to be set by ENV variable by passing a comma separated
string of domains.

---------

Co-authored-by: Andrew Dryga <andrew@dryga.com>
2024-03-17 18:12:25 -06:00
Andrew Dryga
cd7cb8f2a9 chore(portal): Fix some typos (#4184)
@bmanifold fixed a few instances in #3739 but I went ahead and replaced
all of them, once we merge it and rebase #3739 on top of it the diff
should be minimal.
2024-03-17 17:33:30 -06:00
Andrew Dryga
1270f34565 Hotfix jobs scheduling 2024-03-16 16:40:52 -06:00
Andrew Dryga
f3c8c734ab feat(portal): Filtering, Fulltext Search, Pagination, Preloads (#3751)
On the domain side this PR extends `Domain.Repo` with filtering,
pagination, and ordering, along with some convention changes are
removing the code that is not needed since we have the filtering now.
This required to touch pretty much all contexts and code, but I went
through all public functions and added missing tests to make sure
nothing will be broken.

On the web side I've introduced a `<.live_table />` which is as close as
possible to being a drop-in replacement for the regular `<.table />`
(but requires to structure the LiveView module differently due to
assigns anyways). I've updated all the listing tables to use it.
2024-03-16 13:27:48 -06:00
Andrew Dryga
b4ccec12d0 Bump prod terraform version and re-init modules 2024-03-16 12:45:32 -06:00
Andrew Dryga
114696c0ba chore(infra): Split terraform files into folders and add domain to production app (#4172) 2024-03-16 11:54:06 -06:00
Andrew Dryga
a85b9ab185 chore(infra): Deploy domain app on a separate instance and enable background jobs on it (#4160)
Closes #3801
2024-03-16 08:58:20 -06:00
Jamil
692fc408e8 refactor(apple): Use String subnetMask not prefix for IPv4Route (#4162)
The Swift API is not consistent.
2024-03-16 05:14:26 -07:00
Thomas Eizinger
de6bbbc10d chore(relay): fix flaky proptest (#4157)
This turned out to be a user error in how I was using proptest.

Related: https://github.com/proptest-rs/proptest/issues/72.
Resolves: #3965.
2024-03-16 01:09:39 +00:00
Jamil
194e8ae579 chore(ci): Add confirmation to hotfix (#4132)
Adds another step to give pause.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Andrew Dryga <andrew@dryga.com>
2024-03-15 22:14:08 +00:00
Reactor Scram
3ced2b3a20 ci(linux): fix incorrect use of grep -v (#4151)
I think I used `-v` wrong here. I meant it to negate a regular grep, but
it will probably always return true since it negates the matching, not
the exit code.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-03-15 19:06:57 +00:00
Reactor Scram
abf3402e50 chore(linux): document DNS control methods (#4147)
Internal (Not private, just un-interesting to most users) docs and
research to explain the DNS control methods.

I think Jamil was right, we should revert `/etc/resolv.conf` on exit in
case it's used on some minimal Debian kitten. We can keep that and the
`systemd-resolved` method around to support desktop Ubuntu. Everything
else is going to be "When someone needs it".
2024-03-15 18:43:43 +00:00
Thomas Eizinger
01bd019d2d refactor(connlib): move Node into {Client,Gateway}State (#4155)
This opens the door for unit testing `ClientState` with a
`GatewayState`, similarly as we have a test for a `ClientNode` and
`ServerNode` in `snownet`.

Before we can do that though, we need to move several functions from
`ClientTunnel` onto `ClientState`, i.e. essentially encapsulate
`ClientState` better. This is left to a future PR though to keep the
steps small.

Resolves: #3928.
2024-03-15 16:59:57 +00:00
dependabot[bot]
2dd8d0accd build(deps-dev): Bump follow-redirects from 1.15.5 to 1.15.6 in /rust/gui-client (#4149)
Bumps
[follow-redirects](https://github.com/follow-redirects/follow-redirects)
from 1.15.5 to 1.15.6.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="35a517c586"><code>35a517c</code></a>
Release version 1.15.6 of the npm package.</li>
<li><a
href="c4f847f851"><code>c4f847f</code></a>
Drop Proxy-Authorization across hosts.</li>
<li><a
href="8526b4a1b2"><code>8526b4a</code></a>
Use GitHub for disclosure.</li>
<li>See full diff in <a
href="https://github.com/follow-redirects/follow-redirects/compare/v1.15.5...v1.15.6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=follow-redirects&package-manager=npm_and_yarn&previous-version=1.15.5&new-version=1.15.6)](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)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/firezone/firezone/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-03-15 15:37:15 +00:00
Thomas Eizinger
62e082d47a refactor(connlib): make {Client,Gateway}State SANS-IO (#4096)
Resolves: #3929.
2024-03-14 23:44:36 +00:00
Thomas Eizinger
d092e22840 feat(connlib): introduce Session::reconnect (#4116)
I ended up calling it `reconnect` because that is really what we are
doing:

- We reconnect to the portal.
- We "reconnect" to all relays, i.e. refresh the allocations.

I decided **not** to use an ICE restart. An ICE restart clears the local
as well as the remote credentials, meaning we would need to run another
instance of the signalling protocol. The current control plane does not
support this and it is also unnecessary in our situation. In the case of
an actual network change (e.g. WiFI to cellular), refreshing of the
allocations will turn up new candidates as that is how we discovered our
original ones in the first place. Because we constantly operate in ICE
trickle mode, those will be sent to the remote via the control plane and
we start testing them.

As those new paths become available, str0m will automatically nominate
them in case the current one runs into an ICE timeout. Here is a
screen-recording of the Linux CLI client where `Session::refresh` is
triggered via the SIGHUP signal:

[Screencast from 2024-03-14
11-16-47.webm](https://github.com/firezone/firezone/assets/5486389/7171d199-f2a2-4b22-92c8-243494d5d6d8)

Provides the infrastructure for: #4028.
2024-03-14 23:23:29 +00:00
Thomas Eizinger
0dfd26a014 feat(snownet): introduce connection span to capture str0m and boringtun logs (#4144)
These new spans help capture logs from within `str0m` and `boringtun`
with the context of our connection ID.

Resolves: #4140.
2024-03-14 20:38:34 +00:00
Reactor Scram
d6827c046a chore(gui-client): fix macOS clippy warning, clean up error types (#4146)
Fixes the compile warning in macOS for the `version-check` CI job.

Removes some error variants that were never matched on, folding them
into `anyhow::Error`s
2024-03-14 20:38:22 +00:00
Thomas Eizinger
a64c34112d ci: activate backtrace for Rust tests (#4137) 2024-03-14 20:21:14 +00:00
Gabi
148bc8c7b2 fix(android): send Cidr format instead of IpNetwork format (#4134)
Fixes android on main and remove the need to parse and re-parse
addresses for android and swift.

---------

Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-03-14 18:57:35 +00:00
Jamil
ffc034d5c4 chore(docker): Add missing okta provider (#4131) 2024-03-14 16:18:26 +00:00
Thomas Eizinger
c62202ac90 fix(android): spawn dedicated thread for connlib (#4145)
Same as https://github.com/firezone/firezone/pull/4141 but for Android.
2024-03-14 05:57:13 +00:00
Gabi
91de68fd4b fix(apple): spawn new thread for runtime to prevent it from being taken down (#4141)
Using the current thread in apple was causing a crashloop, since
connlib's thread was taken down by the network extension after
`WrappedSession::connect` returned.

Now we force the runtime to create the thread to prevent it from being
taken down.
2024-03-14 05:49:28 +00:00
Gabi
05e5ca609c chore(apple): initiate logging subscriber as early as possible (#4143)
Also, return error with tracing subscriber initialization
2024-03-14 05:45:22 +00:00
Thomas Eizinger
be22e99380 ci: scope Rust cache by targets to be built (#4136) 2024-03-14 01:19:18 +00:00
Thomas Eizinger
53cc7d6fd5 refactor(connlib): don't start a runtime as part of Session (#4119)
Currently, each use of `Session` creates its own `Runtime`. That is
unnecessary because some platforms already have a tokio runtime running.
Instead of creating another one, we simply ask the caller to provide us
with a `Handle` to an existing tokio runtime. For Android and iOS we
spawn a new single-threaded runtime to satisfy this new requirement.
2024-03-14 00:06:29 +00:00
Jamil
63c546eb45 chore(docker): Fix docker image local builds (#4127)
Fixes an artifact leftover from the refactor.

Fixes #4122
2024-03-14 00:06:10 +00:00
Thomas Eizinger
9767bddcca feat(gateway): add HTTP health check (#4120)
This adds the same kind of HTTP health-check that is already present in
the relay to the gateway. The health-check returns 200 OK for as long as
the gateway is active. The gateway automatically shuts down on fatal
errors (like authentication failures with the portal).

To enable this, I've extracted a crate `http-health-check` that shares
this code between the relay and the gateway.

Resolves: #2465.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-03-13 21:05:21 +00:00
Reactor Scram
4c77aae3d2 chore(windows): document Windows network_changes behavior (#4130)
Ref #3429 

It doesn't report DNS changes, but I added a proof of concept for how we
could do that.
2024-03-13 20:59:52 +00:00
Thomas Eizinger
6a7d8c8a3d refactor(snownet): introduce is_connected_to to simplify unit test (#4121)
Instead of tracking this state separately, we can expose a getter on a
`snownet::Node`.
2024-03-13 20:48:45 +00:00
Thomas Eizinger
bd94461d65 feat(connlib): reduce stack size usage (#3958)
With the use of `snownet`, we now have explicit control over how we read
and write messages to sockets. As such, we can make the remaining
stack-allocated buffer heap-allocated and remove the increased
stack-size on our tokio worker threads.
2024-03-13 20:47:22 +00:00
Thomas Eizinger
6ab7e51264 refactor(connlib): allow commands to be sent to eventloop (#4112)
This refactors `Session` to allow for commands to be sent to the
`Eventloop`. Currently, we only send a `Stop` command. With #3429, we
will add more commands like refreshing and updating the DNS servers.
2024-03-13 20:09:48 +00:00
Andrew Dryga
7fd3d1a6b1 fix(portal): Increase group name max length (#4128)
Fixes
https://firezonehq.slack.com/archives/C05JUKPT83T/p1710324078226719
2024-03-13 12:38:09 -06:00
Reactor Scram
52cde610e1 feat(linux): make deep link auth work (#4102)
Right now it only works on my dev VM, not on my test VMs, due to #4053
and #4103, but it passes tests and should be safe to merge.

There's one doc fix and one script fix which are unrelated and could be
their own PRs, but they'd be tiny, so I left them in here.

Ref #4106 and #3713 for the plan to fix all this by splitting the tunnel
process off so that the GUI runs as a normal user.
2024-03-13 18:11:04 +00:00
Jamil
32d18abb09 chore(ci): Use explicit images for hotfix workflow (#4126)
Hotfix calls integrations tests separately, so we need to explicitly
define the images for it to use.
2024-03-13 08:12:05 -07:00
Jamil
ec4eb2583f chore(ci): Explicit empty string and use GITHUB_OUTPUT (#4125)
Image names...
2024-03-13 00:02:20 -07:00
Jamil
e55f2325bc chore(ci): fix name naming (#4124) 2024-03-12 23:36:37 -07:00
Jamil
e185a5818a chore(ci): Add workflow trigger to description (#4123)
Getting some unexpected values for `github.event_name` so adding more
logging to diagnose.
2024-03-12 23:34:17 -07:00
Thomas Eizinger
5744ed2a13 chore(connlib): remove unused event (#4110)
Seems to be a left-over from a previous design.
2024-03-13 03:25:21 +00:00
Jamil
1cfe2c5d4a chore(ci): use output image from build for integration tests (#4117)
In CI, images have `debug/`. In CD, they don't, so test them that way.
2024-03-13 02:58:17 +00:00
Jamil
c555167e64 chore(ci): Check github.event_name == "pull_request" before using debug image prefix (#4115) 2024-03-12 18:26:35 -07:00
Jamil
2d79f32394 chore(ci): Don't namespace release images (#4114)
Fixes a logic bug.
2024-03-12 18:16:52 -07:00
Jamil
b1871ea24d Fix typo in _deploy_production.yml (#4113) 2024-03-12 17:02:20 -07:00
Jamil
78e730e6b5 chore(ci): Fix sha typo (#4111)
workflow_dispatch doesn't allow vars
2024-03-12 16:36:15 -07:00
Thomas Eizinger
6b1c2c9369 chore(snownet): add basic unit test for a connection (#4097)
This is heavily inspired by how `str0m`'s `IceAgent` is tested. I left a
link for attribution. We can copy / move this later to write unit tests
for the `Tunnel`.
2024-03-12 22:26:10 +00:00