From 56189b724a87dd14dde990775026bae6e9d62ecb Mon Sep 17 00:00:00 2001 From: Timothe Litt Date: Tue, 16 May 2017 08:05:30 -0400 Subject: [PATCH] Add option for full protocol trace -t FILE (or GODADDY_TFILE=FILE) will append command arguments and all wire traffic to a file. This provides all the information needed for debugging future issues. --- dns_scripts/dns_godaddy | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/dns_scripts/dns_godaddy b/dns_scripts/dns_godaddy index 0e6454c..ff25449 100755 --- a/dns_scripts/dns_godaddy +++ b/dns_scripts/dns_godaddy @@ -2,7 +2,8 @@ # Copyright (2017) Timothe Litt litt at acm _dot org -VERSION="1.0.0" +VERSION="1.0.1" +PROG="`basename $0`" # This script is used to update TXT records in GoDaddy DNS server # It depends on JSON.sh from https://github.com/dominictarr/JSON.sh @@ -28,19 +29,20 @@ DEBUG="$GODADDY_DEBUG" [ -z "$JSON" ] && JSON="$GODADDY_JSON" [ -z "$JSON" ] && JSON="`dirname $0`/JSON.sh" -while getopts 'dhj:k:s:qv' opt; do +while getopts 'dhj:k:s:t:qv' opt; do case $opt in d) DEBUG="Y" ;; j) JSON="$OPTARG" ;; k) GODADDY_KEY="$OPTARG" ;; s) GODADDY_SECRET="$OPTARG" ;; + t) TRACE="$OPTARG" ;; q) VERB= ;; v) echo "dns_godaddy version $VERSION"; exit 0 ;; *) cat <&2 + echo "$PROG: $op $domain $name \"$data\" $ttl" >&2 # Authorization header has secret and key authhdr="Authorization: sso-key $GODADDY_KEY:$GODADDY_SECRET" +if [ -n "$TRACE" ]; then + function timestamp { local tm="`date '+%T:%S%N'`" + local class="$1"; shift + echo "${tm:0:15} ** ${class}: $*" >>"$TRACE" + } + timestamp 'Info' "$PROG" "V$VERSION" 'Starting new protocol trace' + timestamp 'Args' "$@" + function curl { + command curl --trace-time --trace-ascii % "$@" 2>>"$TRACE" + } + [ -n "$VERB" ] && echo "Appending protocol trace to $TRACE" +fi + [ -n "$DEBUG" ] && echo "$authhdr" >&2 if [ "$op" = "add" ]; then