From 737597bf3b8693dcca84de678abb3cea27a990ab Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Tue, 4 Apr 2023 07:48:41 +0200 Subject: [PATCH] pdns error handling added --- pdns-get | 10 ++++++++-- pdns-proxy | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pdns-get b/pdns-get index 38a57f0..cd47090 100755 --- a/pdns-get +++ b/pdns-get @@ -1,4 +1,10 @@ -#!/bin/sh +#!/bin/bash # -wget -O - stdout http://pdns.mount-mockery.de 2> /dev/null|jq .$1 +IP=`wget -O - stdout http://pdns.mount-mockery.de 2> /dev/null|jq .$1` +if [[ "$IP" = "null" ]]; then + echo No IP found for host $1. + exit 1 +else + echo $IP +fi diff --git a/pdns-proxy b/pdns-proxy index 30268bc..09e34d7 100755 --- a/pdns-proxy +++ b/pdns-proxy @@ -1,5 +1,8 @@ -#/bin/sh +#/bin/bash # HOST=`pdns-get $1` -socat stdio tcp:$HOST:22 - +if [[ $? -eq 0 ]]; then + socat stdio tcp:$HOST:22 +else + >&2 echo CONNECTION ERROR: IP of host $1 is unknown. +fi