diff --git a/app/lib/dto/ConfDTO.ts b/app/lib/dto/ConfDTO.ts index 1227913e3f3e6139fb636e6ef8aa82d4597122ac..f6c57cc5eea581e96a0e188d4265941ceb79b239 100644 --- a/app/lib/dto/ConfDTO.ts +++ b/app/lib/dto/ConfDTO.ts @@ -49,6 +49,7 @@ export interface KeypairConfDTO { export interface NetworkConfDTO { proxiesConf: ProxiesConf|undefined nobma: boolean + bmaWithCrawler: boolean remoteport: number remotehost: string|null remoteipv4: string|null @@ -136,6 +137,7 @@ export class ConfDTO implements CurrencyConfDTO, KeypairConfDTO, NetworkConfDTO, public homename: string, public memory: boolean, public nobma: boolean, + public bmaWithCrawler: boolean, public proxiesConf: ProxiesConf|undefined, public ws2p?: { privateAccess: boolean @@ -155,7 +157,7 @@ export class ConfDTO implements CurrencyConfDTO, KeypairConfDTO, NetworkConfDTO, ) {} static mock() { - return new ConfDTO("", "", [], [], 0, 0, 0.6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, false, 0, 0, 0, 0, 0, { pub:'', sec:'' }, null, "", "", 0, "", "", "", 0, "", "", null, false, "", true, true, undefined) + return new ConfDTO("", "", [], [], 0, 0, 0.6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, false, 0, 0, 0, 0, 0, { pub:'', sec:'' }, null, "", "", 0, "", "", "", 0, "", "", null, false, "", true, false, true, undefined) } static defaultConf() { diff --git a/app/modules/bma/index.ts b/app/modules/bma/index.ts index 914a6ecf4465032babe6e223b09273bf017ef416..2abe0ba7af3dba53b4b8cd99c9ccc8d5180568ce 100644 --- a/app/modules/bma/index.ts +++ b/app/modules/bma/index.ts @@ -29,6 +29,8 @@ export const BmaDependency = { { value: '--noupnp', desc: 'Do not use UPnP to open remote port.' }, { value: '--bma', desc: 'Enables BMA API and its crawlers.' }, { value: '--nobma', desc: 'Disables BMA API and its crawlers.' }, + { value: '--bma-with-crawler', desc: 'Enables BMA Crawler.' }, + { value: '--bma-without-crawler', desc: 'Disable BMA Crawler.' }, { value: '-p, --port <port>', desc: 'Port to listen for requests', parser: (val:string) => parseInt(val) }, { value: '--ipv4 <address>', desc: 'IPv4 interface to listen for requests' }, { value: '--ipv6 <address>', desc: 'IPv6 interface to listen for requests' }, @@ -73,6 +75,9 @@ export const BmaDependency = { } } + // If bmaWithCrawler hasn't been defined yet + if (conf.bmaWithCrawler === undefined) { conf.bmaWithCrawler = false } + if (program.port !== undefined) conf.port = parseInt(program.port) if (program.ipv4 !== undefined) conf.ipv4 = program.ipv4; if (program.ipv6 !== undefined) conf.ipv6 = program.ipv6; @@ -82,6 +87,8 @@ export const BmaDependency = { if (program.remotep !== undefined) conf.remoteport = parseInt(program.remotep) if (program.bma !== undefined) conf.nobma = false if (program.nobma !== undefined) conf.nobma = true + if (program.bmaWithCrawler !== undefined) conf.bmaWithCrawler = true + if (program.bmaWithoutCrawler !== undefined) conf.bmaWithCrawler = false if (!conf.ipv4) delete conf.ipv4; if (!conf.ipv6) delete conf.ipv6; diff --git a/app/modules/bma/lib/network.ts b/app/modules/bma/lib/network.ts index 250a622bf2eea56c49bc2c6446a053e0aee0b49b..3e9e026f966695db0dd83a977605e5a26c1f2439 100644 --- a/app/modules/bma/lib/network.ts +++ b/app/modules/bma/lib/network.ts @@ -339,6 +339,7 @@ async function upnpConf (noupnp:boolean, logger:any) { const conf:NetworkConfDTO = { proxiesConf: undefined, nobma: true, + bmaWithCrawler: false, port: privatePort, ipv4: '127.0.0.1', ipv6: '::1', diff --git a/app/modules/crawler/lib/crawler.ts b/app/modules/crawler/lib/crawler.ts index 44bf5a217fa08548046b2a2e297c9dd341db41c5..9520c5e3abbae6b58d033c04f7879ef051205b56 100644 --- a/app/modules/crawler/lib/crawler.ts +++ b/app/modules/crawler/lib/crawler.ts @@ -48,7 +48,7 @@ export class Crawler extends stream.Transform implements DuniterService { } startService() { - if (this.conf.nobma) { + if (this.conf.nobma || !this.conf.bmaWithCrawler) { return Promise.resolve() } return Promise.all([ @@ -60,7 +60,7 @@ export class Crawler extends stream.Transform implements DuniterService { } stopService() { - if (this.conf.nobma) { + if (this.conf.nobma || !this.conf.bmaWithCrawler) { return Promise.resolve() } return Promise.all([ diff --git a/app/modules/router.ts b/app/modules/router.ts index 1530cc43e516b63511b385767f50390ebe88bcba..d6484f05ba8d3ef1a74e8440c44c25aae80af128 100644 --- a/app/modules/router.ts +++ b/app/modules/router.ts @@ -44,7 +44,7 @@ class Router extends stream.Transform { }; async startService() { - if (this.server.conf.nobma) { + if (this.server.conf.nobma || !this.server.conf.bmaWithCrawler) { // Disable BMA return Promise.resolve() } @@ -69,7 +69,7 @@ class Router extends stream.Transform { } async stopService() { - if (this.server.conf.nobma) { + if (this.server.conf.nobma || !this.server.conf.bmaWithCrawler) { // Disable BMA return Promise.resolve() }