src/eric7/Utilities/BackgroundService.py

branch
eric7
changeset 9521
a663a8be64da
parent 9473
3f23dbf37dbe
child 9624
b47dfa7a137d
--- a/src/eric7/Utilities/BackgroundService.py	Tue Nov 22 16:33:30 2022 +0100
+++ b/src/eric7/Utilities/BackgroundService.py	Wed Nov 23 10:48:46 2022 +0100
@@ -56,18 +56,27 @@
         self.services = {}
 
         networkInterface = Preferences.getDebugger("NetworkInterface")
-        if networkInterface == "all" or "." in networkInterface:
-            self.hostAddress = "127.0.0.1"
+        if networkInterface in ("allv4", "localv4") or "." in networkInterface:
+            # IPv4
+            self.__hostAddress = "127.0.0.1"
+        elif networkInterface in ("all", "allv6", "localv6"):
+            # IPv6
+            self.__hostAddress = "::1"
         else:
-            self.hostAddress = "::1"
-        self.listen(QHostAddress(self.hostAddress))
+            self.__hostAddress = networkInterface
+        self.listen(QHostAddress(self.__hostAddress))
 
         self.newConnection.connect(self.on_newConnection)
 
+        ## Note: Need the address and port if started external in debugger:
         port = self.serverPort()
-        ## Note: Need the port if started external in debugger:
-        print("Background Service listening on: {0:d}".format(port))
-        # __IGNORE_WARNING__
+        hostAddressStr = (
+            "[{0}]".format(self.__hostAddress)
+            if ":" in self.__hostAddress
+            else self.__hostAddress
+        )
+        print("Background Service listening on: {0}:{1:d}".format(hostAddressStr, port))
+        # __IGNORE_WARNING_M801__
 
         interpreter = self.__getPythonInterpreter()
         if interpreter:
@@ -112,7 +121,7 @@
         proc.setProcessChannelMode(QProcess.ProcessChannelMode.ForwardedChannels)
         args = [
             backgroundClient,
-            self.hostAddress,
+            self.__hostAddress,
             str(port),
             str(Preferences.getUI("BackgroundServiceProcesses")),
             Globals.getPythonLibraryDirectory(),

eric ide

mercurial