ircii-ssl
pidfile="/var/tmp/stunnel.$$.$USER.$1.pid"
logfile="/var/tmp/stunnel.$USER.log"
conf="/var/tmp/stunnel.$$.$USER.$1.conf"
random() {
random=`head -c 2 /dev/urandom| od -tu | head -1 \
| awk '{print "(" $2 "/2)-1000+32000" }' | bc`
echo $random
}
create_stunnel_conf() {
port=$1
echo 'client = yes'
echo 'pid = '"$pidfile"
echo 'output = '."$logfile"
echo '[obiircd]'
echo 'accept = localhost:'$port
echo 'connect = irc.pilgerer.org:'9999
}
clean_up() {
kill `head -1 $pidfile`
rm -f "$conf" "$pidfile"
exit;
}
if type stunnel ; then
if [ "`stunnel -version 2>&1 | head -c 9`" != "stunnel 4" ] ; then
echo stunnel version 4 required
exit 2
fi
else
echo stunnel version 4 required
exit 2
fi
if [ -z "$1" ] ; then
echo 'specify your nickname on the commandline';
exit 2
fi
set -e
set -x
trap clean_up 2 3 15 30 31
port=`random`
create_stunnel_conf $port > "$conf"
stunnel "$conf"
sleep 1
irc -p $port $1 localhost
clean_up