diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c23774c..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Launch", - "type": "go", - "request": "launch", - "mode": "auto", - "program": "${fileDirname}", - "env": {}, - "args": [] - } - ] -} \ No newline at end of file diff --git a/cyphernodeconf_docker/prompters/040_tor.js b/cyphernodeconf_docker/prompters/040_tor.js index 41c5fdf..05146f8 100644 --- a/cyphernodeconf_docker/prompters/040_tor.js +++ b/cyphernodeconf_docker/prompters/040_tor.js @@ -75,3 +75,17 @@ module.exports = { // // What is your public IP address? +// TOR +// - HS +// - torrc +// - hostname, secret, public +// - Bitcoin Node +// - bitcoin.conf: +// - LN Node +// - config +// - OTS +// - OTS webhooks +// - Address Watch webhooks +// - TXID Watch webhooks +// - Clearnet Bitcoin Node +// - Clearnet LN Node diff --git a/cyphernodeconf_docker/prompters/100_lightning.js b/cyphernodeconf_docker/prompters/100_lightning.js index 501b63f..e0bf169 100644 --- a/cyphernodeconf_docker/prompters/100_lightning.js +++ b/cyphernodeconf_docker/prompters/100_lightning.js @@ -53,8 +53,11 @@ module.exports = { default: utils.getDefault( 'lightning_announce' ), message: prefix()+'Do you want to announce your lightning node?'+utils.getHelp('lightning_announce'), }, + /* + Next question is asked when lightning_annouce is YES and (not TOR or (TOR and LN clearnet)). + */ { - when: (props) => { return featureCondition(props) && props.lightning_announce }, + when: (props) => { return featureCondition(props) && props.lightning_announce && (props.torifyables.indexOf('tor_lnnode') == -1 || props.clearnet.indexOf('clearnet_lnnode') != -1) }, type: 'input', name: 'lightning_external_ip', default: utils.getDefault( 'lightning_external_ip' ), diff --git a/cyphernodeconf_docker/templates/bitcoin/bitcoin.conf b/cyphernodeconf_docker/templates/bitcoin/bitcoin.conf index 0ea411a..13c8f38 100644 --- a/cyphernodeconf_docker/templates/bitcoin/bitcoin.conf +++ b/cyphernodeconf_docker/templates/bitcoin/bitcoin.conf @@ -15,13 +15,14 @@ txindex=1 zmqpubrawblock=tcp://0.0.0.0:18501 zmqpubrawtx=tcp://0.0.0.0:18502 +listen=1 + <% if ( features.indexOf('tor_bitcoinnode') !== -1 ) { %> #tor proxy=tor:9050 -<% if ( features.indexOf('clearnet_bitcoinnode') == -1 ) { %> +<% if ( clearnet.indexOf('clearnet_bitcoinnode') == -1 ) { %> onlynet=onion <% } %> -listen=1 <% } %> maxmempool=64 @@ -38,20 +39,17 @@ server=1 test.wallet=watching01.dat test.wallet=xpubwatching01.dat test.wallet=spending01.dat -test.wallet=ln01.dat test.rpcbind=0.0.0.0 <% } else if ( net === 'regtest' ) { %> regtest.wallet=watching01.dat regtest.wallet=xpubwatching01.dat regtest.wallet=spending01.dat -regtest.wallet=ln01.dat regtest.rpcbind=0.0.0.0 regtest.rpcport=18443 <% } else { %> main.wallet=watching01.dat main.wallet=xpubwatching01.dat main.wallet=spending01.dat -main.wallet=ln01.dat main.rpcbind=0.0.0.0 <% } %> diff --git a/cyphernodeconf_docker/templates/installer/config.sh b/cyphernodeconf_docker/templates/installer/config.sh index ef6fc99..f462565 100644 --- a/cyphernodeconf_docker/templates/installer/config.sh +++ b/cyphernodeconf_docker/templates/installer/config.sh @@ -10,6 +10,9 @@ TRAEFIK_DATAPATH=<%= traefik_datapath %> FEATURE_TOR=<%= (features.indexOf('tor') != -1)?'true':'false' %> <% if ( features.indexOf('tor') !== -1 ) { %> TOR_DATAPATH=<%= tor_datapath %> +TOR_OTS_WEBHOOKS=<%= (torifyables.indexOf('tor_otswebhooks') != -1)?'true':'false' %> +TOR_ADDR_WATCH_WEBHOOKS=<%= (torifyables.indexOf('tor_addrwatcheswebhooks') != -1)?'true':'false' %> +TOR_TXID_WATCH_WEBHOOKS=<%= (torifyables.indexOf('tor_txidwatcheswebhooks') != -1)?'true':'false' %> <% } %> DOCKER_MODE=<%= docker_mode %> RUN_AS_USER=<%= run_as_different_user?username:'' %> diff --git a/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml b/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml index 7806399..6ebb45b 100644 --- a/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml +++ b/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml @@ -224,7 +224,7 @@ services: <% if (net === 'testnet') { %> - "TESTNET=1" <% } %> - <% if ( features.indexOf('tor') !== -1 ) { %> + <% if ( torifyables.indexOf('tor_otsoperations') !== -1 ) { %> - "TOR_HOST=tor" - "TOR_PORT=9050" <% } %> diff --git a/cyphernodeconf_docker/templates/lightning/c-lightning/config b/cyphernodeconf_docker/templates/lightning/c-lightning/config index f6bce82..8e42b95 100644 --- a/cyphernodeconf_docker/templates/lightning/c-lightning/config +++ b/cyphernodeconf_docker/templates/lightning/c-lightning/config @@ -17,23 +17,28 @@ rgb=<%= lightning_nodecolor %> addr=0.0.0.0:9735 <% if ( torifyables.indexOf('tor_lnnode') !== -1 ) { %> -#tor +# TOR proxy=tor:9050 <% if ( clearnet.indexOf('clearnet_lnnode') == -1 ) { %> +# TOR only, no clearnet always-use-proxy=true <% } %> #disable-dns -<% } else { %> +<% if (lightning_announce) { %> +# Announcing TOR address +announce-addr=<%= locals.tor_hostname %>:1234 +<% if ( clearnet.indexOf('clearnet_lnnode') !== -1 ) { %> <% if( locals.lightning_external_ip ) { %> +# Announcing clearnet address +announce-addr=<%= locals.lightning_external_ip %>:9735 +<% } %> +<% } %> +<% } %> +<% } else { %> +<% if (lightning_announce) { %> +<% if( locals.lightning_external_ip ) { %> +# Announcing clearnet address announce-addr=<%= locals.lightning_external_ip %>:9735 <% } %> <% } %> -<% if (lightning_announce) { %> - <% if ( torifyables.indexOf('tor_lnnode') !== -1 ) { %> - announce-addr=<%= locals.lightning_external_ip %>:1234 - <% if ( clearnet.indexOf('clearnet_lnnode') == -1 ) { %> - announce-addr=<%= locals.tor_hostname %>:9735 - - <% } %> - <% } %> <% } %> diff --git a/dist/setup.sh b/dist/setup.sh index 2be2723..f89d55a 100755 --- a/dist/setup.sh +++ b/dist/setup.sh @@ -407,7 +407,9 @@ install_docker() { fi copy_file $cyphernodeconf_filepath/tor/torrc $TOR_DATAPATH/torrc 1 $SUDO_REQUIRED - copy_file $cyphernodeconf_filepath/tor/hidden_service/* $TOR_DATAPATH/hidden_service/ 1 $SUDO_REQUIRED + copy_file $cyphernodeconf_filepath/tor/hidden_service/hs_ed25519_secret_key $TOR_DATAPATH/hidden_service/hs_ed25519_secret_key 1 $SUDO_REQUIRED + copy_file $cyphernodeconf_filepath/tor/hidden_service/hs_ed25519_public_key $TOR_DATAPATH/hidden_service/hs_ed25519_public_key 1 $SUDO_REQUIRED + copy_file $cyphernodeconf_filepath/tor/hidden_service/hostname $TOR_DATAPATH/hidden_service/hostname 1 $SUDO_REQUIRED fi diff --git a/proxy_docker/app/script/callbacks_job.sh b/proxy_docker/app/script/callbacks_job.sh index 62ff7a4..3bc7a06 100644 --- a/proxy_docker/app/script/callbacks_job.sh +++ b/proxy_docker/app/script/callbacks_job.sh @@ -249,7 +249,7 @@ curl_callback() { local returncode - notify_web "${1}" "${2}" + notify_web "${1}" "${2}" ${TOR_ADDR_WATCH_WEBHOOKS} returncode=$? trace_rc ${returncode} diff --git a/proxy_docker/app/script/callbacks_txid.sh b/proxy_docker/app/script/callbacks_txid.sh index 9e6c1e1..c5c7242 100644 --- a/proxy_docker/app/script/callbacks_txid.sh +++ b/proxy_docker/app/script/callbacks_txid.sh @@ -115,7 +115,7 @@ curl_callback_txid() { local returncode - notify_web "${1}" "${2}" + notify_web "${1}" "${2}" ${TOR_TXID_WATCH_WEBHOOKS} returncode=$? trace_rc ${returncode} diff --git a/proxy_docker/app/script/notify.sh b/proxy_docker/app/script/notify.sh index f190ed1..d3ac113 100644 --- a/proxy_docker/app/script/notify.sh +++ b/proxy_docker/app/script/notify.sh @@ -6,6 +6,7 @@ notify_web() { trace "Entering notify_web()..." local url=${1} + local torbypass=${3} # Let's encode the body to base64 so we won't have to escape the special chars... local body=$(echo "${2}" | base64 | tr -d '\n') @@ -14,10 +15,17 @@ notify_web() { local response local http_code local curl_code + local msg + + if [ -n "${torbypass}" ]; then + msg="{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"${url}\",\"body\":\"${body}\",\"torbypass\":${torbypass}}" + else + msg="{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"${url}\",\"body\":\"${body}\"}" + fi # We use the pid as the response-topic, so there's no conflict in responses. - trace "[notify_web] mosquitto_rr -h broker -W 21 -t notifier -e \"response/$$\" -m \"{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"${url}\",\"body\":\"${body}\"}\"" - response=$(mosquitto_rr -h broker -W 21 -t notifier -e "response/$$" -m "{\"response-topic\":\"response/$$\",\"cmd\":\"web\",\"url\":\"${url}\",\"body\":\"${body}\"}") + trace "[notify_web] mosquitto_rr -h broker -W 21 -t notifier -e \"response/$$\" -m \"${msg}\"" + response=$(mosquitto_rr -h broker -W 21 -t notifier -e "response/$$" -m ${msg}) returncode=$? trace_rc ${returncode} diff --git a/proxy_docker/app/script/ots.sh b/proxy_docker/app/script/ots.sh index ef6d243..c72a182 100644 --- a/proxy_docker/app/script/ots.sh +++ b/proxy_docker/app/script/ots.sh @@ -213,7 +213,7 @@ serve_ots_backoffice() { if [ -n ${url} ]; then trace "[serve_ots_backoffice] url is not empty, now trying to call it!" - notify_web "${url}" + notify_web "${url}" ${TOR_OTS_WEBHOOKS} returncode=$? trace_rc ${returncode}