Browse Source

Merge pull request #147 from Samourai-Wallet/feat_dojo_config_ip

increase control over ports exposed by dojo
use-env-var-docker
kenshin samourai 5 years ago
committed by GitHub
parent
commit
625e731a04
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      accounts/index.js
  2. 2
      docker/my-dojo/.env
  3. 4
      docker/my-dojo/node/keys.index.js
  4. 9
      keys/index-example.js
  5. 10
      lib/http-server/http-server.js
  6. 2
      package-lock.json
  7. 2
      package.json
  8. 2
      pushtx/index-orchestrator.js
  9. 5
      pushtx/index.js
  10. 3
      tracker/index.js
  11. 2
      tracker/tracker.js

3
accounts/index.js

@ -52,8 +52,9 @@
hdaHelper.activateExternalDerivation() hdaHelper.activateExternalDerivation()
// Initialize the http server // Initialize the http server
const host = keys.apiBind
const port = keys.ports.account const port = keys.ports.account
const httpServer = new HttpServer(port) const httpServer = new HttpServer(port, host)
// Initialize the rest api endpoints // Initialize the rest api endpoints
const authRestApi = new AuthRestApi(httpServer) const authRestApi = new AuthRestApi(httpServer)

2
docker/my-dojo/.env

@ -13,7 +13,7 @@ COMPOSE_CONVERT_WINDOWS_PATHS=1
DOJO_VERSION_TAG=1.6.0 DOJO_VERSION_TAG=1.6.0
DOJO_DB_VERSION_TAG=1.1.1 DOJO_DB_VERSION_TAG=1.1.1
DOJO_BITCOIND_VERSION_TAG=1.5.0 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_NGINX_VERSION_TAG=1.4.0
DOJO_TOR_VERSION_TAG=1.3.0 DOJO_TOR_VERSION_TAG=1.3.0
DOJO_EXPLORER_VERSION_TAG=1.2.0 DOJO_EXPLORER_VERSION_TAG=1.2.0

4
docker/my-dojo/node/keys.index.js

@ -64,6 +64,10 @@ module.exports = {
connectionLimitPushTxApi: 5, connectionLimitPushTxApi: 5,
connectionLimitPushTxOrchestrator: 5 connectionLimitPushTxOrchestrator: 5
}, },
/*
* IP address used to expose the API ports
*/
apiBind: '0.0.0.0',
/* /*
* TCP Ports * TCP Ports
*/ */

9
keys/index-example.js

@ -15,7 +15,7 @@ module.exports = {
/* /*
* Dojo version * Dojo version
*/ */
dojoVersion: '1.5.0', dojoVersion: '1.6.0',
/* /*
* Bitcoind * Bitcoind
*/ */
@ -61,6 +61,10 @@ module.exports = {
connectionLimitPushTxApi: 5, connectionLimitPushTxApi: 5,
connectionLimitPushTxOrchestrator: 5 connectionLimitPushTxOrchestrator: 5
}, },
/*
* IP address used to expose the API ports
*/
apiBind: '127.0.0.1',
/* /*
* TCP Ports * TCP Ports
*/ */
@ -216,7 +220,7 @@ module.exports = {
* Testnet parameters * Testnet parameters
*/ */
testnet: { testnet: {
dojoVersion: '1.5.0', dojoVersion: '1.6.0',
bitcoind: { bitcoind: {
rpc: { rpc: {
user: 'user', user: 'user',
@ -240,6 +244,7 @@ module.exports = {
connectionLimitPushTxApi: 1, connectionLimitPushTxApi: 1,
connectionLimitPushTxOrchestrator: 5 connectionLimitPushTxOrchestrator: 5
}, },
apiBind: '127.0.0.1',
ports: { ports: {
account: 18080, account: 18080,
pushtx: 18081, pushtx: 18081,

10
lib/http-server/http-server.js

@ -18,9 +18,11 @@ class HttpServer {
/** /**
* Constructor * Constructor
* @param {int} port - port used by the http server * @param {int} port - port used by the http server
* @param {string} host - host exposing the http server
*/ */
constructor(port) { constructor(port, host) {
// Initialize server port // Initialize server host and port
this.host = host ? host : '127.0.0.1'
this.port = port this.port = port
// Listening server instance // Listening server instance
@ -54,8 +56,8 @@ class HttpServer {
}) })
// Start a http server // Start a http server
this.server = this.app.listen(this.port, () => { this.server = this.app.listen(this.port, this.host, () => {
Logger.info('HTTP server listening on port ' + this.port) Logger.info(`HTTP server listening on ${this.host}:${this.port}`)
}) })
this.server.timeout = 600 * 1000 this.server.timeout = 600 * 1000

2
package-lock.json

@ -1,6 +1,6 @@
{ {
"name": "samourai-dojo", "name": "samourai-dojo",
"version": "1.5.0", "version": "1.6.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "samourai-dojo", "name": "samourai-dojo",
"version": "1.5.0", "version": "1.6.0",
"description": "Backend server for Samourai Wallet", "description": "Backend server for Samourai Wallet",
"main": "accounts/index.js", "main": "accounts/index.js",
"scripts": { "scripts": {

2
pushtx/index-orchestrator.js

@ -39,7 +39,7 @@
// Initialize notification sockets of singleton pushTxProcessor // Initialize notification sockets of singleton pushTxProcessor
pushTxProcessor.initNotifications({ pushTxProcessor.initNotifications({
uriSocket: `tcp://*:${keys.ports.orchestrator}` uriSocket: `tcp://127.0.0.1:${keys.ports.orchestrator}`
}) })
// Initialize and start the orchestrator // Initialize and start the orchestrator

5
pushtx/index.js

@ -40,12 +40,13 @@
// Initialize notification sockets of singleton pushTxProcessor // Initialize notification sockets of singleton pushTxProcessor
pushTxProcessor.initNotifications({ pushTxProcessor.initNotifications({
uriSocket: `tcp://*:${keys.ports.notifpushtx}` uriSocket: `tcp://127.0.0.1:${keys.ports.notifpushtx}`
}) })
// Initialize the http server // Initialize the http server
const host = keys.apiBind
const port = keys.ports.pushtx const port = keys.ports.pushtx
const httpServer = new HttpServer(port) const httpServer = new HttpServer(port, host)
// Initialize the PushTx rest api // Initialize the PushTx rest api
const pushtxRestApi = new PushTxRestApi(httpServer) const pushtxRestApi = new PushTxRestApi(httpServer)

3
tracker/index.js

@ -39,8 +39,9 @@
const tracker = new Tracker() const tracker = new Tracker()
// Initialize the http server // Initialize the http server
const host = keys.apiBind
const port = keys.ports.trackerApi const port = keys.ports.trackerApi
const httpServer = new HttpServer(port) const httpServer = new HttpServer(port, host)
// Initialize the rest api endpoints // Initialize the rest api endpoints
const trackerRestApi = new TrackerRestApi(httpServer, tracker) const trackerRestApi = new TrackerRestApi(httpServer, tracker)

2
tracker/tracker.js

@ -22,7 +22,7 @@ class Tracker {
constructor() { constructor() {
// Notification socket for client events // Notification socket for client events
this.notifSock = zmq.socket('pub') 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 // Initialize the blockchain processor
// and the mempool buffer // and the mempool buffer

Loading…
Cancel
Save