feat: don't report inbound stream upgrade errors to handler

When an inbound stream upgrade fails, there isn't a whole lot we can do about that in the handler. In fact, for several errors, we wouldn't even know which specific handler to target, for example, `NegotiationFailed`. Similiarly, in case of an IO error during the upgrade, we don't know which handler the stream was eventually meant to be for.

Pull-Request: #3605.
This commit is contained in:
Thomas Eizinger
2023-05-08 06:54:50 +02:00
committed by GitHub
parent 2130923aa5
commit 53e5370919
21 changed files with 90 additions and 553 deletions

View File

@ -150,14 +150,7 @@ impl ConnectionHandler for Handler {
}));
}
ConnectionEvent::ListenUpgradeError(ListenUpgradeError { info: (), error }) => {
match error {
ConnectionHandlerUpgrErr::Timeout => {}
ConnectionHandlerUpgrErr::Timer => {}
ConnectionHandlerUpgrErr::Upgrade(error) => match error {
libp2p_core::UpgradeError::Select(_) => {}
libp2p_core::UpgradeError::Apply(v) => void::unreachable(v),
},
}
void::unreachable(error)
}
}
}

View File

@ -30,8 +30,7 @@ use libp2p_swarm::{
ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound,
ListenUpgradeError,
},
ConnectionHandler, ConnectionHandlerEvent, ConnectionHandlerUpgrErr, KeepAlive, StreamProtocol,
SubstreamProtocol,
ConnectionHandler, ConnectionHandlerEvent, KeepAlive, StreamProtocol, SubstreamProtocol,
};
use log::error;
use void::Void;
@ -106,14 +105,7 @@ impl ConnectionHandler for Handler {
}
ConnectionEvent::AddressChange(_) => {}
ConnectionEvent::ListenUpgradeError(ListenUpgradeError { info: (), error }) => {
match error {
ConnectionHandlerUpgrErr::Timeout => {}
ConnectionHandlerUpgrErr::Timer => {}
ConnectionHandlerUpgrErr::Upgrade(error) => match error {
libp2p_core::UpgradeError::Select(_) => {}
libp2p_core::UpgradeError::Apply(v) => void::unreachable(v),
},
}
void::unreachable(error)
}
}
}