diff --git a/app/modules/bma/index.ts b/app/modules/bma/index.ts index ca769502a415cade3f3599d5a2d70aeb59be4e64..fc1e5d3fe9c7242ec4bd0cd92289521f581ac0f6 100644 --- a/app/modules/bma/index.ts +++ b/app/modules/bma/index.ts @@ -275,6 +275,34 @@ export class BMAPI extends stream.Transform { } startService = async () => { + // Override BMA configuration from environment variables + if (process.env.DUNITER_BMA_ENABLED === "true") { + if (this.conf.nobma) { + this.conf.nobma = false; + } + if (this.server.conf.upnp) { + this.server.conf.upnp = false; + } + } + + if (process.env.DUNITER_BMA_IP4) { + this.server.conf.ipv4 = process.env.DUNITER_BMA_IP4; + } + if (process.env.DUNITER_BMA_IP6) { + this.server.conf.ipv6 = process.env.DUNITER_BMA_IP6; + } + if (process.env.DUNITER_BMA_REMOTE_HOST) { + this.server.conf.remotehost = process.env.DUNITER_BMA_REMOTE_HOST; + } + if (process.env.DUNITER_BMA_PORT) { + this.server.conf.port = parseInt(process.env.DUNITER_BMA_PORT); + } + if (process.env.DUNITER_BMA_REMOTE_PORT) { + this.server.conf.remoteport = parseInt( + process.env.DUNITER_BMA_REMOTE_PORT + ); + } + if (this.conf.nobma) { // Disable BMA return Promise.resolve(); diff --git a/app/modules/bma/lib/network.ts b/app/modules/bma/lib/network.ts index 059c4b2c27139c53b6e62283ef06573456318cd3..799b0a78b1365782b9b71840346afd8996c401fb 100644 --- a/app/modules/bma/lib/network.ts +++ b/app/modules/bma/lib/network.ts @@ -80,7 +80,16 @@ export const Network = { if (whitelist.indexOf("127.0.0.1") === -1) { whitelist.push("127.0.0.1"); } + if (whitelist.indexOf("::1") === -1) { + whitelist.push("::1"); + } const ddosConf = server.conf.dos || {}; + + // Override BMA DDOS configuration from environment variables + if (process.env.DUNITER_BMA_WHITELIST) { + ddosConf.whitelist = process.env.DUNITER_BMA_WHITELIST.split(","); + } + ddosConf.silentStart = true; ddosConf.whitelist = Underscore.uniq( (ddosConf.whitelist || []).concat(whitelist)