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 link when external IP is IPv6 #335

Conversation

neverpanic
Copy link
Contributor

The external IP module can return an IPv6 address, in which case the method to append a port is to wrap it in square brackets before appending the :%d port string.

Unfortunately Go's IP module does not have a great way to determine whether an address is an IPv6 address, so fall back to counting the number of colons in the result as suggested in https://stackoverflow.com/a/48519490.

The external IP module can return an IPv6 address, in which case the
method to append a port is to wrap it in square brackets before
appending the ":%d" port string.

Unfortunately Go's IP module does not have a great way to determine
whether an address is an IPv6 address, so fall back to counting the
number of colons in the result as suggested in
https://stackoverflow.com/a/48519490.
@neverpanic
Copy link
Contributor Author

Without this patch, the link doesn't work:

Scan the following URL with a QR reader to start the file transfer, press CTRL+C or "q" to exit:
http://2a01:c23:b898:1a00:593b:f434:10b4:9a4b:56036/receive/0rww

With this patch, browsers understand what to do:

Scan the following URL with a QR reader to start the file transfer, press CTRL+C or "q" to exit:
http://[2a01:c23:b898:1a00:593b:f434:10b4:9a4b]:56428/receive/nx0o

@claudiodangelis
Copy link
Owner

Good catch! I'll give it a try next week.
Thanks for this,
Claudio

@claudiodangelis
Copy link
Owner

LGTM, thanks for taking the time for this.
C

@claudiodangelis claudiodangelis self-requested a review September 1, 2024 14:18
@claudiodangelis claudiodangelis changed the base branch from main to release/0.11.3 September 1, 2024 14:30
@claudiodangelis claudiodangelis merged commit 0a0bd60 into claudiodangelis:release/0.11.3 Sep 1, 2024
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.

2 participants