Commit Graph

212 Commits

Author SHA1 Message Date
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
Alexis Sellier 94899f7be2
node: Update `localtime` crate 2023-03-07 10:47:12 +01:00
Alexis Sellier 85df613682
cli: Implement automatic issue announcement 2023-03-07 08:40:20 +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 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 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 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 411c54a604
node: Use loopback address as git-daemon default
Prevents external connections to it.
2023-03-01 13:03:42 +01:00
Alexis Sellier 207030d2e1
cli: Don't fail clone if we have repo locally 2023-02-27 18:19:02 +01:00
Fintan Halpenny c70dc71b18
node: improve seeds information
Previously, the seeds information would only consist of the connected
NodeIds.

Improve on this by adding any disconnected and fetching seeds as
well. A seed can either be disconnected, connected, or fetching --
where fetching implies connected.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-27 17:48:11 +01:00
Fintan Halpenny c0b92d25fb
radicle: remove FetchResult associated type
The Handle trait defines a FetchResult associated type. This type is
always instantiated to be the FetchResult enum in radicle::node.

Remove the associated type to simplify the trait.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-27 17:17:00 +01:00
Alexis Sellier 11da344e3a
node: Add `--tracking-policy` flag
Sets the default tracking policy.
2023-02-27 13:46:40 +01:00
Dr Maxim Orlovsky 158f1ff7fa Update to fixed `io-reactor` timer 2023-02-22 16:21:25 +01:00
Alexis Sellier 7e1b2b6222
crypto: Cleanup `hash` module
Remove `Digest` type and use `ssh-key` for formatting public ssh key.
2023-02-17 10:51:27 +01:00
Fintan Halpenny 8e26e4c046
radicle: canonicalize home path
If a path was passed to `Home` in non-canonical form it would not use
the right path for any initialisation or use.

The aim is to use the `canonicalize` function for paths. However, this
may return an error if none of the paths exist. To ensure that the
path exists the `new` constructor for `Home` creates the directory and
canonicalizes the path.

Since `new` now initialises the home directory, it would be useful if
it also initialised all the necessary subdirectories -- which removes
the need for the `init` method.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-16 16:35:59 +01:00
Alexis Sellier a7d2fa95cd
node: Remove redundant handshake
With `NoiseXK` handshake implemented, there is no longer a need to
have an `Initialize` message and an extra state in the session.
2023-02-16 15:10:31 +01:00
Alexis Sellier 71561a8e12
node: Move state transition code to session 2023-02-16 15:09:53 +01:00
Alexis Sellier 011923f1df
node: Buffer gossips until fetch is completed
This change ensures that gossip messages are buffered if we try to
send them during a fetch, and sent after the fetch completes.
2023-02-16 15:09:53 +01:00
Alexis Sellier 0f81f8a7aa
node: Take session reference when writing messages
This ensures that we have an existing session when sending messages.
It also will allow us to check the session's state.
2023-02-16 15:09:53 +01:00
Alexis Sellier 950fae209d
Make `ReadStorage` more usable
Previously, we were not able to access a `ReadRepository` instance
through `ReadStorage`. With this change, we are able to.
2023-02-15 22:08:20 +01:00
Alexis Sellier 89fcc6de1c
node: Subscribe on track-repo
We re-subscribe after our tracking policy has been changed so that
peers are informed of our interests.
2023-02-15 22:07:51 +01:00
Alexis Sellier 8cbc3c2403
node: Move to NoiseXK
Move from NoiseNN with a custom authentication protocol, to NoiseXK.
Uses ECDH on the ed25519 curve via the `ec25519` library.
2023-02-15 22:05:04 +01:00
Slack Coder 76d23a3fa9
node: Add more command argument documentation
Document `--git-daemon` and describe the default values.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2023-02-15 15:17:07 +01:00
Alexis Sellier b29ce1a222
node: Fix bug when socket file is deleted
If the socket file is deleted while the node is running, we can no
longer quit with Ctrl-C. This is the "fix".
2023-02-15 10:41:09 +01:00
Alexis Sellier ee513ccf7e
node: Complete the "relay" seed test
These are the final changes to get the "relay" scenario passing.
There are still some issues left, though it's done as far as the
test is concerned.
2023-02-14 20:31:40 +01:00
Alexis Sellier 7919c7ea61
node: Use millisecond precision for timestamps
Previously we used seconds, which could result in false positives
when checking for stale announcements, if things happened too quickly.
2023-02-14 20:31:40 +01:00
Alexis Sellier 72c99b7939
node: Handle `SIGINT` and `SIGTERM` properly
This ensures that the socket file is cleaned up on exit.
2023-02-14 13:28:16 +01:00
Alexis Sellier 3ae826dee2
node: Add clone test with seed acting as relay 2023-02-13 10:30:04 +01:00
Alexis Sellier 3e7761740f
node: Rely on inventory announcement in `rad init` 2023-02-13 09:59:44 +01:00
Alexis Sellier c673f5db68
node: Add some useful test utility functions 2023-02-12 21:03:28 +01:00
Alexis Sellier 7087288cfb
node: Implement inventory sync command 2023-02-12 20:57:33 +01:00
Alexis Sellier 2f1a18470e
node: Fix filter construction and policy code 2023-02-12 17:07:57 +01:00
Alexis Sellier 5f4c6edee4
node: Simulator logging improvements 2023-02-12 16:48:46 +01:00
Alexis Sellier 42b4d95f93
node: Improve output of `Session::fetch` function 2023-02-12 16:22:51 +01:00
Alexis Sellier bd7c5a0daa
node: Add ability to have default tracking policy
When a specific tracking policy isn't found, we allow setting a default.
To preserve existing behavior, the default is `Block`, ie. if a node
isn't tracked explicitly, it is blocked.

