commit f3fe187e5d9b0122605261bd50e4c0bf99264fca
parent 981a7b256a80c010c296799a4c1010478a57339a
Author: ingolevin <34458804+ingolevin@users.noreply.github.com>
Date: Tue, 10 Aug 2021 22:05:38 +0200
Add tor_proxy config option (#20)
* Added VS Code IDE and venv folders to .gitignore
* Workaround Issue #8: Downgrade eventlet==0.30.2
* Added VS Code IDE and venv folders to .gitignore
* Rollback .gitignore
* Add python .venv folder to gitignore
* Add missing PySocks to requirements.txt
* Add database.db to .gitignore
* Add explicit tor_proxy (host:port) config.py option to allow non default ports
* Improve ssh/tor clarity
* Add default if tor_proxy is None
Co-authored-by: Ingo Levin <ingo.levin@absolute-bi.com>
Co-authored-by: nickfarrow <nicholas.w.farrow@gmail.com>
Diffstat:
4 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -6,3 +6,5 @@ gateways/__pycache__/
invoice/__pycache__/
pay/__pycache__/
SatSale_API_key
+.venv/
+database.db
+\ No newline at end of file
diff --git a/config.py b/config.py
@@ -15,13 +15,21 @@ wallet = ""
# File in which API key will be stored
api_key_path = "SatSale_API_key"
-# SSH tunnel to node (raspberry pi!)
+
+#### Connect To Remote Node ####
+# Can use SSH or TOR
+# to tunnel/relay ports required to talk to the node via RPC (gRPC for lightning)
+
+# SSH tunnel to node
# Make sure this command works `ssh HOST@IP -q -N -L 8332:localhost:8332`
-# This forwards the ports required to talk to the node via RPC (or gRPC in the case of lightning)
# Use host = "127.0.0.1" and you will be able to see your node on 8332
tunnel_host = None # "HOST@IP"
-# OR TOR HIDDEN SERVICE TO RPC
-tor_bitcoinrpc_host = None
+
+# or tor hidden service for RPC (see docs for how to set up), need onion:
+tor_bitcoinrpc_host = None # e.g. "http://if...dwr.onion"
+# and a tor proxy, default 127.0.0.1:9050 (for Tor Browser use "127.0.0.1:9150")
+tor_proxy = None
+################################
# Check for payment every xx seconds
pollrate = 15
diff --git a/gateways/tor.py b/gateways/tor.py
@@ -7,11 +7,14 @@ import config
time.sleep(3)
-print("Using tor proxies {}:{}".format("localhost", 9050))
+if config.tor_proxy is None:
+ config.tor_proxy = "127.0.0.1:9050"
+
+print("Using tor proxies {}".format(config.tor_proxy))
session = requests.session()
session.proxies = {
- "http": "socks5h://localhost:9050",
- "https": "socks5h://localhost:9050",
+ "http": "socks5h://{}".format(config.tor_proxy),
+ "https": "socks5h://{}".format(config.tor_proxy)
}
print(
diff --git a/requirements.txt b/requirements.txt
@@ -8,6 +8,7 @@ Pillow==8.01.1
protobuf==3.15.6
flask_restplus==0.13.0
Werkzeug==0.16.1
+PySocks=1.7.1
# For lightning (optional)