1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Kept attachments whose read-back failed, Closed the Rust client's connection when out of step

- Replication: a peer's DataMismatch has the sender read its own copy
  back. Dropped as damaged only when read whole and not matching, or a
  part missing; a read-back that failed otherwise (a busy database, a
  connection not opened) dropped it too, the only copy if this server
  was its origin: now kept and warned about (push_to.rs, judge)
- bakashrot-client: an I/O error, a timeout, an answer that isn't the
  request's or doesn't decode, parts cut short or interrupted, a source
  failing mid-upload close the connection; requests after fail with
  NotConnected without reading, so a late answer is never taken for
  the next request's (a push could return the previous one's id).
  is_closed(), set_answer_timeout() / answer_timeout() (30 s by
  default), is_open() always blocking again
- The DLL forgets a client its connection closed that way, whatever the
  code, so connecting again works
- tests/failures.rs in bakashrot-client: a fake TLS server answering
  late, wrongly, cut short; end_to_end.rs for a revoked certificate and
  a failed upload; docs (client.md, server.md) and revamp.md (step 18)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 23:37:01 +01:00
parent 6fae7e61c9
commit 8ebac633d0
8 changed files with 681 additions and 50 deletions
+35
View File
@@ -18,6 +18,31 @@ wire: `protocol.md`; the server's side: `server.md`.
**Status:** steps 7 to 9: connecting, pushes, messages, attachments,
names, queries, several clients.
## The Rust client
`bakashrot_client::Client`, blocking, one request at a time. A refusal
(1-99), or an argument refused before anything is sent
(`InvalidArgument`), keeps the connection. **Anything that leaves it out
of step closes it** (2026-11-19): an I/O error, no answer within
`answer_timeout()` (`ConnectionLost`), an answer that isn't the
request's or doesn't decode (`ProtocolError`), an attachment's parts cut
short or of the wrong size, a refusal among them, a source failing
mid-upload (`FileError`). Every request after fails with `NotConnected`
without reading anything: before, the socket stayed open, and a late
answer could be read as the next request's (a push returning the
previous push's id). `is_closed()` says so. The DLL forgets its client
whenever it's closed so (it did on `ConnectionLost` and `ProtocolError`
already; now on a file failing mid-upload too), so connecting again
works; Python and C# go through it.
- `set_answer_timeout()`: how long an answer, or sending a packet, may
take: 30 s (`ANSWER_TIMEOUT`) until changed, more than 0. Longer for a
slow query, say.
- `is_open()`: false once closed; it looks at the socket without
blocking, then always makes it blocking again (it was left
non-blocking when it found the connection gone).
- `ping()`: keeps an idle connection open (`protocol.md`, "Rules").
## Who connects: certificates
A client is its certificate, issued by the CA the servers trust
@@ -243,6 +268,16 @@ bakashrot list nodes --topics 'sensors.*' Nodes (2): those that pushed to s
## Tests
`crates/bakashrot-client/tests/failures.rs`, against a fake server (TLS
with a test CA, then scripted answers): a late answer never taken for
the next request's, a wrong, malformed or cut answer, a part of the
wrong size, a refusal among the parts, a source failing mid-upload, a
connection the server closed (each: closed, `NotConnected` after,
nothing more sent); a refusal and an argument refused before sending
keeping it; a longer timeout waiting for a slow answer; `is_open()`
leaving it blocking. Each closing path broken on purpose once: the
tests caught it.
`crates/bakashrot-capi/tests/`, each against a server on a free port:
- `exports.rs`, `exports`: the exports as C calls them, on one client: certificates from files and
+4 -1
View File
@@ -131,7 +131,10 @@ otherwise:
part it needs. One it says doesn't match its SHA-256 is read back
here: damaged (a disk, a bug), this server's copy is dropped and asked
for again from its own peers (`replicating`, not served meanwhile),
instead of sent again at every check-in.
instead of sent again at every check-in. Damaged means read whole and
not matching, or a part missing; a read-back that fails otherwise (the
database busy, a connection not opened) says nothing, so the copy is
kept and warned about (2026-11-19): it may be the only one there is.
**Receiving** (`accept_from.rs`): replication requests are answered only
if the connection comes from `accept_from` (a hostname looked up at its