// Path: src/main/java/com/monkeyk/sos/web/WebUtils.java
// public abstract class WebUtils {
// 
// 
//     public static final String UTF_8 = "UTF-8";
// 
// 
//     /**
//      * Sync by pom.xml   <version></version>
//      */
//     public static final String VERSION = "2.0.1";
// 
// 
//     private static ThreadLocal<String> ipThreadLocal = new ThreadLocal<>();
// 
// 
//     public static void setIp(String ip) {
//         ipThreadLocal.set(ip);
//     }
// 
//     public static String getIp() {
//         return ipThreadLocal.get();
//     }
// 
//     //private
//     private WebUtils() {
//     }
// 
// 
//     /**
//      * Retrieve client ip address
//      *
//      * @param request HttpServletRequest
//      * @return IP
//      */
//     public static String retrieveClientIp(HttpServletRequest request) {
//         String ip = request.getHeader("x-forwarded-for");
//         if (isUnAvailableIp(ip)) {
//             ip = request.getHeader("Proxy-Client-IP");
//         }
//         if (isUnAvailableIp(ip)) {
//             ip = request.getHeader("WL-Proxy-Client-IP");
//         }
//         if (isUnAvailableIp(ip)) {
//             ip = request.getRemoteAddr();
//         }
//         return ip;
//     }
// 
//     private static boolean isUnAvailableIp(String ip) {
//         return StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip);
//     }
// 
// }


import com.monkeyk.sos.web.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.filter.CharacterEncodingFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
package com.monkeyk.sos.web.filter;



/**
 * 2016/1/30
 *
 * @author Shengzhao Li
 */
public class CharacterEncodingIPFilter extends CharacterEncodingFilter {

    private static final Logger LOG = LoggerFactory.getLogger(CharacterEncodingIPFilter.class);


    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        recordIP(request);
        super.doFilterInternal(request, response, filterChain);
    }

    private void recordIP(HttpServletRequest request) {
// Path: src/main/java/com/monkeyk/sos/web/WebUtils.java
// public abstract class WebUtils {
// 
// 
//     public static final String UTF_8 = "UTF-8";
// 
// 
//     /**
//      * Sync by pom.xml   <version></version>
//      */
//     public static final String VERSION = "2.0.1";
// 
// 
//     private static ThreadLocal<String> ipThreadLocal = new ThreadLocal<>();
// 
// 
//     public static void setIp(String ip) {
//         ipThreadLocal.set(ip);
//     }
// 
//     public static String getIp() {
//         return ipThreadLocal.get();
//     }
// 
//     //private
//     private WebUtils() {
//     }
// 
// 
//     /**
//      * Retrieve client ip address
//      *
//      * @param request HttpServletRequest
//      * @return IP
//      */
//     public static String retrieveClientIp(HttpServletRequest request) {
//         String ip = request.getHeader("x-forwarded-for");
//         if (isUnAvailableIp(ip)) {
//             ip = request.getHeader("Proxy-Client-IP");
//         }
//         if (isUnAvailableIp(ip)) {
//             ip = request.getHeader("WL-Proxy-Client-IP");
//         }
//         if (isUnAvailableIp(ip)) {
//             ip = request.getRemoteAddr();
//         }
//         return ip;
//     }
// 
//     private static boolean isUnAvailableIp(String ip) {
//         return StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip);
//     }
// 
// }


// Path: src/main/java/com/monkeyk/sos/web/filter/CharacterEncodingIPFilter.java
import com.monkeyk.sos.web.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.filter.CharacterEncodingFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

package com.monkeyk.sos.web.filter;



/**
 * 2016/1/30
 *
 * @author Shengzhao Li
 */
public class CharacterEncodingIPFilter extends CharacterEncodingFilter {

    private static final Logger LOG = LoggerFactory.getLogger(CharacterEncodingIPFilter.class);


    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        recordIP(request);
        super.doFilterInternal(request, response, filterChain);
    }

    private void recordIP(HttpServletRequest request) {
        final String ip = WebUtils.retrieveClientIp(request);