[][src]Crate koibumi_socks

This crate is a minimal SOCKS5 client library. Supports async-std only.

Intended to use with a local Tor SOCKS5 proxy. No authentication is supported.

Examples

Connect to the web server at example.net:80 via a local Tor SOCKS5 proxy at 127.0.0.1:9050, issue a GET command, read and print the response:

use async_std::{
    io::{prelude::WriteExt, ReadExt},
    net::TcpStream,
};
use koibumi_socks::{self as socks, DomainName, SocketDomainName};

let mut stream = TcpStream::connect("127.0.0.1:9050").await?;

let destination = socks::SocketAddr::DomainName(
    SocketDomainName::new(
        DomainName::new(b"example.net".to_vec()).unwrap(), 80));

let _dest = socks::connect(&mut stream, destination).await?;

stream.write_all(b"GET /\n").await?;

let mut bytes = Vec::new();
stream.read_to_end(&mut bytes).await?;
print!("{}", String::from_utf8_lossy(&bytes));

Structs

DomainName

This type represents a domain name used by SOCKS5.

SocketDomainName

This type represents a socket address which uses domain name, that is, a domain name with a port.

Enums

Addr

This type represents IPv4, IPv6 address or a domain name used by SOCKS5.

ConnectError

An error which can be returned when connecting to a destination host via SOCKS5 proxy server.

ParseDomainNameError

An error which can be returned when parsing a domain name.

SocketAddr

This type represents a socket address used by SOCKS5.

Functions

connect

Connects to an arbitrary network destination via a SOCKS5 server.

Type Definitions

Result

A specialized Result type for SOCKS5 operations.