diff --git a/darklight_driver/src/streams.rs b/darklight_driver/src/streams.rs index c0a0a370..26f61a80 100644 --- a/darklight_driver/src/streams.rs +++ b/darklight_driver/src/streams.rs @@ -313,13 +313,21 @@ impl StreamsHandler { let io_method = self.io_method.as_mut().unwrap(); let mut read = io_method._read(); read.0 = read.0.replace("\0", ""); - println!("read: {}", read.0); + //println!("read: {}", read.0); if read.1 == READ_SUCCESS { let ri = Message::get_ri_from_encoded(&read.0); if ri.rid == local_user_id().unwrap() { + println!("receving id: {}", ri.rid); for i in 0..self.stream_info.len() { + // For servers receiving client messages + if self.stream_info[i].rid == local_user_id().unwrap() && self.stream_info[i].port == ri.port { + self.write_to_stream_file(self.stream_info[i].rid, ri.port, &read.0); + continue; + } + + // For clients if self.stream_info[i].port == ri.port { let ti = Message::decode(&read.0, dlwp::encryption::EncryptionInfo { encode_function: libcerpton_encode, decode_function: libcerpton_decode, info: self.stream_info[i].info }).ti; println!("writing to stream file"); diff --git a/dlwp/src/stream.rs b/dlwp/src/stream.rs index e2426c63..deccd94c 100644 --- a/dlwp/src/stream.rs +++ b/dlwp/src/stream.rs @@ -242,7 +242,6 @@ impl Stream { for line in reader.lines() { if line.is_ok() { - println!("reading: {:?}", line); ret.push(line.unwrap()); } } diff --git a/test_streams/test_server/src/main.rs b/test_streams/test_server/src/main.rs index 18dd69f1..fcdbc9a2 100644 --- a/test_streams/test_server/src/main.rs +++ b/test_streams/test_server/src/main.rs @@ -1,4 +1,6 @@ +use dlwp::cerpton::{libcerpton_decode, libcerpton_encode}; use dlwp::codes::{Code, REQUEST_RESPONSE, STATUS_OK}; +use dlwp::encryption::EncryptionInfo; use dlwp::message::ReceiveInfo; use dlwp::stream::{Stream, StreamType}; use std::{thread::sleep, time::Duration}; @@ -8,6 +10,11 @@ const PORT: u16 = 5000; fn main() { let mut stream = Stream::new(StreamType::Server { port: PORT }, false); + stream.add_encryption_info(EncryptionInfo { + encode_function: libcerpton_encode, + decode_function: libcerpton_decode, + info: [2, 1, 2, 0, 0, 0] + }); println!("starting"); let ret = stream.start(); println!("started: {:?}", ret);