fix: centralize ttdy host#749
Open
oliverxchen wants to merge 1 commit into
Open
Conversation
- ttyd binds to 127.0.0.1 but vhs.go was opening Chrome at http://localhost:<port>. This fails when Chrome choose IPv6 first. - This fix centralizes the ttdy host in `ttyHost`, uses it for both the ttyd --interface and the browser URL, and adds `vhs_test.go` to ensure they stay aligned.
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.
ttyd binds to 127.0.0.1 but vhs.go was opening Chrome at http://localhost:. This does not fail on all machines, but may fail when Chrome chooses IPv6 first.
This fix centralizes the ttdy host in
ttyHost, uses it for both the ttyd --interface and the browser URL, and addsvhs_test.goto ensure they stay aligned.I have read
CONTRIBUTING.md.Bug fix, not applicable.
I have created a discussion that was approved by a maintainer (for new features).How to check whether your machine is susceptible to the bug
Start ttyd the same way VHS does, bound to IPv4 loopback only:
ttyd --port=19760 --interface 127.0.0.1 --once --writable "$SHELL"In another terminal, test IPv4 and IPv6 localhost separately:
curl -4 -I http://localhost:19760 curl -6 -I http://localhost:19760 curl -g -I 'http://[::1]:19760'A machine is likely affected when IPv4 works but IPv6 fails:
This can combine badly if
localhostresolves to::1before127.0.0.1:If
::1appears before127.0.0.1, Chrome may try IPv6 first when VHS openshttp://localhost:<port>, while ttyd is only listening on127.0.0.1.