Skip to content

Commit

Permalink
Merge pull request google#6 from hellpf/master
Browse files Browse the repository at this point in the history
IPv6 URL support
  • Loading branch information
nkzawa committed Sep 21, 2014
2 parents be0a44c + a5559c2 commit 0609ab3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/com/github/nkzawa/engineio/client/Socket.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,19 @@ public Socket(URI uri, Options opts) {

public Socket(Options opts) {
if (opts.host != null) {
String[] pieces = opts.host.split(":");
opts.hostname = pieces[0];
if (pieces.length > 1) {
opts.port = Integer.parseInt(pieces[pieces.length - 1]);
boolean ipv6uri = opts.host.indexOf(']') != -1;
String[] pieces = ipv6uri ? opts.host.split("]:") : opts.host.split(":");
boolean ipv6 = (pieces.length > 2 || opts.host.indexOf("::") == -1);
if (ipv6) {
opts.hostname = opts.host;
} else {
opts.hostname = pieces[0];
if (ipv6uri) {
opts.hostname = opts.hostname.substring(1);
}
if (pieces.length > 1) {
opts.port = Integer.parseInt(pieces[pieces.length - 1]);
}
}
}

Expand Down

0 comments on commit 0609ab3

Please sign in to comment.