Add: verbose flag to show logs in detail
This commit is contained in:
@@ -13,3 +13,4 @@ tokio-rustls = "0.24"
|
||||
x509-parser = "0.16"
|
||||
tokio-socks = "0.5"
|
||||
url = "2"
|
||||
tracing = "0.1"
|
||||
|
||||
@@ -8,6 +8,7 @@ use tokio::net::TcpStream;
|
||||
use tokio::time::timeout;
|
||||
use tokio_rustls::TlsConnector;
|
||||
use tokio_socks::tcp::Socks5Stream;
|
||||
use tracing::debug;
|
||||
use url::Url;
|
||||
use x509_parser::prelude::{FromDer, X509Certificate};
|
||||
|
||||
@@ -85,6 +86,15 @@ pub struct TlsOptions {
|
||||
}
|
||||
|
||||
pub async fn handshake(target: &str, options: TlsOptions) -> Result<TlsHandshakeReport, TlsError> {
|
||||
debug!(
|
||||
target,
|
||||
sni = ?options.sni,
|
||||
alpn = ?options.alpn,
|
||||
proxy = ?options.socks5,
|
||||
timeout_ms = options.timeout_ms,
|
||||
prefer_ipv4 = options.prefer_ipv4,
|
||||
"tls handshake start"
|
||||
);
|
||||
let (host, port, server_name) = parse_target(target, options.sni.as_deref())?;
|
||||
let connector = build_connector(options.insecure, &options.alpn)?;
|
||||
let stream = connect(
|
||||
@@ -115,6 +125,15 @@ pub async fn handshake(target: &str, options: TlsOptions) -> Result<TlsHandshake
|
||||
}
|
||||
|
||||
pub async fn verify(target: &str, options: TlsOptions) -> Result<TlsVerifyReport, TlsError> {
|
||||
debug!(
|
||||
target,
|
||||
sni = ?options.sni,
|
||||
alpn = ?options.alpn,
|
||||
proxy = ?options.socks5,
|
||||
timeout_ms = options.timeout_ms,
|
||||
prefer_ipv4 = options.prefer_ipv4,
|
||||
"tls verify start"
|
||||
);
|
||||
let (host, port, server_name) = parse_target(target, options.sni.as_deref())?;
|
||||
let connector = build_connector(false, &options.alpn)?;
|
||||
match connect(
|
||||
@@ -159,6 +178,15 @@ pub async fn verify(target: &str, options: TlsOptions) -> Result<TlsVerifyReport
|
||||
}
|
||||
|
||||
pub async fn certs(target: &str, options: TlsOptions) -> Result<TlsCertReport, TlsError> {
|
||||
debug!(
|
||||
target,
|
||||
sni = ?options.sni,
|
||||
alpn = ?options.alpn,
|
||||
proxy = ?options.socks5,
|
||||
timeout_ms = options.timeout_ms,
|
||||
prefer_ipv4 = options.prefer_ipv4,
|
||||
"tls certs start"
|
||||
);
|
||||
let (host, port, server_name) = parse_target(target, options.sni.as_deref())?;
|
||||
let connector = build_connector(options.insecure, &options.alpn)?;
|
||||
let stream = connect(
|
||||
@@ -180,6 +208,15 @@ pub async fn certs(target: &str, options: TlsOptions) -> Result<TlsCertReport, T
|
||||
}
|
||||
|
||||
pub async fn alpn(target: &str, options: TlsOptions) -> Result<TlsAlpnReport, TlsError> {
|
||||
debug!(
|
||||
target,
|
||||
sni = ?options.sni,
|
||||
alpn = ?options.alpn,
|
||||
proxy = ?options.socks5,
|
||||
timeout_ms = options.timeout_ms,
|
||||
prefer_ipv4 = options.prefer_ipv4,
|
||||
"tls alpn start"
|
||||
);
|
||||
let (host, port, server_name) = parse_target(target, options.sni.as_deref())?;
|
||||
let connector = build_connector(options.insecure, &options.alpn)?;
|
||||
let stream = connect(
|
||||
|
||||
Reference in New Issue
Block a user