package com.ytpm.util;


import javax.servlet.http.HttpServletRequest;

/**
 * @author lih
 * @date 2025/9/4
 */
public class IPUtil {

    public static String getClientIp(HttpServletRequest request) {
        String xfHeader = request.getHeader("X-Forwarded-For");
        if (xfHeader == null) {
            return request.getRemoteAddr();
        }
        return xfHeader.split(",")[0]; // 可能会有多个IP，这里取第一个逗号前的IP
    }
}
