A toolkit library for distributed software
Find a file
networkException 47a470b281
everywhere: support unix sockets
This patch adds support for listening on and connecting to unix sockets.

This requires having wrapper types for various tokio specific network
abstractions while also supporting things like serialization and
deserialization.

Unfortionately i was unable to find a published crate fulfilling these
requirements.

For this reason I've published a crate myself. Called `tokio-unix-tcp`,
it serves as a drop in replacement for Tokio's TCP and Unix network
types.

I plan to maintain this library outside the scope of this project as
well, in general the code should be simple and stable enough however
to not require maintainance going forward.

As i said this crate aims to support the requirement mentioned above.
In addition to this it also strives to be more correct about handling
the different types of unix sockets, which the libraries i reviewed
were weak at. A list of these crates can be found in the crate README
under "Related work".

---

The changes to netapp can be summarized as the following:

- `std::net::SocketAddr` has been replaced by
  `tokio_unix_tcp::NamedSocketAddr` in most places. This enum encapsulates
  a IP address and port as well as a path in its variants and describes
  a concrete socket address netapp can bind or connect to.

- In some places `tokio_unix_tcp::SocketAddr` is used instead of
  `tokio_unix_tcp::NamedSocketAddr` as mentioned above. This is due to
  the way unix sockets work:

  The remote peer of a client from the perspective of a server is not
  a concrete path but `unnamed`. They just share a file descriptor
  for the actual communication channel. The local address of the server
  is the actual file system path the server is listening on.

  In some cases netapp might be configured to connect to another peer
  using a unix socket and to not send a reachable IP address and port
  or unix socket path using the `HelloMessage`.

  As per the above (the client's remote address will be `unnamed`),
  we have no way of connecting back to that peer. This will currently
  cause the connection to be aborted by the server.

- Listening on Unix sockets requires some additional handling like
  removing a previous file at the bind path and setting a correct
  mode (defaulting to `0o222` currently). This is handled by
  `tokio_unix_tcp`.

---

I've tested these changes by including them in garage and running basic
administration commands against a node and by running the unit tests here.

Basalt peering is currently lacking a proper cost calculation for unix
sockets - I'm sadly not familiar with this code.
2023-11-05 22:29:12 +01:00
examples everywhere: support unix sockets 2023-11-05 22:29:12 +01:00
src everywhere: support unix sockets 2023-11-05 22:29:12 +01:00
.drone.yml update .drone.yml 2023-02-01 00:09:13 +01:00
.gitignore First commit 2020-12-02 13:30:47 +01:00
Cargo.lock cargo: add tokio-unix-tcp as a dependency 2023-11-05 22:29:11 +01:00
Cargo.toml cargo: add tokio-unix-tcp as a dependency 2023-11-05 22:29:11 +01:00
LICENSE Prepare Cargo.toml for publication 2020-12-14 11:35:41 +01:00
Makefile Move things around 2022-07-21 17:37:52 +02:00
README.md Add CI badge 2021-02-18 12:10:10 +01:00
rustfmt.toml First commit 2020-12-02 13:30:47 +01:00
target update rmp-serde to v1.1, bump to 0.10.0 2023-09-27 12:32:54 +02:00

Netapp - a toolkit library for distributed software

Build Status

Netapp is a Rust library that takes care of a few common tasks in distributed software:

  • establishing secure connections
  • managing connection lifetime, reconnecting on failure
  • checking peer's state
  • peer discovery
  • query/response message passing model for communications
  • multiplexing transfers over a connection
  • overlay networks: full mesh, and byzantine-tolerant random peer sampling using Bᴀsᴀʟᴛ.

See examples folder to learn how to use netapp.