Authored by qinchao

恶意ip接口

@@ -303,6 +303,7 @@ public class HttpUriContants { @@ -303,6 +303,7 @@ public class HttpUriContants {
303 public static final String GET_MIPS_RECORD_FROM_OPS_DB_FORBID = "/maliciousIp/getMaliciousIpRecordForbidList"; 303 public static final String GET_MIPS_RECORD_FROM_OPS_DB_FORBID = "/maliciousIp/getMaliciousIpRecordForbidList";
304 304
305 public static final String GET_MIPS_RECORD_FROM_OPS_HBASE="/maliciousIp/getMaliciousDetection"; 305 public static final String GET_MIPS_RECORD_FROM_OPS_HBASE="/maliciousIp/getMaliciousDetection";
  306 + public static final String GET_MIPS_RECORD_FROM_OPS_HBASE_MIN="/maliciousIp/getMaliciousDetectionBeforeMin";
306 public static final String GET_MIPS_FROM_OPS_REIDS = "/maliciousIp/getMipsFromOpsReids"; 307 public static final String GET_MIPS_FROM_OPS_REIDS = "/maliciousIp/getMipsFromOpsReids";
307 public static final String DEL_MIPS_FROM_OPS_REDIS = "/maliciousIp/delMipsFromOpsRedis"; 308 public static final String DEL_MIPS_FROM_OPS_REDIS = "/maliciousIp/delMipsFromOpsRedis";
308 public static final String ADD_MIPS_FROM_OPS_REDIS = "/maliciousIp/addMipsFromOpsRedis"; 309 public static final String ADD_MIPS_FROM_OPS_REDIS = "/maliciousIp/addMipsFromOpsRedis";
@@ -80,7 +80,7 @@ public class MaliciousIpCtrl { @@ -80,7 +80,7 @@ public class MaliciousIpCtrl {
80 @RequestMapping("/getMaliciousDetection") 80 @RequestMapping("/getMaliciousDetection")
81 @ResponseBody 81 @ResponseBody
82 public BaseResponse getMaliciousDetection(MaliciousIpRecordReq req) { 82 public BaseResponse getMaliciousDetection(MaliciousIpRecordReq req) {
83 - if(StringUtils.isBlank(req.getIp())){ 83 + if(StringUtils.isBlank(req.getIp())||req.getTimestamp()<=0){
84 return null; 84 return null;
85 } 85 }
86 BaseResponse response = httpClient.defaultPost(HttpUriContants.GET_MIPS_RECORD_FROM_OPS_HBASE, req, 86 BaseResponse response = httpClient.defaultPost(HttpUriContants.GET_MIPS_RECORD_FROM_OPS_HBASE, req,
@@ -88,6 +88,19 @@ public class MaliciousIpCtrl { @@ -88,6 +88,19 @@ public class MaliciousIpCtrl {
88 return response; 88 return response;
89 } 89 }
90 90
  91 + @RequestMapping("/getMaliciousDetectionBeforeMin")
  92 + @ResponseBody
  93 + public BaseResponse getMaliciousDetectionBeforeMin(MaliciousIpRecordReq req) {
  94 + if(StringUtils.isBlank(req.getIp())||req.getTimestamp()<=0){
  95 + return null;
  96 + }
  97 + BaseResponse response = httpClient.defaultPost(HttpUriContants.GET_MIPS_RECORD_FROM_OPS_HBASE_MIN, req,
  98 + BaseResponse.class);
  99 + return response;
  100 + }
  101 +
  102 +
  103 +
91 /** 104 /**
92 * 从运维系统的redis获取恶意ip 105 * 从运维系统的redis获取恶意ip
93 * @return 106 * @return
@@ -101,6 +101,25 @@ @@ -101,6 +101,25 @@
101 </div> 101 </div>
102 102
103 </div> 103 </div>
  104 +
  105 +<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  106 + <div class="modal-dialog" style="width:900px;">
  107 + <div class="modal-content" style="width: 140%">
  108 + <div class="modal-header">
  109 + <button type="button" class="close" data-dismiss="modal"
  110 + aria-hidden="true">&times;</button>
  111 + <h4 class="modal-title" id="myModalLabel"></h4>
  112 + </div>
  113 + <div class="modal-body">
  114 + <input id="hbasePrefix"type="text" readonly disabled style="width:350px;" />
  115 + <div id="hbaseTable" style="overflow-y: auto; overflow-x:hidden;max-height: 700px" /></div>
  116 + </div>
  117 + <div class="modal-footer">
  118 + <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
  119 + </div>
  120 + </div>
  121 +</div>
  122 +
104 </body> 123 </body>
105 <script src="<%=basePath %>script/common/genarate_left_panel.js"></script> 124 <script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
106 125
@@ -119,6 +138,103 @@ @@ -119,6 +138,103 @@
119 }); 138 });
120 139
121 refreshTable(); 140 refreshTable();
  141 +
  142 + $("#hbaseTable").table({
  143 + url: contextPath + "maliciousIp/getMaliciousDetectionBeforeMin",
  144 + queryParams:{},
  145 + dataType: 'json',
  146 + striped: true,
  147 + pagination: false,
  148 + //pageSize: 10,
  149 + //sortName: 'count', // 设置默认排序为 name
  150 + //sortOrder: 'desc', // 设置排序为反序 desc
  151 + panelClass: "panel-success",
  152 + loadFilter: function (data) {
  153 + return defaultLoadFilter(data);
  154 + },
  155 + columns: [
  156 + {
  157 + title: "本地IP",
  158 + width:"12%",
  159 + field: "localIp",
  160 + styler : function(value, rowData, rowIndex){
  161 + return {
  162 + "vertical-align" : "middle"
  163 + };
  164 + }
  165 + },{
  166 + title: "用户IP",
  167 + width:"12%",
  168 + field: "userIp",
  169 + styler : function(value, rowData, rowIndex){
  170 + return {
  171 + "vertical-align" : "middle"
  172 + };
  173 + }
  174 + },{
  175 + title: "时间",
  176 + width:"9%",
  177 + field: "currDateStr",
  178 + styler : function(value, rowData, rowIndex){
  179 + return {
  180 + "vertical-align" : "middle"
  181 + };
  182 + }
  183 + },{
  184 + title: "请求方式",
  185 + width:"7%",
  186 + field: "requestType",
  187 + styler : function(value, rowData, rowIndex){
  188 + return {
  189 + "vertical-align" : "middle"
  190 + };
  191 + }
  192 + },{
  193 + title: "User-Agent",
  194 + width:"9%",
  195 + field: "userAgent",
  196 + styler : function(value, rowData, rowIndex){
  197 + return {
  198 + "vertical-align" : "middle"
  199 + };
  200 + }
  201 + },{
  202 + title: "请求标示",
  203 + field: "requestMark",
  204 + styler : function(value, rowData, rowIndex){
  205 + return {
  206 + "vertical-align" : "middle"
  207 + };
  208 + }
  209 + },{
  210 + title: "请求参数",
  211 + field: "requestParam",
  212 + styler : function(value, rowData, rowIndex){
  213 + return {
  214 + "vertical-align" : "middle"
  215 + };
  216 + }
  217 + },{
  218 + title: "HTTP响应码",
  219 + width:"9%",
  220 + field: "responseCode",
  221 + styler : function(value, rowData, rowIndex){
  222 + return {
  223 + "vertical-align" : "middle"
  224 + };
  225 + }
  226 + },{
  227 + title: "请求处理时间",
  228 + width:"9%",
  229 + field: "dealTime",
  230 + styler : function(value, rowData, rowIndex){
  231 + return {
  232 + "vertical-align" : "middle"
  233 + };
  234 + }
  235 + }
  236 + ]
  237 + });
122 }); 238 });
123 239
124 //点击搜索按钮 240 //点击搜索按钮
@@ -152,7 +268,7 @@ @@ -152,7 +268,7 @@
152 }, 268 },
153 { 269 {
154 title: "reason", 270 title: "reason",
155 - width: "60%", 271 + width: "50%",
156 field: "reason", 272 field: "reason",
157 align: "left", 273 align: "left",
158 formatter:function(value,rowData,rowIndex){ 274 formatter:function(value,rowData,rowIndex){
@@ -194,10 +310,42 @@ @@ -194,10 +310,42 @@
194 310
195 311
196 } 312 }
  313 + },
  314 + {
  315 + title: "操作",
  316 + field: "ip",
  317 + width: "10%",
  318 + formatter:function (value,rowData,rowIndex) {
  319 + var div = $("<div>");
  320 + $("<button onclick=\"qpsDetailMip(\'" + rowData.ip +"\'"+ ","+"\'"+rowData.hbaseTime+"\'"+ ","+"\'"+rowData.hbaseSource+"\')\">").addClass("btn btn-xs btn-info").html("详情").appendTo(div);
  321 + return div;
  322 + }
197 }] 323 }]
198 }); 324 });
199 } 325 }
200 326
  327 + function qpsDetailMip(mip,hbaseTime,hbaseSource){
  328 + if(!hbaseTime){
  329 + hbaseTime=0;
  330 + }
  331 +
  332 + $("#hbasePrefix").val(hbaseSource+" "+mip+":"+hbaseTime+":");
  333 + refreshHbaseTable(mip,hbaseTime,hbaseSource);
  334 + $("#myModal").modal('show');
  335 + }
  336 +
  337 + function refreshHbaseTable(mip,hbaseTime,hbaseSource){
  338 + $("#hbaseTable").table("loadLoaclData",[]);
  339 + var param={
  340 + ip:mip,
  341 + timestamp:hbaseTime,
  342 + cloudType:hbaseSource,
  343 + type:"message"
  344 + };
  345 +
  346 + $("#hbaseTable").table("load", param);
  347 + }
  348 +
201 function showResons(elememt){ 349 function showResons(elememt){
202 var that = elememt; 350 var that = elememt;
203 var btnText = $(that).attr("value"); 351 var btnText = $(that).attr("value");