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

ipv6 port problem when extracting information from the authority data #56

Closed
ecejnj42 opened this issue Jan 19, 2024 · 5 comments · Fixed by #59
Closed

ipv6 port problem when extracting information from the authority data #56

ecejnj42 opened this issue Jan 19, 2024 · 5 comments · Fixed by #59
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ecejnj42
Copy link

Questions

An exception is thrown on ipv6 environments because the authority information could be described using an ipv6 ip address.
In such situations, the ipv6 uses ":" as separator for address fields, therefore when also using the ":" to look for the port information is misleading.
A simple example for ipv6 authority info is like this one: "[7a03:908:671:b520:ba27:bbff:ffff:fed2]:1234"

Class "io.vertx.httpproxy.impl.ProxiedRequest" uses some code like this:

` String proxiedAuthority = proxiedRequest.host();

int idx = proxiedAuthority.indexOf(':');
String proxiedHost;
int proxiedPort;
if (idx == -1) {
  proxiedHost = proxiedAuthority;
  proxiedPort = -1;
} else {
  proxiedHost = proxiedAuthority.substring(0, idx);
  proxiedPort = Integer.parseInt(proxiedAuthority.substring(idx + 1));
}`

This causes the following exception when authority is ipv6 format:

java.lang.NumberFormatException: For input string: "1b74:8f:f43b::1]:80" at java.lang.NumberFormatException. forInputString(NumberFormatException.java:67) at java.lang.Integer.parseInt(Integer.java:668) at java.lang.Integer.parseInt(Integer.java:786) at io.vertx.httpproxy.impl.ProxiedRequest.sendRequest (ProxiedRequest.java:186) at io.vertx.httpproxy.impl.ProxiedRequest.send(ProxiedRequest.java:238)

Version

io.vertx 4.5.1

Context

ipv6 environment over an already proxied request.

Do you have a reproducer?

Reproduce easily on a test just setting the authority to "[7a03:908:671:b520:ba27:bbff:ffff:fed2]:1234"

Steps to reproduce

Extra

Tested on linux 6.2.0-37-generic with jdk 17.

@ecejnj42 ecejnj42 added the bug Something isn't working label Jan 19, 2024
@tsegismont tsegismont added this to the 4.5.2 milestone Jan 19, 2024
@tsegismont
Copy link
Contributor

Thanks for the report, can you contribute the fix?

@vietj
Copy link
Member

vietj commented Jan 19, 2024

instead this code should use proxiedRequest.authority() that returns a proper host/port object

@chevaris
Copy link

chevaris commented Jan 20, 2024

Code in main does not have the problem

@ecejnj42
Copy link
Author

Sorry, I cannot fix it due to legal issues.

@vietj
Copy link
Member

vietj commented Jan 23, 2024

hum ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants