补充内容
This commit is contained in:
+1
@@ -9,6 +9,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* @author zlt
|
||||
* @date 2019/5/1
|
||||
*/
|
||||
@EnableLoginArgResolver
|
||||
@EnableDiscoveryClient
|
||||
|
||||
@@ -132,6 +132,9 @@ INSERT INTO `sys_menu` VALUES (67, -1, '任务管理', '#!job', 'http://127.0.0.
|
||||
INSERT INTO `sys_menu` VALUES (68, 63, '应用吞吐量监控', '#!sentinel', 'http://127.0.0.1:6999', NULL, 'layui-icon-chart', 4, '2019-01-22 16:31:55', '2019-01-22 16:34:03', 1, 0);
|
||||
INSERT INTO `sys_menu` VALUES (69, 37, '配置中心', '#!nacos', 'http://127.0.0.1:8848/nacos', NULL, 'layui-icon-tabs', 1, '2019-01-23 14:06:10', '2019-01-23 14:06:10', 1, 0);
|
||||
INSERT INTO `sys_menu` VALUES (70, 63, 'APM监控', '#!apm', 'http://127.0.0.1:8080', null, 'layui-icon-engine', 5, '2019-02-27 10:31:55', '2019-02-27 10:31:55', 1, 0);
|
||||
INSERT INTO `sys_menu` VALUES (71, -1, '搜索管理', 'javascript:;', '', NULL, 'layui-icon-set', 3, '2018-08-25 10:41:58', '2019-01-23 15:07:07', 1, 0);
|
||||
INSERT INTO `sys_menu` VALUES (72, 71, '索引管理', '#!index', 'search/index_manager.html', NULL, 'layui-icon-template', 1, '2019-01-10 18:35:55', '2019-01-12 00:27:20', 1, 0);
|
||||
INSERT INTO `sys_menu` VALUES (73, 71, '用户搜索', '#!userSearch', 'search/user_search.html', NULL, 'layui-icon-user', 2, '2019-01-10 18:35:55', '2019-01-12 00:27:20', 1, 0);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sys_role_menu
|
||||
@@ -164,6 +167,9 @@ INSERT INTO `sys_role_menu` VALUES (1, 67);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 68);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 69);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 70);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 71);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 72);
|
||||
INSERT INTO `sys_role_menu` VALUES (1, 73);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 2);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 3);
|
||||
INSERT INTO `sys_role_menu` VALUES (2, 4);
|
||||
|
||||
+29
-18
@@ -1,5 +1,6 @@
|
||||
package com.central.gateway.filter.pre;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.central.log.monitor.PointUtil;
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
@@ -11,14 +12,16 @@ import org.springframework.stereotype.Component;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 统计分析埋点过滤器
|
||||
* 请求统计分析埋点过滤器
|
||||
*
|
||||
* @author zlt
|
||||
* @date 2018/11/20
|
||||
* @date 2019/5/6
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RequestStatisticsFilter extends ZuulFilter {
|
||||
private final static String UNKNOWN_STR = "unknown";
|
||||
|
||||
@Override
|
||||
public String filterType() {
|
||||
return FilterConstants.PRE_TYPE;
|
||||
@@ -41,9 +44,10 @@ public class RequestStatisticsFilter extends ZuulFilter {
|
||||
UserAgent userAgent = UserAgent.parseUserAgentString(req.getHeader("User-Agent"));
|
||||
|
||||
//埋点
|
||||
PointUtil.debug("0","request-statistics","ip="+this.getIpAddr(req)
|
||||
+"&browser="+userAgent.getBrowser()
|
||||
+"&operatingSystem="+userAgent.getOperatingSystem());
|
||||
PointUtil.debug("0","request-statistics",
|
||||
"ip="+this.getIpAddr(req)
|
||||
+"&browser="+userAgent.getBrowser()
|
||||
+"&operatingSystem="+userAgent.getOperatingSystem());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -52,21 +56,28 @@ public class RequestStatisticsFilter extends ZuulFilter {
|
||||
*/
|
||||
public String getIpAddr(HttpServletRequest request){
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
if (isEmptyIP(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
if (isEmptyIP(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
if (isEmptyIP(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
if (isEmptyIP(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
if (isEmptyIP(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
private boolean isEmptyIP(String ip) {
|
||||
if (StrUtil.isEmpty(ip) || UNKNOWN_STR.equalsIgnoreCase(ip)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user