Crates.io | qproxy |
lib.rs | qproxy |
version | 0.2.7 |
source | src |
created_at | 2024-04-08 15:38:37.257524 |
updated_at | 2024-04-12 14:37:25.323655 |
description | A simple forward proxy server written in Rust |
homepage | https://github.com/quannadev/qproxy |
repository | https://github.com/quannadev/qproxy |
max_upload_size | |
id | 1200453 |
size | 154,524 |
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.
cargo build --release
./target/release/qproxy <port> <proxy>
./target/release/qproxy -p 8080 --proxy ip:port:username:password
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())
}
socks5://127.0.0.1:8080