From 57d2e809972f25ccdd9f1afe6088199cbf975cb8 Mon Sep 17 00:00:00 2001 From: David Timber Date: Fri, 25 Oct 2024 23:39:16 +0200 Subject: Initial commit --- common.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 common.sh (limited to 'common.sh') diff --git a/common.sh b/common.sh new file mode 100644 index 0000000..d07a69f --- /dev/null +++ b/common.sh @@ -0,0 +1,28 @@ +open_db () { + cat bangbang - | nc whois.radb.net 43 +} + +extract_answer () { + set -e + local c + local l + local eot + + while read l + do + c="${l:0:1}" + + if [ "$c" == "A" ]; then + c="${l:1}" + read -N "$c" l + # consume "C" + read eot && [ "$eot" == "C" ] || echo "Protocol error" >&2 || exit 1 + printf '%s\0' "$l" + elif [ "$c" == "%" ]; then + read + printf '\0' + elif [ "$c" == "D" ]; then + printf '\0' + fi + done +} -- cgit