Skip to content

Commit a58ac29

Browse files
committed
replace LengthDelimitedCodec with custom MessageFrameCodec
1 parent 4b5f0f1 commit a58ac29

6 files changed

Lines changed: 367 additions & 36 deletions

File tree

crates/anemo/src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ pub struct Config {
6363
///
6464
/// This limit is applied in the following ways:
6565
/// - Inbound connections from [`KnownPeers`] with [`PeerAffinity::High`] or
66-
/// [`PeerAffinity::Allowed`] bypass this limit. All other inbound
67-
/// connections are only accepted if the total number of inbound and outbound
68-
/// connections, irrespective of affinity, is less than this limit.
66+
/// [`PeerAffinity::Allowed`] bypass this limit. All other inbound
67+
/// connections are only accepted if the total number of inbound and outbound
68+
/// connections, irrespective of affinity, is less than this limit.
6969
/// - Outbound connections explicitly made by the application via [`Network::connect`] or
70-
/// [`Network::connect_with_peer_id`] bypass this limit.
70+
/// [`Network::connect_with_peer_id`] bypass this limit.
7171
/// - Outbound connections made in the background, due to configured [`KnownPeers`], to peers with
72-
/// [`PeerAffinity::High`] bypass this limit and are always attempted.
72+
/// [`PeerAffinity::High`] bypass this limit and are always attempted.
7373
///
7474
/// If unspecified, there will be no limit on the number of concurrent connections.
7575
///

crates/anemo/src/crypto.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,12 @@ fn pki_error(error: webpki::Error) -> rustls::Error {
326326
BadDer | BadDerTime => {
327327
rustls::Error::InvalidCertificate(rustls::CertificateError::BadEncoding)
328328
}
329+
#[allow(deprecated)]
329330
InvalidSignatureForPublicKey
330331
| UnsupportedSignatureAlgorithm
331-
| UnsupportedSignatureAlgorithmForPublicKey => {
332+
| UnsupportedSignatureAlgorithmForPublicKey
333+
| UnsupportedSignatureAlgorithmContext(..)
334+
| UnsupportedSignatureAlgorithmForPublicKeyContext(..) => {
332335
rustls::Error::InvalidCertificate(rustls::CertificateError::BadSignature)
333336
}
334337
e => {

crates/anemo/src/network/request_handler.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use super::wire::MessageFrameCodec;
12
use super::{
23
wire::{network_message_frame_codec, read_request, write_response},
34
ActivePeers,
@@ -10,7 +11,7 @@ use bytes::Bytes;
1011
use quinn::RecvStream;
1112
use std::convert::Infallible;
1213
use std::sync::Arc;
13-
use tokio_util::codec::{FramedRead, FramedWrite, LengthDelimitedCodec};
14+
use tokio_util::codec::{FramedRead, FramedWrite};
1415
use tower::{util::BoxCloneService, ServiceExt};
1516
use tracing::{debug, trace};
1617

@@ -121,8 +122,8 @@ impl InboundRequestHandler {
121122
struct BiStreamRequestHandler {
122123
connection: Connection,
123124
service: BoxCloneService<Request<Bytes>, Response<Bytes>, Infallible>,
124-
send_stream: FramedWrite<SendStream, LengthDelimitedCodec>,
125-
recv_stream: FramedRead<RecvStream, LengthDelimitedCodec>,
125+
send_stream: FramedWrite<SendStream, MessageFrameCodec>,
126+
recv_stream: FramedRead<RecvStream, MessageFrameCodec>,
126127
}
127128

128129
impl BiStreamRequestHandler {

0 commit comments

Comments
 (0)