From: David ‘Bombe’ Roden Date: Mon, 13 Jul 2015 18:30:31 +0000 (+0200) Subject: Add method to clear listen only on a peer X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8cfb423373226c1fa0b459230f79f25f7f5da9f3;p=jFCPlib.git Add method to clear listen only on a peer --- diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java index ef00205..d421ae1 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java @@ -18,6 +18,7 @@ public interface ModifyPeerCommand { ModifyPeerCommand setBurstOnly(); ModifyPeerCommand clearBurstOnly(); ModifyPeerCommand setListenOnly(); + ModifyPeerCommand clearListenOnly(); Executable> byName(String name); Executable> byIdentity(String nodeIdentity); diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java index 58d750d..6877245 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java @@ -78,6 +78,12 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand { } @Override + public ModifyPeerCommand clearListenOnly() { + listenOnly.set(false); + return this; + } + + @Override public Executable> byName(String name) { nodeIdentifier.set(name); return this::execute; diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 8da2967..c87e47a 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1466,4 +1466,31 @@ public class DefaultFcpClientTest { assertThat(peer.get().get().getIdentity(), is("id1")); } + @Test + public void defaultFcpClientCanClearListenOnlyForPeer() + throws InterruptedException, ExecutionException, IOException { + Future> peer = fcpClient.modifyPeer().clearListenOnly().byIdentity("id1").execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "ModifyPeer", + "Identifier=" + identifier, + "NodeIdentifier=id1", + "IsListenOnly=false", + "EndMessage" + )); + assertThat(lines, not(contains(startsWith("AllowLocalAddresses=")))); + assertThat(lines, not(contains(startsWith("IsDisabled=")))); + assertThat(lines, not(contains(startsWith("IsBurstOnly=")))); + fcpServer.writeLine( + "Peer", + "Identifier=" + identifier, + "NodeIdentifier=Friend1", + "identity=id1", + "EndMessage" + ); + assertThat(peer.get().get().getIdentity(), is("id1")); + } + }