proxy-server

Crates.ioproxy-server
lib.rsproxy-server
version0.6.5
sourcesrc
created_at2023-02-26 04:51:09.098895
updated_at2024-04-02 05:22:21.669857
descriptionLow level proxy server
homepage
repositoryhttps://github.com/kolserdav/proxy-server
max_upload_size
id794844
size53,165
Sergei Kol'miller (kolserdav)

documentation

README

proxy-server

Low level proxy server. To implement request proxying, only standard TcpStream was used without additional libraries.

Examples

With default params:

use proxy_server::Builder;

fn main() {
	Builder::new().bind().expect("Error in proxy");
}

With custom params:

use proxy_server::{log::LogLevel, Builder};

fn main() {
	Builder::new()
		.with_address("127.0.0.1:3000")
		.with_target("127.0.0.1:3001")
		.with_log_level(LogLevel::Warn)
		.with_threads(4)
		.bind()
		.expect("Error in proxy");
}

With check and change target if needed on ev ery request

fn get_actual_target(old: &str) -> &'static str {
	let target1 = "127.0.0.1:3001";
	let target2 = "127.0.0.1:3003";
	let res = match old {
		"127.0.0.1:3001" => target2,
		"127.0.0.1:3003" => target1,
		_ => target1,
	};
	res
}

fn main() {
	let cb: ChangeTarget = |old| get_actual_target(old);
	Builder::new()
		.bind(Some(cb))
       	.expect("Error in proxy");
}

Versioning

This package follows the Semantic Versioning (SemVer) scheme. See the CHANGELOG for release history.

Commit count: 73

cargo fmt