From 96f6301282e21417d64cb6b55e819e4e5baee5bd Mon Sep 17 00:00:00 2001 From: kexkey Date: Fri, 8 Nov 2019 16:50:54 -0500 Subject: [PATCH] TOR first, fixed when OFF, small tweaks --- cyphernodeconf_docker/features.json | 8 ++-- cyphernodeconf_docker/lib/app.js | 4 +- .../prompters/999_installer.js | 4 +- .../schema/config-v0.2.3.json | 44 +++++++++---------- .../installer/docker/docker-compose.yaml | 4 +- .../test/data/config.0.2.3.json | 4 +- notifier_docker/script/web.sh | 3 +- proxy_docker/app/script/requesthandler.sh | 8 +++- 8 files changed, 43 insertions(+), 36 deletions(-) diff --git a/cyphernodeconf_docker/features.json b/cyphernodeconf_docker/features.json index bf1faea..337705a 100644 --- a/cyphernodeconf_docker/features.json +++ b/cyphernodeconf_docker/features.json @@ -1,4 +1,8 @@ [ + { + "name": "TOR Hidden Service/Gateway", + "value": "tor" + }, { "name": "Lightning node", "value": "lightning" @@ -6,9 +10,5 @@ { "name": "Opentimestamps client", "value": "otsclient" - }, - { - "name": "Tor Hidden Service/Gateway", - "value": "tor" } ] diff --git a/cyphernodeconf_docker/lib/app.js b/cyphernodeconf_docker/lib/app.js index 321a9d3..c9cced2 100644 --- a/cyphernodeconf_docker/lib/app.js +++ b/cyphernodeconf_docker/lib/app.js @@ -474,9 +474,11 @@ module.exports = class App { } }, otsclient: { + networks: ['cyphernodenet'], docker: "cyphernode/otsclient:" + this.config.docker_versions['cyphernode/otsclient'] }, lightning: { + networks: ['cyphernodenet'], docker: "cyphernode/clightning:"+this.config.docker_versions['cyphernode/clightning'], extra: { nodename: this.config.data.lightning_nodename, @@ -494,7 +496,7 @@ module.exports = class App { name: feature.name, label: feature.value, host: feature.value, - networks: ['cyphernodenet'], + networks: optional_features_data[feature.value].networks, docker: optional_features_data[feature.value].docker }; diff --git a/cyphernodeconf_docker/prompters/999_installer.js b/cyphernodeconf_docker/prompters/999_installer.js index 2ee6ad6..9a58f2c 100644 --- a/cyphernodeconf_docker/prompters/999_installer.js +++ b/cyphernodeconf_docker/prompters/999_installer.js @@ -98,13 +98,13 @@ module.exports = { message: prefix()+'Where do you want to store your tor data?'+utils.getHelp('tor_datapath'), }, { - when: (props)=>{ return installerDocker(props) && props.features.indexOf('tor') !== -1 && props.otsclient_datapath === '_custom' }, + when: (props)=>{ return installerDocker(props) && props.features.indexOf('tor') !== -1 && props.tor_datapath === '_custom' }, type: 'input', name: 'tor_datapath_custom', default: utils.getDefault( 'tor_datapath_custom' ), filter: utils.trimFilter, validate: utils.pathValidator, - message: prefix()+'Custom path for tor data?'+utils.getHelp('tor_datapath_custom'), + message: prefix()+'Custom path for TOR data?'+utils.getHelp('tor_datapath_custom'), }, { when: installerDocker, diff --git a/cyphernodeconf_docker/schema/config-v0.2.3.json b/cyphernodeconf_docker/schema/config-v0.2.3.json index eb47fe0..55e18c2 100644 --- a/cyphernodeconf_docker/schema/config-v0.2.3.json +++ b/cyphernodeconf_docker/schema/config-v0.2.3.json @@ -85,6 +85,24 @@ ] } }, + { + "if": { + "properties": { + "features": { + "contains": { + "enum": [ + "tor" + ] + } + } + } + }, + "then": { + "required": [ + "tor_datapath" + ] + } + }, { "if": { "properties": { @@ -125,24 +143,6 @@ "otsclient_datapath" ] } - }, - { - "if": { - "properties": { - "features": { - "contains": { - "enum": [ - "tor" - ] - } - } - } - }, - "then": { - "required": [ - "tor_datapath" - ] - } } ], "properties": { @@ -180,16 +180,16 @@ "$id": "#/properties/features/items", "type": "string", "enum": [ + "tor", "lightning", - "otsclient", - "tor" + "otsclient" ], "title": "The feature", "default": "", "examples": [ + "tor", "lightning", - "otsclient", - "tor" + "otsclient" ] } }, diff --git a/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml b/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml index 5f4f304..ddb77b3 100644 --- a/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml +++ b/cyphernodeconf_docker/templates/installer/docker/docker-compose.yaml @@ -122,8 +122,10 @@ services: notifier: image: cyphernode/notifier:<%= notifier_version %> command: $USER ./startnotifier.sh + <% if ( features.indexOf('tor') !== -1 ) { %> volumes: - "<%= tor_datapath %>/curlcfg:/notifier/curlcfg" + <% } %> networks: - cyphernodenet - cyphernodeappsnet @@ -246,8 +248,6 @@ services: tor: image: cyphernode/tor:<%= tor_version %> command: $USER sh -c 'export HOME=/tor && tor -f /tor/torrc' - depends_on: - - traefik volumes: - "<%= tor_datapath %>:/tor" restart: always diff --git a/cyphernodeconf_docker/test/data/config.0.2.3.json b/cyphernodeconf_docker/test/data/config.0.2.3.json index 296ff86..a876743 100644 --- a/cyphernodeconf_docker/test/data/config.0.2.3.json +++ b/cyphernodeconf_docker/test/data/config.0.2.3.json @@ -3,9 +3,9 @@ "setup_version": "setup_version", "docker_versions": {}, "features": [ + "tor", "lightning", - "otsclient", - "tor" + "otsclient" ], "net": "testnet", "use_xpub": true, diff --git a/notifier_docker/script/web.sh b/notifier_docker/script/web.sh index f63f2e5..36dd0b0 100644 --- a/notifier_docker/script/web.sh +++ b/notifier_docker/script/web.sh @@ -56,7 +56,8 @@ curl_it() { local response local rnd=$(dd if=/dev/urandom bs=5 count=1 | xxd -pc 5) - if [ "${torbypass}" = "true" ]; then + if [ "${torbypass}" = "true" ] || [ ! -f "curlcfg" ]; then + # If we want to bypass tor or the config file doesn't exist torbypass="" else torbypass="-K curlcfg" diff --git a/proxy_docker/app/script/requesthandler.sh b/proxy_docker/app/script/requesthandler.sh index e58a22a..c62a761 100644 --- a/proxy_docker/app/script/requesthandler.sh +++ b/proxy_docker/app/script/requesthandler.sh @@ -79,8 +79,12 @@ main() { installation_info) # GET http://192.168.111.152:8080/info if [ -f "$DB_PATH/info.json" ]; then - # Replace tor_hostname_placeholder with actual tor hostname from tor file - response=$(sed "s/tor_hostname_placeholder/`tr -d '\n\r' < tor/hidden_service/hostname`/g" "$DB_PATH/info.json") + if [ -f "tor/hidden_service/hostname" ]; then + # Replace tor_hostname_placeholder with actual tor hostname from tor file + response=$(sed "s/tor_hostname_placeholder/`tr -d '\n\r' < tor/hidden_service/hostname`/g" "$DB_PATH/info.json") + else + response=$(cat "$DB_PATH/info.json") + fi else response='{ "error": "missing installation data" }' fi