Commit Graph

204 Commits

Author SHA1 Message Date
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
Alexis Sellier 5494490c40
crypto: implement an OpenSSH keystore
This will become the primary keystore.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-02 14:11:07 +01:00
Alexis Sellier f5212405c5
ssh: simplify `radicle-ssh` crate implementation
Remove the internal buffer and simplify code around that.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-01 22:12:19 +01:00
Alexis Sellier 16b22d9178
Move `radicle/id` and `radicle/signature`
We move the identity branch out of `heads/` and to the old location:

  refs/rad/id

We move the signed refs branch to:

  refs/rad/sigrefs

Keeping both "special" branches under the same hierarchy makes things a
bit easier to work with, and tells the user that they should be updated
with special tooling.

We also revert to `rad/` because we no longer have the issue of having
`rad/rad/id` when doing a checkout of the remote branch in a working
copy.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-01 15:56:06 +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
Slack Coder c11f5b13bf rad-auth: create profile when not found
Be careful about when to attempt creating a profile.  Errors could
trigger creating a profile even when unrelated to it not existing.

Profile::load(..) is altered to distinguish between these cases.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-28 09:38:12 -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 3407c6c017
Add `ToString` support for transport URLs
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-24 21:57:53 +02:00
Alexis Sellier 66493422c2
Add 'local' and 'remote' URL formats
To distinguish between working-copy-to-storage (local) and
storage-to-storage (remote) replication, we create two new
URL types: a `remote::Url` (`heartwood://`) and a `local::Url`
(`rad://`).

These schemes are to be used for the remote and local transports,
respectively.

The difference between the two schemes is that remote replication
requires a node id.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-24 20:19:45 +02:00
Slack Coder 7c65f08cd1
radicle: fix typo
Correct radicle::node::Error::Connect's string.
2022-10-21 22:13:40 +02:00
Alexis Sellier 5f4fc8236e
A couple of docs and naming improvements
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-20 18:06:31 +02:00
Alexis Sellier 8b834a7b6e
Protect ourselves against naked refs
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-20 12:59:55 +02:00
Alexis Sellier 1906124497
Re-use `HEAD` reference if it exists
Since the `HEAD` reference is trusted (we set it locally), use that
when possible, instead of re-computing it.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-20 12:44:51 +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
Alexis Sellier 961c18319f
Test canonical refs are set
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 15:35:35 +02:00
Alexis Sellier e6fd85f249
Implement `public_references` helper function
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 15:20:44 +02:00
Alexis Sellier 111480cd6e
Make use of `git2::Repository::refname_to_id`
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 14:47:12 +02:00
Alexis Sellier 94f7675c72
Move `sign_refs` to `WriteRepository` trait
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 14:41:12 +02:00
Alexis Sellier 657a951df0
Create `url` module shared between crates
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 14:30:01 +02:00
Alexis Sellier 617e0c1877
Remove redundant `Options` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 11:47:29 +02:00
Alexis Sellier 2f6cf9c7a5
httpd: implement `git` fetch-only server
Introduces a new `radicle-httpd` crate which will serve as the basis
for heartwood's HTTP backend.

The first part of this is a git server which allows projects to be
fetched from storage using plain `git`.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 11:36:16 +02:00
Alexis Sellier 3bff9a9dc1
Set repository canonical refs
We set the `HEAD` and eg. `refs/heads/master` refs when updating
repositories, which allows users to easily clone with git.

For now, `HEAD` is chosen based on a unanimity quorum of delegates.
This can be made more sophisticated in the future.

We've also had to ignore some refs during verification, since these
have cropped in for eg. due to the staging copy clone and the
changes included here.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 10:27: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 240825387d
Implement correct `did:key` format
We weren't including the *multicodec* bytes previously.
This is now tested against some test vectors from the spec.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-17 16:37:06 +02:00
Alexis Sellier a2fc976ed6
remote-helper: Initialize
Implement a `git-remote-rad` helper for `rad://` remotes.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-17 16:23:16 +02: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 ba95725028
Add placeholder README 2022-10-14 13:19:28 +02:00
Fintan Halpenny a56d9008e6
radicle: depend on radicle-git published crates
The `git-ref-format`[0] and `radicle-git-ext`[1] crates are now
published to crates.io.

Switch the dependency to rely on them. This also required to update
the `git2` dependency to `0.15.0` as well as using the
`vendored-libgit2` feature -- avoiding the openssl dependency too.

[0]: https://crates.io/crates/git-ref-format
[1]: https://crates.io/crates/radicle-git-ext

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-14 13:16:11 +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