feat: add hostile harness, multi-session driver, and frame header deadline

This commit is contained in:
randogoth 2026-09-29 10:27:44 +03:00
parent 8ea6865e7e
commit c152a955e5
5 changed files with 649 additions and 4 deletions

View file

@ -7,7 +7,7 @@ use std::time::Duration;
use crate::bind::TransportBindValues;
use crate::channel::{handshake, Channel};
use crate::crypto::{b32, derive_public};
use crate::proto::{FETCH_BUDGET, IDLE_TIMEOUT_SECS, KEY_LEN, MALFORMED, PURGE_INTERVAL_SECS};
use crate::proto::{FETCH_BUDGET, HEADER_TIMEOUT_SECS, KEY_LEN, MALFORMED, PURGE_INTERVAL_SECS};
use crate::ratelimit::RateLimiter;
use crate::session::{ServerConfig, Session};
use crate::store::Store;
@ -94,14 +94,19 @@ pub fn run(args: ServeArgs) -> anyhow::Result<()> {
Ok(())
}
fn handle_connection(
/// Also the hostile harness's entry point: it drives real connections
/// through the same accept/handshake/session path the TCP carrier serves.
pub(crate) fn handle_connection(
mut stream: TcpStream,
config: &ServerConfig,
static_key: &[u8; KEY_LEN],
db_path: &str,
peer_ip: &str,
) -> anyhow::Result<()> {
stream.set_read_timeout(Some(Duration::from_secs(IDLE_TIMEOUT_SECS)))?;
// The handshake runs under the header budget; once it completes,
// Channel::read_noise picks between the header and idle deadlines per
// frame state.
stream.set_read_timeout(Some(Duration::from_secs(HEADER_TIMEOUT_SECS)))?;
let handshake_started = std::time::Instant::now();
let (transport, handshake_hash) = match handshake(&mut stream, static_key) {