From d70bd0ebc95818f0e4ad89676c762111b4a5e167 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 12 Dec 2017 13:45:35 +0100 Subject: [PATCH] CURA-4649 Blocking printers that have localhost IP address. --- .../UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py index 46538f1af9..0d3ed52f03 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py @@ -43,6 +43,7 @@ class NetworkPrinterOutputDevicePlugin(QObject, OutputDevicePlugin): # List of old printer names. This is used to ensure that a refresh of zeroconf does not needlessly forces # authentication requests. self._old_printers = [] + self._excluded_addresses = ["127.0.0.1"] # Adding a list of not allowed IP addresses. At this moment, just localhost # Because the model needs to be created in the same thread as the QMLEngine, we use a signal. self.addPrinterSignal.connect(self.addPrinter) @@ -300,6 +301,9 @@ class NetworkPrinterOutputDevicePlugin(QObject, OutputDevicePlugin): if type_of_device: if type_of_device == b"printer": address = '.'.join(map(lambda n: str(n), info.address)) + if address in self._excluded_addresses: + Logger.log("d", "The IP address %s of the printer \'%s\' is not correct. Trying to reconnect.", address, name) + return False # When getting the localhost IP, then try to reconnect self.addPrinterSignal.emit(str(name), address, info.properties) else: Logger.log("w", "The type of the found device is '%s', not 'printer'! Ignoring.." % type_of_device )