Skip to content

Commit

Permalink
Removing handling of brankets in addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
yadudoc committed Nov 25, 2024
1 parent 68a5742 commit ce7a984
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions parsl/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,16 @@ def get_any_address() -> str:

def tcp_url(address: str, port: Union[str, int, None] = None) -> str:
"""Construct a tcp url safe for IPv4 and IPv6"""
stripped_address = address.strip('[]')
if address == "*":
return "tcp://*"

ip_addr = ipaddress.ip_address(stripped_address)
ip_addr = ipaddress.ip_address(address)

port_suffix = f":{port}" if port else ""

if ip_addr.version == 6 and port_suffix:
url = f"tcp://[{stripped_address}]{port_suffix}"
url = f"tcp://[{address}]{port_suffix}"
else:
url = f"tcp://{stripped_address}{port_suffix}"
url = f"tcp://{address}{port_suffix}"

return url
3 changes: 2 additions & 1 deletion parsl/tests/unit/test_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
("::1", "55001", "tcp://[::1]:55001"),
("::ffff:127.0.0.1", 55001, "tcp://[::ffff:127.0.0.1]:55001"),
("::ffff:127.0.0.1", None, "tcp://::ffff:127.0.0.1"),
("[::ffff:127.0.0.1]", None, "tcp://::ffff:127.0.0.1"),
("::ffff:127.0.0.1", None, "tcp://::ffff:127.0.0.1"),
("*", None, "tcp://*"),
])
def test_tcp_url(address, port, expected):
"""Confirm valid address generation"""
Expand Down

0 comments on commit ce7a984

Please sign in to comment.