Add tor proxy setting to envvars

This commit is contained in:
Reckless_Satoshi 2022-08-03 14:21:02 -07:00
parent 5d711467e5
commit 5ed4245298
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 7 additions and 2 deletions

View File

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

View File

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