From 3a99f2bcfbd2a0aa39af9936ef4591a75dedd8fb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 13 Jul 2015 20:37:32 +0200 Subject: [PATCH] Add method to not ignore source of a peer --- .../fcp/quelaton/ModifyPeerCommand.java | 1 + .../fcp/quelaton/ModifyPeerCommandImpl.java | 6 +++++ .../fcp/quelaton/DefaultFcpClientTest.java | 28 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java index 104401f..0c8a0a4 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommand.java @@ -20,6 +20,7 @@ public interface ModifyPeerCommand { ModifyPeerCommand setListenOnly(); ModifyPeerCommand clearListenOnly(); ModifyPeerCommand ignoreSource(); + ModifyPeerCommand useSource(); 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 257bcfa..5dd2bf9 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java @@ -91,6 +91,12 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand { } @Override + public ModifyPeerCommand useSource() { + ignoreSource.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 80fb19c..cf7a4ae 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -1521,4 +1521,32 @@ public class DefaultFcpClientTest { assertThat(peer.get().get().getIdentity(), is("id1")); } + @Test + public void defaultFcpClientCanUseSourceForPeer() + throws InterruptedException, ExecutionException, IOException { + Future> peer = fcpClient.modifyPeer().useSource().byIdentity("id1").execute(); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + assertThat(lines, matchesFcpMessage( + "ModifyPeer", + "Identifier=" + identifier, + "NodeIdentifier=id1", + "IgnoreSourcePort=false", + "EndMessage" + )); + assertThat(lines, not(contains(startsWith("AllowLocalAddresses=")))); + assertThat(lines, not(contains(startsWith("IsDisabled=")))); + assertThat(lines, not(contains(startsWith("IsBurstOnly=")))); + assertThat(lines, not(contains(startsWith("IsListenOnly=")))); + fcpServer.writeLine( + "Peer", + "Identifier=" + identifier, + "NodeIdentifier=Friend1", + "identity=id1", + "EndMessage" + ); + assertThat(peer.get().get().getIdentity(), is("id1")); + } + } -- 2.7.4