zeloxy 0.4.0

A library for creating lightweight, async, and lag-free proxy connections.
Documentation

Zeloxy

Russian Documentation | English Documentation | Examples | License

A Rust library for working with various proxies.

Supported proxy protocols:

  • HTTP (without auth / with basic auth)
  • HTTPS (without auth / with basic auth)
  • SOCKS5 (without auth / with user / pass auth)
  • SOCKS4 (without auth / with ident auth)

Focusing

  • Lightweight: This crate does not use unnecessary dependencies and useless functionality.
  • Simplicity: This crate contains clear and logical functionality with examples.
  • Built-in: This crate offers built-in tools for convenient proxy management.
  • Asynchrony: This crate is based on an asynchronous environment.
  • Lag-free: This crate limits almost all operations with timeouts to prevent lags / freezes.

Tasks and Goals

  • SOCKS4 proxy support
  • SOCKS5 proxy support
  • HTTP proxy support
  • HTTPS proxy support
  • Basic authorizations support
  • Proxy chain implementation
  • Automatic reordering of proxy chain on error
  • Built-in proxy stream
  • Proxy scraper
  • Proxy lookup
  • Proxy ping
  • Proxy stealth check

Include

In Cargo.toml:

[dependencies]
zeloxy = { version = "0.4.0", features = ["all"] }

Information about available features: read

Examples

Current examples can be found here: browse

Create a HTTP proxy stream

use zeloxy::{Proxy, ProxyResult, ProxyStream, ProxyProtocol};

#[tokio::main]
async fn main() -> ProxyResult<()> {
  // Создаём HTTP-прокси (в данном примере используется публичный прокси)
  let proxy = Proxy::new("91.132.92.231:80", ProxyProtocol::Http);

  // Создаём поток с прокси
  let stream = ProxyStream::new(proxy);

  // Подключаемся к целевому серверу
  stream.connect("example.com", 80).await?;

  // Отправляем GET-запрос на example.com
  let buf = "GET / HTTP/1.0\r\nHost: example.com\r\n\r\n".as_bytes();
  stream.write(buf).await?;

  // Читаем ответ и логгируем его
  let mut resp = Vec::new();
  stream.read_to_end(&mut resp).await?;
  println!("Ответ от example.com: {}", String::from_utf8_lossy(&resp));

  Ok(())
}

Connect to SOCKS5 proxy

use zeloxy::Proxy;

#[tokio::main]
async fn main() {
  // Создаём SOCKS5-прокси (в данном примере используется публичный прокси)
  let proxy = Proxy::from("socks5://212.58.132.5:1080");

  // Подключаемся к прокси и логгируем результат
  match proxy.connect("ipinfo.io", 80).await {
    Ok(_) => {
      println!("Подключение установлено");
    }
    Err(e) => {
      println!("Ошибка подключения: {:?}", e);
    }
  }
}

Create a proxy chain

use tokio::io::{AsyncReadExt, AsyncWriteExt};
use zeloxy::{Proxy, ProxyChain, ProxyResult};

#[tokio::main]
async fn main() -> ProxyResult<()> {
  // Создаём список прокси
  let proxies = vec![
    "socks4://98.181.137.83:4145",
    "socks4://98.170.57.249:4145",
    "socks5://212.58.132.5:1080",
  ];

  // Создаём цепочку прокси
  let mut chain = ProxyChain::from(proxies);

  // Подключаемся к целевому серверу через цепочку
  let mut stream = chain.connect("ipinfo.io", 80, false).await?;

  // Отправляем GET-запрос
  stream.write_all(b"GET / HTTP/1.0\r\nHost: ipinfo.io\r\n\r\n").await?;

  // Читаем ответ (в данном случае информация об IP)
  let mut resp = Vec::new();
  stream.read_to_end(&mut resp).await?;

  // Логгируем выходной IP (здесь должно быть { "ip": "212.58.132.5:1080" })
  println!("Выход: {}", String::from_utf8_lossy(&resp));

  Ok(())
}