Commit Graph

343 Commits

Author SHA1 Message Date
Reactor Scram
d25bbf5582 fix(windows): give the encrypted credential a unique name (#2972)
I found out `keyring-rs` wasn't doing "firezone/token" internally, so
our credential was just "token", which is too generic. I changed it to
use our domain so it's "dev.firezone.client/token".
2023-12-20 22:55:03 +00:00
Reactor Scram
6ebbe746e8 feat(windows): count log files (#2964)
There's a 200 ms delay between each file, for debugging. It's nice to
demo how it thinks, but it needs to go behind a fault injection flag or
be removed completely before merging.


![image](https://github.com/firezone/firezone/assets/13400041/af364170-0e76-45fa-83f2-521b3de679de)
2023-12-20 22:38:37 +00:00
Reactor Scram
f4ffebda75 fix(windows): make sure the worker thread for wintun shuts down cleanly (#2971)
This thread will go away when I change it to non-blocking, but for now
it was causing multiple sign ins during the same run of the client app
to fail.
2023-12-20 20:17:55 +00:00
Reactor Scram
7e6f2621b4 feat(windows): Handle routes and DNS (#2889)
Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-20 19:44:53 +00:00
Reactor Scram
f284e06014 refactor(windows): extract modules from gui module (#2961)
So everything in `gui` is controller logic.
2023-12-20 01:54:55 +00:00
Reactor Scram
61bff3b1ed fix(windows): copy default debug and release settings from Android (#2963)
and fix a couple other settings.
2023-12-20 01:43:58 +00:00
Reactor Scram
0beafbfb9e refactor(windows): fix up MSI installer package and try to build it in CI (#2938) 2023-12-20 01:42:03 +00:00
Reactor Scram
8951be1ad2 fix(windows): disconnect tunnel on sign-out (#2932) 2023-12-20 00:51:27 +00:00
Gabi
92c5e5f1de connlib: dont fail on ipv6 add route failure (#2962)
Fixes a bug where gateway failed to start if we couldn't add ipv6
routes.
2023-12-20 00:49:32 +00:00
Gabi
9b51094f73 connlib: prevent resource leak for non-handled record types (#2955)
Partially fixes #2920

As explained in
https://github.com/firezone/firezone/issues/2920#issuecomment-1861642550
in the future we should change the way we resolve DNS queries in the
gateway to properly handle HTTPS record types.

With this patch this is what happens to an HTTPS query while firezone is
running:


```
kdig -t HTTPS ifconfig.net
;; ->>HEADER<<- opcode: QUERY; status: NXDOMAIN; id: 15773
;; Flags: qr rd; QUERY: 1; ANSWER: 0; AUTHORITY: 0; ADDITIONAL: 0

;; QUESTION SECTION:
;; ifconfig.net.       		IN	HTTPS

;; Received 30 B
;; Time 2023-12-18 18:34:23 -03
;; From 100.100.111.1@53(UDP) in 0.6 ms
```
2023-12-20 00:05:39 +00:00
Gabi
1d595fd15c refactor(connlib): log more details about failed queries (#2934)
Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-19 21:56:52 +00:00
Gabi
73823ecba0 Fix/firezone id handling (#2958)
fixes #2651 

Wip because firezone portal doesn't handle names longer than 8
characters yet cc @AndrewDryga
2023-12-19 15:38:27 -06:00
Jamil
aabc06c3c1 Fix java method signature bug (#2950)
Fixes a bug introduced in the DNS stuff

Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2023-12-19 19:54:13 +00:00
Jamil
b28e99cdab chore(ci): Use 1.0.0 as version base (#2949)
Fixes #2948 

So it seems that it's easiest just to use an old-fashioned semver
string. This means we'll need to keep a version matrix in the docs of
which components are supported and for how long, but it's better than
having different version schemes for different Firezone components
altogether.
2023-12-19 14:19:16 +00:00
Reactor Scram
64f76f5edb feat(windows): Elevate with UAC automatically on startup (#2913)
Automatically write the wintun.dll file on startup and then detect
whether we need to elevate to admin privileges.

I check for privileges by making a test tunnel, so I did #2758 as part
of this, which bundles the DLL inside the exe, and then the exe deploys
it.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-18 23:54:45 +00:00
Reactor Scram
a40d550bb0 refactor(windows): remove unused code, redundant platform checks (#2937)
Removes local_webserver module and many redundant stubs for Unix
2023-12-18 22:53:18 +00:00
Reactor Scram
f19b8fc5de fix(windows): put the bundle version back in tauri.conf.json to fix CI (#2952)
PR #2949 will make this redundant and I'll remove it from
tauri.conf.json again
2023-12-18 13:17:48 -06:00
Reactor Scram
6b0149e58d ci(windows): remove hello-world and permissions-test projects (#2926)
Don't need them any more. `build-tauri` is about 5 minutes faster
without the permissions test, since it had to be a separate project /
workspace entirely and rebuilt a bunch of stuff. That's a reason I
prefer subcommands. For some reason sccache didn't seem to do much for
it. This is also a flaw in Tauri, I couldn't figure out any proper way
to keep a Tauri project inside the examples dir of another Tauri
project. With two non-Tauri apps it's easier and probably wouldn't add
much build time.
2023-12-17 17:12:50 +00:00
Reactor Scram
364d415b67 fix(windows): #2927 - Use Cargo.toml version instead of tauri.conf.json (#2936) 2023-12-17 17:12:25 +00:00
Jamil
bdbfa0dc5b Prevent DNS sentinel from being used as a fallback resolver (#2922)
Prevent the edge case where our DNS sentinel could be used as a fallback
resolver. I didn't observe this in the wild, but we should avoid it in
case.

---------

Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2023-12-16 01:24:07 +00:00
Jamil
0013a18586 Remove SMBios (#2921) 2023-12-16 01:17:15 +00:00
Reactor Scram
8fcc99ae14 windows: fix deep links (#2903)
Stacked on PR #2888

This will fix #2878 by setting some Windows security permissions to let
non-admin clients connect to a named pipe server owned by an admin
process.

It should also give us a path to fix 2808 (If I link it, Github assumes
this PR closes that issue?), since it'll be our own code instead of
tauri-plugin-deep-link, and we can just choose not to panic. I'm using
Tokio's `named_pipe` module where that panic happens, and Tokio is good
about just returning Results instead of panicking.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-15 19:17:55 +00:00
Gabi
1cc5164f4e connlib: decouple data and control plane and fix backoff reset (#2906)
This fixes #2503 
Also:
* decouples data-plane and control-plane on the gateway
* fixes a thing were a client would stop retrying connecting to a
resource if it failed too many times
* add all routes on start instead of on a per-route basis
2023-12-15 19:05:01 +00:00
Jamil
0014172c0a Don't automatically delete log files after successful upload (#2904)
Prevents cases where "Export logs" doesn't contain the full log cache.

Fixes #2886
2023-12-14 19:31:40 +00:00
Jamil
b332780cc8 Use correct type for ioctl codes (#2905)
Fixes
https://github.com/firezone/firezone/actions/runs/7202636231/job/19621864921
2023-12-14 11:19:37 +00:00
Reactor Scram
aa46089dd1 windows: use settings log_filter instead of env var (#2888)
Stacked on PR #2883

There will be more changes after this PR, these features are still
broken:
- Can't change filter at runtime yet, you have to restart the client app
- connlib and GUI are sending logs to the same connlib logs files, they
should be separated

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-13 23:57:52 +00:00
Reactor Scram
d1a7211f64 windows: Integrate wintun, run the VPN (#2883)
With this one, ICMP and TCP work, but the client doesn't set up routes
or handle DNS yet, so I've been using `netsh` to fake that.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-13 23:19:36 +00:00
Gabi
186ceb18e6 Connlib: reduce failover timeout (#2897)
This reduces the failover time by depending on webrtc's keepalive
instead of wireguard's.

We have much more control over that, since boringtun doesn't bubble up
any of the keepalives timeout(only a trace warning).

In the a next commit, when things are more stable, we should just get
rid of wireguard's keep alive. When we remove webrtc we will build our
own.

Events based on `keepalive` timeouts are key to our failover system, so
we **need** it.

Draft because it's built on top of #2891 (which is completely separate
code but without that the failover just doesn't work correctly)
2023-12-13 22:40:04 +00:00
Jamil
8499580388 Remove Apple SplitDNS in favor of unified split DNS approach (#2894)
<img width="1552" alt="Screenshot 2023-12-12 at 11 29 43 PM"
src="https://github.com/firezone/firezone/assets/167144/d517c830-64a8-462d-8cb5-c41835fa2059">

Found a reliable way to return default system DNS resolvers on iOS and
macOS. Even if this method is not perfect, I think it's still worth
pursuing because:

* Many administrators will set an upstream resolver in the portal anyway
(bypassing client system resolvers)
* It unifies our Split DNS approach across platforms (assuming we can
query the default system resolvers on Windows), allowing connlib to
intercept all DNS queries on all platforms. This opens the door for some
interesting feature possibilities in the area of malicious query
blocking. This also makes DNS bugs easier to investigate because there's
only one codepath for packets to take. See
https://github.com/firezone/firezone/issues/2859

Draft because it needs more testing and I need to figure out the
`RustVec<RustString>` type for the Swift -> Rust FFI.

Refs #2713
2023-12-13 22:01:00 +00:00
Gabi
34dce6f185 connlib: try to reuse old ips even with new peers (#2891)
When a peer expired the os might have cached the old internal ips that
we used, then with a new peer we were assigning new ips and that cached
ip might have been wrong, then the tunnel would be in state where it
would send the wrong response to this ips.

With this PR we try to always reuse the old ip if there's any available.
2023-12-13 18:33:51 +00:00
Gabi
b9cbc1786f connlib: disconnect on token expiration (#2890)
Previously, we just expected the portal to disconnects us and 401 on the
retry, right now we harden that behaviour by also just disconnecting
when token expiration.

This seems to work, there's another part to this which is not only
handling the replies but also handling the message generated by the
portal, I'll implement that when I can easily test expirying tokens, for
now this makes the client much more stable.
2023-12-13 15:10:43 +00:00
Gabi
75d90d7372 connlib: set DNS response type for answers (#2892)
just silly but important mistake 😛 

fixes #2858 and #2859 (though there might be an additional edge case in
#2859 where the upstream server is set as a dns, though it seems to work
some further testing would be good)
2023-12-13 03:14:42 +00:00
Thomas Eizinger
0de16d3676 refactor(connlib): remove async from the Device API (#2815)
At present, the definition of `Device` is heavily nested with
conditional code. I've found this hard to understand and navigate.
Recent refactorings now made it possible to remove a lot of these layers
so we primarily deal with two concepts:

- A `Device` which offers async read and non-blocking write functions
- A `Tun` abstraction which is platform-specific

Instead of dedicated modules, I chose to feature-flag individual
functions on `Device` with `#[cfg(target_family = "unix")]` and
`#[cfg(target_family = "windows")]`. I find this easier to understand
because the code is right next to each other.

In addition, changing the module hierarchy of `Device` allows us to
remove `async` from the public API which is only introduced by the use
of `rtnetlink` in Linux. Instead of making functions across all `Tun`
implementations `async`, we embed a "worker" within the `linux::Tun`
implementation that gets polled before `poll_read`.

---------

Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2023-12-12 19:47:26 +00:00
Reactor Scram
cd3114cc1d windows: tell Windows that our release builds should always run as admin (#2838)
It'll show UAC when you first run the app. After that we can open and
close the VPN network adapter without showing more UAC dialogs since we
have sudo powers.
2023-12-12 17:49:32 +00:00
Reactor Scram
a339f5b437 feat(windows): generate device ID and persist it on disk (#2840)
Relating to #2697 and #2711

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2023-12-12 17:46:26 +00:00
Gabi
e1fb6c80a0 fix(connlib): attempt to join topic upon unmatched topic error (#2874)
Fixes: #2854.

Note: this is ready for review but reproducing the bug that triggered
the fix takes ~1 hour or so, so I would like to wait to check that's
fixed.

Can be reviewed meanwhile.
2023-12-12 16:57:47 +00:00
Reactor Scram
5853b13794 windows: add module to install the wintun.dll by embedding it in the client's exe and then copying it out at runtime (#2843)
Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-12 16:28:48 +00:00
Andrew Dryga
52b284abd9 Terraform improvements for production (#2873) 2023-12-11 19:41:01 -06:00
Gabi
8d3bdf7d45 connlib: add dns routes at tunnel init (#2870)
Fixes #2853 

Note: it seems that this actually fixes ERR_NETWORK_CHANGED.
2023-12-11 19:42:55 +00:00
Reactor Scram
8718cc9245 feat(windows): check in wintun x64 DLL 0.14.1 for #2758 (#2842)
Just adds the DLL and header

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-11 19:17:51 +00:00
Jamil
be37ed1b5c Use the dnsFallbackStrategy configured in portal for macOS/iOS (#2860)
Fixes #2857
2023-12-11 00:13:55 +00:00
Reactor Scram
a8c0c5255f windows: add example / test binary to keep debugging code out of the main exe (#2822)
It doesn't run with `--example` because Tauri's build process doesn't
seem to be compatible with that.
But it does build the permissions test exe in CI. I might change that a
general test exe later so that I don't have to add more build targets.

It adds about 5 minutes to the CI, sccache only seems to speed up the
build for the 2nd exe a tiny bit.
2023-12-09 20:43:27 +00:00
Gabi
3b3cf6bf27 connlib: fix ipv6 range (#2844) 2023-12-09 18:54:59 +00:00
Gabi
b817ddfe7f Assorted fixes (#2839) 2023-12-08 19:43:40 +00:00
Reactor Scram
4b833e06ab docs(windows): requirements for diagnostic logging tab (#2834)
Add requirements for the Diagnostic Logs tab per internal discussion
2023-12-08 17:13:30 +00:00
Reactor Scram
7a9c1321dc windows: get actor_name from auth callback (#2820)
Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-08 16:39:31 +00:00
Gabi
d19beb7ae6 swift: fix for the new resource format (#2833) 2023-12-08 09:35:17 -05:00
Gabi
8e34457340 Add support for DNS sudomains (#2735)
This PR changes the protocol and adds support for DNS subdomains, now
when a DNS resource is added all its subdomains are automatically
tunneled too. Later we will add support for `*.domain` or `?.domain` but
currently there is an Apple split tunnel implementation limitation which
is too labor-intensive to fix right away.

Fixes #2661 

Co-authored-by: Andrew Dryga <andrew@dryga.com>
2023-12-08 00:16:42 -05:00
Reactor Scram
8f433a8c45 docs(windows): document manual test cases (#2819)
This will help me keep all the expected behaviors of the client app
centralized and avoid regressions when I change things.
2023-12-07 22:04:41 +00:00
Reactor Scram
6d9360c150 windows: fix advanced settings loading, catch deep link error (#2811)
Based / Blocked on #2795

Fixes #2807 where I accidentally bail out of the controller task if the
settings file is missing or isn't valid in any way.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-12-07 18:28:28 +00:00