Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added benchmark script #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ RUST_LOG=debug cargo run --example server -- --listen-addr 127.0.0.1:1337 passwo
curl -v --proxy socks5://admin:[email protected]: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
Expand Down
45 changes: 45 additions & 0 deletions bench/bench.sh
Original file line number Diff line number Diff line change
@@ -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
65 changes: 65 additions & 0 deletions bench/proxychains.conf
Original file line number Diff line number Diff line change
@@ -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