aboutsummaryrefslogtreecommitdiff
path: root/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'common.sh')
-rw-r--r--common.sh28
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
+}