Created
September 19, 2018 08:20
-
-
Save shalk/14b3d6571603ecd1ee388367b069b898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
InetAddress addr = InetAddress.getLocalHost(); | |
if (addr.isSiteLocalAddress() | |
&& !addr.isLoopbackAddress() | |
&& !(addr instanceof Inet6Address) | |
) { | |
return addr.getHostAddress(); | |
} | |
} catch (Throwable e) { | |
LOGGER.warn("InetAddress.getLocalHost() fail", e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment