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

fix(cli): Fix client IPv6 URI generation for gRPC connections #3830

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

redgoat650
Copy link
Contributor

@redgoat650 redgoat650 commented Apr 30, 2024

Connecting to gRPC repository API using an IPv6 address does not correctly configure the URI for the client's dial. Reconstructing the parsed URL into hostname + ":" + port will remove the square brackets required for IPv6 addressing, resulting in a too many colons in address error.

Fix the issue by instead using the helper net.JoinHostPort(), which will add square brackets for IPv6 hostnames.

Tested by running TestServer with httptest.serve flag set, forcing the test server to listen on the IPv6 loopback:

cd internal/server
go test -v -run=TestServer$ --httptest.serve=[::1]:0 ./server

Fails without fix:

    server_test.go:48: 
                Error Trace:    /workspaces/kopia/internal/server/server_test.go:48
                Error:          Received unexpected error:
                                failed to exit idle mode: invalid target address ::1:45373, error info: address ::1:45373:443: too many colons in address

Passes with fix:

--- PASS: TestServer (0.81s)
PASS

@redgoat650 redgoat650 changed the title Fix client IPv6 URI generation for gRPC connections fix(cli): Fix client IPv6 URI generation for gRPC connections Apr 30, 2024
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.06%. Comparing base (cb455c6) to head (9c6e238).
Report is 121 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3830      +/-   ##
==========================================
+ Coverage   75.86%   77.06%   +1.19%     
==========================================
  Files         470      476       +6     
  Lines       37301    28682    -8619     
==========================================
- Hits        28299    22104    -6195     
+ Misses       7071     4684    -2387     
+ Partials     1931     1894      -37     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@julio-lopez julio-lopez merged commit dc0dea4 into kopia:master Apr 30, 2024
24 of 25 checks passed
@julio-lopez julio-lopez deleted the fix-ipv6-uri branch April 30, 2024 02:33
@julio-lopez
Copy link
Collaborator

julio-lopez commented Apr 30, 2024

@redgoat650 Should we either run
go test -v -run=TestServer$ --httptest.serve=[::1]:0 ./server in CI or add a explicit tests, for this case? probably reusing the TestServer test.

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

Successfully merging this pull request may close these issues.

None yet

3 participants