tryout rustls

This commit is contained in:
lastlink 2019-08-08 20:45:26 -04:00
parent 533809e0ee
commit 7bcdd21a0e
2 changed files with 38 additions and 1 deletions

View File

@ -4,4 +4,5 @@ version = "0.1.0"
authors = ["lastlink <theefunk@gmail.com>"]
edition = "2018"
[dependencies]
[dependencies]
rustls = "0.15.2"

View File

@ -1,4 +1,9 @@
extern crate rustls;
// extern crate webpki_roots;
use std::sync::Arc;
use std::env;
use rustls::{ClientConfig, ClientSession, Session, TLSError};
fn help() {
println!(
@ -8,6 +13,37 @@ fn help() {
ex: sclient whatever.com:4080 0.0.0.0:3000"
);
}
// https://github.com/HowNetWorks/trytls-rustls-stub/blob/master/src/main.rs
fn communicate(host: String, port: u16, config: ClientConfig) {
let rc_config = Arc::new(config);
// let mut client = ClientSession::new(&rc_config, &host);
// let mut stream = (TcpStream::connect((&*host, port)));
// (client.write(b"GET / HTTP/1.0\r\nConnection: close\r\nContent-Length: 0\r\n\r\n"));
loop {
// while client.wants_write() {
// // (client.write_tls(&mut stream));
// }
// if client.wants_read() {
// if (client.read_tls(&mut stream)) == 0 {
// return Err(From::from("Connection closed"));
// }
// if let Err(err) = client.process_new_packets() {
// return match err {
// TLSError::WebPKIError(_) |
// TLSError::AlertReceived(_) => Ok(Verdict::Reject(err)),
// _ => Err(From::from(format!("{:?}", err))),
// };
// }
// if (client.read(&mut [0])) > 0 {
// return Ok(Verdict::Accept);
// }
// }
}
}
fn main() {
let args: Vec<String> = env::args().collect();