qproxy

Crates.ioqproxy
lib.rsqproxy
version0.2.7
sourcesrc
created_at2024-04-08 15:38:37.257524
updated_at2024-04-12 14:37:25.323655
descriptionA simple forward proxy server written in Rust
homepagehttps://github.com/quannadev/qproxy
repositoryhttps://github.com/quannadev/qproxy
max_upload_size
id1200453
size154,524
Quân Nguyễn (quannadev)

documentation

README

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

image

Commit count: 23

cargo fmt