X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2Fhighlevel%2FFcpClient.java;h=bcbc21dddd3ba7bed83ae0f4657a9de2de40bf25;hb=1c2b138872a5388fbe25f7e3b6ad33ae79742db5;hp=4af4426c87442e14fc1410f9066f75eb4c877ad5;hpb=07b8dedfe353a27cb06c7f7d3086680829917c48;p=jFCPlib.git diff --git a/src/net/pterodactylus/fcp/highlevel/FcpClient.java b/src/net/pterodactylus/fcp/highlevel/FcpClient.java index 4af4426..bcbc21d 100644 --- a/src/net/pterodactylus/fcp/highlevel/FcpClient.java +++ b/src/net/pterodactylus/fcp/highlevel/FcpClient.java @@ -254,6 +254,78 @@ public class FcpClient { } /** + * Returns all darknet peers. + * + * @param withMetadata + * true to include peer metadata + * @param withVolatile + * true to include volatile peer data + * @return A set containing the node’s darknet peers + * @throws IOException + * if an I/O error occurs + * @throws FcpException + * if an FCP error occurs + */ + public Collection getDarknetPeers(boolean withMetadata, boolean withVolatile) throws IOException, FcpException { + Collection allPeers = getPeers(withMetadata, withVolatile); + Collection darknetPeers = new HashSet(); + for (Peer peer : allPeers) { + if (!peer.isOpennet() && !peer.isSeed()) { + darknetPeers.add(peer); + } + } + return darknetPeers; + } + + /** + * Returns all opennet peers. + * + * @param withMetadata + * true to include peer metadata + * @param withVolatile + * true to include volatile peer data + * @return A set containing the node’s opennet peers + * @throws IOException + * if an I/O error occurs + * @throws FcpException + * if an FCP error occurs + */ + public Collection getOpennetPeers(boolean withMetadata, boolean withVolatile) throws IOException, FcpException { + Collection allPeers = getPeers(withMetadata, withVolatile); + Collection opennetPeers = new HashSet(); + for (Peer peer : allPeers) { + if (peer.isOpennet() && !peer.isSeed()) { + opennetPeers.add(peer); + } + } + return opennetPeers; + } + + /** + * Returns all seed peers. + * + * @param withMetadata + * true to include peer metadata + * @param withVolatile + * true to include volatile peer data + * @return A set containing the node’s seed peers + * @throws IOException + * if an I/O error occurs + * @throws FcpException + * if an FCP error occurs + */ + public Collection getSeedPeers(boolean withMetadata, boolean withVolatile) throws IOException, FcpException { + Collection allPeers = getPeers(withMetadata, withVolatile); + Collection seedPeers = new HashSet(); + for (Peer peer : allPeers) { + if (peer.isSeed()) { + seedPeers.add(peer); + } + } + return seedPeers; + } + + /** * Adds the given peer to the node. * * @param peer