Skip to content

Commit

Permalink
chore: update dependencies and remove some debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
ihciah committed Feb 12, 2023
1 parent 3e6420d commit ffe5000
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ version = "0.2.15"

[dependencies]
monoio = {version = "0.0.9"}
monoio-rustls-fork-shadow-tls = {version = "0.0.7"}
rustls-fork-shadow-tls = {version = "0.20", default-features = false}
monoio-rustls-fork-shadow-tls = {version = "0.0.8-mod.2"}
rustls-fork-shadow-tls = {version = "0.20.9-mod.2", default-features = false}

anyhow = "1"
byteorder = "1"
Expand Down
1 change: 1 addition & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,5 +545,6 @@ fn generate_session_id(hmac: &Hmac, buf: &[u8]) -> [u8; TLS_SESSION_ID_SIZE] {
HMAC_SIZE,
)
}
tracing::debug!("ClientHello before sign: {buf:?}, session_id {session_id:?}");
session_id
}
18 changes: 5 additions & 13 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<LA, TA> ShadowTlsServer<LA, TA> {
let mut handshake_stream = TcpStream::connect(addr).await?;
mod_tcp_conn(&mut handshake_stream, true, self.nodelay);
tracing::debug!("handshake server connected: {addr}");

tracing::trace!("ClientHello frame {first_client_frame:?}");
let (res, _) = handshake_stream.write_all(first_client_frame).await;
res?;
if !client_hello_pass {
Expand All @@ -281,7 +281,7 @@ impl<LA, TA> ShadowTlsServer<LA, TA> {
return Ok(());
}
};
tracing::debug!("ServerRandom extracted: {server_random:?}");
tracing::debug!("Client authenticated. ServerRandom extracted: {server_random:?}");

if !support_tls13(&first_server_frame) {
tracing::error!("TLS 1.3 is not supported, will copy bidirectional");
Expand Down Expand Up @@ -780,21 +780,13 @@ async fn copy_by_frame_until_hmac_matches(
let mut g_buffer = Vec::new();

loop {
tracing::debug!("copy_by_frame_until_hmac_matches getting frame");
let buffer = read_exact_frame_into(&mut read, g_buffer).await?;
tracing::debug!("copy_by_frame_until_hmac_matches get a frame: {buffer:?}",);
if buffer.len() > 9 && buffer[0] == APPLICATION_DATA {
// check hmac
let mut tmp_hmac = hmac.to_owned();
tmp_hmac.update(&buffer[TLS_HMAC_HEADER_SIZE..]);
let h = tmp_hmac.finalize();

tracing::debug!(
"tmp hmac({:?}) = {h:?}, raw = {:?}",
&buffer[TLS_HMAC_HEADER_SIZE..],
&buffer[TLS_HEADER_SIZE..TLS_HMAC_HEADER_SIZE]
);

if buffer[TLS_HEADER_SIZE..TLS_HMAC_HEADER_SIZE] == h {
hmac.update(&buffer[TLS_HMAC_HEADER_SIZE..]);
hmac.update(&buffer[TLS_HEADER_SIZE..TLS_HMAC_HEADER_SIZE]);
Expand Down Expand Up @@ -829,7 +821,6 @@ async fn copy_by_frame_with_modification(
monoio::select! {
// this function can be stopped by a channel when reading.
_ = &mut stop => {
tracing::debug!("copy_by_frame_with_modification recv stop");
return Ok(());
},
buffer_res = read_exact_frame_into(&mut read, g_buffer) => {
Expand Down Expand Up @@ -893,10 +884,11 @@ fn support_tls13(frame: &[u8]) -> bool {
read_ok!(cursor.skip_by_u16());
continue;
}
tracing::debug!("found supported_versions extension");
let ext_len = read_ok!(cursor.read_u16::<BigEndian>());
let ext_val = read_ok!(cursor.read_u16::<BigEndian>());
return ext_len == 2 && ext_val == TLS_13;
let use_tls13 = ext_len == 2 && ext_val == TLS_13;
tracing::debug!("found supported_versions extension, tls1.3: {use_tls13}");
return use_tls13;
}
false
}
Expand Down

0 comments on commit ffe5000

Please sign in to comment.