From 8ad148b34b2af334e4705ddf21cb602757d2c536 Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Fri, 15 Oct 2021 01:24:12 -0400 Subject: [PATCH] send protocol version # for checking compatibility the protocol version number allows us to print errors about mismatched versions if the client-server API changes in the future --- kaya | 4 ++++ kaya-client | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/kaya b/kaya index 17e6e33..41a44cb 100755 --- a/kaya +++ b/kaya @@ -24,6 +24,9 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR +# first stable version of API between kaya and kaya-client +kaya_protocol_version=1 + kaya-usage() { cat << EOF >&2 @@ -134,6 +137,7 @@ start-backup() { # make the backup over a forwarded port cat << EOF | ssh -R "${remote_port}:localhost:${local_port}" "${remote_user}@${hostname}" kaya-client \ "${remote_port@Q}" "${hostname@Q}" "${backup_options[@]@Q}" +${kaya_protocol_version} ${password} EOF diff --git a/kaya-client b/kaya-client index e57cd61..f8e2ff6 100755 --- a/kaya-client +++ b/kaya-client @@ -23,6 +23,14 @@ shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR +read -r kaya_protocol_version + +if [[ $kaya_protocol_version != 1 ]] ; then + echo "kaya-client: error: mismatched protocol version with kaya" >&2 + echo "kaya-client: error: kaya protocol version: ${kaya_protocol_version} kaya-client protocol version: 1" >&2 + exit 1 +fi + read -r password port="$1" -- 2.25.1