From 20b6f22e19c6a48d78635491b89953a3df80b58b Mon Sep 17 00:00:00 2001 From: kexkey Date: Mon, 9 Dec 2019 15:59:40 -0500 Subject: [PATCH] Added TORification info on components for info.json / welcome app --- cyphernodeconf_docker/lib/app.js | 21 ++++++++-- cyphernodeconf_docker/lib/torgen.js | 9 ++--- cyphernodeconf_docker/prompters/040_tor.js | 2 +- .../schema/config-v0.2.3.json | 2 +- .../templates/bitcoin/bitcoin.conf | 2 +- .../templates/lightning/c-lightning/config | 2 +- cyphernodeconf_docker/templates/tor/torrc | 7 +++- cyphernodeconf_docker/torgen/torgen.go | 38 +++++++++++++++---- 8 files changed, 60 insertions(+), 23 deletions(-) diff --git a/cyphernodeconf_docker/lib/app.js b/cyphernodeconf_docker/lib/app.js index 54920da..7eec054 100644 --- a/cyphernodeconf_docker/lib/app.js +++ b/cyphernodeconf_docker/lib/app.js @@ -427,7 +427,9 @@ module.exports = class App { prune: this.config.data.bitcoin_prune, prune_size: this.config.data.bitcoin_prune_size, expose: this.config.data.bitcoin_expose, - uacomment: this.config.data.bitcoin_uacomment + uacomment: this.config.data.bitcoin_uacomment, + torified: this.torifyables.find(data => data.value === 'tor_bitcoinnode').checked, + clearnet: this.isChecked('clearnet', 'clearnet_bitcoinnode') } }, { @@ -446,7 +448,12 @@ module.exports = class App { label: 'proxy', host: 'proxy', networks: ['cyphernodenet'], - docker: 'cyphernode/proxy:'+this.config.docker_versions['cyphernode/proxy'] + docker: 'cyphernode/proxy:'+this.config.docker_versions['cyphernode/proxy'], + extra: { + torified_addr_watch_webhooks: this.torifyables.find(data => data.value === 'tor_addrwatcheswebhooks').checked, + torified_txid_watch_webhooks: this.torifyables.find(data => data.value === 'tor_txidwatcheswebhooks').checked, + torified_ots_watch_webhooks: this.torifyables.find(data => data.value === 'tor_otswebhooks').checked + } }, { name: 'Proxy cron', @@ -491,7 +498,11 @@ module.exports = class App { }, otsclient: { networks: ['cyphernodenet'], - docker: "cyphernode/otsclient:" + this.config.docker_versions['cyphernode/otsclient'] + docker: "cyphernode/otsclient:" + this.config.docker_versions['cyphernode/otsclient'], + extra: { + torified: this.torifyables.find(data => data.value === 'tor_otsoperations').checked, + torified_webhooks: this.torifyables.find(data => data.value === 'tor_otswebhooks').checked + } }, lightning: { networks: ['cyphernodenet'], @@ -501,7 +512,9 @@ module.exports = class App { nodecolor: this.config.data.lightning_nodecolor, expose: this.config.data.lightning_expose, external_ip: this.config.data.lightning_external_ip, - implementation: this.config.data.lightning_implementation + implementation: this.config.data.lightning_implementation, + torified: this.torifyables.find(data => data.value === 'tor_lnnode').checked, + clearnet: this.isChecked('clearnet', 'clearnet_lnnode') } } } diff --git a/cyphernodeconf_docker/lib/torgen.js b/cyphernodeconf_docker/lib/torgen.js index 512f87d..7cf3a57 100644 --- a/cyphernodeconf_docker/lib/torgen.js +++ b/cyphernodeconf_docker/lib/torgen.js @@ -10,8 +10,6 @@ module.exports = class TorGen { } async generateTorFiles() { -// console.log(chalk.green( 'TOR datapath=' + this.path )); - if( !fs.existsSync(this.path) ) { console.log(chalk.green( 'Creating TOR Hidden Service directory...' )); fs.mkdirSync(this.path, { recursive: true }); @@ -19,7 +17,7 @@ module.exports = class TorGen { if( !fs.existsSync(this.path + '/hostname') ) { - console.log(chalk.bold.green( 'Generating TOR Hidden Service secret key, public key and hostname...' )); + console.log(chalk.green( 'Generating TOR Hidden Service secret key, public key and hostname...' )); const torgenbin = spawn('./torgen/torgen', [this.path]); try { @@ -29,14 +27,13 @@ module.exports = class TorGen { return ""; } -// console.log(chalk.bold.green( 'Generated TOR Hidden Service secret key, public key and hostname.' )); - } else { - console.log(chalk.red('TOR config files already exist, skipping generation') ); + console.log(chalk.green('TOR config files already exist, skipping TOR generation.') ); } try { var data = fs.readFileSync(this.path + '/hostname', 'utf8'); + // Remove the LF at the end of the host name return data.slice(0, -1); } catch (err) { console.log(chalk.bold.red('Error: ' + err) ); diff --git a/cyphernodeconf_docker/prompters/040_tor.js b/cyphernodeconf_docker/prompters/040_tor.js index 05146f8..bd27642 100644 --- a/cyphernodeconf_docker/prompters/040_tor.js +++ b/cyphernodeconf_docker/prompters/040_tor.js @@ -33,7 +33,7 @@ module.exports = { type: 'checkbox', name: 'clearnet', default: utils.getDefault( 'clearnet' ), - message: prefix()+'What features do you want to allow using clearnet?'+utils.getHelp('clearnet'), + message: prefix()+'What features do you want to also allow using clearnet?'+utils.getHelp('clearnet'), choices: [{ name: "Bitcoin Node", value: "clearnet_bitcoinnode" diff --git a/cyphernodeconf_docker/schema/config-v0.2.3.json b/cyphernodeconf_docker/schema/config-v0.2.3.json index c4f9c1b..6c7006f 100644 --- a/cyphernodeconf_docker/schema/config-v0.2.3.json +++ b/cyphernodeconf_docker/schema/config-v0.2.3.json @@ -321,7 +321,7 @@ "compose" ], "title": "How to run the containers", - "default": "compose", + "default": "swarm", "examples": [ "compose" ] diff --git a/cyphernodeconf_docker/templates/bitcoin/bitcoin.conf b/cyphernodeconf_docker/templates/bitcoin/bitcoin.conf index 13c8f38..fbcd4ba 100644 --- a/cyphernodeconf_docker/templates/bitcoin/bitcoin.conf +++ b/cyphernodeconf_docker/templates/bitcoin/bitcoin.conf @@ -17,7 +17,7 @@ zmqpubrawtx=tcp://0.0.0.0:18502 listen=1 -<% if ( features.indexOf('tor_bitcoinnode') !== -1 ) { %> +<% if ( torifyables.indexOf('tor_bitcoinnode') !== -1 ) { %> #tor proxy=tor:9050 <% if ( clearnet.indexOf('clearnet_bitcoinnode') == -1 ) { %> diff --git a/cyphernodeconf_docker/templates/lightning/c-lightning/config b/cyphernodeconf_docker/templates/lightning/c-lightning/config index 8e42b95..801a73a 100644 --- a/cyphernodeconf_docker/templates/lightning/c-lightning/config +++ b/cyphernodeconf_docker/templates/lightning/c-lightning/config @@ -26,7 +26,7 @@ always-use-proxy=true #disable-dns <% if (lightning_announce) { %> # Announcing TOR address -announce-addr=<%= locals.tor_hostname %>:1234 +announce-addr=<%= locals.tor_hostname %>:9735 <% if ( clearnet.indexOf('clearnet_lnnode') !== -1 ) { %> <% if( locals.lightning_external_ip ) { %> # Announcing clearnet address diff --git a/cyphernodeconf_docker/templates/tor/torrc b/cyphernodeconf_docker/templates/tor/torrc index f218bf5..088675a 100644 --- a/cyphernodeconf_docker/templates/tor/torrc +++ b/cyphernodeconf_docker/templates/tor/torrc @@ -3,8 +3,11 @@ HiddenServiceDir /tor/hidden_service/ HiddenServiceVersion 3 HiddenServicePort 80 traefik:80 HiddenServicePort 443 traefik:443 -<% if ( features.indexOf('lightning') !== -1 ) { %> -HiddenServicePort 1234 lightning:9735 +<% if ( torifyables.indexOf('tor_lnnode') !== -1 && lightning_expose ) { %> +HiddenServicePort 9735 lightning:9735 +<% } %> +<% if ( torifyables.indexOf('tor_bitcoinnode') !== -1 && bitcoin_expose) { %> +HiddenServicePort 8333 bitcoin:8333 <% } %> <% } %> diff --git a/cyphernodeconf_docker/torgen/torgen.go b/cyphernodeconf_docker/torgen/torgen.go index 6a3bd6b..3f7e798 100644 --- a/cyphernodeconf_docker/torgen/torgen.go +++ b/cyphernodeconf_docker/torgen/torgen.go @@ -83,9 +83,17 @@ func main() { fileBytes.Write(bytes.Repeat([]byte{0x00}, 3)) fileBytes.Write(h[:]) - prvFile, _ := os.Create(path + "/hs_ed25519_secret_key") - fileBytes.WriteTo(prvFile) - prvFile.Close() + prvFile, err := os.Create(path + "/hs_ed25519_secret_key") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + _, err = fileBytes.WriteTo(prvFile) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = prvFile.Close() // Create the Tor Hidden Service public key file fmt.Println("Creating public file...") @@ -94,8 +102,16 @@ func main() { fileBytes.Write(bytes.Repeat([]byte{0x00}, 3)) fileBytes.Write([]byte(publicKey)) - pubFile, _ := os.Create(path + "/hs_ed25519_public_key") - fileBytes.WriteTo(pubFile) + pubFile, err := os.Create(path + "/hs_ed25519_public_key") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + _, err = fileBytes.WriteTo(pubFile) + if err != nil { + fmt.Println(err) + os.Exit(1) + } pubFile.Close() // From https://github.com/rdkr/oniongen-go @@ -116,8 +132,16 @@ func main() { // Create the Tor Hidden Service hostname file fmt.Println("Creating onion address file...") - nameFile, _ := os.Create(path + "/hostname") - nameFile.WriteString(strings.ToLower(onionAddress) + ".onion\n") + nameFile, err := os.Create(path + "/hostname") + if err != nil { + fmt.Println(err) + os.Exit(1) + } + _, err = nameFile.WriteString(strings.ToLower(onionAddress) + ".onion\n") + if err != nil { + fmt.Println(err) + os.Exit(1) + } nameFile.Close() fmt.Println("Done!")