Commit Graph

19 Commits

Author SHA1 Message Date
Thomas Eizinger
b2fe02c2d5 fix(relay): treat stamp_secret as string (#1660)
Previously, the relay would treat the `stamp_secret` internally as bytes and share it with the outside world as hex-string. The portal however treats it as an opaque string and uses the UTF-8 bytes to create username and password.

This patch aligns the relay's functionality with the portal and stores the `stamp_secret` internally as a string.
2023-06-16 09:25:15 +02:00
Thomas Eizinger
a491521ef7 feat(relay): add Dockerfile (#1661)
This adds a basic Dockerfile for the relay so users and devs can easily
start it.
2023-06-15 19:59:53 +02:00
Thomas Eizinger
6491ad13c9 feat(relay): provide a commandline interface using clap (#1658)
This saves us several lines of code and allows usage of the relay via
commandline arguments in addition to env variables. Note that because of
`#[arg(env)]`, all of these can still be configured via environment
variables too.
2023-06-15 18:17:02 +02:00
Thomas Eizinger
5090d207c2 feat(relay): implement nonces for authentication (#1654)
To complete the authentication scheme for the relay, we need to prompt
the client with a nonce when they send an unauthenticated request. The
semantic meaning of a nonce is opaque to the client. As a starting
point, we implement a count-based scheme. Each nonce is valid for 10
requests. After that, a request will be rejected with a 401 and the
client has to authenticate with a new nonce.

This scheme provides a basic form of replay-protection.
2023-06-15 09:11:08 -07:00
Thomas Eizinger
ec453a2d9c feat(rust): bump to new stable release 1.70.0 (#1648) 2023-06-09 14:32:52 -07:00
Thomas Eizinger
16156a6448 relay: implement authentication (#1641) 2023-06-07 06:17:20 -07:00
Thomas Eizinger
d27856a8f1 refactor(relay): introduce type-safe Server APIs (#1630)
We introduce dedicated types for each message that the `Server` can
handle. This allows us to make the functions public because the
type-system now guarantees that those are either parsed from bytes or
constructed with the correct data.

The latter will be useful to write tests against a richer API.
2023-05-31 15:18:20 +01:00
Thomas Eizinger
f5fdd56812 relay: create channel bindings and relay data (#1618)
Here is a short demo:


[Relay](https://github.com/firezone/firezone/assets/5486389/c0199294-70ca-47b4-90ae-2c96428bdb56)

You can run this locally using the `./run_smoke_test.sh` shell-script.
It is not reliable enough yet to be used in CI but I used one if its
outputs to make a regression test.

---------

Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-05-22 17:25:16 -07:00
Jamil
0647eeebca 1.0 views (part 1) (#1599)
# Todo
- [x] Users
- [x] Groups
- [x] Devices
- [x] Gateways
2023-05-22 17:09:41 -07:00
Thomas Eizinger
9c120fb35a fix(relay): use correct variable (#1617)
We had a semantic conflict here that resulted in a broken build. This PR
fixes that.

Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-05-17 09:36:32 -07:00
Thomas Eizinger
52df0cbfb4 relay: remember allocations by port (#1613)
Instead of remembering the used ports separately, we store a reference
to each allocation by port.
2023-05-16 09:05:51 +02:00
Thomas Eizinger
5e74143ede relay: don't repeat magic numbers througout the code (#1612)
A small refactoring to keep magic numbers only in one place.
2023-05-16 09:05:13 +02:00
Thomas Eizinger
675cb2dd54 relay: refresh allocations (#1610) 2023-05-16 07:21:02 +10:00
Thomas Eizinger
01f33ed4a0 relay: add basic README (#1611) 2023-05-16 05:39:28 +10:00
Thomas Eizinger
c0774523a8 relay: Parse and respond to allocation requests (#1604)
With this patch, the relay can parse and respond to allocation requests. I
ran some basics tests against https://icetest.info/ and implemented a
regression test as a result of the logged data.

In writing this, I also had to slightly change the design of `Server`
(as expected). Event handlers for incoming data now do not return a
message directly. Instead, the caller is responsible to drain `Command`s
from it.

When creating an allocation, we need to start listening on a new port.
This needs to happen outside the `Server` as I am going for a sans-IO
style. We emit a `Command` that instructs the main event loop to listen
on a new port. Any incoming data on that port will be forwarded to the
`Server`.

At the moment, this incoming data is just dropped. This is actually
standards-compliant because we cannot handle binding requests yet which
would allow this data to be forwarded to the client.

In some areas, the code is still a bit rough but I expect to iron those
things out as we go along.
2023-05-16 04:58:33 +10:00
Thomas Eizinger
70e6982e45 Implement basic STUN server (#1603)
This is an alternative to https://github.com/firezone/firezone/pull/1602
that implements the server using a library I've found called
`stun_codec`.

It already has support for parsing a variety of attributes.

The following is a nice website to test some of the functionality:
https://icetest.info/

The server is still listening on:
`ec2-3-89-112-240.compute-1.amazonaws.com:3478`.
2023-05-10 07:58:32 -07:00
Thomas Eizinger
718e4da41a Move rust-toolchain to workspace root 2023-05-08 19:06:34 -03:00
Thomas Eizinger
8db82445ba Move gitignore and lockfile to workspace root 2023-05-08 19:06:34 -03:00
Thomas Eizinger
f9b6e96b5e Move everything to a workspace 2023-05-08 19:06:34 -03:00