package net.northking.cctp.device.util;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
@Component
public class IpUtil {

    public String getRemoteIP(HttpServletRequest request){
        if (request.getHeader("x-forwarded-for") == null){
            return request.getRemoteAddr();
        }
        String[] ip = request.getHeader("x-forwarded-for").split(",");
        return ip[0];
    }
}
