Skip to content
Snippets Groups Projects
Commit bf062f05 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] #1084 WS2P: add a BMA URL /network/ws2p/info

parent 9df2429c
No related branches found
No related tags found
No related merge requests found
...@@ -70,6 +70,7 @@ export const bma = function(server:Server, interfaces:NetworkInterface[], httpLo ...@@ -70,6 +70,7 @@ export const bma = function(server:Server, interfaces:NetworkInterface[], httpLo
httpMethods.httpGET( '/network/peering/peers', (req:any) => net.peersGet(req), BMALimitation.limitAsVeryHighUsage()); httpMethods.httpGET( '/network/peering/peers', (req:any) => net.peersGet(req), BMALimitation.limitAsVeryHighUsage());
httpMethods.httpPOST( '/network/peering/peers', (req:any) => net.peersPost(req), BMALimitation.limitAsHighUsage()); httpMethods.httpPOST( '/network/peering/peers', (req:any) => net.peersPost(req), BMALimitation.limitAsHighUsage());
httpMethods.httpGET( '/network/peers', (req:any) => net.peers(), BMALimitation.limitAsHighUsage()); httpMethods.httpGET( '/network/peers', (req:any) => net.peers(), BMALimitation.limitAsHighUsage());
httpMethods.httpGET( '/network/ws2p/info', (req:any) => net.ws2pInfo(), BMALimitation.limitAsHighUsage());
httpMethods.httpPOST( '/wot/add', (req:any) => wot.add(req), BMALimitation.limitAsHighUsage()); httpMethods.httpPOST( '/wot/add', (req:any) => wot.add(req), BMALimitation.limitAsHighUsage());
httpMethods.httpPOST( '/wot/certify', (req:any) => wot.certify(req), BMALimitation.limitAsHighUsage()); httpMethods.httpPOST( '/wot/certify', (req:any) => wot.certify(req), BMALimitation.limitAsHighUsage());
httpMethods.httpPOST( '/wot/revoke', (req:any) => wot.revoke(req), BMALimitation.limitAsHighUsage()); httpMethods.httpPOST( '/wot/revoke', (req:any) => wot.revoke(req), BMALimitation.limitAsHighUsage());
......
import {AbstractController} from "./AbstractController"; import {AbstractController} from "./AbstractController";
import {BMAConstants} from "../constants"; import {BMAConstants} from "../constants";
import {HttpMerkleOfPeers, HttpPeer, HttpPeers} from "../dtos"; import {HttpMerkleOfPeers, HttpPeer, HttpPeers, HttpWS2PInfo} from "../dtos";
import {WS2PDependency} from "../../../ws2p/index"
const _ = require('underscore'); const _ = require('underscore');
const http2raw = require('../http2raw'); const http2raw = require('../http2raw');
...@@ -64,4 +65,20 @@ export class NetworkBinding extends AbstractController { ...@@ -64,4 +65,20 @@ export class NetworkBinding extends AbstractController {
}) })
}; };
} }
async ws2pInfo(): Promise<HttpWS2PInfo> {
const cluster = this.server.ws2pCluster
let level1 = 0
let level2 = 0
if (cluster) {
level1 = await cluster.clientsCount()
level2 = await cluster.servedCount()
}
return {
peers: {
level1,
level2
}
};
}
} }
...@@ -395,6 +395,13 @@ export interface HttpPeers { ...@@ -395,6 +395,13 @@ export interface HttpPeers {
peers: DBPeer2[] peers: DBPeer2[]
} }
export interface HttpWS2PInfo {
peers: {
level1: number,
level2: number
}
}
export const MerkleOfPeers = { export const MerkleOfPeers = {
"depth": Number, "depth": Number,
"nodesCount": Number, "nodesCount": Number,
......
...@@ -22,6 +22,7 @@ import {RevocationDTO} from "./app/lib/dto/RevocationDTO" ...@@ -22,6 +22,7 @@ import {RevocationDTO} from "./app/lib/dto/RevocationDTO"
import {TransactionDTO} from "./app/lib/dto/TransactionDTO" import {TransactionDTO} from "./app/lib/dto/TransactionDTO"
import {PeerDTO} from "./app/lib/dto/PeerDTO" import {PeerDTO} from "./app/lib/dto/PeerDTO"
import {OtherConstants} from "./app/lib/other_constants" import {OtherConstants} from "./app/lib/other_constants"
import {WS2PCluster} from "./app/modules/ws2p/lib/WS2PCluster"
export interface HookableServer { export interface HookableServer {
generatorGetJoinData: (...args:any[]) => Promise<any> generatorGetJoinData: (...args:any[]) => Promise<any>
...@@ -48,6 +49,7 @@ export class Server extends stream.Duplex implements HookableServer { ...@@ -48,6 +49,7 @@ export class Server extends stream.Duplex implements HookableServer {
private paramsP:Promise<any>|null private paramsP:Promise<any>|null
private endpointsDefinitions:(()=>Promise<string>)[] = [] private endpointsDefinitions:(()=>Promise<string>)[] = []
private wrongEndpointsFilters:((endpoints:string[])=>Promise<string[]>)[] = [] private wrongEndpointsFilters:((endpoints:string[])=>Promise<string[]>)[] = []
ws2pCluster:WS2PCluster|undefined
conf:ConfDTO conf:ConfDTO
dal:FileDAL dal:FileDAL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment