Skip to content

Commit

Permalink
fix conflict (#949)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola authored Mar 11, 2024
1 parent d8b228c commit 83a90f4
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 83a90f4

Please sign in to comment.