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.
This commit is contained in:
mischief 2014-12-27 23:38:21 -08:00
parent dc69af5010
commit 31e1c15d44
2 changed files with 25 additions and 27 deletions

View file

@ -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

View file

@ -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.