8 releases
0.2.7 | Apr 12, 2024 |
---|---|
0.2.6 | Apr 12, 2024 |
0.1.6 | Apr 9, 2024 |
#1444 in Network programming
95KB
572 lines
QProxy
QProxy is a simple proxy server that can be used to forward requests to a different server. It is written in Rust and uses the socket
module to create a server that listens for incoming connections. When a connection is received, the server reads the request and forwards it to the specified server. The response from the server is then sent back to the client.
Usage
cargo build --release
./target/release/qproxy <port> <proxy>
Example
./target/release/qproxy -p 8080 --proxy ip:port:username:password
Code Example
use clap::Parser;
use tokio::time;
use qproxy::{Config, ForwardProxy};
pub struct Config {
#[arg(short, long, default_value_t = 8080)]
pub port: i16,
#[arg(long)]
pub proxy: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = Config::parse();
let server = ForwardProxy::try_from((config.port as u16, config.proxy))?;
let server_clone = server.clone();
tokio::spawn(async move {
time::sleep(time::Duration::from_secs(4)).await;
server_clone.stop();
});
server.start().map_err(|e| e.into())
}
Config FireFox Proxy
socks5://127.0.0.1:8080
Dependencies
~8–20MB
~282K SLoC