|
|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
|
|
|
+import withStyles from '@material-ui/core/styles/withStyles';
|
|
|
import Table from '@material-ui/core/Table';
|
|
|
import TableHead from '@material-ui/core/TableHead';
|
|
|
import TableBody from '@material-ui/core/TableBody';
|
|
|
@@ -27,17 +28,23 @@ import Grid from '@material-ui/core/Grid/Grid';
|
|
|
import Typography from '@material-ui/core/Typography';
|
|
|
import {AreaChart, Area, Tooltip, YAxis} from 'recharts';
|
|
|
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
|
|
-import {faCircle as fasCircle} from '@fortawesome/free-solid-svg-icons';
|
|
|
-import {faCircle as farCircle} from '@fortawesome/free-regular-svg-icons';
|
|
|
+import {faCircle as fasCircle} from '@fortawesome/free-solid-svg-icons'; // More icons at fontawesome.com/icons
|
|
|
+import {faCircle as farCircle, faClipboard as farClipboard} from '@fortawesome/free-regular-svg-icons';
|
|
|
import convert from 'color-convert';
|
|
|
+import {Scrollbars} from 'react-custom-scrollbars';
|
|
|
|
|
|
import CustomTooltip, {bytePlotter, multiplier} from 'CustomTooltip';
|
|
|
import type {Network as NetworkType, PeerEvent} from '../types/content';
|
|
|
-import {styles as commonStyles, chartStrokeWidth, hues, hueScale} from '../common';
|
|
|
+import {chartStrokeWidth, hues, hueScale} from '../common';
|
|
|
|
|
|
// Peer chart dimensions.
|
|
|
-const trafficChartHeight = 18;
|
|
|
-const trafficChartWidth = 400;
|
|
|
+const trafficChartHeight = 15;
|
|
|
+const trafficChartWidth = 200;
|
|
|
+
|
|
|
+// attemptSeparator separates the peer connection attempts
|
|
|
+// such as the peers from the addresses with more attempts
|
|
|
+// go to the beginning of the table, and the rest go to the end.
|
|
|
+const attemptSeparator = 9;
|
|
|
|
|
|
// setMaxIngress adjusts the peer chart's gradient values based on the given value.
|
|
|
const setMaxIngress = (peer, value) => {
|
|
|
@@ -120,6 +127,58 @@ const setEgressChartAttributes = (peer) => {
|
|
|
setMaxEgress(peer, max);
|
|
|
};
|
|
|
|
|
|
+// shortName adds some heuristics to the node name in order to make it look meaningful.
|
|
|
+const shortName = (name: string) => {
|
|
|
+ const parts = name.split('/');
|
|
|
+ if (parts[0].substring(0, 'parity'.length).toLowerCase() === 'parity') {
|
|
|
+ // Merge Parity and Parity-Ethereum under the same name.
|
|
|
+ parts[0] = 'Parity';
|
|
|
+ }
|
|
|
+ if (parts.length < 2) {
|
|
|
+ console.error('Incorrect node name', name);
|
|
|
+ return parts[0];
|
|
|
+ }
|
|
|
+ const versionRE = RegExp(/^v?\d+\.\d+\.\d+.*/);
|
|
|
+ // Drop optional custom identifier.
|
|
|
+ if (!versionRE.test(parts[1])) {
|
|
|
+ if (parts.length < 3 || !versionRE.test(parts[2])) {
|
|
|
+ console.error('Incorrect node name', name);
|
|
|
+ return parts[0];
|
|
|
+ }
|
|
|
+ parts[1] = parts[2];
|
|
|
+ }
|
|
|
+ // Cutting anything from the version after the first - or +.
|
|
|
+ parts[1] = parts[1].split('-')[0].split('+')[0];
|
|
|
+ return `${parts[0]}/${parts[1]}`;
|
|
|
+};
|
|
|
+
|
|
|
+// shortLocation returns a shortened version of the given location object.
|
|
|
+const shortLocation = (location: Object) => {
|
|
|
+ if (!location) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return `${location.city ? `${location.city}/` : ''}${location.country ? location.country : ''}`;
|
|
|
+};
|
|
|
+
|
|
|
+// protocol returns a shortened version of the eth protocol values.
|
|
|
+const protocol = (p: Object) => {
|
|
|
+ if (!p) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ if (typeof p === 'string') {
|
|
|
+ return p;
|
|
|
+ }
|
|
|
+ if (!(p instanceof Object)) {
|
|
|
+ console.error('Wrong protocol type', p, typeof p);
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ if (!p.hasOwnProperty('version') || !p.hasOwnProperty('difficulty') || !p.hasOwnProperty('head')) {
|
|
|
+ console.error('Missing protocol attributes', p);
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return `h=${p.head.substring(0, 10)} v=${p.version} td=${p.difficulty}`;
|
|
|
+};
|
|
|
+
|
|
|
// inserter is a state updater function for the main component, which handles the peers.
|
|
|
export const inserter = (sampleLimit: number) => (update: NetworkType, prev: NetworkType) => {
|
|
|
// The first message contains the metered peer history.
|
|
|
@@ -134,84 +193,104 @@ export const inserter = (sampleLimit: number) => (update: NetworkType, prev: Net
|
|
|
if (!peer.maxEgress) {
|
|
|
setEgressChartAttributes(peer);
|
|
|
}
|
|
|
+ if (!peer.name) {
|
|
|
+ peer.name = '';
|
|
|
+ peer.shortName = '';
|
|
|
+ } else if (!peer.shortName) {
|
|
|
+ peer.shortName = shortName(peer.name);
|
|
|
+ }
|
|
|
+ if (!peer.enode) {
|
|
|
+ peer.enode = '';
|
|
|
+ }
|
|
|
+ if (!peer.protocols) {
|
|
|
+ peer.protocols = {};
|
|
|
+ }
|
|
|
+ peer.eth = protocol(peer.protocols.eth);
|
|
|
+ peer.les = protocol(peer.protocols.les);
|
|
|
});
|
|
|
}
|
|
|
+ bundle.shortLocation = shortLocation(bundle.location);
|
|
|
});
|
|
|
}
|
|
|
if (Array.isArray(update.diff)) {
|
|
|
update.diff.forEach((event: PeerEvent) => {
|
|
|
- if (!event.ip) {
|
|
|
- console.error('Peer event without IP', event);
|
|
|
+ if (!event.addr) {
|
|
|
+ console.error('Peer event without TCP address', event);
|
|
|
return;
|
|
|
}
|
|
|
switch (event.remove) {
|
|
|
case 'bundle': {
|
|
|
- delete prev.peers.bundles[event.ip];
|
|
|
+ delete prev.peers.bundles[event.addr];
|
|
|
return;
|
|
|
}
|
|
|
case 'known': {
|
|
|
- if (!event.id) {
|
|
|
- console.error('Remove known peer event without ID', event.ip);
|
|
|
+ if (!event.enode) {
|
|
|
+ console.error('Remove known peer event without node URL', event.addr);
|
|
|
return;
|
|
|
}
|
|
|
- const bundle = prev.peers.bundles[event.ip];
|
|
|
- if (!bundle || !bundle.knownPeers || !bundle.knownPeers[event.id]) {
|
|
|
- console.error('No known peer to remove', event.ip, event.id);
|
|
|
+ const bundle = prev.peers.bundles[event.addr];
|
|
|
+ if (!bundle || !bundle.knownPeers || !bundle.knownPeers[event.enode]) {
|
|
|
+ console.error('No known peer to remove', event.addr, event.enode);
|
|
|
return;
|
|
|
}
|
|
|
- delete bundle.knownPeers[event.id];
|
|
|
+ delete bundle.knownPeers[event.enode];
|
|
|
return;
|
|
|
}
|
|
|
- case 'attempt': {
|
|
|
- const bundle = prev.peers.bundles[event.ip];
|
|
|
- if (!bundle || !Array.isArray(bundle.attempts) || bundle.attempts.length < 1) {
|
|
|
- console.error('No unknown peer to remove', event.ip);
|
|
|
- return;
|
|
|
- }
|
|
|
- bundle.attempts.splice(0, 1);
|
|
|
- return;
|
|
|
}
|
|
|
- }
|
|
|
- if (!prev.peers.bundles[event.ip]) {
|
|
|
- prev.peers.bundles[event.ip] = {
|
|
|
+ if (!prev.peers.bundles[event.addr]) {
|
|
|
+ prev.peers.bundles[event.addr] = {
|
|
|
location: {
|
|
|
country: '',
|
|
|
city: '',
|
|
|
latitude: 0,
|
|
|
longitude: 0,
|
|
|
},
|
|
|
+ shortLocation: '',
|
|
|
knownPeers: {},
|
|
|
- attempts: [],
|
|
|
+ attempts: 0,
|
|
|
};
|
|
|
}
|
|
|
- const bundle = prev.peers.bundles[event.ip];
|
|
|
+ const bundle = prev.peers.bundles[event.addr];
|
|
|
if (event.location) {
|
|
|
bundle.location = event.location;
|
|
|
+ bundle.shortLocation = shortLocation(bundle.location);
|
|
|
return;
|
|
|
}
|
|
|
- if (!event.id) {
|
|
|
- if (!bundle.attempts) {
|
|
|
- bundle.attempts = [];
|
|
|
- }
|
|
|
- bundle.attempts.push({
|
|
|
- connected: event.connected,
|
|
|
- disconnected: event.disconnected,
|
|
|
- });
|
|
|
+ if (!event.enode) {
|
|
|
+ bundle.attempts++;
|
|
|
return;
|
|
|
}
|
|
|
if (!bundle.knownPeers) {
|
|
|
bundle.knownPeers = {};
|
|
|
}
|
|
|
- if (!bundle.knownPeers[event.id]) {
|
|
|
- bundle.knownPeers[event.id] = {
|
|
|
+ if (!bundle.knownPeers[event.enode]) {
|
|
|
+ bundle.knownPeers[event.enode] = {
|
|
|
connected: [],
|
|
|
disconnected: [],
|
|
|
ingress: [],
|
|
|
egress: [],
|
|
|
active: false,
|
|
|
+ name: '',
|
|
|
+ shortName: '',
|
|
|
+ enode: '',
|
|
|
+ protocols: {},
|
|
|
+ eth: '',
|
|
|
+ les: '',
|
|
|
};
|
|
|
}
|
|
|
- const peer = bundle.knownPeers[event.id];
|
|
|
+ const peer = bundle.knownPeers[event.enode];
|
|
|
+ if (event.name) {
|
|
|
+ peer.name = event.name;
|
|
|
+ peer.shortName = shortName(event.name);
|
|
|
+ }
|
|
|
+ if (event.enode) {
|
|
|
+ peer.enode = event.enode;
|
|
|
+ }
|
|
|
+ if (event.protocols) {
|
|
|
+ peer.protocols = event.protocols;
|
|
|
+ peer.eth = protocol(peer.protocols.eth);
|
|
|
+ peer.les = protocol(peer.protocols.les);
|
|
|
+ }
|
|
|
if (!peer.maxIngress) {
|
|
|
setIngressChartAttributes(peer);
|
|
|
}
|
|
|
@@ -300,11 +379,29 @@ export const inserter = (sampleLimit: number) => (update: NetworkType, prev: Net
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ prev.activePeerCount = 0;
|
|
|
+ Object.entries(prev.peers.bundles).forEach(([addr, bundle]) => {
|
|
|
+ if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Object.entries(bundle.knownPeers).forEach(([enode, peer]) => {
|
|
|
+ if (peer.active === true) {
|
|
|
+ prev.activePeerCount++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
return prev;
|
|
|
};
|
|
|
|
|
|
// styles contains the constant styles of the component.
|
|
|
const styles = {
|
|
|
+ title: {
|
|
|
+ marginLeft: 5,
|
|
|
+ },
|
|
|
+ table: {
|
|
|
+ borderCollapse: 'unset',
|
|
|
+ padding: 5,
|
|
|
+ },
|
|
|
tableHead: {
|
|
|
height: 'auto',
|
|
|
},
|
|
|
@@ -317,13 +414,39 @@ const styles = {
|
|
|
paddingBottom: 0,
|
|
|
paddingLeft: 5,
|
|
|
border: 'none',
|
|
|
+ fontFamily: 'monospace',
|
|
|
+ fontSize: 10,
|
|
|
+ },
|
|
|
+ content: {
|
|
|
+ height: '800px',
|
|
|
},
|
|
|
};
|
|
|
|
|
|
+// themeStyles returns the styles generated from the theme for the component.
|
|
|
+const themeStyles = theme => ({
|
|
|
+ title: {
|
|
|
+ color: theme.palette.common.white,
|
|
|
+ },
|
|
|
+ table: {
|
|
|
+ background: theme.palette.grey[900],
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+// limitedWidthStyle returns a style object which cuts the long text with three dots.
|
|
|
+const limitedWidthStyle = (width) => {
|
|
|
+ return {
|
|
|
+ textOverflow: 'ellipsis',
|
|
|
+ maxWidth: width,
|
|
|
+ overflow: 'hidden',
|
|
|
+ whiteSpace: 'nowrap',
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
export type Props = {
|
|
|
- container: Object,
|
|
|
- content: NetworkType,
|
|
|
- shouldUpdate: Object,
|
|
|
+ classes: Object, // injected by withStyles()
|
|
|
+ container: Object,
|
|
|
+ content: NetworkType,
|
|
|
+ shouldUpdate: Object,
|
|
|
};
|
|
|
|
|
|
type State = {};
|
|
|
@@ -351,179 +474,385 @@ class Network extends Component<Props, State> {
|
|
|
return `${month}/${date}/${hours}:${minutes}:${seconds}`;
|
|
|
};
|
|
|
|
|
|
- copyToClipboard = (id) => (event) => {
|
|
|
+ copyToClipboard = (text: string) => (event) => {
|
|
|
event.preventDefault();
|
|
|
- navigator.clipboard.writeText(id).then(() => {}, () => {
|
|
|
- console.error("Failed to copy node id", id);
|
|
|
+ navigator.clipboard.writeText(text).then(() => {}, () => {
|
|
|
+ console.error("Failed to copy", text);
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ lesList = () => {
|
|
|
+ const list = [];
|
|
|
+ Object.values(this.props.content.peers.bundles).forEach((bundle) => {
|
|
|
+ if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Object.entries(bundle.knownPeers).forEach(([enode, peer]) => {
|
|
|
+ if (peer.les === '' || peer.eth !== '') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ list.push({enode, name: peer.name, location: bundle.location, protocols: peer.protocols});
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ };
|
|
|
+
|
|
|
+ ethList = () => {
|
|
|
+ const list = [];
|
|
|
+ Object.values(this.props.content.peers.bundles).forEach((bundle) => {
|
|
|
+ if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Object.entries(bundle.knownPeers).forEach(([enode, peer]) => {
|
|
|
+ if (peer.eth === '' && peer.les !== '') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ list.push({enode, name: peer.name, location: bundle.location, protocols: peer.protocols});
|
|
|
+ });
|
|
|
});
|
|
|
+ return list;
|
|
|
};
|
|
|
|
|
|
- peerTableRow = (ip, id, bundle, peer) => {
|
|
|
+ attemptList = () => {
|
|
|
+ const list = [];
|
|
|
+ Object.entries(this.props.content.peers.bundles).forEach(([addr, bundle]) => {
|
|
|
+ if (!bundle.attempts) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ list.push({addr, location: bundle.location, attempts: bundle.attempts});
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ };
|
|
|
+
|
|
|
+ knownPeerTableRow = (addr, enode, bundle, peer, showTraffic, proto) => {
|
|
|
const ingressValues = peer.ingress.map(({value}) => ({ingress: value || 0.001}));
|
|
|
const egressValues = peer.egress.map(({value}) => ({egress: -value || -0.001}));
|
|
|
-
|
|
|
return (
|
|
|
- <TableRow key={`known_${ip}_${id}`} style={styles.tableRow}>
|
|
|
+ <TableRow key={`known_${addr}_${enode}`} style={styles.tableRow}>
|
|
|
<TableCell style={styles.tableCell}>
|
|
|
{peer.active
|
|
|
? <FontAwesomeIcon icon={fasCircle} color='green' />
|
|
|
- : <FontAwesomeIcon icon={farCircle} style={commonStyles.light} />
|
|
|
+ : <FontAwesomeIcon icon={farCircle} />
|
|
|
}
|
|
|
</TableCell>
|
|
|
- <TableCell style={{fontFamily: 'monospace', cursor: 'copy', ...styles.tableCell, ...commonStyles.light}} onClick={this.copyToClipboard(id)}>
|
|
|
- {id.substring(0, 10)}
|
|
|
+ <TableCell
|
|
|
+ style={{
|
|
|
+ cursor: 'copy',
|
|
|
+ ...styles.tableCell,
|
|
|
+ ...limitedWidthStyle(80),
|
|
|
+ }}
|
|
|
+ onClick={this.copyToClipboard(enode)}
|
|
|
+ >
|
|
|
+ {enode.substring(8)}
|
|
|
</TableCell>
|
|
|
- <TableCell style={styles.tableCell}>
|
|
|
- {bundle.location ? (() => {
|
|
|
- const l = bundle.location;
|
|
|
- return `${l.country ? l.country : ''}${l.city ? `/${l.city}` : ''}`;
|
|
|
- })() : ''}
|
|
|
+ <TableCell
|
|
|
+ style={{
|
|
|
+ cursor: 'copy',
|
|
|
+ ...styles.tableCell,
|
|
|
+ ...limitedWidthStyle(80),
|
|
|
+ }}
|
|
|
+ onClick={this.copyToClipboard(peer.name)}
|
|
|
+ >
|
|
|
+ {peer.shortName}
|
|
|
+ </TableCell>
|
|
|
+ <TableCell
|
|
|
+ style={{
|
|
|
+ cursor: 'copy',
|
|
|
+ ...styles.tableCell,
|
|
|
+ ...limitedWidthStyle(100),
|
|
|
+ }}
|
|
|
+ onClick={this.copyToClipboard(JSON.stringify(bundle.location))}
|
|
|
+ >
|
|
|
+ {bundle.shortLocation}
|
|
|
</TableCell>
|
|
|
<TableCell style={styles.tableCell}>
|
|
|
- <AreaChart
|
|
|
- width={trafficChartWidth}
|
|
|
- height={trafficChartHeight}
|
|
|
- data={ingressValues}
|
|
|
- margin={{top: 5, right: 5, bottom: 0, left: 5}}
|
|
|
- syncId={`peerIngress_${ip}_${id}`}
|
|
|
- >
|
|
|
- <defs>
|
|
|
- <linearGradient id={`ingressGradient_${ip}_${id}`} x1='0' y1='1' x2='0' y2='0'>
|
|
|
- {peer.ingressGradient
|
|
|
- && peer.ingressGradient.map(({offset, color}, i) => (
|
|
|
- <stop
|
|
|
- key={`ingressStop_${ip}_${id}_${i}`}
|
|
|
- offset={`${offset}%`}
|
|
|
- stopColor={color}
|
|
|
- />
|
|
|
- ))}
|
|
|
- </linearGradient>
|
|
|
- </defs>
|
|
|
- <Tooltip cursor={false} content={<CustomTooltip tooltip={bytePlotter('Download')} />} />
|
|
|
- <YAxis hide scale='sqrt' domain={[0.001, dataMax => Math.max(dataMax, 0)]} />
|
|
|
- <Area
|
|
|
- dataKey='ingress'
|
|
|
- isAnimationActive={false}
|
|
|
- type='monotone'
|
|
|
- fill={`url(#ingressGradient_${ip}_${id})`}
|
|
|
- stroke={peer.ingressGradient[peer.ingressGradient.length - 1].color}
|
|
|
- strokeWidth={chartStrokeWidth}
|
|
|
- />
|
|
|
- </AreaChart>
|
|
|
- <AreaChart
|
|
|
- width={trafficChartWidth}
|
|
|
- height={trafficChartHeight}
|
|
|
- data={egressValues}
|
|
|
- margin={{top: 0, right: 5, bottom: 5, left: 5}}
|
|
|
- syncId={`peerIngress_${ip}_${id}`}
|
|
|
- >
|
|
|
- <defs>
|
|
|
- <linearGradient id={`egressGradient_${ip}_${id}`} x1='0' y1='1' x2='0' y2='0'>
|
|
|
- {peer.egressGradient
|
|
|
- && peer.egressGradient.map(({offset, color}, i) => (
|
|
|
- <stop
|
|
|
- key={`egressStop_${ip}_${id}_${i}`}
|
|
|
- offset={`${offset}%`}
|
|
|
- stopColor={color}
|
|
|
- />
|
|
|
- ))}
|
|
|
- </linearGradient>
|
|
|
- </defs>
|
|
|
- <Tooltip cursor={false} content={<CustomTooltip tooltip={bytePlotter('Upload', multiplier(-1))} />} />
|
|
|
- <YAxis hide scale='sqrt' domain={[dataMin => Math.min(dataMin, 0), -0.001]} />
|
|
|
- <Area
|
|
|
- dataKey='egress'
|
|
|
- isAnimationActive={false}
|
|
|
- type='monotone'
|
|
|
- fill={`url(#egressGradient_${ip}_${id})`}
|
|
|
- stroke={peer.egressGradient[0].color}
|
|
|
- strokeWidth={chartStrokeWidth}
|
|
|
- />
|
|
|
- </AreaChart>
|
|
|
+ {showTraffic ? (
|
|
|
+ <>
|
|
|
+ <AreaChart
|
|
|
+ width={trafficChartWidth}
|
|
|
+ height={trafficChartHeight}
|
|
|
+ data={ingressValues}
|
|
|
+ margin={{top: 5, right: 5, bottom: 0, left: 5}}
|
|
|
+ syncId={`peerIngress_${addr}_${enode}`}
|
|
|
+ >
|
|
|
+ <defs>
|
|
|
+ <linearGradient id={`ingressGradient_${addr}_${enode}`} x1='0' y1='1' x2='0' y2='0'>
|
|
|
+ {peer.ingressGradient
|
|
|
+ && peer.ingressGradient.map(({offset, color}, i) => (
|
|
|
+ <stop
|
|
|
+ key={`ingressStop_${addr}_${enode}_${i}`}
|
|
|
+ offset={`${offset}%`}
|
|
|
+ stopColor={color}
|
|
|
+ />
|
|
|
+ ))}
|
|
|
+ </linearGradient>
|
|
|
+ </defs>
|
|
|
+ <Tooltip cursor={false} content={<CustomTooltip tooltip={bytePlotter('Download')} />} />
|
|
|
+ <YAxis hide scale='sqrt' domain={[0.001, dataMax => Math.max(dataMax, 0)]} />
|
|
|
+ <Area
|
|
|
+ dataKey='ingress'
|
|
|
+ isAnimationActive={false}
|
|
|
+ type='monotone'
|
|
|
+ fill={`url(#ingressGradient_${addr}_${enode})`}
|
|
|
+ stroke={peer.ingressGradient[peer.ingressGradient.length - 1].color}
|
|
|
+ strokeWidth={chartStrokeWidth}
|
|
|
+ />
|
|
|
+ </AreaChart>
|
|
|
+ <AreaChart
|
|
|
+ width={trafficChartWidth}
|
|
|
+ height={trafficChartHeight}
|
|
|
+ data={egressValues}
|
|
|
+ margin={{top: 0, right: 5, bottom: 5, left: 5}}
|
|
|
+ syncId={`peerIngress_${addr}_${enode}`}
|
|
|
+ >
|
|
|
+ <defs>
|
|
|
+ <linearGradient id={`egressGradient_${addr}_${enode}`} x1='0' y1='1' x2='0' y2='0'>
|
|
|
+ {peer.egressGradient
|
|
|
+ && peer.egressGradient.map(({offset, color}, i) => (
|
|
|
+ <stop
|
|
|
+ key={`egressStop_${addr}_${enode}_${i}`}
|
|
|
+ offset={`${offset}%`}
|
|
|
+ stopColor={color}
|
|
|
+ />
|
|
|
+ ))}
|
|
|
+ </linearGradient>
|
|
|
+ </defs>
|
|
|
+ <Tooltip cursor={false} content={<CustomTooltip tooltip={bytePlotter('Upload', multiplier(-1))} />} />
|
|
|
+ <YAxis hide scale='sqrt' domain={[dataMin => Math.min(dataMin, 0), -0.001]} />
|
|
|
+ <Area
|
|
|
+ dataKey='egress'
|
|
|
+ isAnimationActive={false}
|
|
|
+ type='monotone'
|
|
|
+ fill={`url(#egressGradient_${addr}_${enode})`}
|
|
|
+ stroke={peer.egressGradient[0].color}
|
|
|
+ strokeWidth={chartStrokeWidth}
|
|
|
+ />
|
|
|
+ </AreaChart>
|
|
|
+ </>
|
|
|
+ ) : null}
|
|
|
</TableCell>
|
|
|
+ {typeof proto === 'object' ? (
|
|
|
+ <>
|
|
|
+ <TableCell
|
|
|
+ style={{
|
|
|
+ cursor: 'copy',
|
|
|
+ ...styles.tableCell,
|
|
|
+ ...limitedWidthStyle(80),
|
|
|
+ }}
|
|
|
+ onClick={this.copyToClipboard(JSON.stringify(proto.head))}
|
|
|
+ >
|
|
|
+ {proto.head}
|
|
|
+ </TableCell>
|
|
|
+ <TableCell
|
|
|
+ style={{
|
|
|
+ cursor: 'copy',
|
|
|
+ ...styles.tableCell,
|
|
|
+ }}
|
|
|
+ onClick={this.copyToClipboard(JSON.stringify(proto.difficulty))}
|
|
|
+ >
|
|
|
+ {proto.difficulty}
|
|
|
+ </TableCell>
|
|
|
+ <TableCell
|
|
|
+ style={{
|
|
|
+ cursor: 'copy',
|
|
|
+ ...styles.tableCell,
|
|
|
+ }}
|
|
|
+ onClick={this.copyToClipboard(JSON.stringify(proto.version))}
|
|
|
+ >
|
|
|
+ {proto.version}
|
|
|
+ </TableCell>
|
|
|
+ </>
|
|
|
+ ) : null }
|
|
|
</TableRow>
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+ connectionAttemptTableRow = (addr, bundle) => (
|
|
|
+ <TableRow key={`attempt_${addr}`} style={styles.tableRow}>
|
|
|
+ <TableCell
|
|
|
+ style={{cursor: 'copy', ...styles.tableCell}}
|
|
|
+ onClick={this.copyToClipboard(addr)}
|
|
|
+ >
|
|
|
+ {addr}
|
|
|
+ </TableCell>
|
|
|
+ <TableCell
|
|
|
+ style={{cursor: 'copy', ...limitedWidthStyle(100), ...styles.tableCell}}
|
|
|
+ onClick={this.copyToClipboard(JSON.stringify(bundle.location))}
|
|
|
+ >
|
|
|
+ {bundle.shortLocation}
|
|
|
+ </TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>
|
|
|
+ {bundle.attempts}
|
|
|
+ </TableCell>
|
|
|
+ </TableRow>
|
|
|
+ );
|
|
|
+
|
|
|
render() {
|
|
|
+ const {classes} = this.props;
|
|
|
return (
|
|
|
- <Grid container direction='row' justify='space-between'>
|
|
|
- <Grid item>
|
|
|
- <Table>
|
|
|
- <TableHead style={styles.tableHead}>
|
|
|
- <TableRow style={styles.tableRow}>
|
|
|
- <TableCell style={styles.tableCell} />
|
|
|
- <TableCell style={styles.tableCell}>Node ID</TableCell>
|
|
|
- <TableCell style={styles.tableCell}>Location</TableCell>
|
|
|
- <TableCell style={styles.tableCell}>Traffic</TableCell>
|
|
|
- </TableRow>
|
|
|
- </TableHead>
|
|
|
- <TableBody>
|
|
|
- {Object.entries(this.props.content.peers.bundles).map(([ip, bundle]) => {
|
|
|
- if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return Object.entries(bundle.knownPeers).map(([id, peer]) => {
|
|
|
- if (peer.active === false) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return this.peerTableRow(ip, id, bundle, peer);
|
|
|
- });
|
|
|
- })}
|
|
|
- </TableBody>
|
|
|
- <TableBody>
|
|
|
- {Object.entries(this.props.content.peers.bundles).map(([ip, bundle]) => {
|
|
|
- if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return Object.entries(bundle.knownPeers).map(([id, peer]) => {
|
|
|
- if (peer.active === true) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return this.peerTableRow(ip, id, bundle, peer);
|
|
|
- });
|
|
|
- })}
|
|
|
- </TableBody>
|
|
|
- </Table>
|
|
|
+ <Grid container direction='row' spacing={3}>
|
|
|
+ <Grid item style={{width: '40%'}}>
|
|
|
+ <div className={classes.table} style={styles.table}>
|
|
|
+ <Typography variant='subtitle1' gutterBottom className={classes.title} style={styles.title}>
|
|
|
+ Full peers
|
|
|
+ <FontAwesomeIcon
|
|
|
+ icon={farClipboard}
|
|
|
+ onClick={this.copyToClipboard(JSON.stringify(this.ethList()))}
|
|
|
+ style={{float: 'right'}}
|
|
|
+ />
|
|
|
+ </Typography>
|
|
|
+ <Scrollbars style={styles.content}>
|
|
|
+ <Table>
|
|
|
+ <TableHead style={styles.tableHead}>
|
|
|
+ <TableRow style={styles.tableRow}>
|
|
|
+ <TableCell style={styles.tableCell} />
|
|
|
+ <TableCell style={styles.tableCell}>Node URL</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Name</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Location</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Traffic</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Head</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>TD</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>V</TableCell>
|
|
|
+ </TableRow>
|
|
|
+ </TableHead>
|
|
|
+ <TableBody>
|
|
|
+ {Object.entries(this.props.content.peers.bundles).map(([addr, bundle]) => {
|
|
|
+ if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return Object.entries(bundle.knownPeers).map(([enode, peer]) => {
|
|
|
+ if (peer.active === false) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (peer.eth === '' && peer.les !== '') {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return this.knownPeerTableRow(addr, enode, bundle, peer, true, peer.protocols.eth);
|
|
|
+ });
|
|
|
+ })}
|
|
|
+ </TableBody>
|
|
|
+ <TableBody>
|
|
|
+ {Object.entries(this.props.content.peers.bundles).map(([addr, bundle]) => {
|
|
|
+ if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return Object.entries(bundle.knownPeers).map(([enode, peer]) => {
|
|
|
+ if (peer.active === true) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (peer.eth === '' && peer.les !== '') {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return this.knownPeerTableRow(addr, enode, bundle, peer, false, peer.protocols.eth);
|
|
|
+ });
|
|
|
+ })}
|
|
|
+ </TableBody>
|
|
|
+ </Table>
|
|
|
+ </Scrollbars>
|
|
|
+ </div>
|
|
|
+ </Grid>
|
|
|
+ <Grid item style={{width: '40%'}}>
|
|
|
+ <div className={classes.table} style={styles.table}>
|
|
|
+ <Typography variant='subtitle1' gutterBottom className={classes.title} style={styles.title}>
|
|
|
+ Light peers
|
|
|
+ <FontAwesomeIcon
|
|
|
+ icon={farClipboard}
|
|
|
+ onClick={this.copyToClipboard(JSON.stringify(this.lesList()))}
|
|
|
+ style={{float: 'right'}}
|
|
|
+ />
|
|
|
+ </Typography>
|
|
|
+ <Scrollbars style={styles.content}>
|
|
|
+ <Table>
|
|
|
+ <TableHead style={styles.tableHead}>
|
|
|
+ <TableRow style={styles.tableRow}>
|
|
|
+ <TableCell style={styles.tableCell} />
|
|
|
+ <TableCell style={styles.tableCell}>Node URL</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Name</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Location</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Traffic</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Head</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>TD</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>V</TableCell>
|
|
|
+ </TableRow>
|
|
|
+ </TableHead>
|
|
|
+ <TableBody>
|
|
|
+ {Object.entries(this.props.content.peers.bundles).map(([addr, bundle]) => {
|
|
|
+ if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return Object.entries(bundle.knownPeers).map(([enode, peer]) => {
|
|
|
+ if (peer.active === false) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (peer.les === '' || peer.eth !== '') {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return this.knownPeerTableRow(addr, enode, bundle, peer, true, peer.protocols.les);
|
|
|
+ });
|
|
|
+ })}
|
|
|
+ </TableBody>
|
|
|
+ <TableBody>
|
|
|
+ {Object.entries(this.props.content.peers.bundles).map(([addr, bundle]) => {
|
|
|
+ if (!bundle.knownPeers || Object.keys(bundle.knownPeers).length < 1) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return Object.entries(bundle.knownPeers).map(([enode, peer]) => {
|
|
|
+ if (peer.active === true) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (peer.les === '' || peer.eth !== '') {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return this.knownPeerTableRow(addr, enode, bundle, peer, false, peer.protocols.les);
|
|
|
+ });
|
|
|
+ })}
|
|
|
+ </TableBody>
|
|
|
+ </Table>
|
|
|
+ </Scrollbars>
|
|
|
+ </div>
|
|
|
</Grid>
|
|
|
- <Grid item>
|
|
|
- <Typography variant='subtitle1' gutterBottom>
|
|
|
- Connection attempts
|
|
|
- </Typography>
|
|
|
- <Table>
|
|
|
- <TableHead style={styles.tableHead}>
|
|
|
- <TableRow style={styles.tableRow}>
|
|
|
- <TableCell style={styles.tableCell}>IP</TableCell>
|
|
|
- <TableCell style={styles.tableCell}>Location</TableCell>
|
|
|
- <TableCell style={styles.tableCell}>Nr</TableCell>
|
|
|
- </TableRow>
|
|
|
- </TableHead>
|
|
|
- <TableBody>
|
|
|
- {Object.entries(this.props.content.peers.bundles).map(([ip, bundle]) => {
|
|
|
- if (!bundle.attempts || bundle.attempts.length < 1) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return (
|
|
|
- <TableRow key={`attempt_${ip}`} style={styles.tableRow}>
|
|
|
- <TableCell style={styles.tableCell}>{ip}</TableCell>
|
|
|
- <TableCell style={styles.tableCell}>
|
|
|
- {bundle.location ? (() => {
|
|
|
- const l = bundle.location;
|
|
|
- return `${l.country ? l.country : ''}${l.city ? `/${l.city}` : ''}`;
|
|
|
- })() : ''}
|
|
|
- </TableCell>
|
|
|
- <TableCell style={styles.tableCell}>
|
|
|
- {Object.values(bundle.attempts).length}
|
|
|
- </TableCell>
|
|
|
+ <Grid item xs>
|
|
|
+ <div className={classes.table} style={styles.table}>
|
|
|
+ <Typography variant='subtitle1' gutterBottom className={classes.title} style={styles.title}>
|
|
|
+ Connection attempts
|
|
|
+ <FontAwesomeIcon
|
|
|
+ icon={farClipboard}
|
|
|
+ onClick={this.copyToClipboard(JSON.stringify(this.attemptList()))}
|
|
|
+ style={{float: 'right'}}
|
|
|
+ />
|
|
|
+ </Typography>
|
|
|
+ <Scrollbars style={styles.content}>
|
|
|
+ <Table>
|
|
|
+ <TableHead style={styles.tableHead}>
|
|
|
+ <TableRow style={styles.tableRow}>
|
|
|
+ <TableCell style={styles.tableCell}>TCP address</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Location</TableCell>
|
|
|
+ <TableCell style={styles.tableCell}>Nr</TableCell>
|
|
|
</TableRow>
|
|
|
- );
|
|
|
- })}
|
|
|
- </TableBody>
|
|
|
- </Table>
|
|
|
+ </TableHead>
|
|
|
+ <TableBody>
|
|
|
+ {Object.entries(this.props.content.peers.bundles).map(([addr, bundle]) => {
|
|
|
+ if (!bundle.attempts || bundle.attempts <= attemptSeparator) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return this.connectionAttemptTableRow(addr, bundle);
|
|
|
+ })}
|
|
|
+ </TableBody>
|
|
|
+ <TableBody>
|
|
|
+ {Object.entries(this.props.content.peers.bundles).map(([addr, bundle]) => {
|
|
|
+ if (!bundle.attempts || bundle.attempts < 1 || bundle.attempts > attemptSeparator) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return this.connectionAttemptTableRow(addr, bundle);
|
|
|
+ })}
|
|
|
+ </TableBody>
|
|
|
+ </Table>
|
|
|
+ </Scrollbars>
|
|
|
+ </div>
|
|
|
</Grid>
|
|
|
</Grid>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export default Network;
|
|
|
+export default withStyles(themeStyles)(Network);
|