Repository navigation
Bracket an IPv6 host in the advertised local URL - #11
Merged
Merged
Conversation
With ACAD_MCP_HOST=::1, local_url() produced http://::1:8770/... which urllib.parse.urlsplit cannot read a port from. Bracket the host when it contains a colon; IPv4 and hostname addresses are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10.
Problem
With
ACAD_MCP_HOST=::1,local_url()returnedhttp://::1:8770/<secret>/mcp. That URL has no IPv6 brackets, andurllib.parse.urlsplitcannot read its port, so the advertised connector URL is unusable for an IPv6 bind.Root cause
local_url()interpolatedHOSTstraight into the authority. IPv6 literals need brackets before the port; IPv4 addresses and hostnames must not have them.Fix
local_url()brackets the host only when it contains a colon. Everything else — port, secret path, IPv4 and hostname forms — is unchanged.Testing
test_ipv6_host_is_bracketed_and_parses:::1withACAD_MCP_SECRET_PATH=offline-fixtureyieldshttp://[::1]:8770/offline-fixture/mcp, andurlsplitreads back hostname::1, port8770and path/offline-fixture/mcp.test_ipv4_and_hostname_hosts_keep_their_shape:127.0.0.1andlocalhostkeep the previous form and parse back to the same hostname.ACAD_MCP_HOSTjoins the variables the test helper clears, so cases cannot leak in from the environment.http://[::1]…vshttp://::1…); with it,python -m unittest tests.test_configruns 16 tests, all passing. No AutoCAD or COM calls are involved.