Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase control over ports exposed by dojo #147

Merged
merged 3 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion accounts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docker/my-dojo/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docker/my-dojo/node/keys.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
9 changes: 7 additions & 2 deletions keys/index-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
/*
* Dojo version
*/
dojoVersion: '1.5.0',
dojoVersion: '1.6.0',
/*
* Bitcoind
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -216,7 +220,7 @@ module.exports = {
* Testnet parameters
*/
testnet: {
dojoVersion: '1.5.0',
dojoVersion: '1.6.0',
bitcoind: {
rpc: {
user: 'user',
Expand All @@ -240,6 +244,7 @@ module.exports = {
connectionLimitPushTxApi: 1,
connectionLimitPushTxOrchestrator: 5
},
apiBind: '127.0.0.1',
ports: {
account: 18080,
pushtx: 18081,
Expand Down
10 changes: 6 additions & 4 deletions lib/http-server/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion pushtx/index-orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pushtx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tracker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tracker/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down