diff --git a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/CommandManagerPlugin.java b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/CommandManagerPlugin.java index eeb7b08..e50eb0f 100644 --- a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/CommandManagerPlugin.java +++ b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/CommandManagerPlugin.java @@ -65,7 +65,9 @@ public Collection createComponents( Supplier repositoriesServiceSupplier ) { this.commandIndex = new CommandIndex(client, clusterService, threadPool); - ConfigReader configReader = new ConfigReader("127.0.0.1", 8080, "", "admin", "admin"); + ConfigReader configReader = new ConfigReader("127.0.0.1", 8080, "/", "admin", "admin"); + //ConfigReader configReader = new ConfigReader("httpbin.org", 80, "/post", "admin", "admin"); + //ConfigReader configReader = new ConfigReader(); JobScheduler jobScheduler = new JobScheduler(threadPool, configReader); return Collections.emptyList(); } diff --git a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/http/client/AsyncRequestRepository.java b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/http/client/AsyncRequestRepository.java index fdcd0f7..4c8fc83 100644 --- a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/http/client/AsyncRequestRepository.java +++ b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/http/client/AsyncRequestRepository.java @@ -57,10 +57,10 @@ public class AsyncRequestRepository { public AsyncRequestRepository(ConfigReader configReader) throws Exception { this.target = new HttpHost(configReader.getHostName(), configReader.getPort()); this.requestUri = configReader.getPath(); - prepareAsyncRequest(); } public void prepareAsyncRequest() { + logger.info("Preparing Async Request"); IOReactorConfig ioReactorConfig = IOReactorConfig.custom() .setSoTimeout(5, TimeUnit.SECONDS) .build(); @@ -98,10 +98,11 @@ public CompletableFuture performAsyncRequest() throws Exception { CompletableFuture future = new CompletableFuture<>(); this.requester.execute( - AsyncRequestBuilder.post() + AsyncRequestBuilder.get() .setHttpHost(this.target) .setPath(this.requestUri) - .setEntity("{\"field\":\"value\"}",ContentType.APPLICATION_JSON) + .addHeader("Content-Type", "application/json") + .setEntity("{\"field\":\"value\"}") .build(), new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), Timeout.ofSeconds(5), @@ -112,7 +113,6 @@ public void completed(final Message message) { final HttpResponse response = message.getHead(); final String body = message.getBody(); logger.info(requestUri + "->{}", response.getCode()); - logger.info(body); future.complete(body); } diff --git a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/scheduler/JobScheduler.java b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/scheduler/JobScheduler.java index 842aba7..347251a 100644 --- a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/scheduler/JobScheduler.java +++ b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/scheduler/JobScheduler.java @@ -27,6 +27,7 @@ private void start(ThreadPool threadPool) { Thread.sleep(5000); logger.info("Running task"); AsyncRequestRepository asyncRequestRepository = new AsyncRequestRepository(this.configReader); + asyncRequestRepository.prepareAsyncRequest(); asyncRequestRepository.performAsyncRequest() .thenAccept( logger::info diff --git a/plugins/command-manager/src/main/plugin-metadata/plugin-security.policy b/plugins/command-manager/src/main/plugin-metadata/plugin-security.policy index 41d5937..a1754fc 100644 --- a/plugins/command-manager/src/main/plugin-metadata/plugin-security.policy +++ b/plugins/command-manager/src/main/plugin-metadata/plugin-security.policy @@ -1,3 +1,3 @@ grant { -permission java.net.SocketPermission "*:8080", "connect,resolve"; +permission java.net.SocketPermission "*", "connect,resolve"; }; \ No newline at end of file