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

Moved the identity OID under NibblePoker's PEN, Added a timeout on what the server sends, Bumped to 0.3.0

- The identity extension's OID is 1.3.6.1.4.1.67681.1.1 (PEN 67681):
  certificates made with the placeholder aren't read any more, the
  warning of `bakashrot-cert` is gone.
- A packet the server sends (an answer, an attachment's part, to a peer
  too) has 30 s: a client that stopped reading is dropped.
- A peer using up a stream's ids: left as it is, why in known-issues.md.
- Version 0.3.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 01:49:59 +01:00
parent ea8499fab5
commit a4950844c6
14 changed files with 95 additions and 135 deletions
+17 -1
View File
@@ -35,6 +35,10 @@ const IDLE_TIMEOUT: Duration = Duration::from_secs(300);
/// How long an attachment's next part may take to come.
const PART_TIMEOUT: Duration = Duration::from_secs(30);
/// How long a packet may take to be sent (an attachment's part is 1 MiB):
/// a client that stopped reading is dropped rather than waited for.
pub(crate) const SEND_TIMEOUT: Duration = Duration::from_secs(30);
/// An upload's parts given to the writer and not written yet, at most: the
/// next ones wait (the client with them, through TCP).
const PARTS_IN_FLIGHT: usize = 4;
@@ -535,6 +539,18 @@ pub(crate) fn refused(code: ErrorCode, reason: String) -> Packet {
RequestRefused::new(code, reason).into()
}
/// Sends a packet, within [`SEND_TIMEOUT`]: an error closes the connection.
pub(crate) async fn send(frames: &mut Frames, packet: Packet) -> std::io::Result<()> {
frames.send(bytes::Bytes::from(packet.encode())).await
match timeout(
SEND_TIMEOUT,
frames.send(bytes::Bytes::from(packet.encode())),
)
.await
{
Ok(sent) => sent,
Err(_) => Err(std::io::Error::new(
std::io::ErrorKind::TimedOut,
"too slow to take an answer",
)),
}
}
+6 -4
View File
@@ -7,6 +7,7 @@
//! `send_*` allow. `accept_from.rs` is the other end.
use crate::Shared;
use crate::connection::SEND_TIMEOUT;
use crate::writer::Write;
use bakashrot_config::Permissions;
use bakashrot_pki::tls;
@@ -297,10 +298,11 @@ impl Link {
}
async fn send(&mut self, packet: Packet) -> Result<(), String> {
self.frames
.send(bytes::Bytes::from(packet.encode()))
.await
.map_err(|error| error.to_string())
let sending = self.frames.send(bytes::Bytes::from(packet.encode()));
match timeout(SEND_TIMEOUT, sending).await {
Ok(sent) => sent.map_err(|error| error.to_string()),
Err(_) => Err("too slow to take a packet".into()),
}
}
async fn receive(&mut self) -> Result<Packet, String> {