Unverified Commit 86ba2884 authored by Éloïs's avatar Éloïs Committed by GitHub
Browse files

Merge branch 'dev' into typage

parents 5f8f3b78 4c67e0e8
......@@ -54,5 +54,7 @@ test/fast/modules/crawler/block_pulling.js*
test/fast/modules/crawler/block_pulling.d.ts
test/fast/fork*.js*
test/fast/fork*.d.ts
test/fast/proxies*.js*
test/fast/proxies*.d.ts
test/fast/modules/ws2p/*.js*
test/fast/modules/ws2p/*.d.ts
......@@ -49,6 +49,12 @@ export const ExecuteCommand = () => {
.option('--nostdout', 'Disable stdout printing for `export-bc` command')
.option('--noshuffle', 'Disable peers shuffling for `sync` command')
.option('--socks-proxy <host:port>', 'Use Socks Proxy')
.option('--tor-proxy <host:port>', 'Use Tor Socks Proxy')
.option('--reaching-clear-ep <clear|tor|none>', 'method for reaching an clear endpoint')
.option('--force-tor', 'force duniter to contact endpoint tor (if you redirect the traffic to tor yourself)')
.option('--rm-proxies', 'Remove all proxies')
.option('--timeout <milliseconds>', 'Timeout to use when contacting peers', parseInt)
.option('--httplogs', 'Enable HTTP logs')
.option('--nohttplogs', 'Disable HTTP logs')
......
......@@ -18,8 +18,8 @@ const POSITIVE_INT = "[1-9][0-9]{0,18}"
const TIMESTAMP = "[1-9][0-9]{0,18}"
const BOOLEAN = "[01]"
const WS2PID = "[0-9a-f]{8}"
const SOFTWARE = "[a-z0-9]{2,15}"
const SOFT_VERSION = "[0-9a-z.-_]{2,15}"
const SOFTWARE = "[a-z0-9._-]{2,15}"
const SOFT_VERSION = "[0-9a-z._-]{2,15}"
const POW_PREFIX = "([1-9]|[1-9][0-9]|[1-8][0-9][0-9])" // 1-899
const SPECIAL_BLOCK = '0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855'
const META_TS = "META:TS:" + BLOCK_UID
......@@ -31,9 +31,13 @@ const UNLOCK = "(SIG\\(" + INTEGER + "\\)|XHX\\(" + XUNLOCK + "\\))"
const CONDITIONS = "(&&|\\|\\|| |[()]|(SIG\\(" + PUBKEY + "\\)|(XHX\\([A-F0-9]{64}\\)|CLTV\\(" + CLTV_INTEGER + "\\)|CSV\\(" + CSV_INTEGER + "\\))))*"
const BMA_REGEXP = /^BASIC_MERKLED_API( ([a-z_][a-z0-9-_.]*))?( ([0-9.]+))?( ([0-9a-f:]+))?( ([0-9]+))$/
const WS2P_REGEXP = /^WS2P ([a-f0-9]{8}) ([a-z_][a-z0-9-_.]*|[0-9.]+|[0-9a-f:]+) ([0-9]+)( (.+))?$/
const BMATOR_REGEXP = /^BMATOR( ([a-z0-9]{16})\.onion)( ([0-9.]+))?( ([0-9a-f:]+))?( ([0-9]+))$/
const WS2P_REGEXP = /^WS2P ([a-f0-9]{8}) ([a-z_][a-z0-9-_.]*|[0-9.]+|[0-9a-f:]+) ([0-9]+)(?: (.+))?$/
const WS2PTOR_REGEXP = /^WS2PTOR ([a-f0-9]{8}) ([a-z0-9-_.]*|[0-9.]+|[0-9a-f:]+.onion) ([0-9]+)(?: (.+))?$/
const WS_FULL_ADDRESS_ONION_REGEX = /^(?:wss?:\/\/)(?:www\.)?([0-9a-z]{16}\.onion)(:[0-9]+)?$/
const IPV4_REGEXP = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
const IPV6_REGEXP = /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b).){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|(([0-9A-Fa-f]{1,4}:){0,5}:((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b).){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|(::([0-9A-Fa-f]{1,4}:){0,5}((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b).){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/;
const HOST_ONION_REGEX = /^(?:www\.)?([0-9a-z]{16}\.onion)$/
const MAXIMUM_LEN_OF_COMPACT_TX = 100
const MAXIMUM_LEN_OF_OUTPUT = 2000
......@@ -89,9 +93,13 @@ export const CommonConstants = {
SWITCH_ON_BRANCH_AHEAD_BY_X_BLOCKS: 3,
BMA_REGEXP,
BMATOR_REGEXP,
WS2P_REGEXP,
WS2PTOR_REGEXP,
WS_FULL_ADDRESS_ONION_REGEX,
IPV4_REGEXP,
IPV6_REGEXP,
HOST_ONION_REGEX,
PUBLIC_KEY: exact(PUBKEY),
INTEGER: /^\d+$/,
BASE58: exact(BASE58),
......
import {CommonConstants} from "../../../lib/common-libs/constants"
import * as stream from "stream"
import {hashf} from "../../../lib/common"
import {NewLogger} from "../../logger"
const logger = NewLogger()
export abstract class GenericParser extends stream.Transform {
......@@ -21,7 +24,7 @@ export abstract class GenericParser extends stream.Transform {
return;
}
syncWrite(str:string, logger:any = null): any {
syncWrite(str:string): any {
let error = ""
const obj = {};
this._parse(str, obj);
......
import {CommonConstants} from "../../../lib/common-libs/constants"
import {GenericParser} from "./GenericParser"
import {rawer} from "../../../lib/common-libs/index"
import { unlock } from '../txunlock';
export class TransactionParser extends GenericParser {
......@@ -105,6 +106,10 @@ function extractOutputs(raw:string) {
for (const line of lines) {
if (line.match(CommonConstants.TRANSACTION.TARGET)) {
outputs.push(line);
const unlocked = unlock(line.split(':')[2], [], {})
if (unlocked === null) {
throw Error("Wrong output format")
}
} else {
// Not a transaction input, stop reading
break;
......
......@@ -44,7 +44,7 @@ let grammar = {
}
};
export function unlock(conditionsStr:string, executions:any, metadata:any) {
export function unlock(conditionsStr:string, executions:any, metadata:any): boolean|null {
let parser = new Parser(grammar);
......@@ -56,6 +56,9 @@ export function unlock(conditionsStr:string, executions:any, metadata:any) {
},
xHx: function(hash:string) {
let xhxParam = executions[this.i++];
if (xhxParam === undefined) {
xhxParam = ""
}
return hashf(xhxParam) === hash;
},
cltv: function(deadline:string) {
......@@ -69,6 +72,6 @@ export function unlock(conditionsStr:string, executions:any, metadata:any) {
try {
return parser.parse(conditionsStr);
} catch(e) {
return false;
return null;
}
}
\ No newline at end of file
......@@ -126,8 +126,11 @@ export class QuickSynchronizer {
// Remember expiration dates
for (const entry of index) {
if (entry.op === 'CREATE' && (entry.expires_on || entry.revokes_on)) {
sync_expires.push(entry.expires_on || entry.revokes_on);
if (entry.expires_on) {
sync_expires.push(entry.expires_on)
}
if (entry.revokes_on) {
sync_expires.push(entry.revokes_on)
}
}
sync_expires = _.uniq(sync_expires);
......@@ -151,8 +154,8 @@ export class QuickSynchronizer {
i--;
}
}
let currentNextExpiring = sync_nextExpiring
sync_nextExpiring = sync_expires.reduce((max, value) => max ? Math.min(max, value) : value, sync_nextExpiring);
const currentNextExpiring = sync_nextExpiring
sync_nextExpiring = sync_expires.reduce((max, value) => max ? Math.min(max, value) : value, 9007199254740991); // Far far away date
const nextExpiringChanged = currentNextExpiring !== sync_nextExpiring
// Fills in correctly the SINDEX
......
......@@ -110,7 +110,8 @@ module.exports = {
STATUS_INTERVAL: {
UPDATE: 2, // Every X blocks
MAX: 20 // MAX Y blocks
}
},
ONION_ENDPOINT_REGEX: new RegExp('(?:https?:\/\/)?(?:www)?(\S*?\.onion)(\/[-\w]*)*')
},
PROOF_OF_WORK: {
EVALUATION: 1000,
......
......@@ -15,6 +15,7 @@ import {DBBlock} from "../db/DBBlock"
import {DBMembership} from "./sqliteDAL/MembershipDAL"
import {MerkleDTO} from "../dto/MerkleDTO"
import {CommonConstants} from "../common-libs/constants"
import { ProxiesConf } from '../proxy';
const fs = require('fs')
const path = require('path')
......@@ -142,7 +143,7 @@ export class FileDAL {
}
async getWS2Peers() {
return this.peerDAL.getPeersWithEndpointsLike('WS2P ')
return this.peerDAL.getPeersWithEndpointsLike('WS2P')
}
async getBlock(number:number) {
......@@ -366,6 +367,10 @@ export class FileDAL {
return this.iindexDAL.getToBeKickedPubkeys()
}
getRevokedPubkeys() {
return this.mindexDAL.getRevokedPubkeys()
}
async searchJustIdentities(search:string) {
const pendings = await this.idtyDAL.searchThoseMatching(search);
const writtens = await this.iindexDAL.searchThoseMatching(search);
......@@ -842,7 +847,11 @@ export class FileDAL {
let conf = ConfDTO.complete(overrideConf || {});
if (!defaultConf) {
const savedConf = await this.confDAL.loadConf();
const savedProxyConf = _(savedConf.proxyConf).extend({});
conf = _(savedConf).extend(overrideConf || {});
if (overrideConf.proxiesConf !== undefined) {} else {
conf.proxyConf = _(savedProxyConf).extend({});
}
}
if (this.loadConfHook) {
await this.loadConfHook(conf)
......
......@@ -70,4 +70,12 @@ export class MIndexDAL extends AbstractIndex<MindexEntry> {
async removeBlock(blockstamp:string) {
return this.exec('DELETE FROM ' + this.table + ' WHERE written_on = \'' + blockstamp + '\'')
}
async getRevokedPubkeys() {
// All those who has been revoked. Make one result per pubkey.
const revovedMemberships = await this.sqlFind({ revoked_on: { $null: false} });
// Filter on those to be revoked, return their pubkey
return revovedMemberships.map((entry:MindexEntry) => entry.pub);
}
}
import {CommonConstants} from "../common-libs/constants"
import { ProxiesConf } from '../proxy';
const _ = require('underscore');
const constants = require('../constants');
......@@ -46,7 +47,9 @@ export interface KeypairConfDTO {
}
export interface NetworkConfDTO {
proxiesConf: ProxiesConf|undefined
nobma: boolean
bmaWithCrawler: boolean
remoteport: number
remotehost: string|null
remoteipv4: string|null
......@@ -73,7 +76,9 @@ export interface WS2PConfDTO {
maxPublic?:number
maxPrivate?:number
preferedNodes?: string[]
preferedOnly: boolean
privilegedNodes?: string[]
privilegedOnly: boolean
}
}
......@@ -135,6 +140,8 @@ 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
publicAccess?: boolean
......@@ -146,14 +153,16 @@ export class ConfDTO implements CurrencyConfDTO, KeypairConfDTO, NetworkConfDTO,
port?: number
host?: string
preferedNodes?: string[]
preferedOnly: boolean
privilegedNodes?: string[]
privilegedOnly: boolean
maxPublic?:number
maxPrivate?:number
}
) {}
static mock() {
return new ConfDTO("", "", [], [], 0, 3600 * 1000, constants.PROOF_OF_WORK.DEFAULT.CPU, 1, constants.PROOF_OF_WORK.DEFAULT.PREFIX, 0, 0, constants.CONTRACT.DEFAULT.C, constants.CONTRACT.DEFAULT.DT, constants.CONTRACT.DEFAULT.DT_REEVAL, 0, constants.CONTRACT.DEFAULT.UD0, 0, 0, constants.CONTRACT.DEFAULT.STEPMAX, constants.CONTRACT.DEFAULT.SIGPERIOD, 0, constants.CONTRACT.DEFAULT.SIGVALIDITY, constants.CONTRACT.DEFAULT.MSVALIDITY, constants.CONTRACT.DEFAULT.SIGQTY, constants.CONTRACT.DEFAULT.SIGSTOCK, constants.CONTRACT.DEFAULT.X_PERCENT, constants.CONTRACT.DEFAULT.PERCENTROT, constants.CONTRACT.DEFAULT.POWDELAY, constants.CONTRACT.DEFAULT.AVGGENTIME, constants.CONTRACT.DEFAULT.MEDIANTIMEBLOCKS, false, 3000, false, constants.BRANCHES.DEFAULT_WINDOW_SIZE, constants.CONTRACT.DEFAULT.IDTYWINDOW, constants.CONTRACT.DEFAULT.MSWINDOW, constants.CONTRACT.DEFAULT.SIGWINDOW, 0, { pub:'', sec:'' }, null, "", "", 0, "", "", "", "", 0, "", "", null, false, "", true, true)
return new ConfDTO("", "", [], [], 0, 3600 * 1000, constants.PROOF_OF_WORK.DEFAULT.CPU, 1, constants.PROOF_OF_WORK.DEFAULT.PREFIX, 0, 0, constants.CONTRACT.DEFAULT.C, constants.CONTRACT.DEFAULT.DT, constants.CONTRACT.DEFAULT.DT_REEVAL, 0, constants.CONTRACT.DEFAULT.UD0, 0, 0, constants.CONTRACT.DEFAULT.STEPMAX, constants.CONTRACT.DEFAULT.SIGPERIOD, 0, constants.CONTRACT.DEFAULT.SIGVALIDITY, constants.CONTRACT.DEFAULT.MSVALIDITY, constants.CONTRACT.DEFAULT.SIGQTY, constants.CONTRACT.DEFAULT.SIGSTOCK, constants.CONTRACT.DEFAULT.X_PERCENT, constants.CONTRACT.DEFAULT.PERCENTROT, constants.CONTRACT.DEFAULT.POWDELAY, constants.CONTRACT.DEFAULT.AVGGENTIME, constants.CONTRACT.DEFAULT.MEDIANTIMEBLOCKS, false, 3000, false, constants.BRANCHES.DEFAULT_WINDOW_SIZE, constants.CONTRACT.DEFAULT.IDTYWINDOW, constants.CONTRACT.DEFAULT.MSWINDOW, constants.CONTRACT.DEFAULT.SIGWINDOW, 0, { pub:'', sec:'' }, null, "", "", 0, "", "", "", "", 0, "", "", null, false, "", true, true, false, new ProxiesConf(), undefined)
}
static defaultConf() {
......
......@@ -94,16 +94,30 @@ export class PeerDTO implements Cloneable {
return bma || {};
}
getWS2P() {
getWS2P(canReachTorEp:boolean, canReachClearEp:boolean) {
let api:{ uuid:string, host:string, port:number, path:string }|null = null
const endpointRegexp = (canReachTorEp) ? CommonConstants.WS2PTOR_REGEXP:CommonConstants.WS2P_REGEXP
for (const ep of this.endpoints) {
const matches:any = !api && ep.match(CommonConstants.WS2P_REGEXP)
if (matches) {
api = {
uuid: matches[1],
host: matches[2] || '',
port: parseInt(matches[3]) || 0,
path: matches[4]
if (canReachTorEp) {
const matches:any = ep.match(CommonConstants.WS2PTOR_REGEXP)
if (matches) {
return {
uuid: matches[1],
host: matches[2] || '',
port: parseInt(matches[3]) || 0,
path: matches[4]
}
}
}
if (canReachClearEp) {
const matches:any = !api && ep.match(CommonConstants.WS2P_REGEXP)
if (matches) {
api = {
uuid: matches[1],
host: matches[2] || '',
port: parseInt(matches[3]) || 0,
path: matches[4]
}
}
}
}
......
......@@ -1622,7 +1622,8 @@ export class Indexer {
// BR_G93
static async ruleIndexGenMembershipExpiry(HEAD: DBHead, dal:any) {
const expiries = [];
const memberships: MindexEntry[] = reduceBy(await dal.mindexDAL.sqlFind({ expires_on: { $lte: HEAD.medianTime } }), ['pub']);
const memberships: MindexEntry[] = reduceBy(await dal.mindexDAL.sqlFind({ expires_on: { $lte: HEAD.medianTime }, revokes_on: { $gt: HEAD.medianTime} }), ['pub']);
for (const POTENTIAL of memberships) {
const MS = await dal.mindexDAL.getReducedMS(POTENTIAL.pub);
const hasRenewedSince = MS.expires_on > HEAD.medianTime;
......
import {CommonConstants} from "./common-libs/constants"
const SocksProxyAgent = require('socks-proxy-agent');
export class ProxiesConf {
public proxySocksAddress: string|undefined
public proxyTorAddress: string|undefined
public reachingClearEp: string
public forceTor: boolean
constructor () {
this.proxySocksAddress = undefined
this.proxyTorAddress = undefined
this.reachingClearEp = 'clear'
this.forceTor = false
}
static canReachClearEndpoint(proxiesConf: ProxiesConf|undefined):boolean {
return (proxiesConf === undefined || proxiesConf.reachingClearEp !== 'none')
}
static canReachTorEndpoint(proxiesConf: ProxiesConf|undefined):boolean {
return (proxiesConf !== undefined && (proxiesConf.forceTor || proxiesConf.proxyTorAddress !== undefined) )
}
static httpProxy(url:string, proxiesConf: ProxiesConf|undefined):string|undefined {
return ProxiesConf.chooseProxyAgent(url, proxiesConf, CommonConstants.HOST_ONION_REGEX)
}
static wsProxy(address:string, proxiesConf: ProxiesConf|undefined):string|undefined {
return ProxiesConf.chooseProxyAgent(address, proxiesConf, CommonConstants.WS_FULL_ADDRESS_ONION_REGEX)
}
private static chooseProxyAgent(address:string, proxiesConf: ProxiesConf|undefined, onionRegex:RegExp):string|undefined {
if (proxiesConf !== undefined) {
if (address.match(onionRegex)) {
if (ProxiesConf.canReachTorEndpoint(proxiesConf)) {
return proxiesConf.proxyTorAddress
}
} else {
if (ProxiesConf.canReachClearEndpoint(proxiesConf)) {
if (proxiesConf.reachingClearEp == 'tor') {
return proxiesConf.proxyTorAddress
} else {
return proxiesConf.proxySocksAddress
}
}
}
}
return undefined
}
}
\ No newline at end of file
......@@ -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;
......@@ -253,6 +260,9 @@ export class BMAPI extends stream.Transform {
function getEndpoint(theConf:NetworkConfDTO) {
let endpoint = 'BASIC_MERKLED_API';
if (theConf.remotehost) {
if (theConf.remotehost.match(BMAConstants.HOST_ONION_REGEX)) {
endpoint = 'BMATOR';
}
endpoint += ' ' + theConf.remotehost;
}
if (theConf.remoteipv4) {
......
import {CommonConstants} from "../../../lib/common-libs/constants"
export const BMAConstants = {
BMA_PORTS_START: 10901,
......@@ -6,6 +7,7 @@ export const BMAConstants = {
DEFAULT_PORT: 10901,
IPV4_REGEXP: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/,
IPV6_REGEXP: /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b).){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|(([0-9A-Fa-f]{1,4}:){0,5}:((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b).){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|(::([0-9A-Fa-f]{1,4}:){0,5}((b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b).){3}(b((25[0-5])|(1d{2})|(2[0-4]d)|(d{1,2}))b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/,
HOST_ONION_REGEX: CommonConstants.HOST_ONION_REGEX,
PORT_START: 15000,
UPNP_INTERVAL: 300,
UPNP_TTL: 600,
......
import { IindexEntry } from './../../../../lib/indexer';
import {AbstractController} from "./AbstractController";
import {BMAConstants} from "../constants";
import {DBIdentity} from "../../../../lib/dal/sqliteDAL/IdentityDAL";
import { IdentityForRequirements } from '../../../../service/BlockchainService';
import {
HttpCert,
HttpCertIdentity, HttpCertifications,
......@@ -153,7 +155,30 @@ export class WOTBinding extends AbstractController {
async requirementsOfPending(req:any): Promise<HttpRequirements> {
const minsig = ParametersService.getMinSig(req)
const identities = await this.server.dal.idtyDAL.query('SELECT i.*, count(c.sig) as nbSig FROM idty i, cert c WHERE c.target = i.hash group by i.hash having nbSig >= ?', minsig)
let identities:IdentityForRequirements[] = await this.server.dal.idtyDAL.query(
'SELECT i.*, count(c.sig) as nbSig ' +
'FROM idty i, cert c ' +
'WHERE c.target = i.hash group by i.hash having nbSig >= ?',
minsig)
const members:IdentityForRequirements[] = (await this.server.dal.idtyDAL.query(
'SELECT i.*, count(c.sig) as nbSig ' +
'FROM i_index i, cert c ' +
'WHERE c.`to` = i.pub group by i.pub having nbSig >= ?',
minsig)).map((i:IindexEntry):IdentityForRequirements => {
return {
hash: i.hash || "",
member: i.member || false,
wasMember: i.wasMember || false,
pubkey: i.pub,
uid: i.uid || "",
buid: i.created_on || "",
sig: i.sig || "",
revocation_sig: "",
revoked: false,
revoked_on: 0
}
})
identities = identities.concat(members)
const all = await this.BlockchainService.requirementsOfIdentities(identities, false);
if (!all || !all.length) {
throw BMAConstants.ERRORS.NO_IDTY_MATCHING_PUB_OR_UID;
......
......@@ -337,7 +337,9 @@ async function upnpConf (noupnp:boolean, logger:any) {
const publicPort = await getAvailablePort(client)
const privatePort = publicPort
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([
......
......@@ -143,7 +143,7 @@ async function promptKey (conf:KeypairConfDTO, program:any) {
const answersWantToChange = await inquirer.prompt([{
type: "confirm",
name: "change",
message: "Modify you keypair?",
message: "Modify your keypair?",
default: changeKeypair
}]);
......
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