From 31e1c15d441e38a740b8f209f86b8b2d0fc49d79 Mon Sep 17 00:00:00 2001 From: mischief Date: Sat, 27 Dec 2014 23:38:21 -0800 Subject: [PATCH] ircrc: use aux/trampoline or tlsclient for connections, add -T flag for tls previously ircrc dialed through /net itself and resolved ips on its own. this prevented the use of an ip address, and also prevented use of ipv6. now you can use an ip, or a dns name that resolves to ipv6. the -T flag is also added to use tlsclient for encrypted connections. --- rc/bin/ircrc | 45 ++++++++++++++++++--------------------------- sys/man/1/ircrc | 7 +++++++ 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/rc/bin/ircrc b/rc/bin/ircrc index 638565dd7..b0de9bc8a 100755 --- a/rc/bin/ircrc +++ b/rc/bin/ircrc @@ -10,6 +10,7 @@ clonefile=/net/tcp/clone netdir=() nick=$user pass=() +tls=0 fn sighup { exit 'hang up' @@ -40,11 +41,8 @@ fn work { } if(~ $target *,*) target = `{echo $target | awk -F',' '{print $NF}'} - while () { - cmd=`{read} + while (cmd=`{read}) { s=$status - if(! ~ `{cat $netdir/status} *Established*) - exit if(~ $s *eof) { echo QUIT : Leaving... > $netdir/data exit @@ -165,12 +163,7 @@ fn privmsg { } fn pretty { - while (~ `{cat $netdir/status} *Established*) { - if(! line=`{read}) { - echo Connection lost - date - exit - } + while (line=`{read}) { switch ($line) { case *PRIVMSG* line = `{echo -n $line | privmsg} @@ -190,10 +183,6 @@ fn pretty { exit } -fn getip { - echo $1 ip | ndb/dnsquery | sed 1q | awk '{print $NF}' -} - fn title { if (! ~ $#winid 0) { if (test -f /mnt/acme/$winid/ctl) @@ -217,8 +206,10 @@ while (~ $1 -*) { case -t target=$2 shift + case -T + tls=1 case -* - echo 'usage: ircrc [-p port] [-r realname] [-t target] [-n nick] [server]' >[1=2] + echo 'usage: ircrc [-p port] [-r realname] [-t target] [-n nick] [-T] [server]' >[1=2] exit 'usage' } shift @@ -235,12 +226,6 @@ if (~ $#* 1) { } } -ip=`{getip $server} -if (~ $#ip 0) { - echo cant translate $server - exit 'unknown host' -} - title userpass=`{auth/userpasswd 'server='^$server^' service=irc user='^$nick >[2]/dev/null} if(~ $#userpass 2 && ~ $nick $user) { @@ -248,10 +233,16 @@ if(~ $#userpass 2 && ~ $nick $user) { pass=$userpass(2) } -<[4] $clonefile { - netdir=`{basename -d $clonefile} ^ / ^ `{cat /fd/4} - echo connect $ip!$port >$netdir/ctl || exit 'cannot connect' - echo connected to tcp!$ip!$port on $netdir - cat $netdir/data | tr -d '\x2\xd\x1f' | pretty & - work +p='/n/ircrc' +bind '#|' $p +echo connecting to tcp!$server!$port... +if(~ $tls 0){ + aux/trampoline tcp!$server!$port <>$p/data1 >[1=0] & } +if not { + tlsclient tcp!$server!$port <>$p/data1 >[1=0] & +} +netdir=$p +cat $netdir/data | tr -d '\x2\xd\x1f' | pretty & +work + diff --git a/sys/man/1/ircrc b/sys/man/1/ircrc index fbcee5e95..7f14fd46d 100644 --- a/sys/man/1/ircrc +++ b/sys/man/1/ircrc @@ -20,6 +20,8 @@ ircrc \- internet relay chat client .I nick ] [ +.B -T +] [ .I server ] .SH DESCRIPTION @@ -60,6 +62,11 @@ unless they are commands. .BI -n " nick Change the default nickname .RB ( $user ). +.TP +.BI -T +.br +Use tls through +.IR tlsclient(8) . .SS Commands .I Ircrc commands begin with a slash.