Handled Cert/Key File errors. Changed data stream R/W to use match

This commit is contained in:
PinkP4nther 2021-08-23 00:56:32 -07:00
commit b25ae45948
2 changed files with 68 additions and 53 deletions

View file

@ -31,7 +31,11 @@ impl DataHandler {
pub fn get_data_stream(&mut self, data: &mut Vec<u8>) -> usize {
let mut data_length: usize = 0;
if self.stream_direction == StreamDirection::DownStream {
match self.stream_direction {
StreamDirection::DownStream => {
loop {
let mut r_buf = [0; 1024];
@ -65,7 +69,8 @@ impl DataHandler {
},
}
}
} else if self.stream_direction == StreamDirection::Upstream {
},
StreamDirection::Upstream => {
loop {
let mut r_buf = [0; 1024];
@ -100,6 +105,7 @@ impl DataHandler {
}
}
}
}
return data_length;
}

View file

@ -2,9 +2,10 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod, SslStream};
use std::io::Write;
use std::net::{TcpListener, TcpStream};
use std::sync::{Arc, Mutex};
use std::thread;
use std::{process, thread};
use std::env;
use std::fs;
use std::path::Path;
use toml::Value as TValue;
@ -144,6 +145,14 @@ impl<H: HandlerCallbacks + std::marker::Sync + std::marker::Send + 'static> SSLR
fn setup_ssl_config(&self, priv_key: String, cert: String) -> Arc<SslAcceptor> {
if !Path::new(priv_key.as_str()).exists() {
println!("[-] [{}] does not exist!", priv_key);
process::exit(-1);
} else if !Path::new(cert.as_str()).exists() {
println!("[-] [{}] does not exist!", cert);
process::exit(-1);
}
let mut acceptor = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
acceptor.set_private_key_file(priv_key, SslFiletype::PEM).unwrap();
acceptor.set_certificate_chain_file(cert).unwrap();