Skip to content

Commit

Permalink
convert compressed ipv6 to full form v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoan HL authored and jaimecasero committed May 30, 2017
1 parent 97beb16 commit 6a9c945
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/gov/nist/core/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,25 @@ public String getIpAddress() {
dbgPrint("Could not resolve hostname " + ex);
}
} else {
rawIpAddress = hostname;
if (addressType == IPV6ADDRESS){
try {
String ipv6FullForm = getInetAddress().toString();
int slashIndex = ipv6FullForm.indexOf("/");
if (slashIndex != -1) {
ipv6FullForm = ipv6FullForm.substring(++slashIndex, ipv6FullForm.length());
}
if (hostname.startsWith("[")) {
rawIpAddress = '[' + ipv6FullForm + ']';
} else {
rawIpAddress = ipv6FullForm;
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
rawIpAddress = hostname;
}
}
return rawIpAddress;
}
Expand Down Expand Up @@ -231,23 +249,6 @@ private void setHost(String host, int type){
if( hostname.startsWith("[") && !hostname.endsWith("]"))
hostname += ']';
}
if (addressType == IPV6ADDRESS){
try {
String ipv6FullForm = getInetAddress().toString();
int slashIndex = ipv6FullForm.indexOf("/");
if (slashIndex != -1) {
ipv6FullForm = ipv6FullForm.substring(++slashIndex, ipv6FullForm.length());
}
if (hostname.startsWith("[")) {
hostname = '[' + ipv6FullForm + ']';
} else {
hostname = ipv6FullForm;
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

Expand Down

0 comments on commit 6a9c945

Please sign in to comment.