2 releases
0.0.1 | Jun 26, 2024 |
---|---|
0.0.0 | Jan 6, 2021 |
#16 in #socks
41 downloads per month
Used in 5 crates
(via koibumi-node-sync)
38KB
764 lines
This crate is a minimal SOCKS5 client library (sync version).
The library is intended to be used with a local Tor SOCKS5 proxy.
lib.rs
:
This crate is a minimal SOCKS5 client library (sync version).
The library is intended to be used with a local Tor SOCKS5 proxy.
Examples
Connect to the web server at example.org:80 via a local Tor SOCKS5 proxy at 127.0.0.1:9050, issue a GET command, read and print the response:
#
use std::{
io::{Write, Read},
net::TcpStream,
};
use koibumi_net::{
domain::{Domain, SocketDomain},
socks::SocketAddr as SocksSocketAddr,
};
use koibumi_socks_sync as socks;
let mut stream = TcpStream::connect("127.0.0.1:9050")?;
let destination = SocksSocketAddr::Domain(
SocketDomain::new(
Domain::new("example.org").unwrap(), 80.into()));
let _dest = socks::connect(&mut stream, destination)?;
stream.write_all(b"GET /\n")?;
let mut bytes = Vec::new();
stream.read_to_end(&mut bytes)?;
print!("{}", String::from_utf8_lossy(&bytes));
#