tryout rustls
This commit is contained in:
parent
533809e0ee
commit
7bcdd21a0e
|
@ -4,4 +4,5 @@ version = "0.1.0"
|
|||
authors = ["lastlink <theefunk@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
[dependencies]
|
||||
rustls = "0.15.2"
|
||||
|
|
36
src/main.rs
36
src/main.rs
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue