处理代理IP地址

v1.4.1
hiparker 4 years ago
parent 95706edc42
commit 44ebde3613

@ -15,6 +15,8 @@
*/
package org.opsli.common.utils;
import cn.hutool.core.net.NetUtil;
import javax.servlet.http.HttpServletRequest;
/**
@ -81,6 +83,17 @@ public final class IPUtil {
}
return request.getRemoteAddr();
}
/***
* ip(穿)
* @param request
* @return
*/
public static String getMultistageReverseProxyIp(HttpServletRequest request) {
String clientIpAddress = getClientIpAddress(request);
return NetUtil.getMultistageReverseProxyIp(clientIpAddress);
}
/***
* ip(穿)
* @param request

@ -21,7 +21,6 @@ import cn.hutool.json.JSONUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
@ -93,7 +92,7 @@ public final class LogUtil {
// 操作方法
String methodName = request.getMethod();
// 获得IP
String clientIpAddress = IPUtil.getClientIpAddress(request);
String clientIpAddress = IPUtil.getMultistageReverseProxyIp(request);
// 设置标题
setTitle(point, method, logsModel, user);

@ -140,7 +140,7 @@ public class LoginRestController {
// 异步保存IP
AsyncProcessQueueReFuse.execute(()->{
// 保存用户最后登录IP
String clientIpAddress = IPUtil.getClientIpAddress(request);
String clientIpAddress = IPUtil.getMultistageReverseProxyIp(request);
user.setLoginIp(clientIpAddress);
iUserService.updateLoginIp(user);
});

Loading…
Cancel
Save