Skip to content

Commit

Permalink
refactor ip v6 method
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Oct 26, 2015
1 parent 3876fa7 commit 716f5fa
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ public String getIp() {
}

private boolean isPublicIpAddress(final InetAddress ipAddress) {
return !ipAddress.isSiteLocalAddress() && !ipAddress.isLoopbackAddress() && -1 == ipAddress.getHostAddress().indexOf(":");
return !ipAddress.isSiteLocalAddress() && !ipAddress.isLoopbackAddress() && !isV6IpAddress(ipAddress);
}

private boolean isLocalIpAddress(final InetAddress ipAddress) {
return ipAddress.isSiteLocalAddress() && !ipAddress.isLoopbackAddress() && -1 == ipAddress.getHostAddress().indexOf(":");
return ipAddress.isSiteLocalAddress() && !ipAddress.isLoopbackAddress() && !isV6IpAddress(ipAddress);
}

private boolean isV6IpAddress(final InetAddress ipAddress) {
return -1 != ipAddress.getHostAddress().indexOf(":");
}

@Override
Expand Down

0 comments on commit 716f5fa

Please sign in to comment.