From 182c508be5ff9e7da747085d4c0c13022c0fab28 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Tue, 26 Aug 2025 11:38:21 +0200 Subject: Add handshake-able version --- src/lib.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 187380a..f2ce6f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,26 @@ -pub mod field; +pub mod error; +pub mod handshake; +// pub mod field; // pub mod transactions; + +use crate::error::HotlineError; +use crate::handshake::accept_handshake; + +use std::net::TcpStream; + +/// Get the stream and act as a server. If you want to act as a client, you +/// will have to write your own handler. +/// +/// # Errors +/// +/// Returns error if handshake fails or stream I/O fails +pub fn handle_client(mut stream: TcpStream) -> Result<(), HotlineError> { + let handshake_request = accept_handshake(&mut stream)?; + + eprintln!( + "Handshake successful with sub_protocol_id: 0x{:08X}, sub_version: {}", + handshake_request.sub_protocol_id, handshake_request.sub_version + ); + + Ok(()) +} -- cgit