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

Protocol.parseTargetHostAndSlot() is IPV4 oriented #982

Closed
allanwax opened this issue May 12, 2015 · 4 comments
Closed

Protocol.parseTargetHostAndSlot() is IPV4 oriented #982

allanwax opened this issue May 12, 2015 · 4 comments
Assignees

Comments

@allanwax
Copy link

The code which splits the host part from the port part is very IPV4 oriented and thus it just splits on a :. To handle IPV6 cases it should be something like:

...
int colon = messageInfo[2].lastIndexOf(":");
...
response[1] = messageInfo[2].substring(0, colon-1);
response[2] = messageInfo[2].substring(colon+1);

Since IPV6 uses colons to separate the parts and Jedis uses a colon to separate host from port, using the index of the last colon will select the host-port divider whether it's IPV4 or IPV6.

@marcosnils marcosnils self-assigned this May 12, 2015
@allanwax
Copy link
Author

Probably in more places than I know. But yes, fix 'em all.

Perhaps a utility function should be made that given a host and port string returns the two pieces. Then replaces all those references with the utility function.

@allanwax
Copy link
Author

Sketchy code !!! Without looking at the current HostAndPort !!!!!!

class HostAndPort {
...
private String host;
private String port;
...
public HostAndPort(String hostAndPort) {
// do proper splitting
host = ...;
port = ...;
}
...
public String getHost() {return host;}
public String getPort() {return port;}
...
}

@sazzad16
Copy link
Collaborator

sazzad16 commented Dec 3, 2017

Closed by #1342

@sazzad16 sazzad16 closed this as completed Dec 3, 2017
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

No branches or pull requests

3 participants