mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: improve ecies error fatal variants (#11303)
This commit is contained in:
@ -13,6 +13,11 @@ impl ECIESError {
|
|||||||
pub fn into_inner(self) -> ECIESErrorImpl {
|
pub fn into_inner(self) -> ECIESErrorImpl {
|
||||||
*self.inner
|
*self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the inner error
|
||||||
|
pub const fn inner(&self) -> &ECIESErrorImpl {
|
||||||
|
&self.inner
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ECIESError {
|
impl fmt::Display for ECIESError {
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
use std::{fmt, io, io::ErrorKind, net::SocketAddr};
|
use std::{fmt, io, io::ErrorKind, net::SocketAddr};
|
||||||
|
|
||||||
use reth_dns_discovery::resolver::ResolveError;
|
use reth_dns_discovery::resolver::ResolveError;
|
||||||
|
use reth_ecies::ECIESErrorImpl;
|
||||||
use reth_eth_wire::{
|
use reth_eth_wire::{
|
||||||
errors::{EthHandshakeError, EthStreamError, P2PHandshakeError, P2PStreamError},
|
errors::{EthHandshakeError, EthStreamError, P2PHandshakeError, P2PStreamError},
|
||||||
DisconnectReason,
|
DisconnectReason,
|
||||||
@ -206,7 +207,17 @@ impl SessionError for PendingSessionHandshakeError {
|
|||||||
fn merits_discovery_ban(&self) -> bool {
|
fn merits_discovery_ban(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Eth(eth) => eth.merits_discovery_ban(),
|
Self::Eth(eth) => eth.merits_discovery_ban(),
|
||||||
Self::Ecies(_) => true,
|
Self::Ecies(err) => matches!(
|
||||||
|
err.inner(),
|
||||||
|
ECIESErrorImpl::TagCheckDecryptFailed |
|
||||||
|
ECIESErrorImpl::TagCheckHeaderFailed |
|
||||||
|
ECIESErrorImpl::TagCheckBodyFailed |
|
||||||
|
ECIESErrorImpl::InvalidAuthData |
|
||||||
|
ECIESErrorImpl::InvalidAckData |
|
||||||
|
ECIESErrorImpl::InvalidHeader |
|
||||||
|
ECIESErrorImpl::Secp256k1(_) |
|
||||||
|
ECIESErrorImpl::InvalidHandshake { .. }
|
||||||
|
),
|
||||||
Self::Timeout => false,
|
Self::Timeout => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +225,17 @@ impl SessionError for PendingSessionHandshakeError {
|
|||||||
fn is_fatal_protocol_error(&self) -> bool {
|
fn is_fatal_protocol_error(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Eth(eth) => eth.is_fatal_protocol_error(),
|
Self::Eth(eth) => eth.is_fatal_protocol_error(),
|
||||||
Self::Ecies(_) => true,
|
Self::Ecies(err) => matches!(
|
||||||
|
err.inner(),
|
||||||
|
ECIESErrorImpl::TagCheckDecryptFailed |
|
||||||
|
ECIESErrorImpl::TagCheckHeaderFailed |
|
||||||
|
ECIESErrorImpl::TagCheckBodyFailed |
|
||||||
|
ECIESErrorImpl::InvalidAuthData |
|
||||||
|
ECIESErrorImpl::InvalidAckData |
|
||||||
|
ECIESErrorImpl::InvalidHeader |
|
||||||
|
ECIESErrorImpl::Secp256k1(_) |
|
||||||
|
ECIESErrorImpl::InvalidHandshake { .. }
|
||||||
|
),
|
||||||
Self::Timeout => false,
|
Self::Timeout => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user