diff options
author | mischief <mischief@offblast.org> | 2014-12-27 23:38:21 -0800 |
---|---|---|
committer | mischief <mischief@offblast.org> | 2014-12-27 23:38:21 -0800 |
commit | 31e1c15d441e38a740b8f209f86b8b2d0fc49d79 (patch) | |
tree | 092cfb1a808ddb5c6fcf2aa93c14f9e9255faffb /rc | |
parent | dc69af5010c1c4860b24d91c7b702ffc199bdf66 (diff) | |
download | plan9front-31e1c15d441e38a740b8f209f86b8b2d0fc49d79.tar.xz |
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.
Diffstat (limited to 'rc')
-rwxr-xr-x | rc/bin/ircrc | 45 |
1 files changed, 18 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 + |