diff --git a/cyphernodeconf_docker/templates/installer/testfeatures.sh b/cyphernodeconf_docker/templates/installer/testfeatures.sh index 9d6565ec0..627c62f52 100644 --- a/cyphernodeconf_docker/templates/installer/testfeatures.sh +++ b/cyphernodeconf_docker/templates/installer/testfeatures.sh @@ -100,7 +100,7 @@ checknotifier() { local response local returncode - response=$(mosquitto_rr -h broker -W 15 -t notifier -e "response/$$" -m "{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"http://proxy:8888/helloworld\",\"torbypass\":true}") + response=$(mosquitto_rr -h broker -W 15 -t notifier -e "response/$$" -m "{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"http://proxy:8888/helloworld\",\"tor\":false}") returncode=$? [ "${returncode}" -ne "0" ] && return 115 http_code=$(echo "${response}" | jq -r ".http_code") diff --git a/notifier_docker/script/web.sh b/notifier_docker/script/web.sh index dcd4cf8f5..390dbb9c5 100644 --- a/notifier_docker/script/web.sh +++ b/notifier_docker/script/web.sh @@ -8,7 +8,7 @@ web() { local msg=${1} local url local body - local torbypass + local tor local returncode local response local result @@ -29,15 +29,15 @@ web() { trace "[web] no body, GET request" fi - torbypass=$(echo ${msg} | jq -e ".torbypass") + tor=$(echo ${msg} | jq -e ".tor") # jq -e will have a return code of 1 if the supplied tag is null. if [ "$?" -ne "0" ]; then - # torbypass tag null - torbypass=false + # tor tag null + tor=false fi - trace "[web] torbypass=${torbypass}" + trace "[web] tor=${tor}" - response=$(curl_it "${url}" "${body}" "${torbypass}") + response=$(curl_it "${url}" "${body}" "${tor}") returncode=$? trace_rc ${returncode} @@ -51,25 +51,25 @@ curl_it() { local url=$(echo "${1}" | tr -d '"') local data=${2} - local torbypass=${3} + local tor=${3} local returncode local response local rnd=$(dd if=/dev/urandom bs=5 count=1 | xxd -pc 5) - if [ "${torbypass}" = "true" ] || [ -z "${TOR_HOST}" ]; then - # If we want to bypass tor or the config file doesn't exist - torbypass="" + if [ "${tor}" = "true" ] && [ -n "${TOR_HOST}" ]; then + # If we want to use tor and the tor host config exists + tor="--socks5-hostname ${TOR_HOST}:${TOR_PORT}" else - torbypass="--socks5-hostname ${TOR_HOST}:${TOR_PORT}" + tor="" fi if [ -n "${data}" ]; then - trace "[curl_it] curl ${torbypass} -o webresponse-${rnd} -m 20 -w \"%{http_code}\" -H \"Content-Type: application/json\" -H \"X-Forwarded-Proto: https\" -d \"${data}\" -k ${url}" - rc=$(curl ${torbypass} -o webresponse-${rnd} -m 20 -w "%{http_code}" -H "Content-Type: application/json" -H "X-Forwarded-Proto: https" -d "${data}" -k ${url}) + trace "[curl_it] curl ${tor} -o webresponse-${rnd} -m 20 -w \"%{http_code}\" -H \"Content-Type: application/json\" -H \"X-Forwarded-Proto: https\" -d \"${data}\" -k ${url}" + rc=$(curl ${tor} -o webresponse-${rnd} -m 20 -w "%{http_code}" -H "Content-Type: application/json" -H "X-Forwarded-Proto: https" -d "${data}" -k ${url}) returncode=$? else - trace "[curl_it] curl ${torbypass} -o webresponse-$$ -m 20 -w \"%{http_code}\" -k ${url}" - rc=$(curl ${torbypass} -o webresponse-${rnd} -m 20 -w "%{http_code}" -k ${url}) + trace "[curl_it] curl ${tor} -o webresponse-$$ -m 20 -w \"%{http_code}\" -k ${url}" + rc=$(curl ${tor} -o webresponse-${rnd} -m 20 -w "%{http_code}" -k ${url}) returncode=$? fi trace "[curl_it] HTTP return code=${rc}" diff --git a/proxy_docker/app/script/notify.sh b/proxy_docker/app/script/notify.sh index d3ac113b9..49792979a 100644 --- a/proxy_docker/app/script/notify.sh +++ b/proxy_docker/app/script/notify.sh @@ -6,7 +6,7 @@ notify_web() { trace "Entering notify_web()..." local url=${1} - local torbypass=${3} + local tor=${3} # Let's encode the body to base64 so we won't have to escape the special chars... local body=$(echo "${2}" | base64 | tr -d '\n') @@ -17,8 +17,8 @@ notify_web() { local curl_code local msg - if [ -n "${torbypass}" ]; then - msg="{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"${url}\",\"body\":\"${body}\",\"torbypass\":${torbypass}}" + if [ -n "${tor}" ]; then + msg="{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"${url}\",\"body\":\"${body}\",\"tor\":${tor}}" else msg="{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"${url}\",\"body\":\"${body}\"}" fi diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index 2d8991117..bc4be006e 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -4,6 +4,7 @@ # # +. ./db/config.sh . ./sendtobitcoinnode.sh . ./callbacks_job.sh . ./watchrequest.sh