mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
simplify shellchat net tls probe
This commit is contained in:
parent
472e4407b8
commit
5feaac2bae
1 changed files with 12 additions and 15 deletions
|
|
@ -500,27 +500,24 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
|
||||||
let url = format!("{}:443", target);
|
let url = format!("{}:443", target);
|
||||||
let mut sock = match TcpStream::connect(url) {
|
let mut sock = match TcpStream::connect(url) {
|
||||||
Ok(mut sock) => {
|
Ok(mut sock) => {
|
||||||
let mut tls = rustls::Stream::new(&mut conn, &mut sock);
|
match conn.complete_io(&mut sock){
|
||||||
log::info!("create http headers and write to server");
|
Ok(_) => log::info!("handshake complete"),
|
||||||
let msg = format!("GET / HTTP/1.1\r\nHost: {}\r\nConnection: keep-alive\r\nAccept-Encoding: identity\r\n\r\n", target);
|
Err(e) => {
|
||||||
match tls.write_all(msg.as_bytes()) {
|
write!(ret, "{e}").ok();
|
||||||
Ok(()) => (),
|
log::warn!("{e}");
|
||||||
Err(e) => log::warn!(
|
}
|
||||||
"failed to write to tls connection {}",
|
}
|
||||||
e
|
conn.send_close_notify();
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
log::info!("close tls connection");
|
match conn.peer_certificates() {
|
||||||
tls.conn.send_close_notify();
|
|
||||||
|
|
||||||
match tls.conn.peer_certificates() {
|
|
||||||
Some(certificates) => tls::check_trust(certificates),
|
Some(certificates) => tls::check_trust(certificates),
|
||||||
None => false,
|
None => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!("failed to establish tls connection {}", e)
|
write!(ret, "{e}").ok();
|
||||||
|
log::warn!("{e}")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue