From eeecdf4f8c4035e5e5cc07437705a5b3a440297e Mon Sep 17 00:00:00 2001 From: yubiuser Date: Sun, 11 May 2025 21:28:18 +0200 Subject: [PATCH] Revert response code logic Signed-off-by: yubiuser --- padd.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/padd.sh b/padd.sh index 2ace59f..f5602c4 100755 --- a/padd.sh +++ b/padd.sh @@ -162,33 +162,33 @@ TestAPIAvailability() { authData=$(printf %s "${authResponse%???}") # Test if http status code was 200 (OK) or 401 (authentication required) - if [ ! "${authStatus}" = 200 ] && [ ! "${authStatus}" = 401 ]; then - # API is not available at this port/protocol combination - apiAvailable=false - else - # API is available at this URL combination - - if [ "${authStatus}" = 200 ]; then - # API is available without authentication - needAuth=false - fi + if [ "${authStatus}" = 200 ]; then + # API is available without authentication + apiAvailable=true + needAuth=false + break + elif [ "${authStatus}" = 401 ]; then + # API is available with authentication + apiAvailable=true + needAuth=true # Check if 2FA is required needTOTP=$(echo "${authData}"| jq --raw-output .session.totp 2>/dev/null) - - apiAvailable=true break - fi + else + # API is not available at this port/protocol combination + apiAvailable=false - # Remove the first URL from the list - local last_api_list - last_api_list="${chaos_api_list}" - chaos_api_list="${chaos_api_list#* }" + # Remove the first URL from the list + local last_api_list + last_api_list="${chaos_api_list}" + chaos_api_list="${chaos_api_list#* }" - # If the list did not change, we are at the last element - if [ "${last_api_list}" = "${chaos_api_list}" ]; then - # Remove the last element - chaos_api_list="" + # If the list did not change, we are at the last element + if [ "${last_api_list}" = "${chaos_api_list}" ]; then + # Remove the last element + chaos_api_list="" + fi fi done