From 3f5b69a5bb4b70594501390f36c022e4f734d353 Mon Sep 17 00:00:00 2001 From: Alexander Fyodorov Date: Tue, 2 Apr 2024 01:53:23 +0400 Subject: [PATCH] added benchmark script --- README.md | 10 +++++++ bench/bench.sh | 45 +++++++++++++++++++++++++++++ bench/proxychains.conf | 65 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100755 bench/bench.sh create mode 100644 bench/proxychains.conf diff --git a/README.md b/README.md index aa1a4d5..ee85e18 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,16 @@ RUST_LOG=debug cargo run --example server -- --listen-addr 127.0.0.1:1337 passwo curl -v --proxy socks5://admin:password@127.0.0.1:1337 https://ipapi.co/json/ ``` +## Benchmarks +`proxychains`, `iperf3` and rust toolchain must be installed + +tested on Ubuntu 22.04 LTS +### run simple benchmark +```bash +cd bench +./bench.sh +``` + ## TODO - Tests have to be implemented - Better Rust doc diff --git a/bench/bench.sh b/bench/bench.sh new file mode 100755 index 0000000..115b96e --- /dev/null +++ b/bench/bench.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +cleanup() { + echo -e "\n------- Closing all processes -------\n" + for PID in $PID1 $PID2 $PID3; do + if kill -0 "$PID" 2>/dev/null; then + kill "$PID" + fi + done + exit 0 +} + +trap cleanup SIGINT SIGTERM + +wait_for_port_open() { + local PORT=$1 + echo "Waiting port $PORT to be open" + until ss -tulwn | grep ":$PORT" > /dev/null; do + sleep 0.1 + done + echo "Port $PORT - listening" +} + +iperf3 -s -1 -i 0 & +PID1=$! + +wait_for_port_open 5201; + +cargo run --release --example server -- --listen-addr 127.0.0.1:1337 no-auth & +PID2=$! + +wait_for_port_open 1337; + +echo -e "\n------- bench client -> server -------\n" +proxychains iperf3 -c 127.0.0.1 -P 4 -i 0 + +iperf3 -s -1 -i 0 & +PID3=$! + +wait_for_port_open 5201; + +echo -e "\n------- bench server -> client -------\n" +proxychains iperf3 -c 127.0.0.1 -P 4 -R -i 0 + +cleanup diff --git a/bench/proxychains.conf b/bench/proxychains.conf new file mode 100644 index 0000000..7a090d7 --- /dev/null +++ b/bench/proxychains.conf @@ -0,0 +1,65 @@ +# proxychains.conf VER 3.1 +# +# HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS. +# + +# The option below identifies how the ProxyList is treated. +# only one option should be uncommented at time, +# otherwise the last appearing option will be accepted +# +#dynamic_chain +# +# Dynamic - Each connection will be done via chained proxies +# all proxies chained in the order as they appear in the list +# at least one proxy must be online to play in chain +# (dead proxies are skipped) +# otherwise EINTR is returned to the app +# +strict_chain +# +# Strict - Each connection will be done via chained proxies +# all proxies chained in the order as they appear in the list +# all proxies must be online to play in chain +# otherwise EINTR is returned to the app +# +#random_chain +# +# Random - Each connection will be done via random proxy +# (or proxy chain, see chain_len) from the list. +# this option is good to test your IDS :) + +# Make sense only if random_chain +#chain_len = 2 + +# Quiet mode (no output from library) +#quiet_mode + +# Proxy DNS requests - no leak for DNS data +proxy_dns + +# Some timeouts in milliseconds +tcp_read_time_out 15000 +tcp_connect_time_out 8000 + +# ProxyList format +# type host port [user pass] +# (values separated by 'tab' or 'blank') +# +# +# Examples: +# +# socks5 192.168.67.78 1080 lamer secret +# http 192.168.89.3 8080 justu hidden +# socks4 192.168.1.49 1080 +# http 192.168.39.93 8080 +# +# +# proxy types: http, socks4, socks5 +# ( auth types supported: "basic"-http "user/pass"-socks ) +# +[ProxyList] +# add proxy here ... +# meanwile +# defaults set to "tor" +socks5 127.0.0.1 1337 +