However, this change allows for using `Track` as the default, which
is a way to track everything without having to know the entities in
advance.
2023-02-12 16:22:51 +01:00
xphoniex bdc0ab9881
Update `radicle-git` and `radicle-surf`
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-02-10 22:14:50 +01:00
Alexis Sellier 488f043226
node: Properly reap git-daemon process 2023-02-10 12:57:04 +01:00
Slack Coder 02c07d7be1
cli: Test rad-clone is deterministic
The last commit of a newly cloned repository should remain untouched by
making `Node::project()` use a repository fixture instead of a randomly
generated one.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2023-02-09 16:49:52 +01:00
Alexis Sellier 69ac8be8fd
node: Update local routing table on announce 2023-02-08 21:28:49 +01:00
Alexis Sellier f01735bef6
cli: Have `init` trigger routing table updates
Before this change, nodes had to be restarted to announce newly
initialized projects.
2023-02-08 16:29:42 +01:00
Alexis Sellier c138cd062c
node: Give each peer its own inbox
Instead of a shared queue, each peer gets its own inbox.
2023-02-08 11:43:39 +01:00
Alexis Sellier 054655d79b
node: Log read buffer if not empty 2023-02-07 21:13:29 +01:00
Alexis Sellier f66ecd4ece
node: Replication fixes
* Read git request line before starting daemon, so that we don't leave
  git data in the socket read buffer in case of an error connecting to
  the daemon.
* Send a response on the fetch channel even if we disconnect the remote.
* Don't send `done` packet if there's an error; it won't be expected.
2023-02-07 21:04:13 +01:00
Alexis Sellier d59c422b9d
node: Send special `done` packet to end protocol 2023-02-07 10:47:35 +01:00
Alexis Sellier f5f36191d9
node: Fix some connection-related logic 2023-02-07 10:47:35 +01:00
Alexis Sellier 7bdedd0ffd
node: Fix bug with persistent peer reconnect
We weren't updating the sessions map when a persistent peer
was re-attempted. It would then panic when `connected` was called,
because the state would be `Disconnected`.
2023-02-07 10:47:35 +01:00
Alexis Sellier 2ceb39553e
node: Remove redundant log 2023-02-07 10:47:35 +01:00