From 0eb8c2cfbea42b6b1b18a4290d9ac13099900cd8 Mon Sep 17 00:00:00 2001 From: kexkey Date: Tue, 10 Dec 2019 15:03:19 -0500 Subject: [PATCH] Hack to get proxy to work in c-lightning, getting the tor container IP dynamically --- cyphernodeconf_docker/prompters/100_lightning.js | 2 +- .../installer/docker/docker-compose.yaml | 2 +- .../templates/lightning/c-lightning/config | 4 ++-- .../templates/lightning/c-lightning/entrypoint.sh | 15 +++++++++++++++ dist/setup.sh | 1 + 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100755 cyphernodeconf_docker/templates/lightning/c-lightning/entrypoint.sh diff --git a/cyphernodeconf_docker/prompters/100_lightning.js b/cyphernodeconf_docker/prompters/100_lightning.js index e0bf169..5238bdf 100644 --- a/cyphernodeconf_docker/prompters/100_lightning.js +++ b/cyphernodeconf_docker/prompters/100_lightning.js @@ -17,7 +17,7 @@ const featureCondition = function(props) { const templates = { 'lnd': [ path.join('lnd','lnd.conf') ], - 'c-lightning': [ path.join('c-lightning','config') ] + 'c-lightning': [ path.join('c-lightning','config'), path.join('c-lightning','entrypoint.sh') ] }; module.exports = { diff --git a/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml b/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml index 6ebb45b..8e8f11d 100644 --- a/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml +++ b/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml @@ -29,7 +29,7 @@ services: lightning: image: cyphernode/clightning:<%= lightning_version %> - command: $USER sh -c 'while [ ! -f "/bitcoin_monitor/up" ]; do echo "bitcoin not ready" ; sleep 10 ; done ; echo "bitcoin ready!" ; lightningd' + command: $USER /.lightning/entrypoint.sh <% if( lightning_expose ) { %> ports: - "9735:9735" diff --git a/cyphernodeconf_docker/templates/lightning/c-lightning/config b/cyphernodeconf_docker/templates/lightning/c-lightning/config index 801a73a..538b393 100644 --- a/cyphernodeconf_docker/templates/lightning/c-lightning/config +++ b/cyphernodeconf_docker/templates/lightning/c-lightning/config @@ -18,12 +18,12 @@ addr=0.0.0.0:9735 <% if ( torifyables.indexOf('tor_lnnode') !== -1 ) { %> # TOR -proxy=tor:9050 +# proxy=tor:9050 this has to be made at execution time because of getaddrinfo and alpine not being friends, see entrypoint.sh <% if ( clearnet.indexOf('clearnet_lnnode') == -1 ) { %> # TOR only, no clearnet always-use-proxy=true +disable-dns <% } %> -#disable-dns <% if (lightning_announce) { %> # Announcing TOR address announce-addr=<%= locals.tor_hostname %>:9735 diff --git a/cyphernodeconf_docker/templates/lightning/c-lightning/entrypoint.sh b/cyphernodeconf_docker/templates/lightning/c-lightning/entrypoint.sh new file mode 100755 index 0000000..275697d --- /dev/null +++ b/cyphernodeconf_docker/templates/lightning/c-lightning/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +while [ ! -f "/bitcoin_monitor/up" ]; do echo "bitcoin not ready" ; sleep 10 ; done + +<% if ( torifyables.indexOf('tor_lnnode') !== -1 ) { %> +while [ -z "${TORIP}" ]; do echo "tor not ready" ; TORIP=$(getent hosts tor | awk '{ print $1 }') ; sleep 10 ; done + +echo "TOR ready at IP ${TORIP}" + +lightningd --proxy=$TORIP:9050 +<% } else { %> + +lightningd + +<% } %> diff --git a/dist/setup.sh b/dist/setup.sh index f89d55a..eb318d9 100755 --- a/dist/setup.sh +++ b/dist/setup.sh @@ -477,6 +477,7 @@ install_docker() { fi copy_file $cyphernodeconf_filepath/lightning/c-lightning/config $LIGHTNING_DATAPATH/config 1 $SUDO_REQUIRED + copy_file $cyphernodeconf_filepath/lightning/c-lightning/entrypoint.sh $LIGHTNING_DATAPATH/entrypoint.sh 1 $SUDO_REQUIRED fi fi