Console: Add status and banned tabs to /peers (WIP)

Status tab now the default
This commit is contained in:
zzz
2022-11-23 12:23:17 -05:00
parent a825949a8a
commit 965f84bbfa
4 changed files with 158 additions and 38 deletions
@@ -173,6 +173,15 @@ public interface Transport {
public int countPeers();
public int countActivePeers();
public int countActiveSendPeers();
/**
* @return 8 bytes:
* version 1 ipv4 in/out, ipv6 in/out
* version 2 ipv4 in/out, ipv6 in/out
* @since 0.9.57
*/
public int[] getPeerCounts();
public boolean haveCapacity();
public boolean haveCapacity(int pct);
@@ -724,6 +724,25 @@ public class NTCPTransport extends TransportImpl {
public int countPeers() {
return _conByIdent.size();
}
/**
* @return 8 bytes:
* version 1 4 bytes all zeros
* version 2 ipv4 in/out, ipv6 in/out
* @since 0.9.57
*/
public int[] getPeerCounts() {
int[] rv = new int[8];
for (NTCPConnection con : _conByIdent.values()) {
int idx = 4;
if (con.isIPv6())
idx += 2;
if (!con.isInbound())
idx++;
rv[idx]++;
}
return rv;
}
/**
* For /peers UI only. Not a public API, not for external use.
@@ -3399,6 +3399,27 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
return _peersByIdent.size();
}
/**
* @return 8 bytes:
* version 1 ipv4 in/out, ipv6 in/out
* version 2 ipv4 in/out, ipv6 in/out
* @since 0.9.57
*/
public int[] getPeerCounts() {
int[] rv = new int[8];
for (PeerState peer : _peersByIdent.values()) {
int idx = 0;
if (peer.getVersion() > 1)
idx += 4;
if (peer.isIPv6())
idx += 2;
if (!peer.isInbound())
idx++;
rv[idx]++;
}
return rv;
}
public int countActivePeers() {
long old = _context.clock().now() - 5*60*1000;
int active = 0;