Commit graph

20 commits

Author SHA1 Message Date
47a470b281
everywhere: support unix sockets
Some checks failed
continuous-integration/drone/pr Build is failing
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
6df6411b72 fix clippy
All checks were successful
continuous-integration/drone/push Build is passing
2023-01-31 23:57:33 +01:00
f0326607ee
slightly change example
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build was killed
2022-09-12 17:19:26 +02:00
b55f61c38b
Fix things going wrong when sending chan is closed
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build was killed
2022-07-26 12:11:48 +02:00
bdf7d4731d
Add stream example to fullmesh example
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-07-26 12:01:13 +02:00
f35fa7d18d
Move things around 2022-07-21 17:37:52 +02:00
8858c94289
Implement version tag for application as well
Some checks failed
continuous-integration/drone/push Build is failing
2022-02-21 16:43:17 +01:00
dfb0ebb8e1
Full mesh peering strategy uses our local address if necessary
Some checks failed
continuous-integration/drone/push Build is failing
2021-10-15 15:34:03 +02:00
7e49d0dac8
Make a public function to parse peer addresses
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-14 11:58:09 +02:00
70839d70d8
Try to handle termination and closing of stuff properly
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-13 17:12:13 +02:00
8dede69dee
Fix netapp protocol & adapt basalt to new api
Some checks failed
continuous-integration/drone/push Build is failing
2021-10-13 12:33:14 +02:00
6742638c81 Replace pk,pubkey,PublicKey by id,NodeID,etc 2020-12-12 21:14:15 +01:00
5040198972 Make it passive-client-friendly 2020-12-12 19:27:18 +01:00
609f0387ca Add ability to specify our public addr for people to contact us back 2020-12-11 15:53:59 +01:00
5a9ae8615e Do not close connections immediately on close signal, await for remaining responses 2020-12-07 13:35:24 +01:00
b247f02c29 Don't close connection at first (stupid) excuse 2020-12-04 17:12:10 +01:00
0b041c77f4 more logging 2020-12-04 14:06:06 +01:00
b63179c699 Logging 2020-12-04 13:58:34 +01:00
14d34e76f4 Documentate 2020-12-02 20:12:24 +01:00
d4de2ffc40 First commit 2020-12-02 13:30:47 +01:00