src/eric7/RemoteServerInterface/EricServerInterface.py

branch
eric7
changeset 10958
79842be466d3
parent 10949
2057b1b198a5
child 11004
5f8d929657b3
--- a/src/eric7/RemoteServerInterface/EricServerInterface.py	Tue Oct 08 11:44:28 2024 +0200
+++ b/src/eric7/RemoteServerInterface/EricServerInterface.py	Tue Oct 08 19:27:23 2024 +0200
@@ -298,6 +298,34 @@
         else:
             return ""
 
+    def parseHost(self, host):
+        """
+        Public method to parse a host string generated with 'getHost()'.
+
+        @param host host string
+        @type str
+        @return tuple containing the host name and the port
+        @rtype tuple of (str, int)
+        """
+        host = host.strip()
+        if "]" in host:
+            # IPv6 address
+            hostname, rest = host.split("]")
+            hostname = hostname[1:]
+            if rest and rest[0] == ":":
+                port = int(rest[1:])
+            else:
+                port = None
+        else:
+            if ":" in host:
+                hostname, port = host.split(":")
+                port = int(port)
+            else:
+                hostname = host
+                port = None
+
+        return hostname, port
+
     #######################################################################
     ## Methods for sending requests and receiving the replies.
     #######################################################################

eric ide

mercurial