Skip to content

Commit

Permalink
Use netloc from urlparse to specify the host (#79)
Browse files Browse the repository at this point in the history
This is because `netloc` is formatted to be the network location, and
wraps ipv6 in square brackets, which we lose if we just use the `host`
field.

`netloc` also contains the port if a port was in the original uri. We
need to append the default port only if the original uri didn't have a
port.

This fixes an issue when creating a grpc Channel with ipv6 addresses.
  • Loading branch information
shsms authored Sep 3, 2024
2 parents cc16989 + 13f223e commit 5dc137c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

## Bug Fixes

<!-- Here goes notable bug fixes that are worth a special mention or explanation -->
- Fixes a bug in creating grpc channels from ipv6 URIs.
6 changes: 3 additions & 3 deletions src/frequenz/client/base/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def parse_grpc_uri(

options = _parse_query_params(uri, parsed_uri.query)

host = parsed_uri.hostname
port = parsed_uri.port or defaults.port
target = f"{host}:{port}"
target = (
parsed_uri.netloc if parsed_uri.port else f"{parsed_uri.netloc}:{defaults.port}"
)

ssl = defaults.ssl.enabled if options.ssl is None else options.ssl
if ssl:
Expand Down

0 comments on commit 5dc137c

Please sign in to comment.