22 releases (5 breaking)

0.6.5 Apr 2, 2024
0.6.4 Dec 19, 2023
0.5.2 Dec 12, 2023
0.4.7 Dec 11, 2023
0.1.1 Feb 26, 2023

#1608 in Network programming

Download history 297/week @ 2024-02-21 109/week @ 2024-02-28 1/week @ 2024-03-06 21/week @ 2024-03-13 133/week @ 2024-03-27 63/week @ 2024-04-03 2/week @ 2024-04-10

198 downloads per month
Used in synchronous-server

MIT license

45KB
1.5K SLoC

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.

Dependencies

~3–10MB
~83K SLoC