Commit Graph

189 Commits

Author SHA1 Message Date
Thomas Eizinger
11ada00617 feat: introduce firezone-connection with basic test suite (#2965)
Initial version of the `firezone-connection` crate. To begin with, we
only establish a connection in a LAN, i.e. no hole-punching, no STUN or
TURN servers, just host candidates. As such, a lot of this PR is just
scaffolding for setting up the test environment and the actual
`ConnectionPool` implementation.

For the curious, I've left some TODOs where I am going to attempt
extending the implementation once we start dealing with STUN and TURN
servers.

I also extended CI to run these tests.
2023-12-23 00:45:43 +00:00
Reactor Scram
82604139ce refactor(windows): remove ResourceDisplay (#3002)
... and move its methods into ResourceDescription.

This was a TODO from some pull request in the last few days. I assume
the goal is to share this function between all clients if needed. It
doesn't reduce the number of lines of code, since I could have removed
ResourceDisplay and done this on-the-fly when building the systray menu,
as an alternative.
2023-12-22 22:18:53 +00:00
Reactor Scram
a6659c36cc fix(connlib): move .log to the end of log filenames (#3008)
This allows GUIs including Windows to associate a text editor with them
2023-12-22 21:43:48 +00:00
Gabi
ecfa919bbc refactor(connlib): refresh dns addresses (#2994)
Fix for #2956 this is achieved by refreshing access to every resource
every 5 minutes.

There's still an open question for this PR:

When the gateway resolves an ip the gateway allows access to a DNS
resource it resolves the address and allow access to that ip for that
client.

Right now, until the access for that resource doesn't expire that access
isn't revoked.

We could change it so that we require the client to refresh such
access(with this PR those refresh queries are already being made every 5
minutes) every x minutes on top of the `expires_at` or we can keep
`expires_at` as to mean "allow access until `expires_at` for whatever
this resource resolves to".
cc @jamilbk @AndrewDryga
2023-12-22 13:12:32 -06:00
Gabi
afb989ced9 security(connlib): Dont allow acces to non-subdomains for a given resource (#2996)
Previously, we just assumed that the domain in the query is a subdomain
of the resource but a malicious actor can hijack that field to access
domains that doesn't correspond to that resource.

With this patch we don't even resolve the address for unrelated domains.
2023-12-22 17:42:32 +00:00
Gabi
eed9608dd0 connlib: add arch and kernel version to user agent (#2987)
Fixes #2470, now for linux it looks like:

```
Alpine Linux/3.19.0 (x86_64;5.15.133.1-microsoft-standard-WSL2;) connlib/1.0.0 
```

For macos it looks like:

```
Mac OS/13.4.1 (arm64;22.5.0;) connlib/1.0.0
```

and this is how it looks on android:

```
Android/Unknown 6.1.23-android14-4-00257-g7e35917775b8-ab9964412 connlib/1.0.0
```

note: seems like in android emulator at least we can't get the
architecture so easily
2023-12-22 03:03:08 +00:00
Reactor Scram
09bfb72d3b refactor(windows): don't block connlib callbacks (#2960)
The code is not pretty but if I land this then I can make it pretty
later.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2023-12-21 21:03:24 +00:00
Gabi
6e77978da7 Fix/lost connection request (#2976)
Should fix #2880

The way I do it is after ~10 seconds dropping the
`gateway_awaiting_connection` and let the client try the connection
again, depending on upper layer, I think this is fine since the cases
where this happens is unlikely.

It's hard to test thoroughly but I'll test with bad-condition
simulators, [pumba](https://github.com/alexei-led/pumba) seems
promising. In the meantime I'm still creating the PR so that I can have
it reviewed.

Edit: Using Pumba with different % of packet loss things seems to go
well, and connections are actually established even if the packets are
loss. (Making a note that we should integrate pumba with our CI)
2023-12-21 20:01:52 +00:00
Gabi
5edfe80eb0 connlib: tune disconnect parameters (#2977)
Should fix #2946 (still testing, trying to reproduce the error reported
in the issue)
2023-12-21 19:37:07 +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
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
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
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
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
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
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
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
Jamil
be37ed1b5c Use the dnsFallbackStrategy configured in portal for macOS/iOS (#2860)
Fixes #2857
2023-12-11 00:13:55 +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
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
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
dependabot[bot]
34bef7e440 build(deps): Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.20 to 1.9.21 in /rust/connlib/clients/android/connlib (#2782)
Bumps
[org.jetbrains.kotlin:kotlin-stdlib](https://github.com/JetBrains/kotlin)
from 1.9.20 to 1.9.21.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/JetBrains/kotlin/releases">org.jetbrains.kotlin:kotlin-stdlib's
releases</a>.</em></p>
<blockquote>
<h2>Kotlin 1.9.21</h2>
<h2>Changelog</h2>
<h3>Compiler</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62885"><code>KT-62885</code></a>
Introduce a language feature entry for expect actual classes for easier
configuration of MPP projects</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63081"><code>KT-63081</code></a>
Optimize new native caches:
CachedLibraries.computeVersionedCacheDirectory()</li>
</ul>
<h3>Docs &amp; Examples</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-55619"><code>KT-55619</code></a>
Document <code>String.format</code> function</li>
</ul>
<h3>IDE. Gradle Integration</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62877"><code>KT-62877</code></a>
Artifact files collecting for project configuration was finished.
Resolution for configuration configuration X will be skipped</li>
</ul>
<h3>IDE. Gradle. Script</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-60813"><code>KT-60813</code></a>
Scripts: NoSuchMethodError: 'void
org.slf4j.Logger.error(java.lang.String, java.lang.Object)' when
dependency uses Slf4j API</li>
</ul>
<h3>JavaScript</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-60785"><code>KT-60785</code></a>
KJS: Destructured value class in suspend function fails with Uncaught
TypeError: can't convert to primitive type error</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63207"><code>KT-63207</code></a>
KMP / JS: &quot;TypeError: <!-- raw HTML omitted --> is not a
function&quot; with 1.9.20</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62778"><code>KT-62778</code></a>
package.json &quot;main&quot; field has .js extension when the result
files have .mjs extension</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-61795"><code>KT-61795</code></a>
KJS: Incremental Cache is not invalidated if <code>useEsClasses</code>
compiler argument was changed</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-61957"><code>KT-61957</code></a>
KJS: &quot;Uncaught ReferenceError: entries is not defined&quot; caused
by enum class with <code>@JsExport</code> and Enum.entries call</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62444"><code>KT-62444</code></a>
KJS with commonJS modules should re-export in 1.9.20</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63184"><code>KT-63184</code></a>
KJS / Serialization: JsExport on serializable interface creates
erroneous TypeScript</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62190"><code>KT-62190</code></a>
KJS: &quot;IllegalStateException: Expect to have either super call or
partial linkage stub inside constructor&quot; caused by Compose and
useEsModules()</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-58685"><code>KT-58685</code></a>
KJS: &quot;IllegalStateException: Not locked&quot; cused by
&quot;unlock&quot; called twice</li>
</ul>
<h3>Klibs</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62515"><code>KT-62515</code></a>
Interop klib of concurrent version is not accepted when building
dependent project: &quot;The library versions don't match&quot;</li>
</ul>
<h3>Tools. CLI</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63139"><code>KT-63139</code></a>
Incorrect kotlin implementation version (1.9.255-SNAPSHOT) in metadata
info</li>
</ul>
<h3>Tools. Gradle</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63499"><code>KT-63499</code></a>
Gradle: Source sets conventions are still registered</li>
</ul>
<h3>Tools. Gradle. JS</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-59523"><code>KT-59523</code></a>
MPP / KJS: ESM modules uses incorrect file extension on package.json
(.mjs)</li>
</ul>
<h3>Tools. Gradle. Kapt</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md">org.jetbrains.kotlin:kotlin-stdlib's
changelog</a>.</em></p>
<blockquote>
<h2>1.9.21</h2>
<h3>Compiler</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62885"><code>KT-62885</code></a>
Introduce a language feature entry for expect actual classes for easier
configuration of MPP projects</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63081"><code>KT-63081</code></a>
Optimize new native caches:
CachedLibraries.computeVersionedCacheDirectory()</li>
</ul>
<h3>Docs &amp; Examples</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-55619"><code>KT-55619</code></a>
Document <code>String.format</code> function</li>
</ul>
<h3>IDE. Gradle Integration</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62877"><code>KT-62877</code></a>
Artifact files collecting for project configuration was finished.
Resolution for configuration configuration X will be skipped</li>
</ul>
<h3>IDE. Gradle. Script</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-60813"><code>KT-60813</code></a>
Scripts: NoSuchMethodError: 'void
org.slf4j.Logger.error(java.lang.String, java.lang.Object)' when
dependency uses Slf4j API</li>
</ul>
<h3>JavaScript</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-60785"><code>KT-60785</code></a>
KJS: Destructured value class in suspend function fails with Uncaught
TypeError: can't convert to primitive type error</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63207"><code>KT-63207</code></a>
KMP / JS: &quot;TypeError: <!-- raw HTML omitted --> is not a
function&quot; with 1.9.20</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62778"><code>KT-62778</code></a>
package.json &quot;main&quot; field has .js extension when the result
files have .mjs extension</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-61795"><code>KT-61795</code></a>
KJS: Incremental Cache is not invalidated if <code>useEsClasses</code>
compiler argument was changed</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-61957"><code>KT-61957</code></a>
KJS: &quot;Uncaught ReferenceError: entries is not defined&quot; caused
by enum class with <code>@JsExport</code> and Enum.entries call</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62444"><code>KT-62444</code></a>
KJS with commonJS modules should re-export in 1.9.20</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63184"><code>KT-63184</code></a>
KJS / Serialization: JsExport on serializable interface creates
erroneous TypeScript</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62190"><code>KT-62190</code></a>
KJS: &quot;IllegalStateException: Expect to have either super call or
partial linkage stub inside constructor&quot; caused by Compose and
useEsModules()</li>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-58685"><code>KT-58685</code></a>
KJS: &quot;IllegalStateException: Not locked&quot; cused by
&quot;unlock&quot; called twice</li>
</ul>
<h3>Klibs</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-62515"><code>KT-62515</code></a>
Interop klib of concurrent version is not accepted when building
dependent project: &quot;The library versions don't match&quot;</li>
</ul>
<h3>Tools. CLI</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63139"><code>KT-63139</code></a>
Incorrect kotlin implementation version (1.9.255-SNAPSHOT) in metadata
info</li>
</ul>
<h3>Tools. Gradle</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63499"><code>KT-63499</code></a>
Gradle: Source sets conventions are still registered</li>
</ul>
<h3>Tools. Gradle. JS</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-59523"><code>KT-59523</code></a>
MPP / KJS: ESM modules uses incorrect file extension on package.json
(.mjs)</li>
</ul>
<h3>Tools. Gradle. Kapt</h3>
<ul>
<li><a
href="https://youtrack.jetbrains.com/issue/KT-63366"><code>KT-63366</code></a>
Kapt processing fails with custom source sets</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="b2740d8957"><code>b2740d8</code></a>
Add changelog for 1.9.21</li>
<li><a
href="5d6520c9fb"><code>5d6520c</code></a>
[K/JS] Fix coroutines but turn back the fix for coroutines intrinsics
`interc...</li>
<li><a
href="8293c8f538"><code>8293c8f</code></a>
KAPT: Use reflection to access code, changed in JDK 21</li>
<li><a
href="e459a6d5d2"><code>e459a6d</code></a>
KAPT: Always print parens on empty annotation parameters</li>
<li><a
href="705c8047ae"><code>705c804</code></a>
KAPT: Run tests on JDK 21</li>
<li><a
href="120c99d455"><code>120c99d</code></a>
Fix ClassCastException in JPS statistics ad update log messages</li>
<li><a
href="68f26183f8"><code>68f2618</code></a>
Fix ClassCastException in JPS statistics ad update log messages</li>
<li><a
href="c66b789f93"><code>c66b789</code></a>
KAPT3: Use another class in com.sun.tools.javac.main</li>
<li><a
href="d4ce8c7262"><code>d4ce8c7</code></a>
Temporarily disable Kapt4IT and KaptIncrementalIT and the
descendants.</li>
<li><a
href="f559dd55ab"><code>f559dd5</code></a>
Stop using IJ's maps in graph implementation of JPS</li>
<li>Additional commits viewable in <a
href="https://github.com/JetBrains/kotlin/compare/v1.9.20...v1.9.21">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=org.jetbrains.kotlin:kotlin-stdlib&package-manager=gradle&previous-version=1.9.20&new-version=1.9.21)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-05 04:17:20 +00:00
Gabi
e3546cfa12 connlib: limit the number of host candidates used (#2746)
In some cases we were obvserving that connections between clients and
gateways couldn't be established.

This happened even when candidates where being found on both ends.

This usually was obvserved when ipv6 isn't working on the relays and
it's still used as one of the viable candidates.

To reproduce this more easily I created an iface with 50 ips using this
script:

```bash
#!/bin/bash

# Generate 10 IPv6 addresses
for i in {1..10}
do
  for j in {1..5}
  do
    # Generate a random IPv6 address
    ipv6_address=$(openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//' | awk '{print "fd00::"$1}')

    # Add IPv6 address to lo0
    sudo ifconfig lo0 inet6 alias $ipv6_address

    echo "Added IPv6 address $ipv6_address to lo0"
  done
done
```

This behavior was almost consistently obvserved, as it depended on the
order candidates were used.

I tried modifying timeouts and the limits to channel binding requests
that are internal to webrtc but the connections were still not
consistent, the only thing that worked was limiting the number of host
candidates.

This is okay since even if we can't stablish the local connection (no
hairpin nat) relayed connection will still happen.

But this is not a good long-term solution. In the future we should be
smarter how we sort and ping candidates, prioritizing srflx to srflx or
srflx to relay and leave host candidates for last. Will be easier to
improve on after refactoring webrtc out.
2023-11-30 14:33:07 +00:00
Gabi
a309f11011 Fix gateway cleanup (#2704)
Yesterday, during some portion of the day connections between clients
and resources were impossible.

While I couldn't pinpoint the exact cause I found some issues with
cleanup. This PR fixes those.

Furthermore, I increased the default log level for tunnels in the
clients so that if this happens again we have better logs to triage.

~~Furthermore, I found out about #2705 so, I removed the limit of relays
from connlib since the portal already limits it to 2 (4 if you count
per-ip), that way we make sure that we always use both ipv4 and ipv6.
The connection start up time seems to slow down due to this but I think
this is better. We might want to go to only 2 urls again later on to
speed this up, if the portal can ensure it's a working relay
load-balanced relay there might not be a point in using more than a
single server~~. cc @AndrewDryga

Edit: we always get an ipv4 and ipv6 address for the same relay as the
first two relays in the relay list, save the case where only one of the
ip types is supported. We should be safe limiting it to 2.

---------

Signed-off-by: Gabi <gabrielalejandro7@gmail.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-11-29 04:49:30 +00:00
Gabi
7528a765fb connlib: fix incorrect assumption for buffer size that was causing panics (#2663)
There was an incorrect assumption with buffer size that was causing a
panic (detected on macos client)
2023-11-17 04:13:45 +00:00
Gabi
683723ee17 connlib: fix logging string for macos (#2658)
filter for macos wasn't being applied correctly, this fixes that.
2023-11-16 06:11:42 +00:00
Gabi
bc8f438a56 feat(connlib): directly send wireguard traffic instead of tunneling it through WebRTC datachannels (#2643)
This PR started as part of a degradation in performance for the
gateways.

The way to test performance in a realistic enviroment is using a GCP vm
as a client and an AWS vm as a gateway with a single iperf server behind
the gateway.

Then the `iperf` results with current main:

```
Connecting to host 172.31.92.238, port 5201
Reverse mode, remote host 172.31.92.238 is sending
[  5] local 100.83.194.77 port 58426 connected to 172.31.92.238 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  1.01 MBytes  8.50 Mbits/sec                  
[  5]   1.00-2.00   sec  1.14 MBytes  9.59 Mbits/sec                  
[  5]   2.00-3.00   sec   699 KBytes  5.73 Mbits/sec                  
[  5]   3.00-4.00   sec  1.11 MBytes  9.31 Mbits/sec                  
[  5]   4.00-5.00   sec   664 KBytes  5.44 Mbits/sec                  
[  5]   5.00-6.00   sec   591 KBytes  4.84 Mbits/sec                  
[  5]   6.00-7.00   sec   722 KBytes  5.91 Mbits/sec                  
[  5]   7.00-8.00   sec   833 KBytes  6.83 Mbits/sec                  
[  5]   8.00-9.00   sec   738 KBytes  6.04 Mbits/sec                  
[  5]   9.00-10.00  sec   836 KBytes  6.85 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.06  sec  8.78 MBytes  7.32 Mbits/sec    3             sender
[  5]   0.00-10.00  sec  8.23 MBytes  6.90 Mbits/sec                  receiver

iperf Done.
```

Most of the performance problems were due to using SCTP and DTLS.

So I created a
[fork](https://github.com/firezone/webrtc/tree/expose-new-endpoint) of
webrtc that let us circumvent those, since we don't need them because we
are depending on wireguard for encryption.

With those changes much better throughput is achieved:

```
gabriel@cloudshell:~ (firezone-personal-instances)$ iperf3 -R -c 172.31.92.238
Connecting to host 172.31.92.238, port 5201
Reverse mode, remote host 172.31.92.238 is sending
[  5] local 100.83.194.77 port 51206 connected to 172.31.92.238 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  5.60 MBytes  47.0 Mbits/sec                  
[  5]   1.00-2.00   sec  17.2 MBytes   144 Mbits/sec                  
[  5]   2.00-3.00   sec  15.8 MBytes   132 Mbits/sec                  
[  5]   3.00-4.00   sec  14.8 MBytes   125 Mbits/sec                  
[  5]   4.00-5.00   sec  15.9 MBytes   133 Mbits/sec                  
[  5]   5.00-6.00   sec  15.8 MBytes   133 Mbits/sec                  
[  5]   6.00-7.00   sec  15.3 MBytes   128 Mbits/sec                  
[  5]   7.00-8.00   sec  15.6 MBytes   131 Mbits/sec                  
[  5]   8.00-9.00   sec  15.6 MBytes   131 Mbits/sec                  
[  5]   9.00-10.00  sec  16.0 MBytes   134 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.05  sec   151 MBytes   126 Mbits/sec   74             sender
[  5]   0.00-10.00  sec   148 MBytes   124 Mbits/sec                  receiver

iperf Done
```

However, this is still worse than it was achieved with a previous
commit(`21afdf0a9a113c996d60a63b2e8c8f32d3aeb87`):
```
gabriel@cloudshell:~ (firezone-personal-instances)$ iperf3 -R -c 172.31.92.238
Connecting to host 172.31.92.238, port 5201
Reverse mode, remote host 172.31.92.238 is sending
[  5] local 100.100.68.41 port 49762 connected to 172.31.92.238 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  6.14 MBytes  51.5 Mbits/sec                  
[  5]   1.00-2.00   sec  17.1 MBytes   144 Mbits/sec                  
[  5]   2.00-3.00   sec  22.8 MBytes   191 Mbits/sec                  
[  5]   3.00-4.00   sec  23.5 MBytes   197 Mbits/sec                  
[  5]   4.00-5.00   sec  23.0 MBytes   193 Mbits/sec                  
[  5]   5.00-6.00   sec  22.1 MBytes   185 Mbits/sec                  
[  5]   6.00-7.00   sec  23.0 MBytes   193 Mbits/sec                  
[  5]   7.00-8.00   sec  22.7 MBytes   190 Mbits/sec                  
[  5]   8.00-9.00   sec  21.0 MBytes   176 Mbits/sec                  
[  5]   9.00-10.00  sec  19.9 MBytes   167 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.05  sec   204 MBytes   170 Mbits/sec  127             sender
[  5]   0.00-10.00  sec   201 MBytes   169 Mbits/sec                  receiver
```

My profiling suggested that this is due to reading/writing packets
happening in its own dedicated tasks. So much so that maybe in the
future we should even consider spawning their own dedicated runtime so
that those loops have a dedicated OS thread.

Also, probably using a multi-queue interface will give us huge gains if
we have a dedicated task for each queue(currently the interface is
started as a multi-queue but a single file descriptor is used) for
handling multiple concurrent clients.

However, the changes proposed in this PR are good enough for now as long
as performance don't degrade.

In that line I will create a CI that reports the throughput using the
local `docker-compose.yml` file that we should always check before
merging, that is not the be all end all of the performance story but for
smaller PRs the correlation to real world throughput should be enough.

For bigger PRs we should manually test before merging for now, until we
have a way in CI to spin up some realistic tests(note that vms should be
in separate cloud enviroments, the same-cloud links are so reliable that
we miss actual performance degradation due to dropped packets). On this
note I'll write a small manual on how to conduct those tests with full
current results that we should use always before merging new PRs that
affect the hot-path. cc @thomaseizinger

Finally, when testing these changes I found some flakiness regarding the
re-connection path. So I changed things so that we cleanup connections
only using wireguard's error(connection expiration). This is quite slow
for now (~120 seconds) but in the future we can issue an ice restart
each time wireguard keepalive expires(rekey timeout) so that we can
restart connection each ~30 seconds and we can reduce the keepalive time
out from the portal to accelerate it even more. And in the future we can
get smarter about it.

---------

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2023-11-16 02:59:48 +00:00
Andrew Dryga
33ab23b636 Cleanup UX and fix a bunch of TODOs (#2641)
This PR cleans up a lot of TODO and some issues I've discovered while
fixing them, there are _a few_ UI changes.

We show `(you)` next to your name on the actor view page, where
`Profile` link goes from the dropdown menu:
<img width="1728" alt="Screenshot 2023-11-13 at 19 05 35"
src="https://github.com/firezone/firezone/assets/1877644/f52b2531-e3be-4d3a-a587-4f9f54ca2c49">

Relays were way behind Gateways in terms of view code, so I changed them
to be exactly the same:
<img width="1728" alt="Screenshot 2023-11-13 at 18 54 39"
src="https://github.com/firezone/firezone/assets/1877644/a9f0905d-80d2-4e91-a744-c4baf7ad4a7c">

We also show authorizations on the Actor page because previously to find
"what this user did" you had to go through all user clients
individually:
<img width="1728" alt="Screenshot 2023-11-13 at 18 54 27"
src="https://github.com/firezone/firezone/assets/1877644/02ada445-e175-427e-99de-f9fa5bdd5aab">

I've noticed there is some confusion around sign-in slugs so I added a
home page where you can use ID or slug to get the in link (not all the
clients will know you need to put that in the URL) and recently used
accounts:
<img width="1728" alt="Screenshot 2023-11-13 at 18 54 06"
src="https://github.com/firezone/firezone/assets/1877644/ccfb9198-ed1f-4b3e-a26f-b76bab24243c">

Buttons to copy the code are more visible now, I've used our accent
color but am open to better ideas:
<img width="1728" alt="Screenshot 2023-11-13 at 19 10 29"
src="https://github.com/firezone/firezone/assets/1877644/a2c0658e-1003-409b-b5ad-d5d3ade60a10">

When code is copied it's also more visible:
<img width="699" alt="Screenshot 2023-11-13 at 19 11 41"
src="https://github.com/firezone/firezone/assets/1877644/62e793d2-d760-4aa7-9a42-92a6bbfcbf52">

We also do not redirect from that page automatically, but the large
button becomes green with the text changed:
<img width="660" alt="Screenshot 2023-11-13 at 19 12 11"
src="https://github.com/firezone/firezone/assets/1877644/780dcde3-8018-4405-91e5-984288431ec1">
2023-11-14 13:02:21 -06:00
Thomas Eizinger
16b41bf14c refactor(connlib): encapsulate Device (#2591)
We encapsulate the internals of `Device` by providing high-level
functions on `Device` itself and make all the fields private. From the
outside, each consumer this only has an `Arc<Device>` that they can
interact with.

To achieve this, we use the `arc-swap` crate to atomically swap out the
reference to the `Arc<Device>` instead of relying on an `RwLock`. Note
that the _reference_ to this `ArcSwapOption` is also wrapped in an `Arc`
because we need to share this pointer across many `peer_handler`s.

Once we get rid of `Arc<Tunnel>`, this will become a lot simpler.
2023-11-08 06:52:21 +00:00
dependabot[bot]
6899b70da2 build(deps): Bump tokio-util from 0.7.9 to 0.7.10 in /rust (#2595)
Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.7.9 to
0.7.10.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/tokio-rs/tokio/commits">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tokio-util&package-manager=cargo&previous-version=0.7.9&new-version=0.7.10)](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>
2023-11-07 00:15:46 +00:00
Gabi
953ddeace6 connlib: update upstream dns format configuration (#2543)
fixes #2297
2023-11-03 05:16:03 +00:00