Skip to content

nullclyze/zeloxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zeloxy

Russian Documentation | English Documentation | Examples | License

A Rust library for working with various proxies.

Supported proxy types:

  • HTTP (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 proxies reordering in chain on error
  • Built-in proxy stream
  • Proxy lookup
  • Proxy ping
  • Proxy stealth check

Examples

Current examples can be found here: browse

Create a HTTP proxy stream

use zeloxy::{GetRequestOpts, Proxy, ProxyResult, ProxyStream, ProxyType};

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

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

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

  // Отправляем GET-запрос на example.com
  let resp = stream.get_request("example.com", GetRequestOpts::default()).await?;

  // Логгируем ответ
  println!("Ответ от example.com: {}", resp);

  Ok(())
}

Connect to SOCKS5 proxy

use zeloxy::{Proxy, ProxyResult};

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

  // Подключаемся к прокси и логгируем результат
  match proxy.connect("ipinfo.io", 80).await {
    ProxyResult::Ok(_) => {
      println!("Подключение установлено");
    }
    ProxyResult::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 chain = ProxyChain::from(proxies);

  // Подключаемся к целевому серверу через цепочку
  let mut stream = chain.connect("ipinfo.io", 80).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(())
}

About

Create lightweight, asynchronous, and lag-free proxy connections.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages