ModifyPeerCommand clearBurstOnly();
ModifyPeerCommand setListenOnly();
ModifyPeerCommand clearListenOnly();
+ ModifyPeerCommand ignoreSource();
Executable<Optional<Peer>> byName(String name);
Executable<Optional<Peer>> byIdentity(String nodeIdentity);
private final AtomicReference<Boolean> allowLocalAddresses = new AtomicReference<>();
private final AtomicReference<Boolean> burstOnly = new AtomicReference<>();
private final AtomicReference<Boolean> listenOnly = new AtomicReference<>();
+ private final AtomicReference<Boolean> ignoreSource = new AtomicReference<>();
public ModifyPeerCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
this.threadPool = MoreExecutors.listeningDecorator(threadPool);
}
@Override
+ public ModifyPeerCommand ignoreSource() {
+ ignoreSource.set(true);
+ return this;
+ }
+
+ @Override
public Executable<Optional<Peer>> byName(String name) {
nodeIdentifier.set(name);
return this::execute;
Optional.ofNullable(allowLocalAddresses.get()).ifPresent(allowed -> modifyPeer.setAllowLocalAddresses(allowed));
Optional.ofNullable(burstOnly.get()).ifPresent(burstOnly -> modifyPeer.setBurstOnly(burstOnly));
Optional.ofNullable(listenOnly.get()).ifPresent(listenOnly -> modifyPeer.setListenOnly(listenOnly));
+ Optional.ofNullable(ignoreSource.get()).ifPresent(ignoreSource -> modifyPeer.setIgnoreSource(ignoreSource));
try (ModifyPeerDialog modifyPeerDialog = new ModifyPeerDialog()) {
return modifyPeerDialog.send(modifyPeer).get();
}
assertThat(peer.get().get().getIdentity(), is("id1"));
}
+ @Test
+ public void defaultFcpClientCanIgnoreSourceForPeer()
+ throws InterruptedException, ExecutionException, IOException {
+ Future<Optional<Peer>> peer = fcpClient.modifyPeer().ignoreSource().byIdentity("id1").execute();
+ connectNode();
+ List<String> lines = fcpServer.collectUntil(is("EndMessage"));
+ String identifier = extractIdentifier(lines);
+ assertThat(lines, matchesFcpMessage(
+ "ModifyPeer",
+ "Identifier=" + identifier,
+ "NodeIdentifier=id1",
+ "IgnoreSourcePort=true",
+ "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"));
+ }
+
}