Package host.anzo.commons.utils
Class IpUtils
java.lang.Object
host.anzo.commons.utils.IpUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StringfromLong(long ipLong) static @Nullable Stringstatic longgetPing(@NotNull InetAddress address) static StringgetRealIp(@NotNull org.eclipse.jetty.websocket.api.Session session) static StringgetRealIp(@NotNull spark.Request request) static booleanisLocalAddress(@NotNull InetAddress address) static long
-
Constructor Details
-
IpUtils
public IpUtils()
-
-
Method Details
-
getExternalIP
- Returns:
- external IP address,
nullif can't detect external IP
-
isLocalAddress
- Parameters:
address- address for check- Returns:
trueif specified address is local,falseotherwise
-
getPing
- Parameters:
address- address to ping- Returns:
- "dirty" (request-response) ping to specified InetAddress
-
getRealIp
- Parameters:
request- request object- Returns:
- real client IP (in case if using reverse-proxify like a CloudFlare)
-
getRealIp
- Parameters:
session- websocket session- Returns:
- extracted from websocket session IP address
-
toLong
- Parameters:
ip- IP address- Returns:
- IP address packed to long
-
fromLong
- Parameters:
ipLong- IP address as packed long value- Returns:
- unpacked from long IP address
-