diff --git a/README.md b/README.md index e657c4a..f4ad005 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ most to least recommended | :--- | :--- | | telnet | `telnet r0c.int` | | socat | `socat -,raw,echo=0 tcp:r0c.int:531` | +| bash | [mostly internals](clients/bash.sh) | | netcat | `nc r0c.int 531` | -| bash | `exec 147<>/dev/tcp/r0c.int/531; cat <&147 & while read -r x; do printf '%s\n' "$x" >&147; done` | -| powershell | [scrolling is kinda broken](clients/powershell.ps1) +| the oneliner | connecting: `exec 147<>/dev/tcp/r0c.int/531;cat<&147 &while read -rN1 x;do printf '%s' "$x">&147;done` | +| | disconnecting: `exec 147<&-; killall cat #sorry` | +| powershell | [scrolling is kinda broken](clients/powershell.ps1) + +the powershell client is useless because powershell's VT100 implementation is buggy; scrolling sometimes work, sometimes doesn't, high chance you'll miss messages but it's (very slightly) better than nothing diff --git a/clients/bash.sh b/clients/bash.sh new file mode 100644 index 0000000..b37b3e6 --- /dev/null +++ b/clients/bash.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -e + +# -------------------------------------------- +# tcp plaintext client without linebuffering +# -------------------------------------------- +# uses bash internals wherever possible, +# let me know if I missed some opportunities +# -------------------------------------------- + +debug='' +#debug=1 + +cat_pid='' + +function ctrl_c() +{ + kill $cat_pid + exit 0 +} + +function connect() +{ + # hook ctrl-c for cleanup + trap ctrl_c INT + + # open the tcp connection + exec 147<>/dev/tcp/$1/$2 + + # dump socket to stdout + cat <&147 & cat_pid=$! + + # read keyboard and send each key to the socket + while read -rN1 x + do + [[ $debug ]] && + { + printf '%s' "$x" | + tee /dev/stderr 2>&1 >&147 | + xxd -c8 -g1 >> /dev/shm/r0c-log + } || + printf '%s' "$x" >&147 + done +} + +[[ "x$2" == "x" ]] && +{ + echo + echo " r0c client (bash edition)" + echo " need argument 1: r0c server ip or hostname" + echo " need argument 2: r0c server port" + echo + exit 1 +} + +connect $1 $2 diff --git a/doc/todo.md b/doc/todo.md index 8308d4e..affcbf0 100644 --- a/doc/todo.md +++ b/doc/todo.md @@ -28,6 +28,8 @@ the other lists are roughly sorted by importance (and additionally split in two # bugs: whatever +* jump to ch0 on nick change +* powershell's vt100 impl is a glitchy mess * py2 deadlocks on quit with threadcapture running * channel cleanup doesn't happen unless user joins another channel after parting * check for queue buildups in general