From 5ed42452984293f86c354c47cd7be320e4f635f2 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Wed, 3 Aug 2022 14:21:02 -0700 Subject: [PATCH] Add tor proxy setting to envvars --- .env-sample | 3 +++ api/utils.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.env-sample b/.env-sample index 65f13893..2a83e4ec 100644 --- a/.env-sample +++ b/.env-sample @@ -20,6 +20,9 @@ POSTGRES_PASSWORD='example' POSTGRES_HOST='127.0.0.1' POSTGRES_PORT='5432' +# Tor proxy for remote calls (e.g. fetching prices or sending Telegram messages) +TOR_PROXY='127.0.0.1:9050' + # Auto unlock LND password. Only used in development docker-compose environment. # It will fail starting up the node without it. # To disable auto unlock, comment out 'wallet-unlock-password-file=/tmp/pwd' from 'docker/lnd/lnd.conf' diff --git a/api/utils.py b/api/utils.py index 591a8233..183da3b2 100644 --- a/api/utils.py +++ b/api/utils.py @@ -9,11 +9,13 @@ from api.models import Order logger = logging.getLogger('api.utils') +TOR_PROXY = config('TOR_PROXY', default='127.0.0.1:9050') + def get_tor_session(): session = requests.session() # Tor uses the 9050 port as the default socks port - session.proxies = {'http': 'socks5://127.0.0.1:9050', - 'https': 'socks5://127.0.0.1:9050'} + session.proxies = {'http': 'socks5://' + TOR_PROXY, + 'https': 'socks5://' + TOR_PROXY} return session