Authored by Xu

恶意ip管理

... ... @@ -245,5 +245,14 @@ public class HttpUriContants {
public static final String INTERNAL_DOMAIN_REFRESH = "/internalDns/refresh";
public static final String INTERNAL_DOMAIN_SELECTBYID = "/internalDns/selectById";
public static final String INTERNAL_DOMAIN_HISTORY = "/internalDns/getHistory";
/**
* 配置管理
* 恶意请求ip
* 获取
*/
public static final String GET_MALICIOUS_IP = "/maliciousIp/getIps";
public static final String GET_MALICIOUS_DETAIL = "/maliciousIp/getDetail";
public static final String GET_MALICIOUS_UPLOADIP = "/maliciousIp/uploadIp";
}
... ...
package com.ui.ctrl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
@Controller
@RequestMapping("maliciousIp")
public class MaliciousIpCtrl {
@Autowired
private HttpRestClient httpClient;
@RequestMapping("/toMaliciousIps")
public ModelAndView toMaliciousIps(Model model) {
return new ModelAndView("malicious/maliciousIpList");
}
@RequestMapping("/showDetail")
public ModelAndView showDetail(Model model, String ip) {
ModelAndView mdv = new ModelAndView("malicious/maliciousIpDetail");
mdv.addObject("ip", ip);
return mdv;
}
@SuppressWarnings("unchecked")
@RequestMapping("/getIps")
@ResponseBody
public BaseResponse<List<Object>> getIps(Model model) {
BaseResponse<List<Object>> response = httpClient.defaultPost(HttpUriContants.GET_MALICIOUS_IP, null,
BaseResponse.class);
return response;
}
@SuppressWarnings("unchecked")
@RequestMapping("/getDetail")
@ResponseBody
public BaseResponse<List<Object>> getDetail(Model model, String ip) {
BaseResponse<List<Object>> response = httpClient.defaultGet(HttpUriContants.GET_MALICIOUS_DETAIL + "?ip=" + ip,
BaseResponse.class);
return response;
}
@SuppressWarnings("unchecked")
@RequestMapping("/uploadIp")
@ResponseBody
public BaseResponse<Object> uploadIp(UpLoadMaliciousIp ips) {
BaseResponse<Object> response = httpClient.defaultPost(HttpUriContants.GET_MALICIOUS_UPLOADIP, ips,
BaseResponse.class);
return response;
}
}
\ No newline at end of file
... ...
package com.ui.ctrl;
/**
* 上传的恶意ip集合
* @author hui.xu
*
*/
public class UpLoadMaliciousIp {
private String ips;
public String getIps() {
return ips;
}
public void setIps(String ips) {
this.ips = ips;
}
}
\ No newline at end of file
... ...
$(function () {
refreshTable();
});
function refreshTable() {
$("#detailTable").table({
url: contextPath + "maliciousIp/getDetail?ip="+$("#ip").val(),
dataType: 'json',
striped: true,
panelClass: "panel-success",
loadFilter: function (data) {
console.log(data.data)
return defaultLoadFilter(data);
},
columns: [
{
title: "ip",
width: "100px",
field: "userIP"
},
{
title: "QPS",
width: "100",
field: "count"
},
{
title: "method",
width: "300",
field: "method"
}]
});
}
\ No newline at end of file
... ...
$(function () {
refreshTable();
});
function refreshTable() {
$("#ipTable").table({
url: contextPath + "maliciousIp/getIps",
dataType: 'json',
striped: true,
sortName: 'count', // 设置默认排序为 name
sortOrder: 'desc', // 设置排序为反序 desc
panelClass: "panel-success",
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [
{
title: "",
width:"50px",
field: "ip",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
//复选框
var checkBox = $("<input name='checkType' type='checkbox' value='"+value+"'>").addClass("ckbox-default").appendTo(div);
return div;
}
},
{
title: "ip",
width: "150px",
field: "ip"
},
{
title: "QPS(分钟)",
width: "150",
field: "count",
sortable: true,
},
{
title: "QPS(秒)",
width: "150",
field: "count",
sortable: true,
formatter: function (value, rowData, rowIndex) {
return parseInt(value / 60);
}
},
{
title: "百分比",
width: "150",
field: "percent",
formatter: function (value, rowData, rowIndex) {
return value + "%";
}
},
{
title: "详情",
width: "200px",
field: "ip",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
//详情
var editBtn = $("<button data-target='#updateModal' data-toggle='modal'>").addClass("btn btn-xs btn-success").html("详情").appendTo(div);
editBtn.click(function () {
getDetail(rowData.ip);
});
return div;
}
}]
});
}
//显示ip的详情
function getDetail(ip){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
size : "modal-lg",
title : "详情",
backdrop : "static",
href : "showDetail?ip=" + ip
});
}
function checkAll(){
$("#ipTable input[type='checkbox']").each(function(){
if($("#checkAll").is(':checked'))
$(this).prop("checked", true);
else
$(this).prop("checked", false);
});
}
function uploadIps(){
var listip = "";
$("#ipTable input[type='checkbox']:checked").each(function(){
listip += $(this).val() + "|";
});
if(listip.length == 0){
return;
}
var params = {};
params.ips = listip;
$.ajax({
url: '/maliciousIp/uploadIp',
type: 'POST',
data: params,
dataType: 'json',
success: function (data) {
if (!data || data.code != 200) {
alert('系统异常:'+data.message);
}else{
if(data.data.status == '0'){
alert('上传成功!');
}else{
alert('上传失败:'+data.data.message);
}
}
},
error: function (data) {
alert('系统异常');
}
});
}
\ No newline at end of file
... ...
<%--
Created by IntelliJ IDEA.
User: yoho
Date: 2016/9/21
Time: 10:42
To change this template use File | Settings | File Templates.
--%>
<%@ page import="org.aspectj.weaver.ast.Var" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
<link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>/js/bootstrap.min.js"></script>
<script src="<%=basePath %>/js/unicorn.js"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jstree/jstree.min.js"></script>
<script src="<%=basePath %>js/jquery.toaster.js"></script>
<script>
var contextPath = '<%=basePath %>';
</script>
<title>YOHO!运维</title>
</head>
<body>
<!-- 头部 -->
<div id="head">
</div>
<input type="hidden" id="ip" value='${ip}'>
<!-- 右侧具体内容 -->
<div class="widget-box">
<div id="detailTable" style="overflow: auto" />
</div>
</body>
<script src="<%=basePath %>js/pagination.js"></script>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script src="<%=basePath %>js/malicious/maliciousIpDetail.js"></script>
<script>
$("#li_config").addClass("active open");
$("#li_malicious_ips").addClass("active");
</script>
</html>
\ No newline at end of file
... ...
<%--
Created by IntelliJ IDEA.
User: yoho
Date: 2016/9/21
Time: 10:42
To change this template use File | Settings | File Templates.
--%>
<%@ page import="org.aspectj.weaver.ast.Var" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
<link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>/js/bootstrap.min.js"></script>
<script src="<%=basePath %>/js/unicorn.js"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jstree/jstree.min.js"></script>
<script src="<%=basePath %>js/jquery.toaster.js"></script>
<script>
var contextPath = '<%=basePath %>';
</script>
<title>YOHO!运维</title>
</head>
<body>
<!-- 头部 -->
<div id="head">
</div>
<!-- 右侧具体内容 -->
<div id="content">
<div id="breadcrumb">
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">恶意请求ip集合</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>恶意ip top 100</h5>
</div>
<div class="widget-title" style="height: 53px;">
<div>
<div class="form-inline" role="form" id="inBoxQueryDiv" style=" margin-top: 12px;margin-left: 25px;float: left;">
<div class="input-group" style="float: left; margin-left: 20px">
<span class="input-group-addon">全选:</span>
<input type="checkbox" id="checkAll" style="margin-left:5px;width:20px;height:20px;" onclick="checkAll()">
</div>
<button id="uploadIps" class="btn-primary" style="margin-left: 80px;" onclick="uploadIps()">上传
</button>
</div>
</div>
</div>
<div id="ipTable" style="overflow: auto" />
</div>
</div>
</div>
</body>
<script src="<%=basePath %>js/pagination.js"></script>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script src="<%=basePath %>js/malicious/maliciousIpList.js"></script>
<script>
$("#li_config").addClass("active open");
$("#li_malicious_ips").addClass("active");
</script>
</html>
\ No newline at end of file
... ...
... ... @@ -63,6 +63,7 @@ innerHTML += "<li id='li_hystrix_info'><a id='li_hystrix_info_a' href=''><i clas
innerHTML += "<li id='li_cache_info'><a id='li_cache_info_a' href=''><i class='icon icon-th'></i> <span>缓存时间配置</span></a></li>";
innerHTML += "<li id='li_aws_ebs'><a id='li_aws_ebs_a' href=''><i class='icon icon-th'></i> <span>AWS_EBS镜像任务</span></a></li>";
innerHTML += "<li id='li_ips_compare'><a id='li_ips_compare_a' href=''><i class='icon icon-th'></i> <span>在线服务Ip配置对比</span></a></li>";
innerHTML += "<li id='li_malicious_ips'><a id='li_malicious_ips_a' href=''><i class='icon icon-th'></i> <span>恶意ip管理</span></a></li>";
innerHTML += "</ul></li>";
/*project*/
... ... @@ -150,6 +151,7 @@ document.getElementById("li_memcachedMonitor_a").setAttribute("href", path + "/m
document.getElementById("li_javarestart_a").setAttribute("href", path + "/javaRestart/toJavaRestart");
//document.getElementById("li_centerswitch_a").setAttribute("href", path + "/centerSwitch/toCenterSwitch");
document.getElementById("li_ips_compare_a").setAttribute("href", path + "/compareIps/toCompareIps");
document.getElementById("li_malicious_ips_a").setAttribute("href", path + "/maliciousIp/toMaliciousIps");
//document.getElementById("li_limitswitch_a").setAttribute("href", path + "/limitSwitch/toLimitSwitch");
//document.getElementById("li_lbswitch_a").setAttribute("href", path + "/lbSwitch/toLbSwitch");
document.getElementById("li_monit_a").setAttribute("href",path+"/monit/toMonit");
... ...