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

Register a invalid IPv6 address #2802

Closed
steverao opened this issue Sep 25, 2022 · 1 comment · Fixed by #2806
Closed

Register a invalid IPv6 address #2802

steverao opened this issue Sep 25, 2022 · 1 comment · Fixed by #2806

Comments

@steverao
Copy link
Collaborator

Which Component
eg. Nacos Discovery

Describe the bug
A clear and concise description of what the bug is.
If I use spring.cloud.inetutils.preferred-networks=00 to filter the invalid IPv6 address, it will return [127.0.0.1], that is a invalid IPv6 address.

image

If I call the service by [127.0.0.1], it will print error information like below:

java.net.URISyntaxException: Malformed IPv6 address at index 8: http://[127.0.0.1]:20003/c
	at java.net.URI$Parser.fail(URI.java:2845) ~[na:1.8.0_291]
	at java.net.URI$Parser.parseIPv6Reference(URI.java:3466) ~[na:1.8.0_291]
	at java.net.URI$Parser.parseServer(URI.java:3216) ~[na:1.8.0_291]
	at java.net.URI$Parser.parseAuthority(URI.java:3152) ~[na:1.8.0_291]
	at java.net.URI$Parser.parseHierarchical(URI.java:3094) ~[na:1.8.0_291]
	at java.net.URI$Parser.parse(URI.java:3050) ~[na:1.8.0_291]
	at java.net.URI.<init>(URI.java:673) ~[na:1.8.0_291]

So, I think if we can't find a valid IPv6 address, we should register a valid IPv4.

@pandaapo
Copy link
Contributor

pandaapo commented Sep 25, 2022

I agree with you on "if we can't find a valid IPv6 address, we should register a valid IPv4". I intend to modify code according to your opinion.

Additionally, I think method findIPv6Address() should not return IPv4, which means method findFirstNonLoopbackHostInfo()(in class InetIPv6Util) should not. Otherwise, the result may contradict the method name and confuse developers.

pandaapo added a commit to pandaapo/spring-cloud-alibaba that referenced this issue Sep 25, 2022
pandaapo added a commit to pandaapo/spring-cloud-alibaba that referenced this issue Sep 28, 2022
steverao pushed a commit that referenced this issue Sep 28, 2022
… (#2806)

* When ipType is IPv6 but there's no IPv6 found, find IPv4(Fixes gh-2802)

* modify the logic of findFirstNonLoopbackIPv6Address()
steverao pushed a commit that referenced this issue Sep 28, 2022
… (#2810)

* When ipType is IPv6 but there's no IPv6 found, find IPv4(Fixes gh-2802)

* correct findIPv6Address()

* correct import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants