Commit Graph

711 Commits

Author SHA1 Message Date
Fintan Halpenny 0302701c98
node: limit number of loops in `routes_to`
The `routes_to` function can loop infinitely during test.

To prevent this from happening a number of tries variable is added. It
checks that the number of tries does not exceed 30, which gives the
function about 3 seconds to complete -- due to the call to
`thread::sleep` using 100ms.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:29:34 +00:00
Fintan Halpenny d476d35887
radicle: populate MockRepository
The MockStorage holds an inventory of repositories and their
identities but when asking for a MockRepository, none of this
information is transferred.

Add `id` and `doc` fields to MockRepository for defining some of its
functionality.

In addition, add a generator for a nonempty MockStorage to use in
tests that will expect the storage to be populated.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:29:33 +00:00
Fintan Halpenny 8c02a8116e
radicle: add delegates to ReadRepository
Getting delegates for a repository is a common task. A method is added
to ReadRepository for this, which default to fetching the identity
document, verifying it, and return the delegates for that identity.
2023-03-08 11:29:33 +00:00
Vincenzo Palazzo 0e491fae79
cli: fix command line silent abort
Fix the command line silents abort when the
the `EDITOR` variable is not specified.

With this commit the result is reported below

```
➜  rio git:(main) RAD_PASSPHRASE=12345 rad issue open
✗ Issue failed: editor not configured: the `EDITOR` environment variable is not set
```

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-03-08 12:25:11 +01:00
Fintan Halpenny e408b0d62c
node: use enum for fetch direction
A fetch is a client-server interaction and so there are two sides to
this interaction. These sides are generally referred to as receive --
the client side -- and upload -- the server side.

The `Fetch` type indicated whether it was doing a receive or upload by
using a field `initiated: bool`. However, this can be confusing when
you pair it with the `namespaces: Namespaces` field, since only the
receive side should be sending what refspecs it wants and the upload
side responds with those matching refspecs.

A better way to represent this is using an enum for which direction
the fetch is being considered, where the receive side contains the
Namespaces. To borrow from Noise, the variant names are 'Initiator'
for the client and 'Responder' for the server.

The resulting code then makes decisions based on what variant of the
enum was passed.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 10:12:54 +00:00
Alexis Sellier c3a5aced07
node: Handle case of crossing fetch requests
It is possible for a pair of nodes to concurrently ask each other
to fetch some repo. These "crossing" requests are problematic,
because the nodes end up waiting for each other to reply, and
the reply never comes.

With this change, the node pair agrees on proceeding with one of
the fetches, while canceling the other.
2023-03-07 16:22:22 +01:00
Alexis Sellier fb635d80c3
node: Gossip once we switch to gossip protocol
Previous to this change, we were attempting to gossip after a successful
fetch, but before the session was switched back to the gossip protocol.
This meant that messages were queued for a short amount of time. With
this change, messages should be sent straight away.
2023-03-07 15:44:10 +01:00
Fintan Halpenny ad63583bee
cli: rad node example
Tests the rad node CLI subcommand.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-07 15:38:41 +01:00
Fintan Halpenny ed985f6fe0
cli: rad node
This adds a rad node subcommand to the CLI.

The subcommand aims to fulfill the following requirements:

- Checking the node status (rad node status)
- Connecting to the node's control socket (rad node connect)
- Printing out our routing table (rad node routing)
- Printing out our tracking policies (rad node tracking)

The following are yet to be implemented:

- Starting the node (rad node start)
- Stopping the node (rad node stop)

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-07 15:38:41 +01:00
Fintan Halpenny f322305f86
node: wire up connect command
The connect command was unimplemented for both Node and the control
socket.

This wires up the connect functionality in both places.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-07 15:38:41 +01:00
Fintan Halpenny 1f837c6572
node: implement tracking and routing
The routing function for Node was not implemented and there were no
functions for getting any tracking information.

This implements routing, tracked_repos, and tracked_nodes. To
accomplish this it was necessary to add associated types to the
Handler trait so that implementations could differ in the types they
use for returning this data, i.e. the control socket needs to use a
channel while the Node needs to return serializable data.

Currently, the Node uses a `Vec` but it would be more beneficial to
return an Iterator directly to ensure we are not always hitting the
heap.

To allow for the tracking types to be used across radicle-node (the
crate) and in radicle::node (the module), it was necessary to move
the types to the common place, i.e. radicle::node. At the same time,
new structs were added to make it easier to refer to tracked repos vs
tracked nodes.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-07 15:38:41 +01:00
xphoniex 900796956c
httpd: Remove `radicle_cli` from tests
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-03-07 15:08:11 +01:00
xphoniex 267b0ed312
httpd: Use `radicle-term` instead of `radicle-cli::terminal`
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-03-07 14:49:18 +01:00
Alexis Sellier 94899f7be2
node: Update `localtime` crate 2023-03-07 10:47:12 +01:00
Alexis Sellier 5fb5df2e61
cli: Update `inquire` crate 2023-03-07 10:39:45 +01:00
xphoniex 488468991c
httpd: Set a max allowed size of 4 MiB when serving files raw
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-03-07 09:37:02 +01:00
Alexis Sellier 85df613682
cli: Implement automatic issue announcement 2023-03-07 08:40:20 +01:00
Alexis Sellier cb3b7a3765
cli: Implement `patch delete` 2023-03-06 15:45:54 +01:00
Alexis Sellier e972cda2c4
remote-helper: Tell the user we're announcing refs 2023-03-06 15:39:35 +01:00
Alexis Sellier 9000a626d7
Use commit oid for COB parent
We were using the blob oid, which was causing the commit tree to
be invalid.
2023-03-06 15:39:34 +01:00
Alexis Sellier fb2c388a5d
cli: Properly trim `patch` message 2023-03-06 15:39:07 +01:00
Alexis Sellier a5ee494fda
node: Correctly handle disconnect in wire protocol 2023-03-06 15:39:07 +01:00
Alexis Sellier 54dc34d4b9
node: Minor logging improvements 2023-03-06 15:39:07 +01:00
Alexis Sellier 35f22ba37a
cli: Update `init` help for consistency 2023-03-06 15:38:42 +01:00
Alexis Sellier be5c9c9258
cli: Add `--verbose` flag to `init` 2023-03-06 15:38:42 +01:00
Alexis Sellier c8c44c884c
cli: Allow `init` without running node 2023-03-06 15:38:42 +01:00
Alexis Sellier e69be6051d
cli: Give more control over `init` announcement
Instead of always announcing the inventory, by default we don't.
Users can run `rad push` to trigger an announcement.
2023-03-06 15:38:42 +01:00
Alexis Sellier 8c22012d61
Remove need to pass public key in cob store 2023-03-06 10:56:20 +01:00
Alexis Sellier 44f3984159
Sign COB refs after modification 2023-03-06 10:42:26 +01:00
Sebastian Martinez 05d2487a47
httpd: Add patch creation endpoint
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-06 10:26:38 +01:00
Alexis Sellier 793c085094
node: Don't force use of RAD_PASSPHRASE
If it isn't set, prompt the user.
2023-03-06 10:22:53 +01:00
Alexis Sellier 02304875ce
Initialize `radicle-term` crate
We split out all non-radicle terminal functionality so that it can be
accessed by `radicle-node` without importing `radicle-cli`.
2023-03-06 10:22:50 +01:00
Alexis Sellier 82d858314f cli: Fix `rad rm` prompt 2023-03-04 22:28:45 +01:00
xphoniex 077c040c08
httpd: Change format of tracing messages
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-03-03 16:13:10 +01:00
Slack Coder dd7e3923b5 cli: expose `rad fetch`
Make `rad fetch` accessible via the command line.  It appears to be
accidently left out.
2023-03-03 09:59:45 -05:00
Alexis Sellier 9d244b221a
Fix clippy warning in release mode 2023-03-02 17:00:31 +01:00
Alexis Sellier de71c5d9b1
cli: Implement `--fetch` on `rad patch` 2023-03-02 17:00:31 +01:00
Alexis Sellier 43bd5fca00
cli: Implement `rad fetch` command 2023-03-02 17:00:27 +01:00
Alexis Sellier 5f59493c70
cob: Don't require a local fork to exist
Before this change, the identity document would be loaded for the
COB signer. This meant that a fork would be needed for that signer.

After this change, it's no longer necessary, since the identity doc
head is computed from available remotes.

While making those changes, it was also apparent that some of the
identity-related functions had bad names and error types, this
was fixed as well.
2023-03-01 15:40:30 +01:00
Alexis Sellier 2a687502c5
cli: Improve `rad inspect`
* Don't always require auth
* Fix `--refs` sub-command
2023-03-01 13:03:42 +01:00
Alexis Sellier 892f02bc43
cli: Improve `rad-auth` first authentication 2023-03-01 13:03:42 +01:00
Alexis Sellier e4b44370d3
cli: Register key on first `auth`
Registers the secret key with ssh-agent when `rad auth` is first called.
2023-03-01 13:03:42 +01:00
Alexis Sellier 411c54a604
node: Use loopback address as git-daemon default
Prevents external connections to it.
2023-03-01 13:03:42 +01:00
Sebastian Martinez 796ae2f96a
httpd: Sort issues and patches by creation date
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-01 13:02:09 +01:00
Sebastian Martinez 432e6aafbb
Add `timestamp` method to `Issues`
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-01 13:01:44 +01:00
Adam Szkoda 7cb7d3a4a2
Track peers by default on the seed server 2023-03-01 13:00:34 +01:00
Alexis Sellier 1bb6f9a921
httpd: Don't load project payload twice 2023-02-28 18:37:26 +01:00
xphoniex de24a04621
httpd: Use `repo.identity_doc()` instead of `repo.identity_of(..)`
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-02-28 18:08:26 +01:00
Alexis Sellier 68aca5dd65
cli: Don't fork if we already have a fork 2023-02-27 18:27:52 +01:00
Alexis Sellier 207030d2e1
cli: Don't fail clone if we have repo locally 2023-02-27 18:19:02 +01:00