diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 40da540..2697858 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,13 +17,13 @@ jobs: strategy: matrix: os: - - ubuntu-latest - - windows-latest + # - ubuntu-latest + # - windows-latest - macos-latest toolchain: - stable - - beta - - nightly + # - beta + # - nightly steps: - uses: actions/checkout@v3 diff --git a/gday_contact_exchange_protocol/src/lib.rs b/gday_contact_exchange_protocol/src/lib.rs index 63cf66b..e7fd55e 100644 --- a/gday_contact_exchange_protocol/src/lib.rs +++ b/gday_contact_exchange_protocol/src/lib.rs @@ -282,7 +282,7 @@ impl std::fmt::Display for FullContact { /// Writes `msg` to `writer` using [`serde_json`], and flushes. /// -/// Prefixes the message with 2 bytes holding the [`PROTOCOL_VERSION`] +/// Prefixes the message with 1 byte holding the [`PROTOCOL_VERSION`] /// and 2 bytes holding the length of the following message (all in big-endian). pub fn write_to(msg: impl Serialize, writer: &mut impl Write) -> Result<(), Error> { let vec = serde_json::to_vec(&msg)?; @@ -300,7 +300,7 @@ pub fn write_to(msg: impl Serialize, writer: &mut impl Write) -> Result<(), Erro /// Asynchronously writes `msg` to `writer` using [`serde_json`], and flushes. /// -/// Prefixes the message with 2 bytes holding the [`PROTOCOL_VERSION`] +/// Prefixes the message with 1 byte holding the [`PROTOCOL_VERSION`] /// and 2 bytes holding the length of the following message (all in big-endian). pub async fn write_to_async( msg: impl Serialize, diff --git a/gday_file_transfer/src/offer.rs b/gday_file_transfer/src/offer.rs index 841b291..839fcfd 100644 --- a/gday_file_transfer/src/offer.rs +++ b/gday_file_transfer/src/offer.rs @@ -163,7 +163,7 @@ impl FileResponseMsg { /// Writes `msg` to `writer` using [`serde_json`], and flushes. /// -/// Prefixes the message with 2 bytes holding the [`PROTOCOL_VERSION`] +/// Prefixes the message with 1 byte holding the [`PROTOCOL_VERSION`] /// and 4 bytes holding the length of the following message (all in big-endian). pub fn write_to(msg: impl Serialize, writer: &mut impl Write) -> Result<(), Error> { let vec = serde_json::to_vec(&msg)?; @@ -181,7 +181,7 @@ pub fn write_to(msg: impl Serialize, writer: &mut impl Write) -> Result<(), Erro /// Asynchronously writes `msg` to `writer` using [`serde_json`], and flushes. /// -/// Prefixes the message with 2 bytes holding the [`PROTOCOL_VERSION`] +/// Prefixes the message with 1 byte holding the [`PROTOCOL_VERSION`] /// and 4 bytes holding the length of the following message (all in big-endian). pub async fn write_to_async( msg: impl Serialize, diff --git a/gday_server/src/connection_handler.rs b/gday_server/src/connection_handler.rs index 0bc6592..8a4167d 100644 --- a/gday_server/src/connection_handler.rs +++ b/gday_server/src/connection_handler.rs @@ -3,7 +3,7 @@ use gday_contact_exchange_protocol::{read_from_async, write_to_async, ClientMsg, use log::{error, info, warn}; use std::net::SocketAddr; use tokio::{ - io::{AsyncRead, AsyncWrite}, + io::{AsyncRead, AsyncWrite, AsyncWriteExt}, net::TcpStream, }; use tokio_rustls::TlsAcceptor; @@ -27,8 +27,10 @@ pub async fn handle_connection( } }; let _ = handle_requests(&mut tls_stream, state, origin).await; + let _ = tls_stream.shutdown().await; } else { let _ = handle_requests(&mut tcp_stream, state, origin).await; + let _ = tcp_stream.shutdown().await; } } diff --git a/gday_server/tests/test_integration.rs b/gday_server/tests/test_integration.rs index 93dd798..8aa6e00 100644 --- a/gday_server/tests/test_integration.rs +++ b/gday_server/tests/test_integration.rs @@ -228,10 +228,10 @@ async fn test_request_limit() { }, &mut stream_v4, ); - assert!(matches!( - result, - Err(gday_contact_exchange_protocol::Error::IO(_)) - )); + assert!( + matches!(result, Err(gday_contact_exchange_protocol::Error::IO(_))), + "Expected Error::IO, got {result:?}." + ); // ensure other connections are unaffected write_to(