Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartConnect cannot handle IPv6 address with square brackets #978

Closed
waynez opened this issue Jan 10, 2022 · 0 comments
Closed

SmartConnect cannot handle IPv6 address with square brackets #978

waynez opened this issue Jan 10, 2022 · 0 comments
Labels

Comments

@waynez
Copy link

waynez commented Jan 10, 2022

Describe the bug

SmartConnect uses __FindSupportedVersion() to read the preferred API version from the host, however that method uses six.moves.http_client.HTTPSConnection(__FindSupportedVersion() -> __GetServiceVersionDescription() -> __GetElementTree()) which cannot handle IPv6 address with square brackets.

   if httpProxyHost:
      kwargs = {"context": sslContext} if sslContext else {}
      conn = http_client.HTTPSConnection(httpProxyHost, port=httpProxyPort, **kwargs)
      conn.set_tunnel(server, port)
   elif protocol == "https":
      kwargs = {"context": sslContext} if sslContext else {}
      conn = http_client.HTTPSConnection(server, port=port, **kwargs)
   elif protocol == "http":
      conn = http_client.HTTPConnection(server, port=port)
   else:
      raise Exception("Protocol " + protocol + " not supported.")
   conn.request("GET", path)

That's a bit contrary when considering we have code logic to handle IPv6 addr with square brackets inside Connect()

   try:
      info = re.match(_rx, host)
      if info is not None:
         host = info.group(1)
         if host[0] == '[':
            host = info.group(1)[1:-1]
         if info.group(2) is not None:
            port = int(info.group(2)[1:])
   except ValueError as ve:
      pass

Reproduction steps

1. SmartConnect(host="[2001:0db8:85a3:0000:0000:8a2e:0370:7334]", user="xxx", pwd="xxx", port=443)
2. Exceptions was thrown out.

Expected behavior

Should be able to handle IPv6 address with square brackets

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant