Commit Graph

58 Commits

Author SHA1 Message Date
Alexis Sellier 45c7f3049b
Update to Rust 1.65
* Use new let-else syntax
* Fix new clippy lints

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-05 12:47:26 +01:00
Alexis Sellier dc79130988
Zeroize passphrases
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 16:52:29 +01:00
Slack Coder c7706156c6
node: fix test dependency error
Enable Radicle Crypto's test feature.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-11-03 16:02:50 +01:00
Alexis Sellier 092ccfdcbc
Add `profile::env` module
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 13:06:08 +01:00
Alexis Sellier 577b632056
Use `Signer::try_sign` in interactive contexts
In interactive (user) contexts, use `try_sign` instead of `sign`.

We also revisit the `Profile` by adding a `signer` method that can
fail, eg. if we couldn't connect to ssh-agent.

Finally, we replace `UnsafeSigner` with `MemorySigner`, which makes
use of `ssh::Keystore`.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 13:06:00 +01:00
Alexis Sellier a79ef67b2a
Add `Signer::try_sign` method and cleanup usage
To support ssh-agent, add a signing method that can fail.
Also cleanup usage so that we always accept signer references.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 10:12:22 +01:00
Slack Coder 25c982cd8c
node: use method to access session's Node ID
Make accessing an important session value, the Node ID, as a method to
Session.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-31 18:17:27 +01:00
Alexis Sellier 6f3a598cc1
Remove `git-url` dependency
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-31 18:14:54 +01:00
Alexis Sellier 7b7e83fbc7
node: implement node announcement sybil resistance
We implement a small proof-of-work on the node announcement message
to prevent the routing table from being filled by fake entries.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-31 18:13:14 +01:00
Slack Coder 3c900f106f radicle-node: distinguish announcment nodes
Its easy to confuse what/who 'node' or 'session' is.

Rename session to 'relayer' to convey its role as message propagator.
Rename the announcement's node to 'announcer', clarifying its as the
source.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-31 11:40:50 -05:00
Slack Coder a8895aee80 node: follow up on session renaming
Rename the module to session from peer to be consistent with recent
renaming of the type from Peer to Session.  Remove stutter by renaming
session::SessionState to session::State, and session::SessionError to
session::Error.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-28 09:57:56 -05:00
Fintan Halpenny c0b0d29e19
radicle-crypto: split out from radicle
The crypto types are useful to use in other components that are
separate from the radicle crate, e.g. the incoming radicle-cobs
crate.

Separate out the types into a radicle-crypto crate. This crate defines
the usual PublicKey, SecretKey, and Signature types. It also provides
the ssh functionality, under the `ssh` feature. It is also necessary
to provide the `From` impl for `Component` here, which again is
guarded by the `git-ref-format` feature.

The `Arbitrary` implementation are moved. The arbitrary decision of
redefining `ByteArray` in both radicle-crypto and radicle was made.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-10-27 20:40:39 +01:00
Alexis Sellier 2a1154ef87
Re-work git transports
The changes in this commit are all intertwined and it was hard to
split them into smaller commits:

* Use custom transports everywhere

Instead of `file://` and instead of using a child process for fetching
and pushing; we go through our custom transports, which use the `rad://`
and `heartwood://` schemes.

* Introduce a 'mock' remote transport

To test the remote transport without needing to spawn TCP streams,
we add a mock transport that works between storages on the file
system.

* Get rid of node's `git-url`

Instead of git urls, nodes simply use their node-ids to replicate.
2022-10-26 21:40:19 +02:00
Alexis Sellier 2ec320acec
Use 'primary key' constraint instead of index
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 22:39:31 +02:00
Alexis Sellier 706fbc6550
Get the node running
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 22:39:24 +02:00
Slack Coder 10d8519101
node: improve ping/pong tests
Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-18 17:23:31 +02:00
Alexis Sellier 09c438f8fb
Remove `Envelope` type
This type that was wrapping `Message` isn't very useful here.
If we decide that we do need something like that, it's best handled one
layer below.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 16:45:10 +02:00
Alexis Sellier 156a3a576a
Enforce max size for `Message` type on wire
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 15:44:06 +02:00
Alexis Sellier f5e881b5a9
Move message size constant to `Message` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:06:45 +02:00
Alexis Sellier c306392d13
Improve wire module
* Set `Size` correctly to `u16`
* Remove `usize` support, since it's OS-dependent

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:04:12 +02:00
Alexis Sellier 874386540a
Document service constants
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:04:12 +02:00
Alexis Sellier ae95b229f5
Activate lint for dead-code checking
For test code, we need it in a couple of places.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:03:34 +02:00
Alexis Sellier 1df5cf0c45
Remove redundant docs from trait impl
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:00:55 +02:00
Alexis Sellier 2499317589
Implement `Handle::listening`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 13:00:50 +02:00
Alexis Sellier d3523ccf78
Remove unused type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 12:37:01 +02:00
Alexis Sellier fbd4fd9fea
Use session RNG for ping
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-18 12:33:12 +02:00
Alexis Sellier 86ed10fca9
Move timestamp columns to the right table
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-17 20:39:30 +02:00
Slack Coder 14690d1951 Service: drop unresponsive peers
Use pings to check connection health with network peers and drop them if
they prove unresponsive.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-17 10:22:43 -05:00
Alexis Sellier 7936ba8773
node: use consistent terminology for tests
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 18:55:30 +02:00
Alexis Sellier d9517cc966
node: add more tests for refs relay
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 18:51:53 +02:00
Alexis Sellier 7c45971998
node: handle announcement relay correctly
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 13:09:06 +02:00
Alexis Sellier 45ea9cc97d
node: refactor announcement timestamp handling
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 12:14:26 +02:00
Alexis Sellier 4c1aa65f90
node: correct handling of announcement timestamps
Since we now have three announcement message types, we need at least
three timestamps per peer. But even that is not enough, since we don't
want to conflate ref announcements for different projects with each
other.

The solution is to also keep a map of timestamps per peer, for each
tracked project. That way we are able to know when a ref announcement is
interesting to us or not.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-14 11:59:54 +02:00
Alexis Sellier 07add86bb6
node: Handle node announcements
To build an address book, peers communicate via gossip, sending
`NodeAnnouncement` messages.

These need to be handled by storing the addresses in an address book
and the addresses need to be persisted to disk.

Node announcement messages should also be relayed to peers like other
gossip messages.
2022-10-14 11:58:17 +02:00
Alexis Sellier a06ed9f6de
Statically link sqlite3 2022-10-12 13:27:45 +02:00
Alexis Sellier fde0af09f7
Handle errors correctly in storage
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-11 09:31:48 +02:00
Alexis Sellier d652df7c30
node: Handle error in handshake call
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-10 14:47:50 +02:00
Alexis Sellier 832c6ad53f
Improve error handling in a few places
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-10 11:29:22 +02:00
Alexis Sellier 78545c2f0f
Implement routing table pruning functions
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-08 13:45:15 +02:00
Alexis Sellier b8c2ab5316
Switch to a lighter sqlite dependency
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-08 12:13:59 +02:00
Alexis Sellier e909e04c6c
Implement proper `node::Features` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-07 22:49:58 +02:00
Alexis Sellier 2d52a53ce5
Add variable bloom filter sizes
This should help small nodes waste less bandwidth, while standardizing
on set sizes.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-05 15:58:34 +02:00
Alexis Sellier 85ac8a1d4d
Implement routing table persistence
Uses SQLite for persistence.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-05 12:13:12 +02:00
Alexis Sellier 15f525299e
Add commnads to query internal service state
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-04 21:07:57 +02:00
Alexis Sellier af06ad6451
Use message timestamp for filtering
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-09-29 10:48:41 +02:00
Alexis Sellier e35ec2f715
Rebroadcast logic for stored gossip messages
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-09-29 10:02:52 +02:00
Slack Coder f9ad3ac155 git: Use RefString types for git::refs
Lean on rust's type system to improve safety.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-09-28 16:11:03 -05:00
Alexis Sellier 27e39c0df5
Make `Id` a `Copy` 2022-09-27 14:13:20 +02:00
Alexis Sellier ca2f766d19
Add `Profile::connect`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-09-26 14:27:56 +02:00
Alexis Sellier 8605946703
node: Add CLI options 2022-09-26 11:25:20 +02:00