Files
proxychains-rs/proxychains/src/error.rs
T
TienjuiWongandClaude Opus 4.6 54b225d269 feat: Initialize Rust implementation of proxychains4
This is a modern Rust rewrite of the classic proxychains tool with
enhanced features and better maintainability.

Core Features:
- Multiple proxy protocols: SOCKS4, SOCKS4a, SOCKS5, HTTP CONNECT
- Chain modes: Strict, Dynamic, Random, Load Balance, Failover
- DNS handling: Local resolution, Remote DNS through proxy, Fake IP
- LD_PRELOAD hooks for transparent proxying (Linux/macOS)
- Configuration compatible with original proxychains.conf format

Project Structure:
- proxychains/       - Core library with protocol implementations
- proxychains-bin/   - CLI binary entry point
- libproxychains/    - LD_PRELOAD shared library

Technical Highlights:
- Thread-safe design with parking_lot mutexes
- Clean error handling with thiserror/anyhow
- Structured logging with tracing
- Comprehensive configuration parser

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 08:21:59 +08:00

69 lines
1.4 KiB
Rust

//! Error types for proxychains
use std::io;
use thiserror::Error;
/// Main error type for proxychains operations
#[derive(Error, Debug)]
pub enum Error {
#[error("IO error: {0}")]
Io(#[from] io::Error),
#[error("Configuration error: {0}")]
Config(String),
#[error("Proxy connection failed: {0}")]
ProxyConnection(String),
#[error("Proxy authentication failed: {0}")]
AuthFailed(String),
#[error("Chain error: {0}")]
Chain(String),
#[error("DNS resolution failed: {0}")]
Dns(String),
#[error("Socket error: {0}")]
Socket(String),
#[error("Timeout error: {0}")]
Timeout(String),
#[error("Protocol error: {0}")]
Protocol(String),
#[error("Blocked by proxy")]
Blocked,
#[error("Chain is empty")]
ChainEmpty,
#[error("Memory allocation failed")]
MemoryFail,
#[error("Socket error")]
SocketError,
#[error("Chain is down")]
ChainDown,
#[error("Invalid address")]
InvalidAddress,
#[error("Nix error: {0}")]
Nix(#[from] nix::Error),
#[error("UTF-8 error: {0}")]
Utf8(#[from] std::string::FromUtf8Error),
}
/// Result type alias for proxychains operations
pub type Result<T> = std::result::Result<T, Error>;
impl From<std::ffi::NulError> for Error {
fn from(e: std::ffi::NulError) -> Self {
Error::Config(e.to_string())
}
}