Package io.jans.net
Class InetAddressUtility
java.lang.Object
io.jans.net.InetAddressUtility
- Author:
- Yuriy Movchan Date: 05/20/2015
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetIpAddress(jakarta.servlet.http.HttpServletRequest httpRequest) static Stringstatic StringStable identifier of this JVM's host: the MAC address of the interface bound to the local host address (seegetMACAddressOrNull()); failing that, the MAC of the first (by name) non-loopback, non-virtual, up interface that has one; failing that, a random UUID that is stable only for the lifetime of the process.static booleanisIpAddress(String ipAddress) Determine if the given string is a valid IPv4 or IPv6 address
-
Method Details
-
getMACAddressOrRandomUUID
Stable identifier of this JVM's host: the MAC address of the interface bound to the local host address (seegetMACAddressOrNull()); failing that, the MAC of the first (by name) non-loopback, non-virtual, up interface that has one; failing that, a random UUID that is stable only for the lifetime of the process. Computed once and cached. Never returnsnullor an empty string; the result is at most 36 characters.The second tier matters on Debian/Ubuntu-style hosts where the host name resolves to
127.0.1.1:NetworkInterface.getByInetAddress(java.net.InetAddress)returnsnullthere, sogetMACAddressOrNull()alone yieldsnulleven when a real NIC exists. -
isIpAddress
Determine if the given string is a valid IPv4 or IPv6 address -
getMACAddressOrNull
-
getIpAddress
- Parameters:
httpRequest- interface to provide request information for HTTP servlets.- Returns:
- IP address of client
- See Also:
-