Package cool.scx.common.util
Class NetUtils
java.lang.Object
cool.scx.common.util.NetUtils
基本网络操作工具类
- Version:
- 0.0.1
- Author:
- scx567888
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetClientIPAddress(io.vertx.core.http.HttpServerRequest request) 获取访问者IPstatic InetAddress[]static InetAddress[]getLocalIPAddress(Predicate<InetAddress> filter) 获取本机的 IP 地址 (不包括回环地址)
-
Constructor Details
-
NetUtils
public NetUtils()
-
-
Method Details
-
getClientIPAddress
获取访问者IP先从Header中获取X-Real-IP,如果不存在再从X-Forwarded-For获得第一个IP(用,分割), 如果还不存在则调用 HttpServerRequest.remoteAddress()
- Parameters:
request- a- Returns:
- IP
-
getLocalIPAddress
获取本机的 IP 地址 (不包括回环地址)- Returns:
- 本机的 IP 地址
- Throws:
SocketException
-
getLocalIPAddress
- Throws:
SocketException
-