udp-ssh-reverse-tunnel - bitreich-gaming-link - bitreich-gaming-link Simple game linking using unix tools.
 (HTM) git clone git://bitreich.org/bitreich-gaming-link git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/bitreich-gaming-link
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
       ---
       udp-ssh-reverse-tunnel (627B)
       ---
            1 #!/bin/bash
            2 
            3 if [ $# -lt 3 ];
            4 then
            5         printf "usage: %s user@sshserver localport remoteport\n" \
            6                 "$(basename "$0")" >&2
            7         exit 1
            8 fi
            9 
           10 sshserver="$1"
           11 localport="$2"
           12 remoteport="$3"
           13 
           14 randinterport=$(($RANDOM % 9000 + 32000))
           15 ssh -R ${randinterport}:localhost:${randinterport} \
           16         ${sshserver} \
           17         "socat -T10 udp4-listen:${remoteport},fork tcp4:localhost:${randinterport}" &
           18 sshpid=$!
           19 socat -T10 tcp4-listen:${randinterport},fork udp4:localhost:${localport} &
           20 socatpid=$!
           21 
           22 printf "Press Enter to exit tunnel.\n"
           23 read -r ${prompt}
           24 kill -HUP $socatpid
           25 kill -HUP $sshpid
           26 ssh ${sshserver} "pkill -HUP -f udp4-listen:${remoteport},fork"
           27