Add method to allow local addresses for a peer
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / quelaton / ModifyPeerCommandImpl.java
index 189e2e2..35d6d57 100644 (file)
@@ -26,6 +26,7 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand {
        private final ConnectionSupplier connectionSupplier;
        private final AtomicReference<String> nodeIdentifier = new AtomicReference<>();
        private final AtomicReference<Boolean> enabled = new AtomicReference<>();
+       private final AtomicReference<Boolean> allowLocalAddresses = new AtomicReference<>();
 
        public ModifyPeerCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
                this.threadPool = MoreExecutors.listeningDecorator(threadPool);
@@ -45,6 +46,12 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand {
        }
 
        @Override
+       public ModifyPeerCommand allowLocalAddresses() {
+               allowLocalAddresses.set(true);
+               return this;
+       }
+
+       @Override
        public Executable<Optional<Peer>> byName(String name) {
                nodeIdentifier.set(name);
                return this::execute;
@@ -69,6 +76,7 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand {
        private Optional<Peer> executeSequence() throws IOException, ExecutionException, InterruptedException {
                ModifyPeer modifyPeer = new ModifyPeer(new RandomIdentifierGenerator().generate(), nodeIdentifier.get());
                Optional.ofNullable(enabled.get()).ifPresent(enabled -> modifyPeer.setEnabled(enabled));
+               Optional.ofNullable(allowLocalAddresses.get()).ifPresent(allowed -> modifyPeer.setAllowLocalAddresses(allowed));
                try (ModifyPeerDialog modifyPeerDialog = new ModifyPeerDialog()) {
                        return modifyPeerDialog.send(modifyPeer).get();
                }