From 4adcaf20f54081508bd778561f476c05808bb110 Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Thu, 9 Apr 2020 17:49:47 +0200 Subject: [PATCH 1/3] hardcode localhost for zmq ports of dojo --- pushtx/index-orchestrator.js | 2 +- pushtx/index.js | 2 +- tracker/tracker.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pushtx/index-orchestrator.js b/pushtx/index-orchestrator.js index 0151b09..c1c1dbc 100644 --- a/pushtx/index-orchestrator.js +++ b/pushtx/index-orchestrator.js @@ -39,7 +39,7 @@ // Initialize notification sockets of singleton pushTxProcessor pushTxProcessor.initNotifications({ - uriSocket: `tcp://*:${keys.ports.orchestrator}` + uriSocket: `tcp://127.0.0.1:${keys.ports.orchestrator}` }) // Initialize and start the orchestrator diff --git a/pushtx/index.js b/pushtx/index.js index 729830b..0d0b1ca 100644 --- a/pushtx/index.js +++ b/pushtx/index.js @@ -40,7 +40,7 @@ // Initialize notification sockets of singleton pushTxProcessor pushTxProcessor.initNotifications({ - uriSocket: `tcp://*:${keys.ports.notifpushtx}` + uriSocket: `tcp://127.0.0.1:${keys.ports.notifpushtx}` }) // Initialize the http server diff --git a/tracker/tracker.js b/tracker/tracker.js index 8ebaf99..1089faa 100644 --- a/tracker/tracker.js +++ b/tracker/tracker.js @@ -22,7 +22,7 @@ class Tracker { constructor() { // Notification socket for client events this.notifSock = zmq.socket('pub') - this.notifSock.bindSync(`tcp://*:${keys.ports.tracker}`) + this.notifSock.bindSync(`tcp://127.0.0.1:${keys.ports.tracker}`) // Initialize the blockchain processor // and the mempool buffer From afc2bc3b26b43971e22798a5c34054b0a59f7fea Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Fri, 10 Apr 2020 13:52:39 +0200 Subject: [PATCH 2/3] add parameter binding the apis to a given host --- accounts/index.js | 3 ++- docker/my-dojo/node/keys.index.js | 4 ++++ keys/index-example.js | 5 +++++ lib/http-server/http-server.js | 10 ++++++---- pushtx/index.js | 3 ++- tracker/index.js | 3 ++- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/accounts/index.js b/accounts/index.js index e04e5c8..9053706 100644 --- a/accounts/index.js +++ b/accounts/index.js @@ -52,8 +52,9 @@ hdaHelper.activateExternalDerivation() // Initialize the http server + const host = keys.apiBind const port = keys.ports.account - const httpServer = new HttpServer(port) + const httpServer = new HttpServer(port, host) // Initialize the rest api endpoints const authRestApi = new AuthRestApi(httpServer) diff --git a/docker/my-dojo/node/keys.index.js b/docker/my-dojo/node/keys.index.js index ff49450..3c2ca42 100644 --- a/docker/my-dojo/node/keys.index.js +++ b/docker/my-dojo/node/keys.index.js @@ -64,6 +64,10 @@ module.exports = { connectionLimitPushTxApi: 5, connectionLimitPushTxOrchestrator: 5 }, + /* + * IP address used to expose the API ports + */ + apiBind: '0.0.0.0', /* * TCP Ports */ diff --git a/keys/index-example.js b/keys/index-example.js index 583540b..419d35d 100644 --- a/keys/index-example.js +++ b/keys/index-example.js @@ -61,6 +61,10 @@ module.exports = { connectionLimitPushTxApi: 5, connectionLimitPushTxOrchestrator: 5 }, + /* + * IP address used to expose the API ports + */ + apiBind: '127.0.0.1', /* * TCP Ports */ @@ -240,6 +244,7 @@ module.exports = { connectionLimitPushTxApi: 1, connectionLimitPushTxOrchestrator: 5 }, + apiBind: '127.0.0.1', ports: { account: 18080, pushtx: 18081, diff --git a/lib/http-server/http-server.js b/lib/http-server/http-server.js index 9076be6..fcd9207 100644 --- a/lib/http-server/http-server.js +++ b/lib/http-server/http-server.js @@ -18,9 +18,11 @@ class HttpServer { /** * Constructor * @param {int} port - port used by the http server + * @param {string} host - host exposing the http server */ - constructor(port) { - // Initialize server port + constructor(port, host) { + // Initialize server host and port + this.host = host ? host : '127.0.0.1' this.port = port // Listening server instance @@ -54,8 +56,8 @@ class HttpServer { }) // Start a http server - this.server = this.app.listen(this.port, () => { - Logger.info('HTTP server listening on port ' + this.port) + this.server = this.app.listen(this.port, this.host, () => { + Logger.info(`HTTP server listening on ${this.host}:${this.port}`) }) this.server.timeout = 600 * 1000 diff --git a/pushtx/index.js b/pushtx/index.js index 0d0b1ca..b336fa9 100644 --- a/pushtx/index.js +++ b/pushtx/index.js @@ -44,8 +44,9 @@ }) // Initialize the http server + const host = keys.apiBind const port = keys.ports.pushtx - const httpServer = new HttpServer(port) + const httpServer = new HttpServer(port, host) // Initialize the PushTx rest api const pushtxRestApi = new PushTxRestApi(httpServer) diff --git a/tracker/index.js b/tracker/index.js index 47d091c..c0cbd86 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -39,8 +39,9 @@ const tracker = new Tracker() // Initialize the http server + const host = keys.apiBind const port = keys.ports.trackerApi - const httpServer = new HttpServer(port) + const httpServer = new HttpServer(port, host) // Initialize the rest api endpoints const trackerRestApi = new TrackerRestApi(httpServer, tracker) From 420472287fb97d4147be3ba62312a590e6b0f53c Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Fri, 10 Apr 2020 16:53:24 +0200 Subject: [PATCH 3/3] bump version of node module --- docker/my-dojo/.env | 2 +- keys/index-example.js | 4 ++-- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/my-dojo/.env b/docker/my-dojo/.env index e9d0f91..57b27e6 100644 --- a/docker/my-dojo/.env +++ b/docker/my-dojo/.env @@ -13,7 +13,7 @@ COMPOSE_CONVERT_WINDOWS_PATHS=1 DOJO_VERSION_TAG=1.6.0 DOJO_DB_VERSION_TAG=1.1.1 DOJO_BITCOIND_VERSION_TAG=1.5.0 -DOJO_NODEJS_VERSION_TAG=1.5.0 +DOJO_NODEJS_VERSION_TAG=1.6.0 DOJO_NGINX_VERSION_TAG=1.4.0 DOJO_TOR_VERSION_TAG=1.3.0 DOJO_EXPLORER_VERSION_TAG=1.2.0 diff --git a/keys/index-example.js b/keys/index-example.js index 419d35d..cd72820 100644 --- a/keys/index-example.js +++ b/keys/index-example.js @@ -15,7 +15,7 @@ module.exports = { /* * Dojo version */ - dojoVersion: '1.5.0', + dojoVersion: '1.6.0', /* * Bitcoind */ @@ -220,7 +220,7 @@ module.exports = { * Testnet parameters */ testnet: { - dojoVersion: '1.5.0', + dojoVersion: '1.6.0', bitcoind: { rpc: { user: 'user', diff --git a/package-lock.json b/package-lock.json index fdea1a1..c22196a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "samourai-dojo", - "version": "1.5.0", + "version": "1.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3d432c8..94a30c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "samourai-dojo", - "version": "1.5.0", + "version": "1.6.0", "description": "Backend server for Samourai Wallet", "main": "accounts/index.js", "scripts": {