From 907fab455a4b5faeab64940045cedcd79e1579b5 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sun, 15 Dec 2024 17:46:50 +0700 Subject: [PATCH] ssh: improve parsing of ipv6 hostnames --- pkgs/clan-cli/clan_cli/ssh/parse.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/clan-cli/clan_cli/ssh/parse.py b/pkgs/clan-cli/clan_cli/ssh/parse.py index 5e85dfb82..f7561a3c9 100644 --- a/pkgs/clan-cli/clan_cli/ssh/parse.py +++ b/pkgs/clan-cli/clan_cli/ssh/parse.py @@ -1,3 +1,4 @@ +import re import urllib.parse from typing import Any @@ -18,7 +19,7 @@ def parse_deployment_address( parts = host.split("@") user: str | None = None # count the number of : in the hostname - if host.count(":") > 1 and not host.startswith("["): + if host.count(":") > 1 and not re.match(r".*\[.*\]", host): msg = f"Invalid hostname: {host}. IPv6 addresses must be enclosed in brackets , e.g. [::1]" raise ClanError(msg) if len(parts) > 1: