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()
// 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)

2
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

4
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
*/

9
keys/index-example.js

@ -15,7 +15,7 @@ module.exports = {
/*
* Dojo version
*/
dojoVersion: '1.5.0',
dojoVersion: '1.6.0',
/*
* Bitcoind
*/
@ -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
*/
@ -216,7 +220,7 @@ module.exports = {
* Testnet parameters
*/
testnet: {
dojoVersion: '1.5.0',
dojoVersion: '1.6.0',
bitcoind: {
rpc: {
user: 'user',
@ -240,6 +244,7 @@ module.exports = {
connectionLimitPushTxApi: 1,
connectionLimitPushTxOrchestrator: 5
},
apiBind: '127.0.0.1',
ports: {
account: 18080,
pushtx: 18081,

10
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

2
package-lock.json

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

2
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": {

2
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

5
pushtx/index.js

@ -40,12 +40,13 @@
// 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
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)

3
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)

2
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

Loading…
Cancel
Save