mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-29 17:19:57 -07:00
bindgen: snap
This commit is contained in:
@@ -35,9 +35,9 @@ pub enum Error {
|
||||
#[error(transparent)]
|
||||
RawDB(#[from] vecdb::RawDBError),
|
||||
|
||||
#[cfg(feature = "minreq")]
|
||||
#[cfg(feature = "ureq")]
|
||||
#[error(transparent)]
|
||||
Minreq(#[from] minreq::Error),
|
||||
Ureq(#[from] ureq::Error),
|
||||
|
||||
#[error(transparent)]
|
||||
SystemTimeError(#[from] time::SystemTimeError),
|
||||
@@ -180,8 +180,8 @@ impl Error {
|
||||
/// Returns false for transient errors worth retrying (timeouts, rate limits, server errors).
|
||||
pub fn is_network_permanently_blocked(&self) -> bool {
|
||||
match self {
|
||||
#[cfg(feature = "minreq")]
|
||||
Error::Minreq(e) => is_minreq_error_permanent(e),
|
||||
#[cfg(feature = "ureq")]
|
||||
Error::Ureq(e) => is_ureq_error_permanent(e),
|
||||
Error::IO(e) => is_io_error_permanent(e),
|
||||
// 403 Forbidden suggests IP/geo blocking; 429 and 5xx are transient
|
||||
Error::HttpStatus { status, .. } => *status == 403,
|
||||
@@ -191,28 +191,18 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "minreq")]
|
||||
fn is_minreq_error_permanent(e: &minreq::Error) -> bool {
|
||||
use minreq::Error::*;
|
||||
match e {
|
||||
// DNS resolution failure - likely blocked or misconfigured
|
||||
IoError(io_err) => is_io_error_permanent(io_err),
|
||||
// Check error message for common blocking indicators
|
||||
other => {
|
||||
let msg = format!("{:?}", other);
|
||||
// DNS/connection failures
|
||||
msg.contains("nodename nor servname")
|
||||
|| msg.contains("Name or service not known")
|
||||
|| msg.contains("No such host")
|
||||
|| msg.contains("connection refused")
|
||||
|| msg.contains("Connection refused")
|
||||
// SSL/TLS failures (often due to blocking/MITM)
|
||||
|| msg.contains("certificate")
|
||||
|| msg.contains("SSL")
|
||||
|| msg.contains("TLS")
|
||||
|| msg.contains("handshake")
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "ureq")]
|
||||
fn is_ureq_error_permanent(e: &ureq::Error) -> bool {
|
||||
let msg = format!("{:?}", e);
|
||||
msg.contains("nodename nor servname")
|
||||
|| msg.contains("Name or service not known")
|
||||
|| msg.contains("No such host")
|
||||
|| msg.contains("connection refused")
|
||||
|| msg.contains("Connection refused")
|
||||
|| msg.contains("certificate")
|
||||
|| msg.contains("SSL")
|
||||
|| msg.contains("TLS")
|
||||
|| msg.contains("handshake")
|
||||
}
|
||||
|
||||
fn is_io_error_permanent(e: &std::io::Error) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user