Initial commit.
This commit is contained in:
commit
9e9d3ef1a7
5
LICENSE
Normal file
5
LICENSE
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Copyright (C) 2024 by bedohswe bedohswe@firemail.cc
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Client for the [Sugoma's RAC protocol](https://bedohswe.eu.org/text/rac/protocol.md.html).
|
||||||
|
There's no help, figure everythin out by yourself.
|
61
dobroho_vechora.bash
Executable file
61
dobroho_vechora.bash
Executable file
@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
ip="${1}"
|
||||||
|
port="${2}"
|
||||||
|
[ -z "${ip}" ] && print_usage 'No IP given.'
|
||||||
|
[ -z "${port}" ] && print_usage 'No port given.'
|
||||||
|
[ -z "${3}" ] || print_usage 'Too many arguments.'
|
||||||
|
get_termsize() {
|
||||||
|
echo "`expr $(stty -a < $(tty) | grep -Po '(?<=rows )\d+') - 1`"
|
||||||
|
}
|
||||||
|
print_usage() {
|
||||||
|
echo "${1}"
|
||||||
|
echo "${0} <IP> <PORT>"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
send_message() {
|
||||||
|
exec 3<> "/dev/tcp/${ip}/${port}"
|
||||||
|
echo "${1}" >&3
|
||||||
|
exec 3>&-
|
||||||
|
}
|
||||||
|
|
||||||
|
get_message() {
|
||||||
|
exec 3<> "/dev/tcp/${ip}/${port}"
|
||||||
|
echo "${1}" >&3
|
||||||
|
timeout 1s cat <&3 || true
|
||||||
|
exec 3>&-
|
||||||
|
}
|
||||||
|
|
||||||
|
while :; do
|
||||||
|
read cmd
|
||||||
|
case "${cmd}" in
|
||||||
|
i)
|
||||||
|
b=""
|
||||||
|
while :; do
|
||||||
|
read c
|
||||||
|
[[ "${c}" != "." ]] || break
|
||||||
|
if [ -z ${b} ]; then
|
||||||
|
b="${c}"
|
||||||
|
else
|
||||||
|
b="${b}"$'\n'"${c}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
send_message 0"${b}"
|
||||||
|
;;
|
||||||
|
I)
|
||||||
|
read a
|
||||||
|
send_message 0"${a}"
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
send_message 1
|
||||||
|
get_message 2
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo ?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user