Mise à jour de GitLab prévue ce samedi 23 octobre 2021 à partir de 9h00 CET

Commit 15d53414 authored by Éloïs's avatar Éloïs
Browse files

[enh] add option to use bma without crawler #1174

parent f231daf6
......@@ -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() {
......
......@@ -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;
......
......@@ -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',
......
......@@ -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([
......
......@@ -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()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment