From: David ‘Bombe’ Roden Date: Fri, 10 Jul 2015 20:04:34 +0000 (+0200) Subject: Add flag to GetNode command to include private data X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4ab59f592d61e27f7e61e80d66aa7fa524abcfb1;p=jFCPlib.git Add flag to GetNode command to include private data --- diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommand.java index da7bf68..ff94622 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommand.java @@ -10,5 +10,6 @@ import net.pterodactylus.fcp.NodeData; public interface GetNodeCommand extends Executable { GetNodeCommand opennetRef(); + GetNodeCommand includePrivate(); } diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommandImpl.java index 3c260ab..23c5ad0 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/GetNodeCommandImpl.java @@ -22,6 +22,7 @@ public class GetNodeCommandImpl implements GetNodeCommand { private final ListeningExecutorService threadPool; private final ConnectionSupplier connectionSupplier; private final AtomicBoolean giveOpennetRef = new AtomicBoolean(false); + private final AtomicBoolean includePrivate = new AtomicBoolean(false); public GetNodeCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); @@ -35,8 +36,15 @@ public class GetNodeCommandImpl implements GetNodeCommand { } @Override + public GetNodeCommand includePrivate() { + includePrivate.set(true); + return this; + } + + @Override public ListenableFuture execute() { - GetNode getNode = new GetNode(new RandomIdentifierGenerator().generate(), giveOpennetRef.get(), false, false); + GetNode getNode = new GetNode(new RandomIdentifierGenerator().generate(), giveOpennetRef.get(), + includePrivate.get(), false); return threadPool.submit(() -> new GetNodeReplySequence().send(getNode).get()); } diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 1bef22d..1e484dc 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -805,4 +805,34 @@ public class DefaultFcpClientTest { assertThat(nodeData.get().getVersion().toString(), is("Fred,0.7,1.0,1466")); } + @Test + public void defaultFcpClientCanGetNodeInformationWithPrivateData() + throws InterruptedException, ExecutionException, IOException { + Future nodeData = fcpClient.getNode().includePrivate().execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "GetNode", + "Identifier=" + identifier, + "GiveOpennetRef=false", + "WithPrivate=true", + "WithVolatile=false", + "EndMessage" + )); + fcpServer.writeLine( + "NodeData", + "Identifier=" + identifier, + "opennet=false", + "ark.pubURI=SSK@3YEf.../ark", + "ark.number=78", + "auth.negTypes=2", + "version=Fred,0.7,1.0,1466", + "lastGoodVersion=Fred,0.7,1.0,1466", + "ark.privURI=SSK@XdHMiRl", + "EndMessage" + ); + assertThat(nodeData.get().getARK().getPrivateURI(), is("SSK@XdHMiRl")); + } + }