From 83a90f4e8c6b95e2908eec385de692b6a5a94b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Nicola?= Date: Mon, 11 Mar 2024 10:06:09 +0100 Subject: [PATCH] fix conflict (#949) --- ospd_openvas/daemon.py | 43 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/ospd_openvas/daemon.py b/ospd_openvas/daemon.py index 8186b132..df3369c0 100644 --- a/ospd_openvas/daemon.py +++ b/ospd_openvas/daemon.py @@ -495,28 +495,6 @@ def __init__( self._mqtt_broker_password = kwargs.get('mqtt_broker_password') def init(self, server: BaseServer) -> None: - notus_handler = NotusResultHandler(self.report_results) - - if self._mqtt_broker_address: - client = MQTTClient( - self._mqtt_broker_address, self._mqtt_broker_port, "ospd" - ) - if self._mqtt_broker_username and self._mqtt_broker_password: - client.username_pw_set( - self._mqtt_broker_username, self._mqtt_broker_password - ) - - daemon = MQTTDaemon(client) - subscriber = MQTTSubscriber(client) - - subscriber.subscribe(ResultMessage, notus_handler.result_handler) - daemon.run() - else: - logger.info( - "MQTT Broker Adress empty. MQTT disabled. Unable to get Notus" - " results." - ) - self.scan_collection.init() server.start(self.handle_client_stream) @@ -525,6 +503,27 @@ def init(self, server: BaseServer) -> None: self.set_params_from_openvas_settings() + # Do not init MQTT daemon if Notus runs via openvasd. + if not self.scan_only_params.get("openvasd_server"): + notus_handler = NotusResultHandler(self.report_results) + + if self._mqtt_broker_address: + client = MQTTClient( + self._mqtt_broker_address, self._mqtt_broker_port, "ospd" + ) + daemon = MQTTDaemon(client) + subscriber = MQTTSubscriber(client) + + subscriber.subscribe( + ResultMessage, notus_handler.result_handler + ) + daemon.run() + else: + logger.info( + "MQTT Broker Address empty. MQTT disabled. " + "Unable to get Notus results." + ) + with self.feed_lock.wait_for_lock(): self.update_vts() self.set_feed_info()