From 5b8de731434ae41958702f502beb636bc2cb42b2 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 20 Nov 2024 19:24:06 +0100 Subject: [PATCH] Correctly display IPv6 addresses in interface names --- RNS/Interfaces/TCPInterface.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/RNS/Interfaces/TCPInterface.py b/RNS/Interfaces/TCPInterface.py index 6015aba..261d671 100644 --- a/RNS/Interfaces/TCPInterface.py +++ b/RNS/Interfaces/TCPInterface.py @@ -409,7 +409,12 @@ class TCPClientInterface(Interface): def __str__(self): - return "TCPInterface["+str(self.name)+"/"+str(self.target_ip)+":"+str(self.target_port)+"]" + if ":" in self.target_ip: + ip_str = f"[{self.target_ip}]" + else: + ip_str = f"{self.target_ip}" + + return "TCPInterface["+str(self.name)+"/"+ip_str+":"+str(self.target_port)+"]" class TCPServerInterface(Interface): @@ -575,7 +580,12 @@ class TCPServerInterface(Interface): def __str__(self): - return "TCPServerInterface["+self.name+"/"+self.bind_ip+":"+str(self.bind_port)+"]" + if ":" in self.bind_ip: + ip_str = f"[{self.bind_ip}]" + else: + ip_str = f"{self.bind_ip}" + + return "TCPServerInterface["+self.name+"/"+ip_str+":"+str(self.bind_port)+"]" class TCPInterfaceHandler(socketserver.BaseRequestHandler):