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:
parent
dc69af5010
commit
31e1c15d44
2 changed files with 25 additions and 27 deletions
45
rc/bin/ircrc
45
rc/bin/ircrc
|
@ -10,6 +10,7 @@ clonefile=/net/tcp/clone
|
||||||
netdir=()
|
netdir=()
|
||||||
nick=$user
|
nick=$user
|
||||||
pass=()
|
pass=()
|
||||||
|
tls=0
|
||||||
|
|
||||||
fn sighup {
|
fn sighup {
|
||||||
exit 'hang up'
|
exit 'hang up'
|
||||||
|
@ -40,11 +41,8 @@ fn work {
|
||||||
}
|
}
|
||||||
if(~ $target *,*)
|
if(~ $target *,*)
|
||||||
target = `{echo $target | awk -F',' '{print $NF}'}
|
target = `{echo $target | awk -F',' '{print $NF}'}
|
||||||
while () {
|
while (cmd=`{read}) {
|
||||||
cmd=`{read}
|
|
||||||
s=$status
|
s=$status
|
||||||
if(! ~ `{cat $netdir/status} *Established*)
|
|
||||||
exit
|
|
||||||
if(~ $s *eof) {
|
if(~ $s *eof) {
|
||||||
echo QUIT : Leaving... > $netdir/data
|
echo QUIT : Leaving... > $netdir/data
|
||||||
exit
|
exit
|
||||||
|
@ -165,12 +163,7 @@ fn privmsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pretty {
|
fn pretty {
|
||||||
while (~ `{cat $netdir/status} *Established*) {
|
while (line=`{read}) {
|
||||||
if(! line=`{read}) {
|
|
||||||
echo Connection lost
|
|
||||||
date
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
switch ($line) {
|
switch ($line) {
|
||||||
case *PRIVMSG*
|
case *PRIVMSG*
|
||||||
line = `{echo -n $line | privmsg}
|
line = `{echo -n $line | privmsg}
|
||||||
|
@ -190,10 +183,6 @@ fn pretty {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
fn getip {
|
|
||||||
echo $1 ip | ndb/dnsquery | sed 1q | awk '{print $NF}'
|
|
||||||
}
|
|
||||||
|
|
||||||
fn title {
|
fn title {
|
||||||
if (! ~ $#winid 0) {
|
if (! ~ $#winid 0) {
|
||||||
if (test -f /mnt/acme/$winid/ctl)
|
if (test -f /mnt/acme/$winid/ctl)
|
||||||
|
@ -217,8 +206,10 @@ while (~ $1 -*) {
|
||||||
case -t
|
case -t
|
||||||
target=$2
|
target=$2
|
||||||
shift
|
shift
|
||||||
|
case -T
|
||||||
|
tls=1
|
||||||
case -*
|
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'
|
exit 'usage'
|
||||||
}
|
}
|
||||||
shift
|
shift
|
||||||
|
@ -235,12 +226,6 @@ if (~ $#* 1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ip=`{getip $server}
|
|
||||||
if (~ $#ip 0) {
|
|
||||||
echo cant translate $server
|
|
||||||
exit 'unknown host'
|
|
||||||
}
|
|
||||||
|
|
||||||
title
|
title
|
||||||
userpass=`{auth/userpasswd 'server='^$server^' service=irc user='^$nick >[2]/dev/null}
|
userpass=`{auth/userpasswd 'server='^$server^' service=irc user='^$nick >[2]/dev/null}
|
||||||
if(~ $#userpass 2 && ~ $nick $user) {
|
if(~ $#userpass 2 && ~ $nick $user) {
|
||||||
|
@ -248,10 +233,16 @@ if(~ $#userpass 2 && ~ $nick $user) {
|
||||||
pass=$userpass(2)
|
pass=$userpass(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
<[4] $clonefile {
|
p='/n/ircrc'
|
||||||
netdir=`{basename -d $clonefile} ^ / ^ `{cat /fd/4}
|
bind '#|' $p
|
||||||
echo connect $ip!$port >$netdir/ctl || exit 'cannot connect'
|
echo connecting to tcp!$server!$port...
|
||||||
echo connected to tcp!$ip!$port on $netdir
|
if(~ $tls 0){
|
||||||
cat $netdir/data | tr -d '\x2\xd\x1f' | pretty &
|
aux/trampoline tcp!$server!$port <>$p/data1 >[1=0] &
|
||||||
work
|
|
||||||
}
|
}
|
||||||
|
if not {
|
||||||
|
tlsclient tcp!$server!$port <>$p/data1 >[1=0] &
|
||||||
|
}
|
||||||
|
netdir=$p
|
||||||
|
cat $netdir/data | tr -d '\x2\xd\x1f' | pretty &
|
||||||
|
work
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ ircrc \- internet relay chat client
|
||||||
.I nick
|
.I nick
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
.B -T
|
||||||
|
] [
|
||||||
.I server
|
.I server
|
||||||
]
|
]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -60,6 +62,11 @@ unless they are commands.
|
||||||
.BI -n " nick
|
.BI -n " nick
|
||||||
Change the default nickname
|
Change the default nickname
|
||||||
.RB ( $user ).
|
.RB ( $user ).
|
||||||
|
.TP
|
||||||
|
.BI -T
|
||||||
|
.br
|
||||||
|
Use tls through
|
||||||
|
.IR tlsclient(8) .
|
||||||
.SS Commands
|
.SS Commands
|
||||||
.I Ircrc
|
.I Ircrc
|
||||||
commands begin with a slash.
|
commands begin with a slash.
|
||||||
|
|
Loading…
Reference in a new issue