Add option to require Tor for outside API calls

This commit is contained in:
Dennis Reimann 2020-07-10 09:45:53 +02:00
parent 2b180c5f71
commit df178f4e4d
No known key found for this signature in database
GPG key ID: 5009E1797F03F8D0
2 changed files with 7 additions and 0 deletions

View file

@ -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"

View file

@ -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