diff options
author | David Timber <dxdt@dev.snart.me> | 2024-10-25 23:39:16 +0200 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2024-10-25 23:39:16 +0200 |
commit | 57d2e809972f25ccdd9f1afe6088199cbf975cb8 (patch) | |
tree | 58933f046b1e32de389b36c3920b20bdc3a34dbc /common.sh |
Initial commit
Diffstat (limited to 'common.sh')
-rw-r--r-- | common.sh | 28 |
1 files changed, 28 insertions, 0 deletions
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 +} |