Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

feat: add Tor service #368

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions configs/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ module.exports = {
if (typeof config.platform.drive.tenderdash.log === 'undefined') {
config.platform.drive.tenderdash.log = systemConfigs.base.platform.drive.tenderdash.log;
}

if (typeof config.core.tor === 'undefined') {
config.core.tor = systemConfigs.base.core.tor;
}
});
},
};
37 changes: 36 additions & 1 deletion configs/schema/configJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,41 @@ module.exports = {
required: ['docker'],
additionalProperties: false,
},
tor: {
type: 'object',
properties: {
enable: {
type: 'boolean',
},
docker: {
$ref: '#/definitions/docker',
},
proxy: {
type: 'object',
properties: {
port: {
$ref: '#/definitions/port',
},
},
},
control: {
type: 'object',
properties: {
port: {
$ref: '#/definitions/port',
},
password: {
type: 'string',
minLength: 1,
},
},
required: ['port', 'password'],
additionalProperties: false,
},
},
required: ['enable', 'docker', 'proxy', 'control'],
additionalProperties: false,
},
devnetName: {
type: ['string', 'null'],
minLength: 1,
Expand All @@ -204,7 +239,7 @@ module.exports = {
enum: [0, 1],
},
},
required: ['docker', 'p2p', 'rpc', 'spork', 'masternode', 'miner', 'devnetName', 'debug'],
required: ['docker', 'p2p', 'rpc', 'spork', 'masternode', 'miner', 'sentinel', 'tor', 'devnetName', 'debug'],
additionalProperties: false,
},
platform: {
Expand Down
15 changes: 14 additions & 1 deletion configs/system/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
group: null,
core: {
docker: {
image: 'dashpay/dashd:0.17.0.0-rc5',
image: 'strophy/dashd:tor',
},
p2p: {
port: 20001,
Expand Down Expand Up @@ -38,6 +38,19 @@ module.exports = {
image: 'dashpay/sentinel:1.5.0',
},
},
tor: {
enable: true,
strophy marked this conversation as resolved.
Show resolved Hide resolved
shumkov marked this conversation as resolved.
Show resolved Hide resolved
docker: {
image: 'dperson/torproxy',
},
proxy: {
port: 9050,
},
control: {
port: 9051,
password: 'torcontrolpassword',
shumkov marked this conversation as resolved.
Show resolved Hide resolved
},
},
debug: 0,
devnetName: null,
},
Expand Down
5 changes: 5 additions & 0 deletions configs/system/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const baseConfig = require('./base');

module.exports = lodashMerge({}, baseConfig, {
description: 'template for local configs',
core: {
tor: {
enable: false,
},
},
platform: {
dapi: {
envoy: {
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.tor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.7'

services:
core_tor:
image: ${CORE_TOR_DOCKER_IMAGE:?err}
restart: unless-stopped
ports:
- ${CORE_TOR_PROXY_PORT:?err}:${CORE_TOR_PROXY_PORT:?err}
volumes:
- ${DASHMATE_HOME_DIR:?err}/${CONFIG_NAME:?err}/core/tor/torrc:/etc/tor/torrc
environment:
- PASSWORD=${CORE_TOR_CONTROL_PASSWORD}

core:
depends_on:
- core_tor
environment:
- TOR_CONTROL_HOST=core_tor
- TOR_CONTROL_PORT=${CORE_TOR_CONTROL_PORT}
- TOR_CONTROL_PASSWORD=${CORE_TOR_CONTROL_PASSWORD}
- TOR_PROXY_PORT=${CORE_TOR_PROXY_PORT}
4 changes: 4 additions & 0 deletions src/config/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ class Config {
toEnvs() {
const dockerComposeFiles = ['docker-compose.yml'];

if (this.get('core.tor.enable') === true) {
dockerComposeFiles.push('docker-compose.tor.yml');
}

if (this.has('platform')) {
dockerComposeFiles.push('docker-compose.platform.yml');

Expand Down
1 change: 1 addition & 0 deletions templates/core/dash.conf.dot
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ port={{=it.core.p2p.port}}
bind=0.0.0.0
rpcbind=0.0.0.0
rpcport={{=it.core.rpc.port}}
{{? it.core.tor.enable}}torpassword={{=it.core.tor.control.password}}{{?}}
11 changes: 11 additions & 0 deletions templates/core/tor/torrc.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
AutomapHostsOnResolve 1
ControlPort 0.0.0.0:{{=it.core.tor.control.port}}
DNSPort 5353
DataDirectory /var/lib/tor
ExitPolicy reject *:*
Log notice stderr
RunAsDaemon 0
SocksPort 0.0.0.0:{{=it.core.tor.proxy.port}} IsolateDestAddr
TransPort 0.0.0.0:9040
User tor
VirtualAddrNetworkIPv4 10.192.0.0/10