]>
Commit | Line | Data |
---|---|---|
1768a611 | 1 | # $OpenBSD: dynamic-forward.sh,v 1.2 2003/07/03 08:21:46 markus Exp $ |
78b2dd04 | 2 | # Placed in the Public Domain. |
3 | ||
4 | tid="dynamic forwarding" | |
5 | ||
6 | PORT=4242 | |
7 | FWDPORT=4243 | |
8 | ||
9 | if [ -x `which nc` ] && nc -h 2>&1 | grep "x proxy address" >/dev/null; then | |
10 | proxycmd="nc -x 127.0.0.1:$FWDPORT -X" | |
11 | elif [ -x `which connect` ]; then | |
12 | proxycmd="connect -S 127.0.0.1:$FWDPORT -" | |
13 | else | |
14 | echo "skipped (no suitable ProxyCommand found)" | |
15 | exit 0 | |
16 | fi | |
17 | trace "will use ProxyCommand $proxycmd" | |
18 | ||
19 | start_sshd | |
20 | ||
21 | for p in 1 2; do | |
78b2dd04 | 22 | trace "start dynamic forwarding, fork to background" |
1768a611 | 23 | ${SSH} -$p -F $OBJ/ssh_config -f -D $FWDPORT -q somehost \ |
24 | exec sh -c \'"echo \$\$ > $OBJ/remote_pid; exec sleep 444"\' | |
78b2dd04 | 25 | |
1768a611 | 26 | for s in 4 5; do |
27 | for h in 127.0.0.1 localhost; do | |
28 | trace "testing ssh protocol $p socks version $s host $h" | |
29 | ${SSH} -F $OBJ/ssh_config \ | |
30 | -o "ProxyCommand ${proxycmd}${s} $h $PORT" \ | |
31 | somehost cat /bin/ls > $OBJ/ls.copy | |
32 | test -f $OBJ/ls.copy || fail "failed copy /bin/ls" | |
33 | cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls" | |
34 | done | |
35 | done | |
78b2dd04 | 36 | |
1768a611 | 37 | if [ -f $OBJ/remote_pid ]; then |
38 | remote=`cat $OBJ/remote_pid` | |
39 | trace "terminate remote shell, pid $remote" | |
40 | if [ $remote -gt 1 ]; then | |
41 | kill -HUP $remote | |
42 | fi | |
43 | else | |
44 | fail "no pid file: $OBJ/remote_pid" | |
45 | fi | |
78b2dd04 | 46 | done |