diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-08-26 11:38:21 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-08-26 11:38:21 +0200 |
| commit | 182c508be5ff9e7da747085d4c0c13022c0fab28 (patch) | |
| tree | cf6deee752a5acdb4696dda8695db8f87f89d6e9 /src/lib.rs | |
| parent | 8cc69f354b9ed1b57eaceecf2d971c079d6698da (diff) | |
Add handshake-able version
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -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(()) +} |