| | |
| | | package com.ruoyi.common.utils.ip; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.http.HtmlUtil; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.html.EscapeUtil; |
| | | |
| | | /** |
| | | * 获取IP方法 |
| | |
| | | { |
| | | ip = request.getRemoteAddr(); |
| | | } |
| | | return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : EscapeUtil.clean(ip); |
| | | return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : HtmlUtil.cleanHtmlTag(ip); |
| | | } |
| | | |
| | | public static boolean internalIp(String ip) |
| | |
| | | |
| | | private static boolean internalIp(byte[] addr) |
| | | { |
| | | if (StringUtils.isNull(addr) || addr.length < 2) |
| | | if (Validator.isNull(addr) || addr.length < 2) |
| | | { |
| | | return true; |
| | | } |