From df178f4e4d19ff324dc8f62dae993df89193aee8 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Fri, 10 Jul 2020 09:45:53 +0200 Subject: [PATCH] Add option to require Tor for outside API calls --- server/.env.sample | 3 +++ server/data.sh | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/server/.env.sample b/server/.env.sample index a238994..aaa4f3f 100644 --- a/server/.env.sample +++ b/server/.env.sample @@ -1,6 +1,9 @@ # Server port DISPLAY_SERVER_PORT=3030 +# Require Tor for outside API calls +DISPLAY_FORCE_TOR=false + # Bitcoin RPC credentials for getting the blockcount. # Omit these setting to use blockchain.info as a fallback. # DISPLAY_BITCOIN_RPC_USER="bitcoin-rpc-user" diff --git a/server/data.sh b/server/data.sh index 84c0b1e..435d960 100755 --- a/server/data.sh +++ b/server/data.sh @@ -13,6 +13,10 @@ torCheck=$(torsocks curl -s https://check.torproject.org/ 2>/dev/null | grep -c if [ ${torCheck} -gt 0 ]; then tor="torsocks" fi +if [[ -z "${tor}" && ${DISPLAY_FORCE_TOR} = true ]]; then + echo >&2 'Tor is required, but not available.' + exit 1 +fi # Get block height using RPC connection or Blockchain.info as fallback if [[ "${DISPLAY_BITCOIN_RPC_USER}" && "${DISPLAY_BITCOIN_RPC_PASS}" ]]; then