Skip to content
Snippets Groups Projects
Commit 984bbf6e authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'bma-env-conf' into 'dev'

feat(bma): configure with env var

See merge request !1382
parents 6df529bd 5dbcd68f
No related branches found
No related tags found
1 merge request!1382feat(bma): configure with env var
...@@ -275,6 +275,34 @@ export class BMAPI extends stream.Transform { ...@@ -275,6 +275,34 @@ export class BMAPI extends stream.Transform {
} }
startService = async () => { 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) { if (this.conf.nobma) {
// Disable BMA // Disable BMA
return Promise.resolve(); return Promise.resolve();
......
...@@ -80,7 +80,16 @@ export const Network = { ...@@ -80,7 +80,16 @@ export const Network = {
if (whitelist.indexOf("127.0.0.1") === -1) { if (whitelist.indexOf("127.0.0.1") === -1) {
whitelist.push("127.0.0.1"); whitelist.push("127.0.0.1");
} }
if (whitelist.indexOf("::1") === -1) {
whitelist.push("::1");
}
const ddosConf = server.conf.dos || {}; 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.silentStart = true;
ddosConf.whitelist = Underscore.uniq( ddosConf.whitelist = Underscore.uniq(
(ddosConf.whitelist || []).concat(whitelist) (ddosConf.whitelist || []).concat(whitelist)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment