SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 02ac078858ffbd7fb095b100ba9528b3b18037bd
parent 52b9eb7e0afa250fff5353b41200c95a29b8bdc8
Author: steepdawn974 <steepdawn974@tutanota.com>
Date:   Thu, 17 Mar 2022 01:32:54 +0100

Add support for custom SSH port

- added config option `tunnel_port`
- added it also to `config.py`, with default 22
- fixed `command` in ssh_tunnel.py to allow for port

Author:    steepdawn974 <steepdawn974@tutanota.com>
Date:      Thu Mar 17 01:32:54 2022 +0100

Diffstat:
Mconfig.py | 1+
Mconfig.toml | 5+++--
Mgateways/ssh_tunnel.py | 10+++++++---
3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/config.py b/config.py @@ -59,6 +59,7 @@ for method_name in config['payment_methods']: host = get_opt("host", "127.0.0.1") api_key_path = get_opt("api_key_path", "SatSale_API_key") tunnel_host = get_opt("tunnel_host", None) +tunnel_port = get_opt("tunnel_port", 22) tor_proxy = get_opt("tor_proxy", None) onchain_dust_limit = get_opt("onchain_dust_limit", 0.00000546) pollrate = get_opt("pollrate", 15) diff --git a/config.toml b/config.toml @@ -22,7 +22,7 @@ lnd_macaroon = "invoice.macaroon" #lightning_address_comment = None # Defaults to: "Thank you for your support <3" ## CLIGHTNING :: Add "clightning" to payment_methods -# If remote clightning, make sure `ssh -nNT -L {local_lightning-rpc}:{remote_lightning-rpc} {tunnel_host}` +# If remote clightning, make sure `ssh -nNT -L {local_lightning-rpc}:{remote_lightning-rpc} {tunnel_host} -p {tunnel_port}` # creates a lightning-rpc unix domain socket. (use full paths local: /home/install/satsale/lightning-rpc) [clightning] clightning_rpc_file = "/home/user/.lightning/bitcoin/lightning-rpc" @@ -33,9 +33,10 @@ clightning_rpc_file = "/home/user/.lightning/bitcoin/lightning-rpc" # to tunnel/relay communications to the remote node # SSH tunnel to node (recommended) -# Make sure this command works `ssh HOST@IP -q -N -L 8332:localhost:8332` +# Make sure this command works `ssh HOST@IP -q -N -L 8332:localhost:8332 -p PORT` # Leave host="127.0.0.1" and you will be able to see your node as if it were local #tunnel_host = None # Format: "HOST@IP" +#tunnel_port = "PORT" #defaults to 22, if left blank # TOR hidden service to node (see docs for how to set up), # Currently only works for bitcoind. diff --git a/gateways/ssh_tunnel.py b/gateways/ssh_tunnel.py @@ -12,15 +12,17 @@ def open_tunnel(host, port): try: command = [ "ssh", - config.tunnel_host, "-q", "-N", "-L", "{}:localhost:{}".format(port, port), + config.tunnel_host, + "-p {}".format(config.tunnel_port), ] print("Opening tunnel to {}.".format(" ".join(command))) return subprocess.Popen(command) + except Exception as e: print("FAILED TO OPEN TUNNEL. Exception: {}".format(e)) @@ -33,7 +35,7 @@ def clightning_unix_domain_socket_ssh(rpc_file, rpc_store_dir=None): local_file = rpc_store_dir + "/lightning-rpc" - # ssh -nNT -L lightning-rpc:~/.lightning/lightning-rpc config.tunnel_host + # ssh -nNT -L lightning-rpc:~/.lightning/lightning-rpc config.tunnel_host -p config.tunnel_port try: command = [ "ssh", @@ -41,11 +43,13 @@ def clightning_unix_domain_socket_ssh(rpc_file, rpc_store_dir=None): "-L", "{}:{}".format(local_file, rpc_file), "{}".format(config.tunnel_host), - ] + "-p {}".format(config.tunnel_port), + ] print("Opening tunnel to {}.".format(" ".join(command))) tunnel_proc = subprocess.Popen(command) return tunnel_proc + except Exception as e: print( "FAILED TO OPEN UNIX DOMAIN SOCKET OVER SSH. Exception: {}".format(e)