Skip to content

Commit 702e142

Browse files
committed
feat: add log
1 parent d64c6b2 commit 702e142

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

backend/api-gateway/src/main/java/com/datamate/gateway/common/filter/OmsAuthFilter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,26 @@ public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
103103
*/
104104
private String getRealIp(ServerHttpRequest request) {
105105
String ip = request.getHeaders().getFirst("X-Real-IP");
106+
log.info("request: {}", request);
106107
if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) {
107108
ip = request.getHeaders().getFirst("X-Forwarded-For");
108109
}
109110
if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) {
110111
ip = request.getHeaders().getFirst("Proxy-Client-IP");
111112
}
113+
log.info("2 ip: {}", ip);
112114
if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) {
113115
ip = request.getHeaders().getFirst("WL-Proxy-Client-IP");
114116
}
117+
log.info("3 ip: {}", ip);
115118
if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) {
116119
ip = request.getRemoteAddress() != null ? request.getRemoteAddress().getAddress().getHostAddress() : "";
117120
}
121+
log.info("4 ip: {}", ip);
118122
if (ip != null && ip.contains(",")) {
119123
ip = ip.split(",")[0].trim();
120124
}
125+
log.info("5 ip: {}", ip);
121126
return ip != null ? ip : "";
122127
}
123128

0 commit comments

Comments
 (0)