-
Notifications
You must be signed in to change notification settings - Fork 0
/
runbwtest
executable file
·112 lines (96 loc) · 2.15 KB
/
runbwtest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -eu
if [[ -f ~/.runbwtestrc ]]; then
. ~/.runbwtestrc
fi
: ${port:=55522}
: ${serveropts:="-D -d"}
: ${clientopts:="127.0.0.1"}
: ${prefix:=""}
sshOpt=""
sshdOpt=""
alt=0
none=0
inf=0
while getopts ":c:d:ahn0" opt; do
case "${opt}" in
c)
sshOpt="${OPTARG}"
;;
d)
sshdOpt="${OPTARG}"
;;
a)
alt=1;
;;
h)
sshOpt="hpnssh"
sshdOpt="hpnsshd"
;;
n)
none=1;
;;
0)
inf=1;
;;
esac
done
shift $((OPTIND-1))
scriptdir="$(dirname -- "$( readlink -f -- "$0"; )";)"
logfile="${scriptdir}/sshd.log"
ddcmd="${scriptdir}/mwdd"
if [[ -n "${sshOpt}" ]]; then
if [[ "${sshOpt}" == /* ]]; then
sshcmd="${sshOpt}"
else
sshcmd="${prefix}/bin/${sshOpt}"
fi
else
sshcmd="${prefix}/bin/ssh"
fi
if [[ -n "${sshdOpt}" ]]; then
if [[ "${sshdOpt}" == /* ]]; then
sshdcmd="${sshdOpt}"
else
sshdcmd="${prefix}/sbin/${sshdOpt}"
fi
else
rawdir="$(dirname "${sshcmd}")/../sbin"
dir=$(realpath ${rawdir})
file=$(basename "${sshcmd}")
sshdcmd="${dir}/${file}d"
fi
sshddate=$(date -r "${sshdcmd}")
sshdate=$(date -r "${sshcmd}")
echo "Now: $(date)"
echo "Server last modified: ${sshddate}"
echo "Cliend last modified: ${sshdate}"
echo
echo "Starting server..."
cmdopts="${serveropts} -p ${port}"
if [[ ${none} -eq 1 ]]; then
cmdopts="${cmdopts} -o NoneEnabled=yes -o NoneMacEnabled=yes"
fi
echo "\""${sshdcmd}"\"" ${cmdopts} "&>""${logfile}"
"${sshdcmd}" ${cmdopts} &>"${logfile}" &
echo "Backgrounded. Writing log to \"${logfile}\"."
echo
sleep 3
echo "Starting client..."
cmdopts="${clientopts} -p ${port}"
if [[ ${none} -eq 1 ]]; then
cmdopts="${cmdopts} -o NoneEnabled=yes -o NoneMacEnabled=yes -o NoneSwitch=yes"
else
cmdopts="${cmdopts} -c chacha20-poly1305@openssh.com"
fi
ddopts="bs=1M iflag=fullblock"
if [[ ${inf} == "0" ]]; then
ddopts="${ddopts} count=51200"
fi
if [[ ${alt} == "0" ]]; then
echo "dd if=/dev/zero ${ddopts} | \"${sshcmd}\" ${cmdopts} \"cat - > /dev/null\""
${ddcmd} if=/dev/zero ${ddopts} | "${sshcmd}" ${cmdopts} "cat - > /dev/null"
else
echo "\"${sshcmd}\" ${cmdopts} \"dd of=/dev/null ${ddopts}\" < /dev/zero"
"${sshcmd}" ${cmdopts} "${ddcmd} of=/dev/null ${ddopts}" < /dev/zero
fi