first commit
This commit is contained in:
3
comm/DDOS/WebContent/META-INF/MANIFEST.MF
Executable file
3
comm/DDOS/WebContent/META-INF/MANIFEST.MF
Executable file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
579
comm/DDOS/WebContent/ip_count_list.jsp
Executable file
579
comm/DDOS/WebContent/ip_count_list.jsp
Executable file
@@ -0,0 +1,579 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>IP请求管理</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询条件</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<form class="form-horizontal" action="<%=basePath%>normal/adminIpCountAction!list.action" method="post"
|
||||
id="queryForm">
|
||||
<input type="hidden" name="pageNo" id="pageNo"
|
||||
value="${param.pageNo}">
|
||||
<div class="col-md-12 col-lg-4">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<s:textfield id="ip_para" name="ip_para" cssClass="form-control " placeholder="ip"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
<%-- <div class="col-md-12 col-lg-4">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<s:select id="type_para" cssClass="form-control "
|
||||
name="type_para"
|
||||
list="#{'white':'白名单'}" listKey="key"
|
||||
listValue="value" headerKey="" headerValue="所有名单"
|
||||
value="type_para" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div> --%>
|
||||
|
||||
<div class="col-md-12 col-lg-2">
|
||||
<button type="submit" class="btn btn-light btn-block">查询</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="col-md-12 col-lg-12" style="margin-top: 10px;">
|
||||
<div class="mailbox clearfix">
|
||||
<div class="panel-title" style="padding-left: 5px;margin-top: -10px;">操作</div>
|
||||
<div class="mailbox-menu" style="border-bottom: hidden;">
|
||||
<ul class="menu">
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-12" >
|
||||
|
||||
<div class="col-md-12 col-lg-3">
|
||||
<button type="button" class="btn btn-light btn-block" onclick="clearData();">清除所有请求数</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">数据汇总</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>ip数</td>
|
||||
<td>总访问量</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<!-- <td>1</td> -->
|
||||
<td><fmt:formatNumber value="${sumdata.ip_sum}" pattern="#0" /></td>
|
||||
<!-- <td>1</td> -->
|
||||
<td><fmt:formatNumber value="${sumdata.ip_request_sum}" pattern="#0" /></td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- Start Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
|
||||
<div class="panel-title">查询结果</div>
|
||||
<a href="javascript:batchAddBlack('<s:property value="ip" />')" class="btn btn-light" style="margin-bottom: 10px" ><i class="fa fa-pencil"></i>批量添加黑名单</a>
|
||||
<div class="panel-body">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<td>ip</td>
|
||||
<td>名单类型</td>
|
||||
<td>累计访问量</td>
|
||||
<td>首次请求时间</td>
|
||||
<td style="width:130px;"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<s:iterator value="page.elements" status="stat">
|
||||
<tr>
|
||||
<td><a href="#" onClick="getUrlsCount('<s:property value="ip" />')"><s:property value="ip" /></a></td>
|
||||
<td>
|
||||
<s:if test='type=="black"'>
|
||||
<span class="right label label-danger">黑名单</span>
|
||||
</s:if>
|
||||
<s:if test='type=="white"'>
|
||||
<span class="right label label-success">白名单</span>
|
||||
</s:if>
|
||||
<s:if test='type==null'>
|
||||
暂无
|
||||
</s:if>
|
||||
</td>
|
||||
<td><s:property value="count" /></td>
|
||||
<td><s:date name="create_time" format="yyyy-MM-dd HH:mm" /></td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-light">操作</button>
|
||||
<button type="button" class="btn btn-light dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="javascript:addBlack('<s:property value="ip" />')">加入黑名单</a></li>
|
||||
<li><a href="javascript:addLock('<s:property value="ip" />')">加入锁定名单</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</s:iterator>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<%@ include file="include/page_simple.jsp"%>
|
||||
<nav>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- End Panel -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
<form
|
||||
action="<%=basePath%>normal/adminIpCountAction!addBlack.action"
|
||||
method="post" id="succeededForm">
|
||||
<s:hidden name="menu_ip" id="menu_ip"></s:hidden>
|
||||
<%-- <s:hidden name="query_symbol" id="query_symbol"></s:hidden> --%>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认加入黑名单</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form
|
||||
action="<%=basePath%>normal/adminIpCountAction!addLock.action"
|
||||
method="post" id="succeededForm">
|
||||
<s:hidden name="menu_ip" id="lock_menu_ip"></s:hidden>
|
||||
<%-- <s:hidden name="query_symbol" id="query_symbol"></s:hidden> --%>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_lock_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认加入锁定名单</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminIpCountAction!batchAddBlack.action"
|
||||
method="post" id="succeededForm">
|
||||
<%-- <s:hidden name="limit_count" id="limit_count"></s:hidden> --%>
|
||||
<%-- <s:hidden name="query_symbol" id="query_symbol"></s:hidden> --%>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_batch_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认加入黑名单</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="ballon color1">访问量高于警戒线的ip都将加入黑名单,请谨慎操作,异步操作会存在延时</p>
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">访问量警戒线</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="limit_count" name="limit_count"
|
||||
class="limit_count" placeholder="请输入数字" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminIpCountAction!clearData.action"
|
||||
method="post" id="succeededForm">
|
||||
<%-- <s:hidden name="query_symbol" id="query_symbol"></s:hidden> --%>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_clear_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认清除数据</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="ballon color1">数据清除后将无法恢复</p>
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="urls_form" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">urls请求数详情</h4>
|
||||
</div>
|
||||
<div class="modal-body" style="max-height: 400px;overflow-y: scroll;">
|
||||
<table class="table table-bordered table-striped" >
|
||||
<thead>
|
||||
<tr>
|
||||
<td>url</td>
|
||||
<td>请求数</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="modal_urls_table">
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- <div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit" class="btn btn-default" >保存</button>
|
||||
|
||||
</div> -->
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function addBlack(ip) {
|
||||
|
||||
$("#menu_ip").val(ip);
|
||||
// $("#query_symbol").val(symbol);
|
||||
$('#modal_succeeded').modal("show");
|
||||
};
|
||||
function addLock(ip) {
|
||||
|
||||
$("#lock_menu_ip").val(ip);
|
||||
// $("#query_symbol").val(symbol);
|
||||
$('#modal_lock_succeeded').modal("show");
|
||||
};
|
||||
function batchAddBlack() {
|
||||
|
||||
// $("#query_symbol").val(symbol);
|
||||
$('#modal_batch_succeeded').modal("show");
|
||||
};
|
||||
function clearData() {
|
||||
|
||||
// $("#query_symbol").val(symbol);
|
||||
$('#modal_clear_succeeded').modal("show");
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
function getUrlsCount(ip){
|
||||
$("#urls_form").modal("show");
|
||||
|
||||
var url = "<%=basePath%>normal/adminIpCountAction!getUrlsCount.action";
|
||||
var data = {"menu_ip":ip};
|
||||
goNewAjaxUrl(url,data,function(tmp){
|
||||
var str='';
|
||||
var content='';
|
||||
for(var i=0;i<tmp.urls_count.length;i++){
|
||||
str += '<tr>'
|
||||
+'<td>'+tmp.urls_count[i].url+'</td>'
|
||||
+'<td>'+tmp.urls_count[i].count+'</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
$("#modal_urls_table").html(str);
|
||||
|
||||
},function(){
|
||||
// $("#coin_value").val(0);
|
||||
});
|
||||
}
|
||||
|
||||
function goNewAjaxUrl(targetUrl,data,Func,Fail){
|
||||
// console.log(data);
|
||||
$.ajax({
|
||||
url:targetUrl,
|
||||
data:data,
|
||||
type : 'get',
|
||||
dataType : "json",
|
||||
success: function (res) {
|
||||
var tmp = $.parseJSON(res)
|
||||
console.log(tmp);
|
||||
if(tmp.code==200){
|
||||
Func(tmp);
|
||||
}else if(tmp.code==500){
|
||||
Fail();
|
||||
swal({
|
||||
title : tmp.message,
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
});
|
||||
}
|
||||
},
|
||||
error : function(XMLHttpRequest, textStatus,
|
||||
errorThrown) {
|
||||
swal({
|
||||
title : "请求错误",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
});
|
||||
console.log("请求错误");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
242
comm/DDOS/WebContent/ip_menu_add.jsp
Executable file
242
comm/DDOS/WebContent/ip_menu_add.jsp
Executable file
@@ -0,0 +1,242 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>IP名单管理</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<form action="<%=basePath%>normal/adminIpMenuAction!list.action"
|
||||
method="post" id="queryForm">
|
||||
<s:hidden name="pageNo" id="pageNo"></s:hidden>
|
||||
<s:hidden name="ip_para" id="ip_para"></s:hidden>
|
||||
<s:hidden name="type_para" id="type_para"></s:hidden>
|
||||
</form>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
新增IP名单
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminIpMenuAction!add.action"
|
||||
method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="ip_para" id="ip_para"></s:hidden>
|
||||
<s:hidden name="type_para" id="type_para"></s:hidden>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">IP</label>
|
||||
<div class="col-sm-5">
|
||||
<s:textfield id="menu_ip" name="menu_ip"
|
||||
cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
<p class="ballon color1">黑名单生成后将24小时后解封</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">名单</label>
|
||||
<div class="col-sm-2">
|
||||
<div class="controls">
|
||||
<s:select id="menu_type" cssClass="form-control "
|
||||
name="menu_type"
|
||||
list="#{'black':'黑名单','lock':'锁定名单','white':'白名单'}" listKey="key"
|
||||
listValue="value"
|
||||
value="menu_type" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%-- <div class="form-group">
|
||||
<label for="input002" class="col-sm-2 control-label form-label">备注</label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<s:textarea name="remarks" id="remarks"
|
||||
cssClass="form-control input-lg" rows="4" cols="20" />
|
||||
|
||||
</div>
|
||||
</div> --%>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认新增</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<a href="javascript:goUrl(<s:property value="pageNo" />)"
|
||||
class="btn">取消</a> <a href="javascript:submit()"
|
||||
class="btn btn-default">保存</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function submit() {
|
||||
$('#modal_succeeded').modal("show");
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var setInt = null;//定时器
|
||||
|
||||
clearInterval(setInt);
|
||||
function sendCode(){
|
||||
var url = "<%=basePath%>normal/adminEmailCodeAction!sendCode.action";
|
||||
var data = {"code_context":"saveSysUser","isSuper":true};
|
||||
goAjaxUrl(url,data,function(tmp){
|
||||
|
||||
$("#email_code_button").attr("disabled","disabled");
|
||||
var timeout = 60;
|
||||
setInt = setInterval(function(){
|
||||
if(timeout<=0){
|
||||
clearInterval(setInt);
|
||||
timeout=60;
|
||||
$("#email_code_button").removeAttr("disabled");
|
||||
$("#email_code_button").html("获取超级签验证码");
|
||||
return;
|
||||
}
|
||||
timeout--;
|
||||
$("#email_code_button").html("获取超级签验证码 "+timeout);
|
||||
},1000);
|
||||
},function(){
|
||||
});
|
||||
}
|
||||
|
||||
function goAjaxUrl(targetUrl,data,Func,Fail){
|
||||
// console.log(data);
|
||||
$.ajax({
|
||||
url:targetUrl,
|
||||
data:data,
|
||||
type : 'get',
|
||||
dataType : "json",
|
||||
success: function (res) {
|
||||
var tmp = $.parseJSON(res)
|
||||
console.log(tmp);
|
||||
if(tmp.code==200){
|
||||
Func(tmp);
|
||||
}else if(tmp.code==500){
|
||||
Fail();
|
||||
swal({
|
||||
title : tmp.message,
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
});
|
||||
}
|
||||
},
|
||||
error : function(XMLHttpRequest, textStatus,
|
||||
errorThrown) {
|
||||
swal({
|
||||
title : "请求错误",
|
||||
text : "请检查管理员邮箱是否配置",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
});
|
||||
console.log("请求错误");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
358
comm/DDOS/WebContent/ip_menu_list.jsp
Executable file
358
comm/DDOS/WebContent/ip_menu_list.jsp
Executable file
@@ -0,0 +1,358 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>IP名单管理
|
||||
(<s:if test="type_para=='white'">白名单</s:if>
|
||||
<s:if test="type_para=='black'">黑名单</s:if>
|
||||
<s:if test="type_para=='lock'">锁定名单</s:if>
|
||||
)
|
||||
</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询条件</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<form class="form-horizontal" action="<%=basePath%>normal/adminIpMenuAction!list.action" method="post"
|
||||
id="queryForm">
|
||||
<input type="hidden" name="pageNo" id="pageNo"
|
||||
value="${param.pageNo}">
|
||||
<input type="hidden" name="type_para" id="type_para">
|
||||
<div class="col-md-12 col-lg-4">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<s:textfield id="ip_para" name="ip_para" cssClass="form-control " placeholder="ip"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
<%-- <div class="col-md-12 col-lg-4">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<s:select id="type_para" cssClass="form-control "
|
||||
name="type_para"
|
||||
list="#{'black':'黑名单','white':'白名单'}" listKey="key"
|
||||
listValue="value" headerKey="" headerValue="所有名单"
|
||||
value="type_para" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div> --%>
|
||||
|
||||
<div class="col-md-12 col-lg-2">
|
||||
<button type="submit" class="btn btn-light btn-block">查询</button>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-12" style="margin-top: 10px;">
|
||||
<div class="mailbox clearfix">
|
||||
<div class="mailbox-menu">
|
||||
<ul class="menu">
|
||||
<li><a href="javascript:setType('white')"> 白名单</a></li>
|
||||
<li><a href="javascript:setType('black')">黑名单</a></li>
|
||||
<li><a href="javascript:setType('lock')">锁定名单</a></li>
|
||||
<!-- <li><a href="javascript:setState('2')">违约</a></li> -->
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- Start Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询结果</div>
|
||||
<a href="<%=basePath%>normal/adminIpMenuAction!toAdd.action?ip_para=<s:property value="ip_para" />&type_para=<s:property value="type_para" />" class="btn btn-light" style="margin-bottom: 10px" ><i class="fa fa-pencil"></i>新增IP名单</a>
|
||||
<div class="panel-body">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<td>ip</td>
|
||||
<td>类型</td>
|
||||
<td>请求次数</td>
|
||||
<td>处理时间</td>
|
||||
<td style="width:130px;"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<s:iterator value="page.elements" status="stat">
|
||||
<tr>
|
||||
<td><a href="#" onClick="getUrlsCount('<s:property value="ip" />')"><s:property value="ip" /></a></td>
|
||||
<td>
|
||||
<s:if test='type=="black"'>
|
||||
<span class="right label label-danger">黑名单</span>
|
||||
</s:if>
|
||||
<s:if test='type=="white"'>
|
||||
<span class="right label label-success">白名单</span>
|
||||
</s:if>
|
||||
<s:if test='type=="lock"'>
|
||||
<span class="right label label-warning">锁定名单</span>
|
||||
</s:if>
|
||||
</td>
|
||||
<td><s:property value="count" /></td>
|
||||
<td><s:date name="last_opera_time" format="yyyy-MM-dd HH:mm" /></td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-light">操作</button>
|
||||
<button type="button" class="btn btn-light dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<%-- <li><a href="<%=basePath%>normal/adminIpMenuAction!toUpdate.action?menu_ip=<s:property value="ip" />">修改</a></li> --%>
|
||||
<li><a href="javascript:del('<s:property value="ip" />')">删除</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</s:iterator>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<%@ include file="include/page_simple.jsp"%>
|
||||
<nav>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- End Panel -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
<form
|
||||
action="<%=basePath%>normal/adminIpMenuAction!toDelete.action"
|
||||
method="post" id="succeededForm">
|
||||
<s:hidden name="menu_ip" id="menu_ip"></s:hidden>
|
||||
<s:hidden name="type_para"></s:hidden>
|
||||
<s:hidden name="ip_para"></s:hidden>
|
||||
<%-- <s:hidden name="query_symbol" id="query_symbol"></s:hidden> --%>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认删除</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="urls_form" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">urls请求数详情</h4>
|
||||
</div>
|
||||
<div class="modal-body" style="max-height: 400px;overflow-y: scroll;">
|
||||
<table class="table table-bordered table-striped" >
|
||||
<thead>
|
||||
<tr>
|
||||
<td>url</td>
|
||||
<td>请求数</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="modal_urls_table">
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- <div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit" class="btn btn-default" >保存</button>
|
||||
|
||||
</div> -->
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function del(ip) {
|
||||
|
||||
$("#menu_ip").val(ip);
|
||||
// $("#query_symbol").val(symbol);
|
||||
$('#modal_succeeded').modal("show");
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
function setType(type_para){
|
||||
document.getElementById("type_para").value=type_para;
|
||||
document.getElementById("queryForm").submit();
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
function getUrlsCount(ip){
|
||||
$("#urls_form").modal("show");
|
||||
|
||||
var url = "<%=basePath%>normal/adminIpCountAction!getUrlsCount.action";
|
||||
var data = {"menu_ip":ip};
|
||||
goNewAjaxUrl(url,data,function(tmp){
|
||||
var str='';
|
||||
var content='';
|
||||
for(var i=0;i<tmp.urls_count.length;i++){
|
||||
str += '<tr>'
|
||||
+'<td>'+tmp.urls_count[i].url+'</td>'
|
||||
+'<td>'+tmp.urls_count[i].count+'</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
$("#modal_urls_table").html(str);
|
||||
|
||||
},function(){
|
||||
// $("#coin_value").val(0);
|
||||
});
|
||||
}
|
||||
|
||||
function goNewAjaxUrl(targetUrl,data,Func,Fail){
|
||||
// console.log(data);
|
||||
$.ajax({
|
||||
url:targetUrl,
|
||||
data:data,
|
||||
type : 'get',
|
||||
dataType : "json",
|
||||
success: function (res) {
|
||||
var tmp = $.parseJSON(res)
|
||||
console.log(tmp);
|
||||
if(tmp.code==200){
|
||||
Func(tmp);
|
||||
}else if(tmp.code==500){
|
||||
Fail();
|
||||
swal({
|
||||
title : tmp.message,
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
});
|
||||
}
|
||||
},
|
||||
error : function(XMLHttpRequest, textStatus,
|
||||
errorThrown) {
|
||||
swal({
|
||||
title : "请求错误",
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
});
|
||||
console.log("请求错误");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
168
comm/DDOS/WebContent/ip_menu_update.jsp
Executable file
168
comm/DDOS/WebContent/ip_menu_update.jsp
Executable file
@@ -0,0 +1,168 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>IP名单管理</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<form action="<%=basePath%>normal/adminIpMenuAction!list.action"
|
||||
method="post" id="queryForm">
|
||||
<s:hidden name="pageNo" id="pageNo"></s:hidden>
|
||||
<s:hidden name="ip_para" id="ip_para"></s:hidden>
|
||||
</form>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
修改IP名单
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminIpMenuAction!update.action"
|
||||
method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="ip_para" id="ip_para"></s:hidden>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">IP</label>
|
||||
<div class="col-sm-5">
|
||||
<s:textfield id="menu_ip" name="menu_ip"
|
||||
cssClass="form-control " readonly="true" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="ballon color1">黑名单生成后将24小时后解封</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">名单</label>
|
||||
<div class="col-sm-2">
|
||||
<div class="controls">
|
||||
<s:select id="menu_type" cssClass="form-control "
|
||||
name="menu_type"
|
||||
list="#{'black':'黑名单','white':'白名单'}" listKey="key"
|
||||
listValue="value"
|
||||
value="menu_type" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认修改</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<a href="javascript:goUrl(<s:property value="pageNo" />)"
|
||||
class="btn">取消</a> <a href="javascript:submit()"
|
||||
class="btn btn-default">保存</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function submit() {
|
||||
$('#modal_succeeded').modal("show");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
226
comm/DDOS/WebContent/url_special_add.jsp
Executable file
226
comm/DDOS/WebContent/url_special_add.jsp
Executable file
@@ -0,0 +1,226 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>特殊URL管理</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<form action="<%=basePath%>normal/adminUrlSpecialAction!list.action"
|
||||
method="post" id="queryForm">
|
||||
<s:hidden name="pageNo" id="pageNo"></s:hidden>
|
||||
<s:hidden name="url_para" id="url_para"></s:hidden>
|
||||
</form>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
新增URL
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminUrlSpecialAction!add.action"
|
||||
method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="ip_para" id="ip_para"></s:hidden>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">URL</label>
|
||||
<div class="col-sm-5">
|
||||
<s:textfield id="url" name="url"
|
||||
cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="input002" class="col-sm-2 control-label form-label">备注</label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<s:textarea name="remarks" id="remarks"
|
||||
cssClass="form-control input-lg" rows="4" cols="20" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认新增</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<a href="javascript:goUrl(<s:property value="pageNo" />)"
|
||||
class="btn">取消</a> <a href="javascript:submit()"
|
||||
class="btn btn-default">保存</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function submit() {
|
||||
$('#modal_succeeded').modal("show");
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var setInt = null;//定时器
|
||||
|
||||
clearInterval(setInt);
|
||||
function sendCode(){
|
||||
var url = "<%=basePath%>normal/adminEmailCodeAction!sendCode.action";
|
||||
var data = {"code_context":"saveSysUser","isSuper":true};
|
||||
goAjaxUrl(url,data,function(tmp){
|
||||
|
||||
$("#email_code_button").attr("disabled","disabled");
|
||||
var timeout = 60;
|
||||
setInt = setInterval(function(){
|
||||
if(timeout<=0){
|
||||
clearInterval(setInt);
|
||||
timeout=60;
|
||||
$("#email_code_button").removeAttr("disabled");
|
||||
$("#email_code_button").html("获取超级签验证码");
|
||||
return;
|
||||
}
|
||||
timeout--;
|
||||
$("#email_code_button").html("获取超级签验证码 "+timeout);
|
||||
},1000);
|
||||
},function(){
|
||||
});
|
||||
}
|
||||
|
||||
function goAjaxUrl(targetUrl,data,Func,Fail){
|
||||
// console.log(data);
|
||||
$.ajax({
|
||||
url:targetUrl,
|
||||
data:data,
|
||||
type : 'get',
|
||||
dataType : "json",
|
||||
success: function (res) {
|
||||
var tmp = $.parseJSON(res)
|
||||
console.log(tmp);
|
||||
if(tmp.code==200){
|
||||
Func(tmp);
|
||||
}else if(tmp.code==500){
|
||||
Fail();
|
||||
swal({
|
||||
title : tmp.message,
|
||||
text : "",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
});
|
||||
}
|
||||
},
|
||||
error : function(XMLHttpRequest, textStatus,
|
||||
errorThrown) {
|
||||
swal({
|
||||
title : "请求错误",
|
||||
text : "请检查管理员邮箱是否配置",
|
||||
type : "warning",
|
||||
showCancelButton : true,
|
||||
confirmButtonColor : "#DD6B55",
|
||||
confirmButtonText : "确认",
|
||||
closeOnConfirm : false
|
||||
});
|
||||
console.log("请求错误");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
202
comm/DDOS/WebContent/url_special_list.jsp
Executable file
202
comm/DDOS/WebContent/url_special_list.jsp
Executable file
@@ -0,0 +1,202 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>特殊url管理</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询条件</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<form class="form-horizontal" action="<%=basePath%>normal/adminUrlSpecialAction!list.action" method="post"
|
||||
id="queryForm">
|
||||
<input type="hidden" name="pageNo" id="pageNo"
|
||||
value="${param.pageNo}">
|
||||
<div class="col-md-12 col-lg-4">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<s:textfield id="url_para" name="url_para" cssClass="form-control " placeholder="url"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 col-lg-2">
|
||||
<button type="submit" class="btn btn-light btn-block">查询</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- Start Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">查询结果</div>
|
||||
<a href="<%=basePath%>normal/adminUrlSpecialAction!toAdd.action?url_para=<s:property value="url_para" />" class="btn btn-light" style="margin-bottom: 10px" ><i class="fa fa-pencil"></i>新增特殊URL</a>
|
||||
<div class="panel-body">
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<td>URL</td>
|
||||
<td>备注</td>
|
||||
<!-- <td>添加时间</td> -->
|
||||
<td style="width:130px;"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<s:iterator value="page.elements" status="stat">
|
||||
<tr>
|
||||
<td><s:property value="url" /></td>
|
||||
<td><s:property value="remarks" /></td>
|
||||
<%-- <td><s:date name="create_time" format="yyyy-MM-dd HH:mm" /></td> --%>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-light">操作</button>
|
||||
<button type="button" class="btn btn-light dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||
<span class="caret"></span>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="<%=basePath%>normal/adminUrlSpecialAction!toUpdate.action?id=<s:property value="id" />">修改</a></li>
|
||||
<li><a href="javascript:del('<s:property value="id" />')">删除</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</s:iterator>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<%@ include file="include/page_simple.jsp"%>
|
||||
<nav>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- End Panel -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
<form
|
||||
action="<%=basePath%>normal/adminUrlSpecialAction!toDelete.action"
|
||||
method="post" id="succeededForm">
|
||||
<s:hidden name="id" id="id"></s:hidden>
|
||||
<%-- <s:hidden name="query_symbol" id="query_symbol"></s:hidden> --%>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认删除</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
function del(id) {
|
||||
|
||||
$("#id").val(id);
|
||||
// $("#query_symbol").val(symbol);
|
||||
$('#modal_succeeded').modal("show");
|
||||
};
|
||||
</script>
|
||||
</html>
|
||||
165
comm/DDOS/WebContent/url_special_update.jsp
Executable file
165
comm/DDOS/WebContent/url_special_update.jsp
Executable file
@@ -0,0 +1,165 @@
|
||||
<%@ page language="java" pageEncoding="utf-8"%>
|
||||
<%@ include file="include/pagetop.jsp"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%@ include file="include/head.jsp"%>
|
||||
</head>
|
||||
<body>
|
||||
<%@ include file="include/loading.jsp"%>
|
||||
<%@ include file="include/top.jsp"%>
|
||||
<%@ include file="include/menu_left.jsp"%>
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTENT -->
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START CONTAINER -->
|
||||
<div class="container-default">
|
||||
<h3>特殊URL管理</h3>
|
||||
<%@ include file="include/alert.jsp"%>
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<!-- START queryForm -->
|
||||
<form action="<%=basePath%>normal/adminUrlSpecialAction!list.action"
|
||||
method="post" id="queryForm">
|
||||
<s:hidden name="pageNo" id="pageNo"></s:hidden>
|
||||
<s:hidden name="ip_para" id="ip_para"></s:hidden>
|
||||
</form>
|
||||
<!-- END queryForm -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-title">
|
||||
修改URL
|
||||
<ul class="panel-tools">
|
||||
<li><a class="icon minimise-tool"><i
|
||||
class="fa fa-minus"></i></a></li>
|
||||
<li><a class="icon expand-tool"><i class="fa fa-expand"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal"
|
||||
action="<%=basePath%>normal/adminUrlSpecialAction!update.action"
|
||||
method="post" name="mainForm" id="mainForm">
|
||||
<s:hidden name="ip_para" id="ip_para"></s:hidden>
|
||||
<s:hidden name="id" id="id"></s:hidden>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label form-label">URL</label>
|
||||
<div class="col-sm-5">
|
||||
<s:textfield id="url" name="url"
|
||||
cssClass="form-control " />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="input002" class="col-sm-2 control-label form-label">备注</label>
|
||||
<div class="col-sm-6">
|
||||
|
||||
<s:textarea name="remarks" id="remarks"
|
||||
cssClass="form-control input-lg" rows="4" cols="20" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<!-- 模态框(Modal) -->
|
||||
<div class="modal fade" id="modal_succeeded" tabindex="-1"
|
||||
role="dialog" aria-labelledby="myModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content" >
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close"
|
||||
data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">确认修改</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">登录人资金密码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="login_safeword" type="password" name="login_safeword"
|
||||
class="login_safeword" placeholder="请输入登录人资金密码" >
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group" style="">
|
||||
|
||||
<label for="input002" class="col-sm-3 control-label form-label">验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="email_code" type="text" name="email_code"
|
||||
class="login_safeword" placeholder="请输入验证码" >
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<button id="email_code_button"
|
||||
class="btn btn-light " onClick="sendCode();" >获取验证码</button>
|
||||
<a id="email_code_button" href="javascript:sendCode();" class="btn btn-light" style="margin-bottom: 10px" >获取超级签验证码</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" >
|
||||
<label for="input002" class="col-sm-3 control-label form-label">超级谷歌验证码</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="super_google_auth_code" name="super_google_auth_code"
|
||||
placeholder="请输入超级谷歌验证码" >
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 0;">
|
||||
<button type="button" class="btn "
|
||||
data-dismiss="modal">关闭</button>
|
||||
<button id="sub" type="submit"
|
||||
class="btn btn-default" >确认</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<a href="javascript:goUrl(<s:property value="pageNo" />)"
|
||||
class="btn">取消</a> <a href="javascript:submit()"
|
||||
class="btn btn-default">保存</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTAINER -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
<%@ include file="include/footer.jsp"%>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Content -->
|
||||
<!-- //////////////////////////////////////////////////////////////////////////// -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<%@ include file="include/js.jsp"%>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function submit() {
|
||||
$('#modal_succeeded').modal("show");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
55
comm/DDOS/config/spring/applicationContext-ddos.xml
Executable file
55
comm/DDOS/config/spring/applicationContext-ddos.xml
Executable file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
|
||||
<bean id="ipRequestTimeWindow" class="project.ddos.utils.IpRequestTimeWindow" >
|
||||
</bean>
|
||||
<bean id="ipSpecialRequestTimeWindow" class="project.ddos.utils.IpSpecialRequestTimeWindow" >
|
||||
</bean>
|
||||
<bean id="blacklistIpSerivceTimeWindow" class="project.ddos.utils.BlacklistIpSerivceTimeWindow" >
|
||||
</bean>
|
||||
<bean id="systemParaReadRequestTimeWindow" class="project.ddos.utils.SystemParaReadRequestTimeWindow" >
|
||||
</bean>
|
||||
<bean id="ipLockRequestTimeWindow" class="project.ddos.utils.IpLockRequestTimeWindow" >
|
||||
</bean>
|
||||
<bean id="locklistIpSerivceTimeWindow" class="project.ddos.utils.LocklistIpSerivceTimeWindow" >
|
||||
</bean>
|
||||
<bean id="ipMenuService" class="project.ddos.internal.IpMenuServiceImpl" init-method="init">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
<property name="blacklistIpSerivceTimeWindow" ref="blacklistIpSerivceTimeWindow" />
|
||||
<property name="locklistIpSerivceTimeWindow" ref="locklistIpSerivceTimeWindow" />
|
||||
</bean>
|
||||
<bean id="urlSpecialService" class="project.ddos.internal.UrlSpecialServiceImpl">
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
<bean id="checkIpRequestCountService" class="project.ddos.internal.CheckIpRequestCountServiceImpl" >
|
||||
<property name="sysparaService" ref="sysparaService" />
|
||||
<property name="ipRequestTimeWindow" ref="ipRequestTimeWindow" />
|
||||
<property name="ipSpecialRequestTimeWindow" ref="ipSpecialRequestTimeWindow" />
|
||||
<property name="blacklistIpSerivceTimeWindow" ref="blacklistIpSerivceTimeWindow" />
|
||||
<property name="ipLockRequestTimeWindow" ref="ipLockRequestTimeWindow" />
|
||||
<property name="locklistIpSerivceTimeWindow" ref="locklistIpSerivceTimeWindow" />
|
||||
<property name="systemParaReadRequestTimeWindow" ref="systemParaReadRequestTimeWindow" />
|
||||
<property name="ipMenuService" ref="ipMenuService" />
|
||||
<property name="urlSpecialService" ref="urlSpecialService" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
|
||||
<dubbo:service
|
||||
interface="project.ddos.IpMenuService"
|
||||
ref="ipMenuService" />
|
||||
<dubbo:service
|
||||
interface="project.ddos.UrlSpecialService"
|
||||
ref="urlSpecialService" />
|
||||
<dubbo:service
|
||||
interface="project.ddos.CheckIpRequestCountService"
|
||||
ref="checkIpRequestCountService" />
|
||||
|
||||
</beans>
|
||||
48
comm/DDOS/config/spring/applicationContext-ddos_admin.xml
Executable file
48
comm/DDOS/config/spring/applicationContext-ddos_admin.xml
Executable file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<dubbo:reference id="checkIpRequestCountService"
|
||||
interface="project.ddos.CheckIpRequestCountService" check="false" />
|
||||
<dubbo:reference id="ipMenuService"
|
||||
interface="project.ddos.IpMenuService" check="false" />
|
||||
<dubbo:reference id="urlSpecialService"
|
||||
interface="project.ddos.UrlSpecialService" check="false" />
|
||||
|
||||
<bean id="adminIpMenuService" class="project.ddos.internal.AdminIpMenuServiceImpl" >
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="secUserService" ref="secUserService" />
|
||||
<property name="logService" ref="logService" />
|
||||
<property name="sysparaService" ref="sysparaService" />
|
||||
<property name="ipMenuService" ref="ipMenuService" />
|
||||
<property name="passwordEncoder" ref="passwordEncoder" />
|
||||
<property name="checkIpRequestCountService" ref="checkIpRequestCountService" />
|
||||
</bean>
|
||||
<bean id="adminUrlSpecialService" class="project.ddos.internal.AdminUrlSpecialServiceImpl" >
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="pagedQueryDao" ref="pagedDao" />
|
||||
<property name="secUserService" ref="secUserService" />
|
||||
<property name="logService" ref="logService" />
|
||||
<property name="sysparaService" ref="sysparaService" />
|
||||
<property name="urlSpecialService" ref="urlSpecialService" />
|
||||
<property name="passwordEncoder" ref="passwordEncoder" />
|
||||
</bean>
|
||||
<bean id="adminIpCountService" class="project.ddos.internal.AdminIpCountServiceImpl" >
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="secUserService" ref="secUserService" />
|
||||
<property name="logService" ref="logService" />
|
||||
<property name="sysparaService" ref="sysparaService" />
|
||||
<property name="ipMenuService" ref="ipMenuService" />
|
||||
<property name="checkIpRequestCountService" ref="checkIpRequestCountService" />
|
||||
<property name="passwordEncoder" ref="passwordEncoder" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
<property name="jdbcTemplate" ref="jdbcTemplate" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
17
comm/DDOS/config/spring/applicationContext-ddos_data.xml
Executable file
17
comm/DDOS/config/spring/applicationContext-ddos_data.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://code.alibabatech.com/schema/dubbo
|
||||
http://code.alibabatech.com/schema/dubbo/dubbo.xsd ">
|
||||
|
||||
<!-- init-method="init" -->
|
||||
|
||||
<bean id="ipHandleCacheService"
|
||||
class="project.ddos.data.loadcache.IpHandleCacheService" >
|
||||
<property name="hibernateTemplate" ref="hibernateTemplate" />
|
||||
<property name="redisHandler" ref="redisHandler" />
|
||||
</bean>
|
||||
</beans>
|
||||
3
comm/DDOS/config/spring/applicationContext-hibernate.xml
Executable file
3
comm/DDOS/config/spring/applicationContext-hibernate.xml
Executable file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
|
||||
20
comm/DDOS/config/spring/normal.xml
Executable file
20
comm/DDOS/config/spring/normal.xml
Executable file
@@ -0,0 +1,20 @@
|
||||
admin
|
||||
<action name="adminIpMenuAction" class="project.ddos.web.AdminIpMenuAction">
|
||||
<result name="list">/ip_menu_list.jsp</result>
|
||||
<result name="add">/ip_menu_add.jsp</result>
|
||||
<result name="update">/ip_menu_update.jsp</result>
|
||||
</action>
|
||||
<action name="adminUrlSpecialAction" class="project.ddos.web.AdminUrlSpecialAction">
|
||||
<result name="list">/url_special_list.jsp</result>
|
||||
<result name="add">/url_special_add.jsp</result>
|
||||
<result name="update">/url_special_update.jsp</result>
|
||||
</action>
|
||||
<action name="adminIpCountAction" class="project.ddos.web.AdminIpCountAction">
|
||||
<result name="list">/ip_count_list.jsp</result>
|
||||
<result name="result_make" type="json">
|
||||
<param name="root">result_make</param>
|
||||
</result>
|
||||
</action>
|
||||
|
||||
|
||||
|
||||
21
comm/DDOS/dbscript/3.0/DDOS-DDL-MYSQL.SQL
Executable file
21
comm/DDOS/dbscript/3.0/DDOS-DDL-MYSQL.SQL
Executable file
@@ -0,0 +1,21 @@
|
||||
DROP TABLE IF EXISTS `T_IP_MENU`;
|
||||
CREATE TABLE `T_IP_MENU` (
|
||||
`UUID` varchar(64) NOT NULL DEFAULT '',
|
||||
`IP` varchar(64) DEFAULT NULL,
|
||||
`TYPE` varchar(32) DEFAULT NULL,
|
||||
`DELETE_STATUS` int(11) DEFAULT '0',
|
||||
`LAST_OPERA_TIME` datetime DEFAULT NULL,
|
||||
`CREATE_TIME` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`UUID`),
|
||||
KEY `INDEX_IP` (`IP`),
|
||||
KEY `INDEX_TYPE` (`TYPE`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `T_URL_SPECIAL`;
|
||||
CREATE TABLE `T_URL_SPECIAL` (
|
||||
`UUID` varchar(64) NOT NULL,
|
||||
`URL` varchar(256) DEFAULT NULL,
|
||||
`REMARKS` varchar(256) DEFAULT NULL,
|
||||
`CREATE_TIME` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`UUID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
33
comm/DDOS/src/project/ddos/AdminIpCountService.java
Executable file
33
comm/DDOS/src/project/ddos/AdminIpCountService.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.ddos;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminIpCountService {
|
||||
|
||||
Page cachePagedQuery(int pageNo, int pageSize, String ip_para, String type_para, Long limit_count);
|
||||
|
||||
/**
|
||||
* 批量添加黑名单
|
||||
*
|
||||
* @param limitCount
|
||||
* @param operatorUsername
|
||||
* @param loginSafeword
|
||||
* @param ip
|
||||
*/
|
||||
public void batchAddBlack(Long limitCount, String operatorUsername, String loginSafeword, String ip);
|
||||
|
||||
public void clearData(String operatorUsername, String loginSafeword, String ip);
|
||||
|
||||
public Map<String, Object> sumDates();
|
||||
|
||||
/**
|
||||
* 获取到url的访问数
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getUrlsCount(String ip);
|
||||
}
|
||||
17
comm/DDOS/src/project/ddos/AdminIpMenuService.java
Executable file
17
comm/DDOS/src/project/ddos/AdminIpMenuService.java
Executable file
@@ -0,0 +1,17 @@
|
||||
package project.ddos;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.ddos.model.IpMenu;
|
||||
|
||||
public interface AdminIpMenuService {
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize, String ip_para, String startTime, String endTime);
|
||||
|
||||
public void save(IpMenu entity, String operatorUsername, String loginSafeword, String ip);
|
||||
|
||||
public void update(IpMenu entity, String operatorUsername, String loginSafeword, String ip);
|
||||
|
||||
public void delete(String menu_ip, String operatorUsername, String loginSafeword, String ip);
|
||||
|
||||
void updateIp(IpMenu ipMenu, String old, String usernameLogin, String loginSafeword, String ip);
|
||||
}
|
||||
16
comm/DDOS/src/project/ddos/AdminUrlSpecialService.java
Executable file
16
comm/DDOS/src/project/ddos/AdminUrlSpecialService.java
Executable file
@@ -0,0 +1,16 @@
|
||||
package project.ddos;
|
||||
|
||||
import kernel.web.Page;
|
||||
import project.ddos.model.UrlSpecial;
|
||||
|
||||
public interface AdminUrlSpecialService {
|
||||
|
||||
Page pagedQuery(int pageNo, int pageSize, String url_para);
|
||||
|
||||
void save(UrlSpecial entity, String operatorUsername, String loginSafeword, String ip);
|
||||
|
||||
void update(UrlSpecial entity, String operatorUsername, String loginSafeword, String ip);
|
||||
|
||||
void delete(String id, String operatorUsername, String loginSafeword, String ip);
|
||||
|
||||
}
|
||||
103
comm/DDOS/src/project/ddos/CheckIpRequestCountService.java
Executable file
103
comm/DDOS/src/project/ddos/CheckIpRequestCountService.java
Executable file
@@ -0,0 +1,103 @@
|
||||
package project.ddos;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public interface CheckIpRequestCountService {
|
||||
|
||||
/**
|
||||
* 返回true:ip已被封, false:ip正常
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
boolean chcekIp(String ip, String url);
|
||||
|
||||
public Map<String, AtomicLong> getIpCountCache();
|
||||
|
||||
public Map<String, Date> getIpTimeCacheCache();
|
||||
|
||||
public void clearIpCountCache();
|
||||
|
||||
public void clearIpTimeCacheCache();
|
||||
|
||||
/**
|
||||
* 分页获取ip计数相关信息,(防止因跨服务请求导致网络带宽不足而响应慢)
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param ip_para ip
|
||||
* @param type_para 黑白名单
|
||||
* @param limit_count 最低访问量
|
||||
* @param isExcludeMenu 是否排除名单 true:排除名单
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> cachePagedQueryIpCount(int pageNo, int pageSize, String ip_para, String type_para,
|
||||
Long limit_count, boolean isExcludeMenu);
|
||||
|
||||
/**
|
||||
* 是否开启检测功能
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean checkButton();
|
||||
|
||||
/**
|
||||
* 根据ip,返回具体链接的请求数
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
public Map<String, AtomicLong> cacheUrlCount(String ip);
|
||||
|
||||
/**
|
||||
* 根据ips批量获取对应的请求数据,减少交互
|
||||
*
|
||||
* @param ips
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Long> ipCountByIps(List<String> ips);
|
||||
|
||||
/**
|
||||
* 获取ip请求汇总数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> ipCountSumDates();
|
||||
|
||||
/**
|
||||
* 登录页相关所需的urls
|
||||
*/
|
||||
public List<String> loginPageRelationAction();
|
||||
|
||||
/**
|
||||
* ip请求清除不在名单里的数据
|
||||
*/
|
||||
public void cacheRequestClearNoMenu();
|
||||
|
||||
/**
|
||||
* ip是否锁定
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
public boolean isLock(String ip);
|
||||
|
||||
/**
|
||||
* ip请求数相关缓存清除
|
||||
*
|
||||
* @param ip
|
||||
*/
|
||||
public void cacheRemoveIp(String ip);
|
||||
|
||||
/**
|
||||
* 检查IP是否黑名单
|
||||
* 返回true:ip已被封, false:ip正常
|
||||
*
|
||||
* @param ip IP地址
|
||||
* @return 结果值
|
||||
*/
|
||||
boolean checkBlackIp(String ip);
|
||||
}
|
||||
21
comm/DDOS/src/project/ddos/DdosRedisKeys.java
Executable file
21
comm/DDOS/src/project/ddos/DdosRedisKeys.java
Executable file
@@ -0,0 +1,21 @@
|
||||
package project.ddos;
|
||||
|
||||
public class DdosRedisKeys {
|
||||
|
||||
/**
|
||||
* ip名单,ip做key
|
||||
*/
|
||||
public final static String IP_MENU_IP = "IP_MENU_IP_";
|
||||
/**
|
||||
* ip名单,ip做key
|
||||
*/
|
||||
public final static String IP_MENU_IP_BLACK = "ip_blacklist";
|
||||
/**
|
||||
* 特殊url 处理
|
||||
*/
|
||||
public final static String URL_SPECIAL_ID = "URL_SPECIAL_ID_";
|
||||
/**
|
||||
* 特殊url map集合
|
||||
*/
|
||||
public final static String URL_SPECIAL_URL_MAP = "URL_SPECIAL_URL_MAP_";
|
||||
}
|
||||
23
comm/DDOS/src/project/ddos/IpMenuService.java
Executable file
23
comm/DDOS/src/project/ddos/IpMenuService.java
Executable file
@@ -0,0 +1,23 @@
|
||||
package project.ddos;
|
||||
|
||||
import project.ddos.model.IpMenu;
|
||||
|
||||
public interface IpMenuService {
|
||||
|
||||
void save(IpMenu entity);
|
||||
|
||||
void update(IpMenu entity);
|
||||
|
||||
void delete(IpMenu entity);
|
||||
|
||||
IpMenu cacheByIp(String ip);
|
||||
|
||||
/**
|
||||
* 新增ip到白名单
|
||||
*
|
||||
* @param ip
|
||||
*/
|
||||
public void saveIpMenuWhite(String ip);
|
||||
|
||||
void updateIp(String oldIp, IpMenu ipMenu);
|
||||
}
|
||||
19
comm/DDOS/src/project/ddos/UrlSpecialService.java
Executable file
19
comm/DDOS/src/project/ddos/UrlSpecialService.java
Executable file
@@ -0,0 +1,19 @@
|
||||
package project.ddos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import project.ddos.model.UrlSpecial;
|
||||
|
||||
public interface UrlSpecialService {
|
||||
|
||||
void save(UrlSpecial entity);
|
||||
|
||||
void update(UrlSpecial entity);
|
||||
|
||||
void delete(UrlSpecial entity);
|
||||
|
||||
public UrlSpecial cacheById(String id);
|
||||
|
||||
public List<String> cacheAllUrls();
|
||||
|
||||
}
|
||||
53
comm/DDOS/src/project/ddos/data/loadcache/IpHandleCacheService.java
Executable file
53
comm/DDOS/src/project/ddos/data/loadcache/IpHandleCacheService.java
Executable file
@@ -0,0 +1,53 @@
|
||||
package project.ddos.data.loadcache;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import project.ddos.DdosRedisKeys;
|
||||
import project.ddos.model.IpMenu;
|
||||
import project.ddos.model.UrlSpecial;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class IpHandleCacheService extends HibernateDaoSupport {
|
||||
private static final Log logger = LogFactory.getLog(IpHandleCacheService.class);
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public void loadcache() {
|
||||
loadIpMenu();
|
||||
loadUrlSpecial();
|
||||
logger.info("完成IP处理 数据加载redis");
|
||||
}
|
||||
|
||||
public void loadIpMenu() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM IpMenu where type = 'black' ");
|
||||
List<IpMenu> list = (List<IpMenu>) this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
for (IpMenu ipMenu : list) {
|
||||
redisHandler.setSync(DdosRedisKeys.IP_MENU_IP + ipMenu.getIp(), ipMenu);
|
||||
redisHandler.sadd(DdosRedisKeys.IP_MENU_IP_BLACK, ipMenu.getIp());
|
||||
}
|
||||
}
|
||||
|
||||
public void loadUrlSpecial() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM UrlSpecial ");
|
||||
List<UrlSpecial> list = (List<UrlSpecial>) this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
Map<String, String> cacheMap = new ConcurrentHashMap<String, String>();
|
||||
|
||||
for (UrlSpecial urlSpecial : list) {
|
||||
cacheMap.put(urlSpecial.getId().toString(), urlSpecial.getUrl());
|
||||
redisHandler.setSync(DdosRedisKeys.URL_SPECIAL_ID + urlSpecial.getId().toString(), urlSpecial);
|
||||
}
|
||||
redisHandler.setSync(DdosRedisKeys.URL_SPECIAL_URL_MAP, cacheMap);
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
170
comm/DDOS/src/project/ddos/filter/AllServiceRequestFilter.java
Executable file
170
comm/DDOS/src/project/ddos/filter/AllServiceRequestFilter.java
Executable file
@@ -0,0 +1,170 @@
|
||||
package project.ddos.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
//import com.alibaba.druid.util.StringUtils;
|
||||
|
||||
import kernel.util.JsonUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import kernel.web.ResultObject;
|
||||
import project.ddos.CheckIpRequestCountService;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import project.syspara.Syspara;
|
||||
import project.syspara.SysparaService;
|
||||
import project.user.token.TokenService;
|
||||
|
||||
/**
|
||||
* 所有服务请求过滤
|
||||
*
|
||||
* @author User
|
||||
*
|
||||
*/
|
||||
public class AllServiceRequestFilter implements Filter {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(AllServiceRequestFilter.class);
|
||||
/**
|
||||
* url 白名单
|
||||
*/
|
||||
private List<String> urls = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
public String getIp(HttpServletRequest request) {
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
if (StringUtils.isNotEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) {
|
||||
// 多次反向代理后会有多个ip值,第一个ip才是真实ip
|
||||
int index = ip.indexOf(",");
|
||||
if (index != -1) {
|
||||
return ip.substring(0, index);
|
||||
} else {
|
||||
return ip;
|
||||
}
|
||||
}
|
||||
ip = request.getHeader("X-Real-IP");
|
||||
if (StringUtils.isNotEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) {
|
||||
return ip;
|
||||
}
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
|
||||
throws IOException, ServletException {
|
||||
// TODO Auto-generated method stub
|
||||
ServletRequest oldRequest = request;
|
||||
ServletResponse oldResponse = response;
|
||||
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
|
||||
String servletPath = httpServletRequest.getServletPath();
|
||||
String ip = getIp(httpServletRequest);
|
||||
// if(urls.contains(servletPath)||!".action".equals(servletPath.substring(servletPath.length()-7))) {//白名单直接过滤,非action请求直接过滤
|
||||
// filterChain.doFilter(oldRequest, oldResponse);
|
||||
// return;
|
||||
// }
|
||||
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
|
||||
CheckIpRequestCountService checkIpRequestCountService = (CheckIpRequestCountService) wac
|
||||
.getBean("checkIpRequestCountService");
|
||||
|
||||
/**
|
||||
* 通过获取系统配置里的用户名来给客户无网络连接状态 start
|
||||
*/
|
||||
if (checkUserBlack(httpServletRequest, httpServletResponse, wac)) {
|
||||
return;
|
||||
}
|
||||
;
|
||||
/**
|
||||
* 通过获取系统配置里的用户名来给客户无网络连接状态 end
|
||||
*/
|
||||
|
||||
if (!checkIpRequestCountService.checkButton()) {// 功能未开启则直接正常返回
|
||||
filterChain.doFilter(oldRequest, oldResponse);
|
||||
return;
|
||||
}
|
||||
if (checkIpRequestCountService.isLock(ip)) {// 锁定的ip直接返回
|
||||
return;
|
||||
}
|
||||
if (checkIpRequestCountService.chcekIp(ip, servletPath)) {
|
||||
// 被封ip只能通过特定的url
|
||||
if (checkIpRequestCountService.loginPageRelationAction().contains(servletPath)) {
|
||||
filterChain.doFilter(oldRequest, oldResponse);
|
||||
return;
|
||||
}
|
||||
httpServletResponse.setCharacterEncoding("UTF-8");
|
||||
httpServletResponse.setContentType("application/json; charset=utf-8");
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
|
||||
PrintWriter out = httpServletResponse.getWriter();
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject.setCode("403");
|
||||
resultObject.setMsg("请重新登录");
|
||||
out.append(JsonUtils.getJsonString(resultObject));
|
||||
} else {
|
||||
filterChain.doFilter(oldRequest, oldResponse);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkUserBlack(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
|
||||
WebApplicationContext wac) throws IOException {
|
||||
SysparaService sysparaService = (SysparaService) wac.getBean("sysparaService");
|
||||
PartyService partyService = (PartyService) wac.getBean("partyService");
|
||||
TokenService tokenService = (TokenService) wac.getBean("tokenService");
|
||||
Syspara syspara = sysparaService.find("stop_user_internet");
|
||||
if (syspara == null) {
|
||||
return false;
|
||||
}
|
||||
String tokenNeame = httpServletRequest.getParameter("token");
|
||||
String partyId = tokenService.cacheGet(tokenNeame);
|
||||
if (StringUtils.isEmpty(partyId)) {
|
||||
return false;
|
||||
}
|
||||
Party party = partyService.cachePartyBy(partyId, true);
|
||||
if(party==null) {
|
||||
return false;
|
||||
}
|
||||
String username = party.getUsername();
|
||||
|
||||
String userRecordNames = syspara.getValue();
|
||||
List<String> userRecordNamesList = Arrays.asList(userRecordNames.split(","));
|
||||
if (CollectionUtils.isNotEmpty(userRecordNamesList) && userRecordNamesList.contains(username)) {
|
||||
|
||||
httpServletResponse.setCharacterEncoding("UTF-8");
|
||||
httpServletResponse.setContentType("application/json; charset=utf-8");
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
|
||||
PrintWriter out = httpServletResponse.getWriter();
|
||||
ResultObject resultObject = new ResultObject();
|
||||
resultObject.setCode("1");
|
||||
resultObject.setMsg("请检查网络连接");
|
||||
out.append(JsonUtils.getJsonString(resultObject));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig arg0) throws ServletException {
|
||||
// TODO Auto-generated method stub
|
||||
urls.add("/api/user!login.action");// 登录时
|
||||
}
|
||||
}
|
||||
263
comm/DDOS/src/project/ddos/internal/AdminIpCountServiceImpl.java
Executable file
263
comm/DDOS/src/project/ddos/internal/AdminIpCountServiceImpl.java
Executable file
@@ -0,0 +1,263 @@
|
||||
package project.ddos.internal;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.UUIDGenerator;
|
||||
import kernel.web.Page;
|
||||
import project.Constants;
|
||||
import project.ddos.AdminIpCountService;
|
||||
import project.ddos.CheckIpRequestCountService;
|
||||
import project.ddos.DdosRedisKeys;
|
||||
import project.ddos.IpMenuService;
|
||||
import project.ddos.model.IpMenu;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.redis.RedisHandler;
|
||||
import project.syspara.SysparaService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class AdminIpCountServiceImpl extends HibernateDaoSupport implements AdminIpCountService {
|
||||
|
||||
private SecUserService secUserService;
|
||||
private LogService logService;
|
||||
private SysparaService sysparaService;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
private IpMenuService ipMenuService;
|
||||
private CheckIpRequestCountService checkIpRequestCountService;
|
||||
private RedisHandler redisHandler;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
public Page cachePagedQuery(int pageNo, int pageSize, String ip_para, String type_para, Long limit_count) {
|
||||
List<Map<String, Object>> cachePagedQueryIpCount = checkIpRequestCountService.cachePagedQueryIpCount(pageNo,
|
||||
pageSize, ip_para, type_para, limit_count, true);
|
||||
Page page = new Page(pageNo, pageSize, Integer.MAX_VALUE);
|
||||
page.setElements(cachePagedQueryIpCount);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Map<String, Object> sumDates() {
|
||||
return checkIpRequestCountService.ipCountSumDates();
|
||||
}
|
||||
|
||||
public void batchAddBlack(Long limitCount, String operatorUsername, String loginSafeword, String ip) {
|
||||
checkLoginSafeword(operatorUsername, loginSafeword);
|
||||
// 异步线程添加黑名单
|
||||
BlackDelayThread lockDelayThread = new BlackDelayThread(ip, limitCount, operatorUsername);
|
||||
Thread t = new Thread(lockDelayThread);
|
||||
t.start();
|
||||
|
||||
}
|
||||
|
||||
public class BlackDelayThread implements Runnable {
|
||||
private String ip;
|
||||
private Long limitCount;
|
||||
private String operatorUsername;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
List<Map<String, Object>> cachePagedQueryIpCount = checkIpRequestCountService.cachePagedQueryIpCount(1,
|
||||
Integer.MAX_VALUE, null, null, limitCount, true);
|
||||
Map<String, Object> batchData = new HashMap<String, Object>();
|
||||
|
||||
List<IpMenu> batchUpdateList = new ArrayList<IpMenu>();
|
||||
List<IpMenu> batchInsertList = new ArrayList<IpMenu>();
|
||||
List<String> ips = new ArrayList<String>();
|
||||
for (Map<String, Object> data : cachePagedQueryIpCount) {
|
||||
ips.add(data.get("ip").toString());
|
||||
IpMenu ipMenu = ipMenuService.cacheByIp(data.get("ip").toString());
|
||||
if (ipMenu == null) {
|
||||
ipMenu = new IpMenu();
|
||||
ipMenu.setCreate_time(new Date());
|
||||
ipMenu.setIp(data.get("ip").toString());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
batchInsertList.add(ipMenu);
|
||||
} else {
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
batchUpdateList.add(ipMenu);
|
||||
}
|
||||
batchData.put(DdosRedisKeys.IP_MENU_IP + ipMenu.getIp(), ipMenu);
|
||||
}
|
||||
updateBatchIpMenu(batchUpdateList);
|
||||
insertBatchIpMenu(batchInsertList);
|
||||
redisHandler.setBatchSync(batchData);
|
||||
|
||||
SecUser user = secUserService.findUserByLoginName(operatorUsername);
|
||||
saveLog(user, operatorUsername,
|
||||
"ip:" + ip + "管理员批量添加IP黑名单,警戒线为[" + limitCount + "],ip名单为[" + String.join(",", ips) + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error("BlackDelayThread error:", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public BlackDelayThread(String ip, Long limitCount, String operatorUsername) {
|
||||
this.ip = ip;
|
||||
this.limitCount = limitCount;
|
||||
this.operatorUsername = operatorUsername;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新黑名单
|
||||
*
|
||||
* @param orderList
|
||||
*/
|
||||
protected void updateBatchIpMenu(final List<IpMenu> dataList) {
|
||||
String sql = "UPDATE T_IP_MENU SET DELETE_STATUS=?,LAST_OPERA_TIME=?,TYPE=? WHERE IP=?";
|
||||
int[] batchUpdate = jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||
ps.setInt(1, dataList.get(i).getDelete_status());
|
||||
ps.setTimestamp(2, new Timestamp(dataList.get(i).getLast_opera_time().getTime()));
|
||||
ps.setString(3, dataList.get(i).getType());
|
||||
ps.setString(4, dataList.get(i).getIp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return dataList.size();
|
||||
}
|
||||
});
|
||||
|
||||
// log.info("end miner batch update attr:{}",batchUpdate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量新增黑名单
|
||||
*
|
||||
* @param orderList
|
||||
*/
|
||||
protected void insertBatchIpMenu(final List<IpMenu> dataList) {
|
||||
String sql = "INSERT INTO T_IP_MENU(UUID,IP,TYPE,DELETE_STATUS,LAST_OPERA_TIME,CREATE_TIME) VALUES(?,?,?,?,?,?)";
|
||||
int[] batchUpdate = jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||
ps.setString(1, UUIDGenerator.getUUID());
|
||||
ps.setString(2, dataList.get(i).getIp());
|
||||
ps.setString(3, dataList.get(i).getType());
|
||||
ps.setInt(4, dataList.get(i).getDelete_status());
|
||||
ps.setTimestamp(5, new Timestamp(dataList.get(i).getLast_opera_time().getTime()));
|
||||
ps.setTimestamp(6, new Timestamp(dataList.get(i).getCreate_time().getTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return dataList.size();
|
||||
}
|
||||
});
|
||||
|
||||
// log.info("end miner batch update attr:{}",batchUpdate);
|
||||
}
|
||||
|
||||
public void clearData(String operatorUsername, String loginSafeword, String ip) {
|
||||
checkLoginSafeword(operatorUsername, loginSafeword);
|
||||
checkIpRequestCountService.clearIpCountCache();
|
||||
checkIpRequestCountService.clearIpTimeCacheCache();
|
||||
SecUser user = secUserService.findUserByLoginName(operatorUsername);
|
||||
saveLog(user, operatorUsername, "ip:" + ip + "管理员清除了所有ip请求数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取到url的访问数
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getUrlsCount(String ip) {
|
||||
Map<String, AtomicLong> cacheUrlCount = this.checkIpRequestCountService.cacheUrlCount(ip);
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
|
||||
if (cacheUrlCount == null || cacheUrlCount.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
for (String key : cacheUrlCount.keySet()) {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("url", key);
|
||||
data.put("count", cacheUrlCount.get(key).get());
|
||||
result.add(data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
*
|
||||
* @param operatorUsername
|
||||
* @param loginSafeword
|
||||
*/
|
||||
private void checkLoginSafeword(String operatorUsername, String loginSafeword) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
String sysSafeword = sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("登录人资金密码错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveLog(SecUser secUser, String operator, String context) {
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setOperator(operator);
|
||||
log.setUsername(secUser.getUsername());
|
||||
log.setPartyId(secUser.getPartyId());
|
||||
log.setLog(context);
|
||||
log.setCreateTime(new Date());
|
||||
logService.saveSync(log);
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setIpMenuService(IpMenuService ipMenuService) {
|
||||
this.ipMenuService = ipMenuService;
|
||||
}
|
||||
|
||||
public void setCheckIpRequestCountService(CheckIpRequestCountService checkIpRequestCountService) {
|
||||
this.checkIpRequestCountService = checkIpRequestCountService;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
210
comm/DDOS/src/project/ddos/internal/AdminIpMenuServiceImpl.java
Executable file
210
comm/DDOS/src/project/ddos/internal/AdminIpMenuServiceImpl.java
Executable file
@@ -0,0 +1,210 @@
|
||||
package project.ddos.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.util.DateUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.Constants;
|
||||
import project.contract.ContractOrder;
|
||||
import project.contract.ContractRedisKeys;
|
||||
import project.ddos.AdminIpMenuService;
|
||||
import project.ddos.CheckIpRequestCountService;
|
||||
import project.ddos.DdosRedisKeys;
|
||||
import project.ddos.IpMenuService;
|
||||
import project.ddos.model.IpMenu;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.redis.RedisHandler;
|
||||
import project.syspara.SysparaService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class AdminIpMenuServiceImpl extends HibernateDaoSupport implements AdminIpMenuService {
|
||||
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private SecUserService secUserService;
|
||||
private LogService logService;
|
||||
private SysparaService sysparaService;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
private IpMenuService ipMenuService;
|
||||
private CheckIpRequestCountService checkIpRequestCountService;
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String ip, String startTime, String endTime) {
|
||||
StringBuffer queryString = new StringBuffer(" SELECT menu.UUID id,menu.IP ip,menu.REMARK remark, "
|
||||
+ " menu.LAST_OPERA_TIME last_opera_time,menu.CREATE_TIME create_time, menu.CREATE_NAME createName ");
|
||||
queryString.append(" FROM T_IP_MENU menu WHERE 1 = 1 AND DELETE_STATUS=0 AND menu.TYPE = 'black' ");
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(ip)) {
|
||||
queryString.append(" and menu.IP like:ip ");
|
||||
parameters.put("ip", "%" + ip + "%");
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(startTime)) {
|
||||
queryString.append(" AND DATE(menu.CREATE_TIME) >= DATE(:startTime) ");
|
||||
parameters.put("startTime", DateUtils.toDate(startTime));
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(endTime)) {
|
||||
queryString.append(" AND DATE(menu.CREATE_TIME) <= DATE(:endTime) ");
|
||||
parameters.put("endTime", DateUtils.toDate(endTime));
|
||||
}
|
||||
queryString.append(" GROUP BY menu.CREATE_TIME desc ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
// handleDatas(page.getElements());
|
||||
return page;
|
||||
}
|
||||
|
||||
public void handleDatas(List<Map<String, Object>> datas) {
|
||||
List<String> ips = new ArrayList<String>();
|
||||
for (Map<String, Object> data : datas) {
|
||||
ips.add(data.get("ip").toString());
|
||||
}
|
||||
Map<String, Long> ipCountByIps = checkIpRequestCountService.ipCountByIps(ips);
|
||||
for (Map<String, Object> data : datas) {
|
||||
data.put("count", ipCountByIps.get(data.get("ip").toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public IpMenu getBlankIp(String ip){
|
||||
StringBuffer queryString = new StringBuffer(" FROM IpMenu where ip=?0 and type = 'black' ");
|
||||
List<IpMenu> list = (List<IpMenu>) this.getHibernateTemplate().find(queryString.toString(), new Object[] { ip });
|
||||
if (list.size() > 0) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void save(IpMenu entity, String operatorUsername, String loginSafeword, String ip) {
|
||||
IpMenu ipMenu = getBlankIp(entity.getIp());
|
||||
if (ipMenu != null && ipMenu.getDelete_status() == 0) {
|
||||
throw new BusinessException("ip名单已经存在");
|
||||
}
|
||||
SecUser user = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
saveLog(user, operatorUsername, "ip:" + ip + "管理员新增黑名单IP,ip名单为[" + entity.getIp() + "]");
|
||||
this.getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(DdosRedisKeys.IP_MENU_IP + entity.getIp(), entity);
|
||||
if (IpMenu.IP_BLACK.equals(entity.getType())) {
|
||||
redisHandler.sadd(DdosRedisKeys.IP_MENU_IP_BLACK, entity.getIp());
|
||||
}
|
||||
}
|
||||
|
||||
public void update(IpMenu entity, String operatorUsername, String loginSafeword, String ip) {
|
||||
IpMenu ipMenu = getBlankIp(entity.getIp());
|
||||
if (ipMenu == null || ipMenu.getDelete_status() == -1) {
|
||||
throw new BusinessException("ip名单不存在");
|
||||
}
|
||||
SecUser user = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
saveLog(user, operatorUsername, "ip:" + ip + "管理员更新IP名单,ip名单为[" + entity.getIp() + "],原ip为[" + ipMenu.getIp()
|
||||
+ "],新ip为[" + entity.getIp() + "]");
|
||||
|
||||
ipMenu.setIp(entity.getIp());
|
||||
ipMenu.setLast_opera_time(entity.getLast_opera_time());
|
||||
this.getHibernateTemplate().merge(ipMenu);
|
||||
redisHandler.remove(DdosRedisKeys.IP_MENU_IP + entity.getIp());
|
||||
redisHandler.setSync(DdosRedisKeys.IP_MENU_IP + entity.getIp(),ipMenu);
|
||||
}
|
||||
|
||||
public void delete(String menu_ip, String operatorUsername, String loginSafeword, String ip) {
|
||||
IpMenu ipMenu = getBlankIp(menu_ip);
|
||||
if (ipMenu == null || ipMenu.getDelete_status() == -1) {
|
||||
throw new BusinessException("ip名单不存在");
|
||||
}
|
||||
SecUser user = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
saveLog(user, operatorUsername, "ip:" + ip + "管理员删除IP名单,ip名单为[" + menu_ip + "],类型为[" + ipMenu.getType() + "]");
|
||||
this.getHibernateTemplate().delete(ipMenu);
|
||||
redisHandler.remove(DdosRedisKeys.IP_MENU_IP + ipMenu.getIp());
|
||||
if (IpMenu.IP_BLACK.equals(ipMenu.getType())) {
|
||||
redisHandler.srem(DdosRedisKeys.IP_MENU_IP_BLACK, ipMenu.getIp());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIp(IpMenu entity, String oldIp, String usernameLogin, String loginSafeword, String ip) {
|
||||
IpMenu ipMenu = getBlankIp(oldIp);
|
||||
if (ipMenu == null || ipMenu.getDelete_status() == -1) {
|
||||
throw new BusinessException("ip名单不存在");
|
||||
}
|
||||
SecUser user = this.secUserService.findUserByLoginName(usernameLogin);
|
||||
saveLog(user, usernameLogin, "ip:" + ip + "管理员更新IP名单,ip名单为[" + entity.getIp() + "],原类型为[" + ipMenu.getType()
|
||||
+ "],新类型为[" + entity.getType() + "]");
|
||||
ipMenu.setIp(entity.getIp());
|
||||
ipMenu.setDelete_status(entity.getDelete_status());
|
||||
ipMenu.setType(entity.getType());
|
||||
ipMenu.setLast_opera_time(entity.getLast_opera_time());
|
||||
ipMenu.setRemark(entity.getRemark());
|
||||
this.ipMenuService.updateIp(oldIp,ipMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
*
|
||||
* @param operatorUsername
|
||||
* @param loginSafeword
|
||||
*/
|
||||
private void checkLoginSafeword(String operatorUsername, String loginSafeword) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
String sysSafeword = sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("登录人资金密码错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveLog(SecUser secUser, String operator, String context) {
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setOperator(operator);
|
||||
log.setUsername(secUser.getUsername());
|
||||
log.setPartyId(secUser.getPartyId());
|
||||
log.setLog(context);
|
||||
log.setCreateTime(new Date());
|
||||
logService.saveSync(log);
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setIpMenuService(IpMenuService ipMenuService) {
|
||||
this.ipMenuService = ipMenuService;
|
||||
}
|
||||
|
||||
public void setCheckIpRequestCountService(CheckIpRequestCountService checkIpRequestCountService) {
|
||||
this.checkIpRequestCountService = checkIpRequestCountService;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
}
|
||||
142
comm/DDOS/src/project/ddos/internal/AdminUrlSpecialServiceImpl.java
Executable file
142
comm/DDOS/src/project/ddos/internal/AdminUrlSpecialServiceImpl.java
Executable file
@@ -0,0 +1,142 @@
|
||||
package project.ddos.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.Constants;
|
||||
import project.ddos.AdminUrlSpecialService;
|
||||
import project.ddos.UrlSpecialService;
|
||||
import project.ddos.model.UrlSpecial;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.syspara.SysparaService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class AdminUrlSpecialServiceImpl extends HibernateDaoSupport implements AdminUrlSpecialService {
|
||||
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private SecUserService secUserService;
|
||||
private LogService logService;
|
||||
private SysparaService sysparaService;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
private UrlSpecialService urlSpecialService;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String url_para) {
|
||||
StringBuffer queryString = new StringBuffer(" SELECT urls.UUID id,urls.URL url,urls.REMARKS remarks ");
|
||||
queryString.append(" FROM T_URL_SPECIAL urls WHERE 1 = 1 ");
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
if (!StringUtils.isNullOrEmpty(url_para)) {
|
||||
queryString.append(" and urls.URL like:url_para ");
|
||||
parameters.put("url_para", "%" + url_para + "%");
|
||||
}
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(UrlSpecial entity, String operatorUsername, String loginSafeword, String ip) {
|
||||
if (urlSpecialService.cacheAllUrls().contains(entity.getUrl())) {
|
||||
throw new BusinessException("url已经存在");
|
||||
}
|
||||
checkLoginSafeword(operatorUsername, loginSafeword);
|
||||
SecUser user = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
saveLog(user, operatorUsername,
|
||||
"ip:" + ip + "管理员新增特殊Url,url为[" + entity.getUrl() + "],备注为[" + entity.getRemarks() + "]");
|
||||
urlSpecialService.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(UrlSpecial entity, String operatorUsername, String loginSafeword, String ip) {
|
||||
UrlSpecial urlSpecial = urlSpecialService.cacheById(entity.getId().toString());
|
||||
if (urlSpecial == null) {
|
||||
throw new BusinessException("url不存在");
|
||||
}
|
||||
if (!urlSpecial.getUrl().equals(entity.getUrl())
|
||||
&& urlSpecialService.cacheAllUrls().contains(entity.getUrl())) {
|
||||
throw new BusinessException("修改后的url已存在");
|
||||
}
|
||||
checkLoginSafeword(operatorUsername, loginSafeword);
|
||||
SecUser user = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
saveLog(user, operatorUsername, "ip:" + ip + "管理员新增特殊Url,原url为[" + urlSpecial.getUrl() + "],原备注为["
|
||||
+ urlSpecial.getRemarks() + "],新url为[" + entity.getUrl() + "],新备注为[" + entity.getRemarks() + "]");
|
||||
urlSpecial.setUrl(entity.getUrl());
|
||||
urlSpecial.setRemarks(entity.getRemarks());
|
||||
urlSpecialService.update(urlSpecial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id, String operatorUsername, String loginSafeword, String ip) {
|
||||
UrlSpecial urlSpecial = urlSpecialService.cacheById(id);
|
||||
if (urlSpecial == null) {
|
||||
throw new BusinessException("url不存在");
|
||||
}
|
||||
checkLoginSafeword(operatorUsername, loginSafeword);
|
||||
SecUser user = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
saveLog(user, operatorUsername,
|
||||
"ip:" + ip + "管理员删除特殊Url,url为[" + urlSpecial.getUrl() + "],备注为[" + urlSpecial.getRemarks() + "]");
|
||||
|
||||
this.urlSpecialService.delete(urlSpecial);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
*
|
||||
* @param operatorUsername
|
||||
* @param loginSafeword
|
||||
*/
|
||||
private void checkLoginSafeword(String operatorUsername, String loginSafeword) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
String sysSafeword = sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("登录人资金密码错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveLog(SecUser secUser, String operator, String context) {
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setOperator(operator);
|
||||
log.setUsername(secUser.getUsername());
|
||||
log.setPartyId(secUser.getPartyId());
|
||||
log.setLog(context);
|
||||
log.setCreateTime(new Date());
|
||||
logService.saveSync(log);
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setUrlSpecialService(UrlSpecialService urlSpecialService) {
|
||||
this.urlSpecialService = urlSpecialService;
|
||||
}
|
||||
|
||||
}
|
||||
594
comm/DDOS/src/project/ddos/internal/CheckIpRequestCountServiceImpl.java
Executable file
594
comm/DDOS/src/project/ddos/internal/CheckIpRequestCountServiceImpl.java
Executable file
@@ -0,0 +1,594 @@
|
||||
package project.ddos.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import project.ddos.CheckIpRequestCountService;
|
||||
import project.ddos.IpMenuService;
|
||||
import project.ddos.UrlSpecialService;
|
||||
import project.ddos.model.IpMenu;
|
||||
import project.ddos.utils.BlacklistIpSerivceTimeWindow;
|
||||
import project.ddos.utils.IpLockRequestTimeWindow;
|
||||
import project.ddos.utils.IpRequestTimeWindow;
|
||||
import project.ddos.utils.IpSpecialRequestTimeWindow;
|
||||
import project.ddos.utils.LocklistIpSerivceTimeWindow;
|
||||
import project.ddos.utils.SystemParaReadRequestTimeWindow;
|
||||
import project.redis.RedisHandler;
|
||||
import project.syspara.SysparaService;
|
||||
|
||||
public class CheckIpRequestCountServiceImpl implements CheckIpRequestCountService, InitializingBean {
|
||||
private Logger log = LoggerFactory.getLogger(CheckIpRequestCountServiceImpl.class);
|
||||
private IpRequestTimeWindow ipRequestTimeWindow;
|
||||
private IpSpecialRequestTimeWindow ipSpecialRequestTimeWindow;
|
||||
private BlacklistIpSerivceTimeWindow blacklistIpSerivceTimeWindow;
|
||||
|
||||
private IpLockRequestTimeWindow ipLockRequestTimeWindow;
|
||||
private LocklistIpSerivceTimeWindow locklistIpSerivceTimeWindow;
|
||||
|
||||
private SystemParaReadRequestTimeWindow systemParaReadRequestTimeWindow;
|
||||
private SysparaService sysparaService;
|
||||
private IpMenuService ipMenuService;
|
||||
private UrlSpecialService urlSpecialService;
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
/**
|
||||
* 是否开启ip检测
|
||||
*/
|
||||
private String request_check_ip;
|
||||
/**
|
||||
* 验证ip请求数量限制(十分钟内)
|
||||
*/
|
||||
private Integer request_check_ip_count;
|
||||
/**
|
||||
* 特殊url验证ip请求数量限制(一分钟内)
|
||||
*/
|
||||
private Integer request_check_ip_special_count;
|
||||
/**
|
||||
* 是否只有白名单才可以访问
|
||||
*/
|
||||
private boolean request_only_white_menu;
|
||||
// private String request_check_ip = "false";
|
||||
// private Integer request_check_ip_count = 500;
|
||||
// private Integer request_check_ip_special_count = 20;
|
||||
|
||||
private Map<String, Integer> ipCache = new ConcurrentHashMap<String, Integer>();
|
||||
/**
|
||||
* 特殊地址ip处理
|
||||
*/
|
||||
private Map<String, Integer> ipSpecialCache = new ConcurrentHashMap<String, Integer>();
|
||||
/**
|
||||
* 登录相关地址ip请求数,判定锁定处理
|
||||
*/
|
||||
private Map<String, Integer> ipLockCache = new ConcurrentHashMap<String, Integer>();
|
||||
/**
|
||||
* ip请求数本地缓存,从服务器启动时开始计数
|
||||
*/
|
||||
private Map<String, AtomicLong> ipCountCache = new ConcurrentHashMap<String, AtomicLong>();
|
||||
/**
|
||||
* ip请求时间本地缓存,从服务器启动时开始
|
||||
*/
|
||||
private Map<String, Date> ipTimeCacheCache = new ConcurrentHashMap<String, Date>();
|
||||
/**
|
||||
* ip urls请求数本地缓存,从服务器启动时开始计数
|
||||
*/
|
||||
private Map<String, Map<String, AtomicLong>> ipUrlCountCache = new ConcurrentHashMap<String, Map<String, AtomicLong>>();
|
||||
/**
|
||||
* 登录页相关所需的urls
|
||||
*/
|
||||
private List<String> urls = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* ip访问计数
|
||||
*
|
||||
* @param ip
|
||||
*/
|
||||
private void ipCount(String ip, String url) {
|
||||
AtomicLong atomicLong = ipCountCache.get(ip);
|
||||
Map<String, AtomicLong> urlCountMap = ipUrlCountCache.get(ip);
|
||||
if (urlCountMap == null) {
|
||||
urlCountMap = new ConcurrentHashMap<String, AtomicLong>();
|
||||
}
|
||||
if (atomicLong == null) {
|
||||
atomicLong = new AtomicLong();
|
||||
ipTimeCacheCache.put(ip, new Date());
|
||||
atomicLong.incrementAndGet();
|
||||
ipCountCache.put(ip, atomicLong);
|
||||
// 累计url次数
|
||||
|
||||
AtomicLong atomicUrlLong = new AtomicLong();
|
||||
atomicUrlLong.incrementAndGet();
|
||||
urlCountMap.put(url, atomicUrlLong);
|
||||
ipUrlCountCache.put(ip, urlCountMap);
|
||||
} else {
|
||||
atomicLong.incrementAndGet();
|
||||
// 累计url次数
|
||||
AtomicLong atomicUrlLong = urlCountMap.get(url);
|
||||
if (atomicUrlLong == null) {
|
||||
atomicUrlLong = new AtomicLong();
|
||||
atomicUrlLong.incrementAndGet();
|
||||
urlCountMap.put(url, atomicUrlLong);
|
||||
ipUrlCountCache.put(ip, urlCountMap);
|
||||
} else {
|
||||
atomicUrlLong.incrementAndGet();
|
||||
}
|
||||
// System.out.println("ip:" + ip + ",url:" + url + ",count:" + atomicUrlLong.get());
|
||||
}
|
||||
// System.out.println("ip:" + ip + ",count:" + atomicLong.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否开启检测功能
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean checkButton() {
|
||||
if (StringUtils.isEmptyString(systemParaReadRequestTimeWindow.get("systemParaRead"))) {
|
||||
readPara();
|
||||
systemParaReadRequestTimeWindow.put("systemParaRead", "1");
|
||||
}
|
||||
return "true".equals(request_check_ip);
|
||||
}
|
||||
|
||||
public void readPara() {
|
||||
String old_request_check_ip = request_check_ip;
|
||||
int old_request_check_ip_count = request_check_ip_count;
|
||||
int old_request_check_ip_special_count = request_check_ip_special_count;
|
||||
boolean old_request_only_white_menu = request_only_white_menu;
|
||||
request_check_ip = sysparaService.find("request_check_ip").getValue();
|
||||
request_check_ip_count = sysparaService.find("request_check_ip_count").getInteger();
|
||||
request_check_ip_special_count = sysparaService.find("request_check_ip_special_count").getInteger();
|
||||
request_only_white_menu = sysparaService.find("request_only_white_menu").getBoolean();
|
||||
if (!old_request_check_ip.equals(request_check_ip)) {
|
||||
log.info("request_check_ip 修改,原值:[{}],新值[{}]", old_request_check_ip, request_check_ip);
|
||||
}
|
||||
if (old_request_check_ip_count != request_check_ip_count) {
|
||||
log.info("request_check_ip_count 修改,原值:[{}],新值[{}]", old_request_check_ip_count, request_check_ip_count);
|
||||
}
|
||||
if (old_request_check_ip_special_count != request_check_ip_special_count) {
|
||||
log.info("request_check_ip_special_count 修改,原值:[{}],新值[{}]", old_request_check_ip_special_count,
|
||||
request_check_ip_special_count);
|
||||
}
|
||||
if (old_request_only_white_menu != request_only_white_menu) {
|
||||
log.info("request_only_white_menu 修改,原值:[{}],新值[{}]", old_request_only_white_menu, request_only_white_menu);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回true:ip已被封, false:ip正常
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean chcekIp(String ip, String url) {
|
||||
// String request_check_ip = sysparaService.find("request_check_ip").getValue();
|
||||
// Integer request_check_ip_count = sysparaService.find("request_check_ip_count").getInteger();
|
||||
if (!"true".equals(request_check_ip))
|
||||
return false;// 不为1时 未开启,直接返回false不做处理
|
||||
ipCount(ip, url);
|
||||
IpMenu ipMenu = ipMenuService.cacheByIp(ip);
|
||||
if (ipMenu != null && ipMenu.getDelete_status() != -1 && IpMenu.IP_WHITE.equals(ipMenu.getType())) {// 白名单直接过
|
||||
return false;
|
||||
} else if (request_only_white_menu) {
|
||||
return true;
|
||||
}
|
||||
if (checkLockUrl(ip, url)) {// 先判断是否锁定
|
||||
return true;
|
||||
}
|
||||
if (blacklistIpSerivceTimeWindow.getBlackIp(ip) != null)
|
||||
return true;// ip被封,不发送
|
||||
if (ipMenu != null && ipMenu.getDelete_status() != -1 && IpMenu.IP_BLACK.equals(ipMenu.getType())) {// 黑名单已过期的
|
||||
ipMenu.setDelete_status(-1);
|
||||
ipMenuService.update(ipMenu);
|
||||
}
|
||||
if (ipRequestTimeWindow.getIpSend(ip) != null) {
|
||||
Integer count = ipCache.get(ip);
|
||||
// System.out.println("ip:" + ip + ",count:" + count);
|
||||
count++;
|
||||
if (count >= request_check_ip_count) {// 从ip发送第一条开始
|
||||
// System.out.println("ip:" + ip + ",count:" + count);
|
||||
// blacklistIpSerivceTimeWindow.putBlackIp(ip, ip);
|
||||
ipCache.remove(ip);
|
||||
ipRequestTimeWindow.delIpSend(ip);
|
||||
|
||||
if (null == ipMenu) {
|
||||
ipMenu = new IpMenu();
|
||||
ipMenu.setCreate_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
ipMenu.setIp(ip);
|
||||
ipMenuService.save(ipMenu);
|
||||
} else {
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
ipMenuService.update(ipMenu);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
ipCache.put(ip, count++);
|
||||
}
|
||||
|
||||
} else {
|
||||
ipCache.put(ip, 1);
|
||||
ipRequestTimeWindow.putIpSend(ip, ip);
|
||||
}
|
||||
if (checkSpecialUrl(ip, url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检验特殊url处理 返回true:ip已被封, false:ip正常
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
public boolean checkSpecialUrl(String ip, String url) {
|
||||
// Integer request_check_ip_special_count = sysparaService.find("request_check_ip_special_count").getInteger();
|
||||
if (!urlSpecialService.cacheAllUrls().contains(url)) {
|
||||
return false;
|
||||
}
|
||||
if (ipSpecialRequestTimeWindow.getIpSend(ip) != null) {
|
||||
Integer count = ipSpecialCache.get(ip);
|
||||
// System.out.println("ip:" + ip + ",count:" + count);
|
||||
count++;
|
||||
if (count >= request_check_ip_special_count) {// 从ip发送第一条开始
|
||||
|
||||
// blacklistIpSerivceTimeWindow.putBlackIp(ip, ip);
|
||||
ipSpecialCache.remove(ip);
|
||||
ipSpecialRequestTimeWindow.delIpSend(ip);
|
||||
|
||||
IpMenu ipMenu = ipMenuService.cacheByIp(ip);
|
||||
if (null == ipMenu) {
|
||||
ipMenu = new IpMenu();
|
||||
ipMenu.setCreate_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
ipMenu.setIp(ip);
|
||||
ipMenuService.save(ipMenu);
|
||||
} else {
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
ipMenuService.update(ipMenu);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
ipSpecialCache.put(ip, count++);
|
||||
}
|
||||
|
||||
} else {
|
||||
ipSpecialCache.put(ip, 1);
|
||||
ipSpecialRequestTimeWindow.putIpSend(ip, ip);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检验锁定相关url处理 返回true:ip已被封, false:ip正常
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
public boolean checkLockUrl(String ip, String url) {
|
||||
if (!urls.contains(url)) {
|
||||
return false;
|
||||
}
|
||||
if (ipLockRequestTimeWindow.getIpSend(ip) != null) {
|
||||
Integer count = this.ipLockCache.get(ip);
|
||||
// System.out.println("ip:" + ip + ",count:" + count);
|
||||
count++;
|
||||
if (count >= request_check_ip_count) {// 从ip发送第一条开始
|
||||
|
||||
// blacklistIpSerivceTimeWindow.putBlackIp(ip, ip);
|
||||
ipLockCache.remove(ip);
|
||||
ipLockRequestTimeWindow.delIpSend(ip);
|
||||
|
||||
IpMenu ipMenu = ipMenuService.cacheByIp(ip);
|
||||
if (null == ipMenu) {
|
||||
ipMenu = new IpMenu();
|
||||
ipMenu.setCreate_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setType(IpMenu.IP_LOCK);
|
||||
ipMenu.setIp(ip);
|
||||
ipMenuService.save(ipMenu);
|
||||
} else {
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setType(IpMenu.IP_LOCK);
|
||||
ipMenuService.update(ipMenu);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
ipLockCache.put(ip, count++);
|
||||
}
|
||||
|
||||
} else {
|
||||
ipLockCache.put(ip, 1);
|
||||
ipLockRequestTimeWindow.putIpSend(ip, ip);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<String, AtomicLong> getIpCountCache() {
|
||||
return ipCountCache;
|
||||
}
|
||||
|
||||
public Map<String, Date> getIpTimeCacheCache() {
|
||||
return ipTimeCacheCache;
|
||||
}
|
||||
|
||||
public void clearIpCountCache() {
|
||||
ipCountCache.clear();
|
||||
}
|
||||
|
||||
public void clearIpTimeCacheCache() {
|
||||
ipTimeCacheCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取ip计数相关信息,(防止因跨服务请求导致网络带宽不足而响应慢)
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param ip_para
|
||||
* @param type_para
|
||||
* @param limit_count
|
||||
* @param isExcludeBlack true:排除黑名单
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> cachePagedQueryIpCount(int pageNo, int pageSize, String ip_para, String type_para,
|
||||
Long limit_count, boolean isExcludeMenu) {
|
||||
Map<String, AtomicLong> ipCountCache = this.getIpCountCache();
|
||||
Map<String, Date> ipTimeCacheCache = this.getIpTimeCacheCache();
|
||||
List<Map<String, Object>> pageList = new ArrayList<Map<String, Object>>();
|
||||
for (Entry<String, AtomicLong> entry : ipCountCache.entrySet()) {
|
||||
if (StringUtils.isNotEmpty(ip_para) && entry.getKey().indexOf(ip_para) == -1) {// ip赛选条件
|
||||
continue;
|
||||
}
|
||||
IpMenu ipMenu = ipMenuService.cacheByIp(entry.getKey());
|
||||
if (StringUtils.isNotEmpty(type_para) && ipMenu != null && !type_para.equals(ipMenu.getType())
|
||||
&& ipMenu.getDelete_status() == 0) {// 类型赛选条件
|
||||
continue;
|
||||
}
|
||||
if (isExcludeMenu && ipMenu != null && ipMenu.getDelete_status() == 0) {// 是否排除黑名单
|
||||
continue;
|
||||
}
|
||||
if (limit_count != null && limit_count > entry.getValue().get()) {
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("ip", entry.getKey());
|
||||
data.put("count", entry.getValue().get());
|
||||
data.put("create_time", ipTimeCacheCache.get(entry.getKey()));
|
||||
data.put("type", ipMenu == null || ipMenu.getDelete_status() == -1 ? null : ipMenu.getType());
|
||||
pageList.add(data);
|
||||
}
|
||||
if (pageList.isEmpty()) {
|
||||
return new LinkedList<Map<String, Object>>();
|
||||
}
|
||||
java.util.Collections.sort(pageList, new Comparator<Map<String, Object>>() {
|
||||
@Override
|
||||
public int compare(Map<String, Object> paramT1, Map<String, Object> paramT2) {
|
||||
// TODO Auto-generated method stub
|
||||
Long t1 = Long.valueOf(paramT1.get("count").toString());
|
||||
Long t2 = Long.valueOf(paramT2.get("count").toString());
|
||||
return -t1.compareTo(t2);
|
||||
}
|
||||
});
|
||||
|
||||
int start = (pageNo - 1) * pageSize;
|
||||
start = start <= 0 ? 0 : start;//
|
||||
int end = start + pageSize;
|
||||
|
||||
if (start >= pageList.size()) {// 起始数据大于总量,返回空
|
||||
return new LinkedList<Map<String, Object>>();
|
||||
}
|
||||
if (pageList.size() <= end)
|
||||
end = pageList.size();
|
||||
|
||||
List<Map<String, Object>> list = pageList.subList(start, end);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ips批量获取对应的请求数据,减少交互
|
||||
*
|
||||
* @param ips
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Long> ipCountByIps(List<String> ips) {
|
||||
Map<String, Long> map = new HashMap<String, Long>();
|
||||
for (String ip : ips) {
|
||||
map.put(ip, !this.ipCountCache.containsKey(ip) ? 0L : ipCountCache.get(ip).get());
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ip请求汇总数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> ipCountSumDates() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Long sumRequest = 0l;
|
||||
Long sumIp = 0l;
|
||||
for (Entry<String, AtomicLong> entry : ipCountCache.entrySet()) {
|
||||
IpMenu ipMenu = ipMenuService.cacheByIp(entry.getKey());
|
||||
if (ipMenu != null && ipMenu.getDelete_status() == 0) {// 排除名单
|
||||
continue;
|
||||
}
|
||||
sumIp++;
|
||||
sumRequest += entry.getValue().get();
|
||||
}
|
||||
map.put("ip_request_sum", sumRequest);
|
||||
map.put("ip_sum", sumIp);
|
||||
return map;
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
request_check_ip = sysparaService.findByDB("request_check_ip").getValue();
|
||||
request_check_ip_count = sysparaService.findByDB("request_check_ip_count").getInteger();
|
||||
request_check_ip_special_count = sysparaService.findByDB("request_check_ip_special_count").getInteger();
|
||||
request_only_white_menu = sysparaService.findByDB("request_only_white_menu").getBoolean();
|
||||
initLoginPageRelationAction();
|
||||
}
|
||||
|
||||
public void initLoginPageRelationAction() {
|
||||
// /pages/login/index登录页:1、api/syspara.action 2、api/user!login.action
|
||||
urls.add("/api/syspara.action");
|
||||
urls.add("/api/user!login.action");
|
||||
// /pages/login/forget找回密码:1、api/syspara.action 2、api/user!resetpswByGoogle 3、api/user!resetpsw.action 4、api/idcode!execute.action 5、api/user!getUserNameVerifTarget
|
||||
// urls.add("/api/syspara.action");
|
||||
urls.add("/api/user!resetpswByGoogle.action");
|
||||
urls.add("/api/user!resetpsw.action");
|
||||
urls.add("/api/idcode!execute.action");
|
||||
urls.add("/api/api/user!getUserNameVerifTarget.action");
|
||||
// /pages/login/register-new注册页面:1、api/localuser!getImageCode 2、api/idcode!execute 3、api/localuser!register_username 4、api/localuser!register
|
||||
urls.add("/api/localuser!getImageCode.action");
|
||||
urls.add("/api/idcode!execute.action");
|
||||
urls.add("/api/localuser!register_username.action");
|
||||
urls.add("/api/localuser!register.action");
|
||||
// /pages/user/server客服 1、api/onlinechat!list.action 2、api/onlinechat!send 3、api/onlinechat!unread
|
||||
urls.add("/api/onlinechat!list.action");
|
||||
urls.add("/api/onlinechat!send.action");
|
||||
urls.add("/api/onlinechat!unread.action");
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录页相关所需的urls
|
||||
*/
|
||||
public List<String> loginPageRelationAction() {
|
||||
return urls;
|
||||
}
|
||||
|
||||
public Map<String, AtomicLong> cacheUrlCount(String ip) {
|
||||
return ipUrlCountCache.get(ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* ip请求数相关缓存清除
|
||||
*
|
||||
* @param ip
|
||||
*/
|
||||
public void cacheRemoveIp(String ip) {
|
||||
this.ipCountCache.remove(ip);
|
||||
this.ipTimeCacheCache.remove(ip);
|
||||
this.ipUrlCountCache.remove(ip);
|
||||
|
||||
/**
|
||||
* 对应的时间窗ip清除
|
||||
*/
|
||||
ipRequestTimeWindow.delIpSend(ip);
|
||||
ipSpecialRequestTimeWindow.delIpSend(ip);
|
||||
ipLockRequestTimeWindow.delIpSend(ip);
|
||||
|
||||
ipLockCache.remove(ip);
|
||||
ipCache.remove(ip);
|
||||
ipSpecialCache.remove(ip);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ip请求清除不在名单里的数据
|
||||
*/
|
||||
public void cacheRequestClearNoMenu() {
|
||||
for (String key : ipCountCache.keySet()) {
|
||||
IpMenu ipMenu = ipMenuService.cacheByIp(key);
|
||||
if (ipMenu != null && ipMenu.getDelete_status() == 0) {// 排除名单
|
||||
continue;
|
||||
}
|
||||
// this.ipCountCache.remove(key);
|
||||
// this.ipTimeCacheCache.remove(key);
|
||||
// this.ipUrlCountCache.remove(key);
|
||||
cacheRemoveIp(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkBlackIp(String ip) {
|
||||
// log.info("检查IP黑名单:{}", ip);
|
||||
if (!"true".equals(request_check_ip)) {
|
||||
return false;// 不为1时 未开启,直接返回false不做处理}
|
||||
}
|
||||
// ipCount(ip, url);
|
||||
IpMenu ipMenu = ipMenuService.cacheByIp(ip);
|
||||
// 黑名单已过期的
|
||||
return ipMenu != null && ipMenu.getDelete_status() != -1 && IpMenu.IP_BLACK.equals(ipMenu.getType());// ip被封,不发送
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ip是否锁定
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
public boolean isLock(String ip) {
|
||||
return locklistIpSerivceTimeWindow.getLockIp(ip) != null;
|
||||
}
|
||||
|
||||
public void setIpRequestTimeWindow(IpRequestTimeWindow ipRequestTimeWindow) {
|
||||
this.ipRequestTimeWindow = ipRequestTimeWindow;
|
||||
}
|
||||
|
||||
public void setBlacklistIpSerivceTimeWindow(BlacklistIpSerivceTimeWindow blacklistIpSerivceTimeWindow) {
|
||||
this.blacklistIpSerivceTimeWindow = blacklistIpSerivceTimeWindow;
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setIpMenuService(IpMenuService ipMenuService) {
|
||||
this.ipMenuService = ipMenuService;
|
||||
}
|
||||
|
||||
public void setIpSpecialRequestTimeWindow(IpSpecialRequestTimeWindow ipSpecialRequestTimeWindow) {
|
||||
this.ipSpecialRequestTimeWindow = ipSpecialRequestTimeWindow;
|
||||
}
|
||||
|
||||
public void setUrlSpecialService(UrlSpecialService urlSpecialService) {
|
||||
this.urlSpecialService = urlSpecialService;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setSystemParaReadRequestTimeWindow(SystemParaReadRequestTimeWindow systemParaReadRequestTimeWindow) {
|
||||
this.systemParaReadRequestTimeWindow = systemParaReadRequestTimeWindow;
|
||||
}
|
||||
|
||||
public void setIpLockRequestTimeWindow(IpLockRequestTimeWindow ipLockRequestTimeWindow) {
|
||||
this.ipLockRequestTimeWindow = ipLockRequestTimeWindow;
|
||||
}
|
||||
|
||||
public void setLocklistIpSerivceTimeWindow(LocklistIpSerivceTimeWindow locklistIpSerivceTimeWindow) {
|
||||
this.locklistIpSerivceTimeWindow = locklistIpSerivceTimeWindow;
|
||||
}
|
||||
|
||||
}
|
||||
163
comm/DDOS/src/project/ddos/internal/IpMenuServiceImpl.java
Executable file
163
comm/DDOS/src/project/ddos/internal/IpMenuServiceImpl.java
Executable file
@@ -0,0 +1,163 @@
|
||||
package project.ddos.internal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.DateUtils;
|
||||
import project.ddos.DdosRedisKeys;
|
||||
import project.ddos.IpMenuService;
|
||||
import project.ddos.model.IpMenu;
|
||||
import project.ddos.utils.BlacklistIpSerivceTimeWindow;
|
||||
import project.ddos.utils.LocklistIpSerivceTimeWindow;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class IpMenuServiceImpl extends HibernateDaoSupport implements IpMenuService {
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
private BlacklistIpSerivceTimeWindow blacklistIpSerivceTimeWindow;
|
||||
private LocklistIpSerivceTimeWindow locklistIpSerivceTimeWindow;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
// public void init() {
|
||||
// StringBuffer queryString = new StringBuffer(" FROM IpMenu WHERE 1=1 AND delete_status=0 ");
|
||||
// List<IpMenu> list = (List<IpMenu>) this.getHibernateTemplate().find(queryString.toString());
|
||||
//
|
||||
// for (IpMenu ipMenu : list) {
|
||||
// // 黑名单 时间+1天>现在
|
||||
// if (DateUtils.addHour(ipMenu.getLast_opera_time(), 24).after(new Date())) {
|
||||
// switch (ipMenu.getType()) {
|
||||
// case IpMenu.IP_BLACK:
|
||||
// blacklistIpSerivceTimeWindow.putBlackIp(ipMenu.getIp(), ipMenu.getIp());
|
||||
// break;
|
||||
// case IpMenu.IP_LOCK:
|
||||
// locklistIpSerivceTimeWindow.putLockIp(ipMenu.getIp(), ipMenu.getIp());
|
||||
// break;
|
||||
// }
|
||||
// } else {
|
||||
// ipMenu.setDelete_status(-1);
|
||||
// checkTimeWindows(ipMenu);
|
||||
// jdbcTemplate.update("UPDATE T_IP_MENU SET DELETE_STATUS=-1 WHERE UUID='"+ipMenu.getId().toString()+"'");
|
||||
// redisHandler.setSync(DdosRedisKeys.IP_MENU_IP + ipMenu.getIp(), ipMenu);
|
||||
//// update(ipMenu);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void save(IpMenu entity) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(DdosRedisKeys.IP_MENU_IP + entity.getIp(), entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIp(String old, IpMenu entity) {
|
||||
getHibernateTemplate().update(entity);
|
||||
redisHandler.remove(DdosRedisKeys.IP_MENU_IP + old);
|
||||
redisHandler.setSync(DdosRedisKeys.IP_MENU_IP + entity.getIp(), entity);
|
||||
if (IpMenu.IP_BLACK.equals(entity.getType())) {
|
||||
redisHandler.sadd(DdosRedisKeys.IP_MENU_IP_BLACK, entity.getIp());
|
||||
redisHandler.srem(DdosRedisKeys.IP_MENU_IP_BLACK, old);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(IpMenu entity) {
|
||||
checkTimeWindows(entity);
|
||||
getHibernateTemplate().update(entity);
|
||||
redisHandler.setSync(DdosRedisKeys.IP_MENU_IP + entity.getIp(), entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(IpMenu entity) {
|
||||
getHibernateTemplate().delete(entity);
|
||||
redisHandler.remove(entity.getIp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IpMenu cacheByIp(String ip) {
|
||||
return (IpMenu) redisHandler.get(DdosRedisKeys.IP_MENU_IP + ip);
|
||||
// return (IpMenu) getHibernateTemplate().get(IpMenu.class, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增ip到白名单
|
||||
*
|
||||
* @param ip
|
||||
*/
|
||||
public void saveIpMenuWhite(String ip) {
|
||||
IpMenu ipMenu = this.cacheByIp(ip);
|
||||
if (null == ipMenu) {
|
||||
ipMenu = new IpMenu();
|
||||
ipMenu.setCreate_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setType(IpMenu.IP_WHITE);
|
||||
ipMenu.setIp(ip);
|
||||
this.save(ipMenu);
|
||||
} else if (ipMenu.getDelete_status() == -1 || !IpMenu.IP_WHITE.equals(ipMenu.getType())) {// 名单被删除或者不是白名单
|
||||
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setType(IpMenu.IP_WHITE);
|
||||
this.update(ipMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkTimeWindows(IpMenu entity) {
|
||||
if (entity.getDelete_status() == -1) {
|
||||
blacklistIpSerivceTimeWindow.delBlackIp(entity.getIp());
|
||||
locklistIpSerivceTimeWindow.delLockIp(entity.getIp());
|
||||
return;
|
||||
}
|
||||
|
||||
switch (entity.getType()) {
|
||||
case IpMenu.IP_WHITE:
|
||||
if (blacklistIpSerivceTimeWindow.getBlackIp(entity.getIp()) != null) {// 白名单直接删除黑名单缓存
|
||||
blacklistIpSerivceTimeWindow.delBlackIp(entity.getIp());
|
||||
}
|
||||
if (locklistIpSerivceTimeWindow.getLockIp(entity.getIp()) != null) {// 白名单直接删除锁定名单缓存
|
||||
locklistIpSerivceTimeWindow.delLockIp(entity.getIp());
|
||||
}
|
||||
break;
|
||||
case IpMenu.IP_BLACK:
|
||||
if (locklistIpSerivceTimeWindow.getLockIp(entity.getIp()) != null) {// 删除锁定名单缓存
|
||||
locklistIpSerivceTimeWindow.delLockIp(entity.getIp());
|
||||
}
|
||||
blacklistIpSerivceTimeWindow.putBlackIp(entity.getIp(), entity.getIp());
|
||||
break;
|
||||
case IpMenu.IP_LOCK:
|
||||
if (blacklistIpSerivceTimeWindow.getBlackIp(entity.getIp()) != null) {// 删除黑名单缓存
|
||||
blacklistIpSerivceTimeWindow.delBlackIp(entity.getIp());
|
||||
}
|
||||
locklistIpSerivceTimeWindow.putLockIp(entity.getIp(), entity.getIp());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateTimeWindows(String oldIp,String newIp) {
|
||||
if (locklistIpSerivceTimeWindow.getLockIp(oldIp) != null) {// 删除锁定名单缓存
|
||||
locklistIpSerivceTimeWindow.delLockIp(oldIp);
|
||||
}
|
||||
blacklistIpSerivceTimeWindow.putBlackIp(newIp, newIp);
|
||||
}
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setBlacklistIpSerivceTimeWindow(BlacklistIpSerivceTimeWindow blacklistIpSerivceTimeWindow) {
|
||||
this.blacklistIpSerivceTimeWindow = blacklistIpSerivceTimeWindow;
|
||||
}
|
||||
|
||||
public void setLocklistIpSerivceTimeWindow(LocklistIpSerivceTimeWindow locklistIpSerivceTimeWindow) {
|
||||
this.locklistIpSerivceTimeWindow = locklistIpSerivceTimeWindow;
|
||||
}
|
||||
|
||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
}
|
||||
74
comm/DDOS/src/project/ddos/internal/UrlSpecialServiceImpl.java
Executable file
74
comm/DDOS/src/project/ddos/internal/UrlSpecialServiceImpl.java
Executable file
@@ -0,0 +1,74 @@
|
||||
package project.ddos.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import project.ddos.DdosRedisKeys;
|
||||
import project.ddos.UrlSpecialService;
|
||||
import project.ddos.model.UrlSpecial;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class UrlSpecialServiceImpl extends HibernateDaoSupport implements UrlSpecialService {
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Override
|
||||
public void save(UrlSpecial entity) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(DdosRedisKeys.URL_SPECIAL_ID + entity.getId().toString(), entity);
|
||||
Map<String, String> cacheMap = (Map<String, String>) redisHandler.get(DdosRedisKeys.URL_SPECIAL_URL_MAP);
|
||||
if (cacheMap == null) {
|
||||
cacheMap = new ConcurrentHashMap<String, String>();
|
||||
}
|
||||
cacheMap.put(entity.getId().toString(), entity.getUrl());
|
||||
redisHandler.setSync(DdosRedisKeys.URL_SPECIAL_URL_MAP, cacheMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(UrlSpecial entity) {
|
||||
getHibernateTemplate().update(entity);
|
||||
redisHandler.setSync(DdosRedisKeys.URL_SPECIAL_ID + entity.getId().toString(), entity);
|
||||
|
||||
Map<String, String> cacheMap = (Map<String, String>) redisHandler.get(DdosRedisKeys.URL_SPECIAL_URL_MAP);
|
||||
if (cacheMap == null) {
|
||||
cacheMap = new ConcurrentHashMap<String, String>();
|
||||
}
|
||||
cacheMap.put(entity.getId().toString(), entity.getUrl());
|
||||
redisHandler.setSync(DdosRedisKeys.URL_SPECIAL_URL_MAP, cacheMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(UrlSpecial entity) {
|
||||
getHibernateTemplate().delete(entity);
|
||||
redisHandler.remove(DdosRedisKeys.URL_SPECIAL_ID + entity.getId().toString());
|
||||
|
||||
Map<String, String> cacheMap = (Map<String, String>) redisHandler.get(DdosRedisKeys.URL_SPECIAL_URL_MAP);
|
||||
if (cacheMap != null && !cacheMap.isEmpty()) {
|
||||
cacheMap.remove(entity.getId().toString());
|
||||
}
|
||||
redisHandler.setSync(DdosRedisKeys.URL_SPECIAL_URL_MAP, cacheMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UrlSpecial cacheById(String id) {
|
||||
return (UrlSpecial) redisHandler.get(DdosRedisKeys.URL_SPECIAL_ID + id);
|
||||
// return (IpMenu) getHibernateTemplate().get(IpMenu.class, id);
|
||||
}
|
||||
|
||||
public List<String> cacheAllUrls() {
|
||||
Map<String, String> cacheMap = (Map<String, String>) redisHandler.get(DdosRedisKeys.URL_SPECIAL_URL_MAP);
|
||||
if (cacheMap == null || cacheMap.isEmpty()) {
|
||||
return new ArrayList<String>();
|
||||
} else {
|
||||
return new ArrayList<String>(cacheMap.values());
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
37
comm/DDOS/src/project/ddos/model/IpMenu.hbm.xml
Executable file
37
comm/DDOS/src/project/ddos/model/IpMenu.hbm.xml
Executable file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.ddos.model.IpMenu" table="T_IP_MENU">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="ip" type="java.lang.String">
|
||||
<column name="IP" />
|
||||
</property>
|
||||
|
||||
<property name="type" type="java.lang.String">
|
||||
<column name="TYPE" />
|
||||
</property>
|
||||
<property name="delete_status" type="int">
|
||||
<column name="DELETE_STATUS" />
|
||||
</property>
|
||||
|
||||
<property name="last_opera_time" type="timestamp">
|
||||
<column name="LAST_OPERA_TIME" />
|
||||
</property>
|
||||
<property name="create_time" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
|
||||
<property name="createName" type="java.lang.String">
|
||||
<column name="CREATE_NAME" />
|
||||
</property>
|
||||
|
||||
<property name="remark" type="java.lang.String">
|
||||
<column name="REMARK" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
111
comm/DDOS/src/project/ddos/model/IpMenu.java
Executable file
111
comm/DDOS/src/project/ddos/model/IpMenu.java
Executable file
@@ -0,0 +1,111 @@
|
||||
package project.ddos.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class IpMenu extends EntityObject {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4196439149608747292L;
|
||||
/**
|
||||
* 白名单
|
||||
*/
|
||||
public static final String IP_WHITE = "white";
|
||||
/**
|
||||
* 黑名单
|
||||
*/
|
||||
public static final String IP_BLACK = "black";
|
||||
/**
|
||||
* 锁定名单
|
||||
*/
|
||||
public static final String IP_LOCK = "lock";
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
private String ip;
|
||||
/**
|
||||
* 类型 :black:黑名单,white:白名单
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* -1:标记删除,0:正常
|
||||
*/
|
||||
private int delete_status;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date create_time;
|
||||
/**
|
||||
* 最后处理时间
|
||||
*/
|
||||
private Date last_opera_time;
|
||||
|
||||
/**
|
||||
*创建人
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getDelete_status() {
|
||||
return delete_status;
|
||||
}
|
||||
|
||||
public Date getCreate_time() {
|
||||
return create_time;
|
||||
}
|
||||
|
||||
public Date getLast_opera_time() {
|
||||
return last_opera_time;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setDelete_status(int delete_status) {
|
||||
this.delete_status = delete_status;
|
||||
}
|
||||
|
||||
public void setCreate_time(Date create_time) {
|
||||
this.create_time = create_time;
|
||||
}
|
||||
|
||||
public void setLast_opera_time(Date last_opera_time) {
|
||||
this.last_opera_time = last_opera_time;
|
||||
}
|
||||
|
||||
|
||||
public String getCreateName() {
|
||||
return createName;
|
||||
}
|
||||
|
||||
public void setCreateName(String createName) {
|
||||
this.createName = createName;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
22
comm/DDOS/src/project/ddos/model/UrlSpecial.hbm.xml
Executable file
22
comm/DDOS/src/project/ddos/model/UrlSpecial.hbm.xml
Executable file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.ddos.model.UrlSpecial" table="T_URL_SPECIAL">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="url" type="java.lang.String">
|
||||
<column name="URL" />
|
||||
</property>
|
||||
<property name="remarks" type="java.lang.String">
|
||||
<column name="REMARKS" />
|
||||
</property>
|
||||
|
||||
<property name="create_time" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
49
comm/DDOS/src/project/ddos/model/UrlSpecial.java
Executable file
49
comm/DDOS/src/project/ddos/model/UrlSpecial.java
Executable file
@@ -0,0 +1,49 @@
|
||||
package project.ddos.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class UrlSpecial extends EntityObject {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4196439149608747292L;
|
||||
/**
|
||||
* url
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date create_time;
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setCreate_time(Date create_time) {
|
||||
this.create_time = create_time;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public Date getCreate_time() {
|
||||
return create_time;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
}
|
||||
40
comm/DDOS/src/project/ddos/utils/BlacklistIpSerivceTimeWindow.java
Executable file
40
comm/DDOS/src/project/ddos/utils/BlacklistIpSerivceTimeWindow.java
Executable file
@@ -0,0 +1,40 @@
|
||||
package project.ddos.utils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class BlacklistIpSerivceTimeWindow implements InitializingBean {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 24小时
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 60 * 24);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String getBlackIp(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void putBlackIp(String key, String ip) {
|
||||
this.timeWindow.add(key, ip);
|
||||
}
|
||||
|
||||
public void putBlackIp(String key, String ip, Date date) {
|
||||
this.timeWindow.add(key, ip, date);
|
||||
}
|
||||
|
||||
public void delBlackIp(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
33
comm/DDOS/src/project/ddos/utils/IpLockRequestTimeWindow.java
Executable file
33
comm/DDOS/src/project/ddos/utils/IpLockRequestTimeWindow.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.ddos.utils;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class IpLockRequestTimeWindow implements InitializingBean {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 10分钟
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 10);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String getIpSend(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void putIpSend(String key, String ip) {
|
||||
this.timeWindow.add(key, ip);
|
||||
}
|
||||
|
||||
public void delIpSend(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
}
|
||||
33
comm/DDOS/src/project/ddos/utils/IpRequestTimeWindow.java
Executable file
33
comm/DDOS/src/project/ddos/utils/IpRequestTimeWindow.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.ddos.utils;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class IpRequestTimeWindow implements InitializingBean {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 10分钟
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 10);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String getIpSend(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void putIpSend(String key, String ip) {
|
||||
this.timeWindow.add(key, ip);
|
||||
}
|
||||
|
||||
public void delIpSend(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
}
|
||||
33
comm/DDOS/src/project/ddos/utils/IpSpecialRequestTimeWindow.java
Executable file
33
comm/DDOS/src/project/ddos/utils/IpSpecialRequestTimeWindow.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.ddos.utils;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class IpSpecialRequestTimeWindow implements InitializingBean {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 1分钟
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 1);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String getIpSend(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void putIpSend(String key, String ip) {
|
||||
this.timeWindow.add(key, ip);
|
||||
}
|
||||
|
||||
public void delIpSend(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
}
|
||||
40
comm/DDOS/src/project/ddos/utils/LocklistIpSerivceTimeWindow.java
Executable file
40
comm/DDOS/src/project/ddos/utils/LocklistIpSerivceTimeWindow.java
Executable file
@@ -0,0 +1,40 @@
|
||||
package project.ddos.utils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class LocklistIpSerivceTimeWindow implements InitializingBean {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 24小时
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 60 * 24);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String getLockIp(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void putLockIp(String key, String ip) {
|
||||
this.timeWindow.add(key, ip);
|
||||
}
|
||||
|
||||
public void putLockIp(String key, String ip, Date date) {
|
||||
this.timeWindow.add(key, ip, date);
|
||||
}
|
||||
|
||||
public void delLockIp(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
33
comm/DDOS/src/project/ddos/utils/SystemParaReadRequestTimeWindow.java
Executable file
33
comm/DDOS/src/project/ddos/utils/SystemParaReadRequestTimeWindow.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.ddos.utils;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class SystemParaReadRequestTimeWindow implements InitializingBean {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 1分钟
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 1);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void put(String key, String value) {
|
||||
this.timeWindow.add(key, value);
|
||||
}
|
||||
|
||||
public void del(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
}
|
||||
280
comm/DDOS/src/project/ddos/web/AdminIpCountAction.java
Executable file
280
comm/DDOS/src/project/ddos/web/AdminIpCountAction.java
Executable file
@@ -0,0 +1,280 @@
|
||||
package project.ddos.web;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.JsonUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.ddos.AdminIpCountService;
|
||||
import project.ddos.AdminIpMenuService;
|
||||
import project.ddos.IpMenuService;
|
||||
import project.ddos.model.IpMenu;
|
||||
|
||||
public class AdminIpCountAction extends PageActionSupport {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3567372733940832371L;
|
||||
private static final Log logger = LogFactory.getLog(AdminIpCountAction.class);
|
||||
private AdminIpCountService adminIpCountService;
|
||||
private AdminIpMenuService adminIpMenuService;
|
||||
private IpMenuService ipMenuService;
|
||||
private String ip_para;
|
||||
private String type_para;
|
||||
|
||||
private String menu_ip;
|
||||
private String menu_type;
|
||||
/**
|
||||
* 登录人资金密码
|
||||
*/
|
||||
private String login_safeword;
|
||||
/**
|
||||
* 条件限制数量
|
||||
*/
|
||||
private Long limit_count;
|
||||
|
||||
private Map<String, Object> sumdata = new HashMap<String, Object>();
|
||||
private String result_make;
|
||||
|
||||
public String list() {
|
||||
this.pageSize = 50;
|
||||
this.page = this.adminIpCountService.cachePagedQuery(this.pageNo, this.pageSize, this.ip_para, type_para, null);
|
||||
sumdata = this.adminIpCountService.sumDates();
|
||||
return "list";
|
||||
}
|
||||
|
||||
public String toAdd() {
|
||||
return "add";
|
||||
}
|
||||
|
||||
private void check() {
|
||||
String loginUserName = this.getUsername_login();
|
||||
if (!("root".equals(loginUserName))) {
|
||||
throw new BusinessException("权限不足,无法操作");
|
||||
}
|
||||
}
|
||||
|
||||
private String verif_add() {
|
||||
|
||||
if (StringUtils.isEmptyString(this.menu_ip)) {
|
||||
return "IP参数异常";
|
||||
}
|
||||
|
||||
// if (StringUtils.isEmptyString(this.menu_type)) {
|
||||
// return "请选择[名单]";
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String addBlack() {
|
||||
try {
|
||||
check();
|
||||
this.error = verif_add();
|
||||
if (!StringUtils.isNullOrEmpty(this.error)) {
|
||||
return list();
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
this.error = "请输入登录人资金密码";
|
||||
return list();
|
||||
}
|
||||
|
||||
IpMenu ipMenu = new IpMenu();
|
||||
ipMenu.setIp(menu_ip);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
|
||||
IpMenu cacheMenu = ipMenuService.cacheByIp(menu_ip);
|
||||
if (cacheMenu != null && cacheMenu.getDelete_status() == 0) {
|
||||
this.adminIpMenuService.update(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
} else {
|
||||
this.adminIpMenuService.save(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
}
|
||||
this.message = "操作成功";
|
||||
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
return list();
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
this.error = ("[ERROR] " + t.getMessage());
|
||||
return list();
|
||||
}
|
||||
return list();
|
||||
}
|
||||
|
||||
public String addLock() {
|
||||
try {
|
||||
check();
|
||||
this.error = verif_add();
|
||||
if (!StringUtils.isNullOrEmpty(this.error)) {
|
||||
return list();
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
this.error = "请输入登录人资金密码";
|
||||
return list();
|
||||
}
|
||||
|
||||
IpMenu ipMenu = new IpMenu();
|
||||
ipMenu.setIp(menu_ip);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setType(IpMenu.IP_LOCK);
|
||||
|
||||
IpMenu cacheMenu = ipMenuService.cacheByIp(menu_ip);
|
||||
if (cacheMenu != null && cacheMenu.getDelete_status() == 0) {
|
||||
this.adminIpMenuService.update(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
} else {
|
||||
this.adminIpMenuService.save(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
}
|
||||
this.message = "操作成功";
|
||||
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
return list();
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
this.error = ("[ERROR] " + t.getMessage());
|
||||
return list();
|
||||
}
|
||||
return list();
|
||||
}
|
||||
|
||||
public String batchAddBlack() {
|
||||
try {
|
||||
check();
|
||||
// this.error = verif_add();
|
||||
// if (!StringUtils.isNullOrEmpty(this.error)) {
|
||||
// return list();
|
||||
// }
|
||||
if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
this.error = "请输入登录人资金密码";
|
||||
return list();
|
||||
}
|
||||
if (limit_count == null || limit_count == 0) {
|
||||
this.error = "警戒线错误";
|
||||
return list();
|
||||
}
|
||||
/**
|
||||
* 补充设值
|
||||
*/
|
||||
this.adminIpCountService.batchAddBlack(limit_count, this.getUsername_login(), login_safeword, this.getIp());
|
||||
this.message = "操作成功";
|
||||
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
this.error = ("[ERROR] " + t.getMessage());
|
||||
}
|
||||
return list();
|
||||
}
|
||||
|
||||
public String clearData() {
|
||||
try {
|
||||
check();
|
||||
if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
this.error = "请输入登录人资金密码";
|
||||
return list();
|
||||
}
|
||||
/**
|
||||
* 补充设值
|
||||
*/
|
||||
this.adminIpCountService.clearData(this.getUsername_login(), login_safeword, this.getIp());
|
||||
this.message = "操作成功";
|
||||
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
this.error = ("[ERROR] " + t.getMessage());
|
||||
}
|
||||
return list();
|
||||
}
|
||||
|
||||
public String getUrlsCount() {
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
try {
|
||||
resultMap.put("code", 200);
|
||||
resultMap.put("urls_count", adminIpCountService.getUrlsCount(menu_ip));
|
||||
} catch (BusinessException e) {
|
||||
resultMap.put("code", 500);
|
||||
resultMap.put("message", e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
resultMap.put("code", 500);
|
||||
resultMap.put("message", "程序错误");
|
||||
}
|
||||
this.result_make = JsonUtils.getJsonString(resultMap);
|
||||
return "result_make";
|
||||
}
|
||||
|
||||
public String getIp_para() {
|
||||
return ip_para;
|
||||
}
|
||||
|
||||
public String getType_para() {
|
||||
return type_para;
|
||||
}
|
||||
|
||||
public void setIp_para(String ip_para) {
|
||||
this.ip_para = ip_para;
|
||||
}
|
||||
|
||||
public void setType_para(String type_para) {
|
||||
this.type_para = type_para;
|
||||
}
|
||||
|
||||
public void setLogin_safeword(String login_safeword) {
|
||||
this.login_safeword = login_safeword;
|
||||
}
|
||||
|
||||
public String getMenu_ip() {
|
||||
return menu_ip;
|
||||
}
|
||||
|
||||
public String getMenu_type() {
|
||||
return menu_type;
|
||||
}
|
||||
|
||||
public void setMenu_ip(String menu_ip) {
|
||||
this.menu_ip = menu_ip;
|
||||
}
|
||||
|
||||
public void setMenu_type(String menu_type) {
|
||||
this.menu_type = menu_type;
|
||||
}
|
||||
|
||||
public void setAdminIpCountService(AdminIpCountService adminIpCountService) {
|
||||
this.adminIpCountService = adminIpCountService;
|
||||
}
|
||||
|
||||
public void setAdminIpMenuService(AdminIpMenuService adminIpMenuService) {
|
||||
this.adminIpMenuService = adminIpMenuService;
|
||||
}
|
||||
|
||||
public void setLimit_count(Long limit_count) {
|
||||
this.limit_count = limit_count;
|
||||
}
|
||||
|
||||
public void setIpMenuService(IpMenuService ipMenuService) {
|
||||
this.ipMenuService = ipMenuService;
|
||||
}
|
||||
|
||||
public Map<String, Object> getSumdata() {
|
||||
return sumdata;
|
||||
}
|
||||
|
||||
public String getResult_make() {
|
||||
return result_make;
|
||||
}
|
||||
|
||||
}
|
||||
197
comm/DDOS/src/project/ddos/web/AdminIpMenuAction.java
Executable file
197
comm/DDOS/src/project/ddos/web/AdminIpMenuAction.java
Executable file
@@ -0,0 +1,197 @@
|
||||
package project.ddos.web;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.ddos.AdminIpMenuService;
|
||||
import project.ddos.IpMenuService;
|
||||
import project.ddos.model.IpMenu;
|
||||
|
||||
//public class AdminIpMenuAction extends PageActionSupport {
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private static final long serialVersionUID = -3567372733940832371L;
|
||||
// private static final Log logger = LogFactory.getLog(AdminIpMenuAction.class);
|
||||
// private AdminIpMenuService adminIpMenuService;
|
||||
// private IpMenuService ipMenuService;
|
||||
//
|
||||
// private String ip_para;
|
||||
// private String type_para;
|
||||
//
|
||||
// private String menu_ip;
|
||||
// private String menu_type;
|
||||
// /**
|
||||
// * 登录人资金密码
|
||||
// */
|
||||
// private String login_safeword;
|
||||
//
|
||||
// public String list() {
|
||||
// this.pageSize = 50;
|
||||
// if (StringUtils.isEmptyString(type_para)) {
|
||||
// type_para = "white";
|
||||
// }
|
||||
// this.page = this.adminIpMenuService.pagedQuery(this.pageNo, this.pageSize, this.ip_para, type_para);
|
||||
// return "list";
|
||||
// }
|
||||
//
|
||||
// public String toAdd() {
|
||||
// return "add";
|
||||
// }
|
||||
//
|
||||
// private void check() {
|
||||
// String loginUserName = this.getUsername_login();
|
||||
// if (!("root".equals(loginUserName))) {
|
||||
// throw new BusinessException("权限不足,无法操作");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String verif_add() {
|
||||
//
|
||||
// if (StringUtils.isEmptyString(this.menu_ip)) {
|
||||
// return "请输入[IP]";
|
||||
// }
|
||||
//
|
||||
// if (StringUtils.isEmptyString(this.menu_type)) {
|
||||
// return "请选择[名单]";
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public String add() {
|
||||
// try {
|
||||
// check();
|
||||
// this.error = verif_add();
|
||||
// if (!StringUtils.isNullOrEmpty(this.error)) {
|
||||
// return toAdd();
|
||||
// }
|
||||
// if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
// this.error = "请输入登录人资金密码";
|
||||
// return toAdd();
|
||||
// }
|
||||
//
|
||||
// IpMenu ipMenu = new IpMenu();
|
||||
// ipMenu.setIp(menu_ip);
|
||||
// ipMenu.setLast_opera_time(new Date());
|
||||
// ipMenu.setCreate_time(new Date());
|
||||
// ipMenu.setDelete_status(0);
|
||||
// ipMenu.setType(menu_type);
|
||||
// /**
|
||||
// * 补充设值
|
||||
// */
|
||||
// this.adminIpMenuService.save(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
// this.message = "操作成功";
|
||||
//
|
||||
// } catch (BusinessException e) {
|
||||
// this.error = e.getMessage();
|
||||
// return toAdd();
|
||||
// } catch (Throwable t) {
|
||||
// logger.error(" error ", t);
|
||||
// this.error = ("[ERROR] " + t.getMessage());
|
||||
// return toAdd();
|
||||
// }
|
||||
// return list();
|
||||
// }
|
||||
//
|
||||
// public String update() {
|
||||
// try {
|
||||
// check();
|
||||
// this.error = verif_add();
|
||||
// if (!StringUtils.isNullOrEmpty(this.error)) {
|
||||
// return toUpdate();
|
||||
// }
|
||||
// IpMenu ipMenu = new IpMenu();
|
||||
// ipMenu.setIp(menu_ip);
|
||||
// ipMenu.setLast_opera_time(new Date());
|
||||
// ipMenu.setDelete_status(0);
|
||||
// ipMenu.setType(menu_type);
|
||||
//
|
||||
// this.adminIpMenuService.update(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
// this.message = "操作成功";
|
||||
// } catch (BusinessException e) {
|
||||
// this.error = e.getMessage();
|
||||
// return toUpdate();
|
||||
// } catch (Throwable t) {
|
||||
// logger.error(" error ", t);
|
||||
// this.error = ("[ERROR] " + t.getMessage());
|
||||
// return toUpdate();
|
||||
// }
|
||||
// return list();
|
||||
// }
|
||||
//
|
||||
// public String toUpdate() {
|
||||
// check();
|
||||
// IpMenu cacheByIp = ipMenuService.cacheByIp(menu_ip);
|
||||
// menu_ip = cacheByIp.getIp();
|
||||
// menu_type = cacheByIp.getType();
|
||||
// return "update";
|
||||
// }
|
||||
//
|
||||
// public String toDelete() {
|
||||
// try {
|
||||
// check();
|
||||
// this.adminIpMenuService.delete(menu_ip, this.getUsername_login(), login_safeword, this.getIp());
|
||||
// this.message = "操作成功";
|
||||
// return list();
|
||||
// } catch (BusinessException e) {
|
||||
// this.error = e.getMessage();
|
||||
// return list();
|
||||
// } catch (Throwable t) {
|
||||
// logger.error("update error ", t);
|
||||
// this.error = "程序错误";
|
||||
// return list();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public String getIp_para() {
|
||||
// return ip_para;
|
||||
// }
|
||||
//
|
||||
// public String getType_para() {
|
||||
// return type_para;
|
||||
// }
|
||||
//
|
||||
// public void setAdminIpMenuService(AdminIpMenuService adminIpMenuService) {
|
||||
// this.adminIpMenuService = adminIpMenuService;
|
||||
// }
|
||||
//
|
||||
// public void setIp_para(String ip_para) {
|
||||
// this.ip_para = ip_para;
|
||||
// }
|
||||
//
|
||||
// public void setType_para(String type_para) {
|
||||
// this.type_para = type_para;
|
||||
// }
|
||||
//
|
||||
// public void setIpMenuService(IpMenuService ipMenuService) {
|
||||
// this.ipMenuService = ipMenuService;
|
||||
// }
|
||||
//
|
||||
// public void setLogin_safeword(String login_safeword) {
|
||||
// this.login_safeword = login_safeword;
|
||||
// }
|
||||
//
|
||||
// public String getMenu_ip() {
|
||||
// return menu_ip;
|
||||
// }
|
||||
//
|
||||
// public String getMenu_type() {
|
||||
// return menu_type;
|
||||
// }
|
||||
//
|
||||
// public void setMenu_ip(String menu_ip) {
|
||||
// this.menu_ip = menu_ip;
|
||||
// }
|
||||
//
|
||||
// public void setMenu_type(String menu_type) {
|
||||
// this.menu_type = menu_type;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
192
comm/DDOS/src/project/ddos/web/AdminUrlSpecialAction.java
Executable file
192
comm/DDOS/src/project/ddos/web/AdminUrlSpecialAction.java
Executable file
@@ -0,0 +1,192 @@
|
||||
package project.ddos.web;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.ddos.AdminUrlSpecialService;
|
||||
import project.ddos.UrlSpecialService;
|
||||
import project.ddos.model.UrlSpecial;
|
||||
|
||||
public class AdminUrlSpecialAction extends PageActionSupport {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3567372733940832371L;
|
||||
private static final Log logger = LogFactory.getLog(AdminUrlSpecialAction.class);
|
||||
private AdminUrlSpecialService adminUrlSpecialService;
|
||||
private UrlSpecialService urlSpecialService;
|
||||
|
||||
private String url_para;
|
||||
|
||||
private String id;
|
||||
private String url;
|
||||
private String remarks;
|
||||
/**
|
||||
* 登录人资金密码
|
||||
*/
|
||||
private String login_safeword;
|
||||
|
||||
public String list() {
|
||||
this.pageSize = 30;
|
||||
this.page = this.adminUrlSpecialService.pagedQuery(this.pageNo, this.pageSize, this.url_para);
|
||||
return "list";
|
||||
}
|
||||
|
||||
public String toAdd() {
|
||||
return "add";
|
||||
}
|
||||
|
||||
private void check() {
|
||||
String loginUserName = this.getUsername_login();
|
||||
if (!("root".equals(loginUserName))) {
|
||||
throw new BusinessException("权限不足,无法操作");
|
||||
}
|
||||
}
|
||||
|
||||
private String verif_add() {
|
||||
|
||||
if (StringUtils.isEmptyString(this.url)) {
|
||||
return "请输入[URL]";
|
||||
}
|
||||
|
||||
// if (StringUtils.isEmptyString(this.menu_type)) {
|
||||
// return "请选择[名单]";
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String add() {
|
||||
try {
|
||||
check();
|
||||
this.error = verif_add();
|
||||
if (!StringUtils.isNullOrEmpty(this.error)) {
|
||||
return toAdd();
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(this.login_safeword)) {
|
||||
this.error = "请输入登录人资金密码";
|
||||
return toAdd();
|
||||
}
|
||||
UrlSpecial urlSpecial = new UrlSpecial();
|
||||
urlSpecial.setCreate_time(new Date());
|
||||
urlSpecial.setUrl(url);
|
||||
urlSpecial.setRemarks(remarks);
|
||||
|
||||
/**
|
||||
* 补充设值
|
||||
*/
|
||||
this.adminUrlSpecialService.save(urlSpecial, this.getUsername_login(), login_safeword, this.getIp());
|
||||
this.message = "操作成功";
|
||||
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
return toAdd();
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
this.error = ("[ERROR] " + t.getMessage());
|
||||
return toAdd();
|
||||
}
|
||||
return list();
|
||||
}
|
||||
|
||||
public String update() {
|
||||
try {
|
||||
check();
|
||||
this.error = verif_add();
|
||||
if (!StringUtils.isNullOrEmpty(this.error)) {
|
||||
return toUpdate();
|
||||
}
|
||||
UrlSpecial urlSpecial = new UrlSpecial();
|
||||
urlSpecial.setCreate_time(new Date());
|
||||
urlSpecial.setId(id);
|
||||
urlSpecial.setUrl(url);
|
||||
urlSpecial.setRemarks(remarks);
|
||||
|
||||
this.adminUrlSpecialService.update(urlSpecial, this.getUsername_login(), login_safeword, this.getIp());
|
||||
this.message = "操作成功";
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
return toUpdate();
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
this.error = ("[ERROR] " + t.getMessage());
|
||||
return toUpdate();
|
||||
}
|
||||
return list();
|
||||
}
|
||||
|
||||
public String toUpdate() {
|
||||
check();
|
||||
UrlSpecial special = urlSpecialService.cacheById(id);
|
||||
url = special.getUrl();
|
||||
remarks = special.getRemarks();
|
||||
return "update";
|
||||
}
|
||||
|
||||
public String toDelete() {
|
||||
try {
|
||||
check();
|
||||
this.adminUrlSpecialService.delete(id, this.getUsername_login(), login_safeword, this.getIp());
|
||||
this.message = "操作成功";
|
||||
return list();
|
||||
} catch (BusinessException e) {
|
||||
this.error = e.getMessage();
|
||||
return list();
|
||||
} catch (Throwable t) {
|
||||
logger.error("update error ", t);
|
||||
this.error = "程序错误";
|
||||
return list();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogin_safeword(String login_safeword) {
|
||||
this.login_safeword = login_safeword;
|
||||
}
|
||||
|
||||
public String getUrl_para() {
|
||||
return url_para;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setAdminUrlSpecialService(AdminUrlSpecialService adminUrlSpecialService) {
|
||||
this.adminUrlSpecialService = adminUrlSpecialService;
|
||||
}
|
||||
|
||||
public void setUrl_para(String url_para) {
|
||||
this.url_para = url_para;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setUrlSpecialService(UrlSpecialService urlSpecialService) {
|
||||
this.urlSpecialService = urlSpecialService;
|
||||
}
|
||||
|
||||
}
|
||||
318
comm/DDOS/src/project/web/admin/AdminIpCountController.java
Executable file
318
comm/DDOS/src/project/web/admin/AdminIpCountController.java
Executable file
@@ -0,0 +1,318 @@
|
||||
package project.web.admin;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.JsonUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.ddos.AdminIpCountService;
|
||||
import project.ddos.AdminIpMenuService;
|
||||
import project.ddos.IpMenuService;
|
||||
import project.ddos.model.IpMenu;
|
||||
|
||||
/**
|
||||
* IP请求管理
|
||||
*/
|
||||
@RestController
|
||||
public class AdminIpCountController extends PageActionSupport {
|
||||
|
||||
private Logger logger = LogManager.getLogger(AdminIpCountController.class);
|
||||
|
||||
@Autowired
|
||||
private AdminIpCountService adminIpCountService;
|
||||
@Autowired
|
||||
private AdminIpMenuService adminIpMenuService;
|
||||
@Autowired
|
||||
private IpMenuService ipMenuService;
|
||||
|
||||
private final String action = "normal/adminIpCountAction!";
|
||||
|
||||
/**
|
||||
* 获取 IP请求 列表
|
||||
*/
|
||||
@RequestMapping(action + "list.action")
|
||||
public ModelAndView list(HttpServletRequest request) {
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
String ip_para = request.getParameter("ip_para");
|
||||
String type_para = request.getParameter("type_para");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("ip_count_list");
|
||||
|
||||
try {
|
||||
|
||||
this.checkAndSetPageNo(pageNo);
|
||||
|
||||
this.pageSize = 50;
|
||||
this.page = this.adminIpCountService.cachePagedQuery(this.pageNo, this.pageSize, ip_para, type_para, null);
|
||||
|
||||
Map<String, Object> sumdata = this.adminIpCountService.sumDates();
|
||||
modelAndView.addObject("sumdata", sumdata);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("pageNo", this.pageNo);
|
||||
modelAndView.addObject("pageSize", this.pageSize);
|
||||
modelAndView.addObject("page", this.page);
|
||||
modelAndView.addObject("message", message);
|
||||
modelAndView.addObject("error", error);
|
||||
modelAndView.addObject("ip_para", ip_para);
|
||||
modelAndView.addObject("type_para", type_para);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
// public String toAdd() {
|
||||
// return "add";
|
||||
// }
|
||||
|
||||
/**
|
||||
* addBlack
|
||||
*/
|
||||
@RequestMapping(action + "addBlack.action")
|
||||
public ModelAndView addBlack(HttpServletRequest request) {
|
||||
String menu_ip = request.getParameter("menu_ip");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
this.check();
|
||||
|
||||
String error = this.verif_add(menu_ip);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(login_safeword)) {
|
||||
throw new BusinessException("请输入登录人资金密码");
|
||||
}
|
||||
|
||||
IpMenu ipMenu = new IpMenu();
|
||||
ipMenu.setIp(menu_ip);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
|
||||
IpMenu cacheMenu = this.ipMenuService.cacheByIp(menu_ip);
|
||||
if (cacheMenu != null && cacheMenu.getDelete_status() == 0) {
|
||||
this.adminIpMenuService.update(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
} else {
|
||||
this.adminIpMenuService.save(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
}
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* addLock
|
||||
*/
|
||||
@RequestMapping(action + "addLock.action")
|
||||
public ModelAndView addLock(HttpServletRequest request) {
|
||||
String menu_ip = request.getParameter("menu_ip");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
this.check();
|
||||
|
||||
String error = this.verif_add(menu_ip);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(login_safeword)) {
|
||||
throw new BusinessException("请输入登录人资金密码");
|
||||
}
|
||||
|
||||
IpMenu ipMenu = new IpMenu();
|
||||
ipMenu.setIp(menu_ip);
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setType(IpMenu.IP_LOCK);
|
||||
|
||||
IpMenu cacheMenu = ipMenuService.cacheByIp(menu_ip);
|
||||
if (cacheMenu != null && cacheMenu.getDelete_status() == 0) {
|
||||
this.adminIpMenuService.update(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
} else {
|
||||
this.adminIpMenuService.save(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
}
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* batchAddBlack
|
||||
*/
|
||||
@RequestMapping(action + "batchAddBlack.action")
|
||||
public ModelAndView batchAddBlack(HttpServletRequest request) {
|
||||
Long limit_count = Long.valueOf(request.getParameter("limit_count"));
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
this.check();
|
||||
|
||||
// this.error = this.verif_add(menu_ip);
|
||||
// if (!StringUtils.isNullOrEmpty(this.error)) {
|
||||
// throw new BusinessException(this.error);
|
||||
// }
|
||||
|
||||
if (StringUtils.isNullOrEmpty(login_safeword)) {
|
||||
throw new BusinessException("请输入登录人资金密码");
|
||||
}
|
||||
|
||||
if (null == limit_count || 0 == limit_count) {
|
||||
throw new BusinessException("警戒线错误");
|
||||
}
|
||||
|
||||
// 补充设值
|
||||
this.adminIpCountService.batchAddBlack(limit_count, this.getUsername_login(), login_safeword, this.getIp());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* clearData
|
||||
*/
|
||||
@RequestMapping(action + "clearData.action")
|
||||
public ModelAndView clearData(HttpServletRequest request) {
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
this.check();
|
||||
|
||||
if (StringUtils.isNullOrEmpty(login_safeword)) {
|
||||
throw new BusinessException("请输入登录人资金密码");
|
||||
}
|
||||
|
||||
// 补充设值
|
||||
this.adminIpCountService.clearData(this.getUsername_login(), login_safeword, this.getIp());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* getUrlsCount
|
||||
*/
|
||||
@RequestMapping(action + "getUrlsCount.action")
|
||||
public String getUrlsCount(HttpServletRequest request) {
|
||||
String menu_ip = request.getParameter("menu_ip");
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
|
||||
try {
|
||||
|
||||
resultMap.put("code", 200);
|
||||
resultMap.put("urls_count", this.adminIpCountService.getUrlsCount(menu_ip));
|
||||
|
||||
} catch (BusinessException e) {
|
||||
resultMap.put("code", 500);
|
||||
resultMap.put("message", e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
resultMap.put("code", 500);
|
||||
resultMap.put("message", "程序错误");
|
||||
}
|
||||
|
||||
return JsonUtils.getJsonString(resultMap);
|
||||
}
|
||||
|
||||
private void check() {
|
||||
String loginUserName = this.getUsername_login();
|
||||
if (!("root".equals(loginUserName))) {
|
||||
throw new BusinessException("权限不足,无法操作");
|
||||
}
|
||||
}
|
||||
|
||||
private String verif_add(String menu_ip) {
|
||||
if (StringUtils.isEmptyString(menu_ip)) {
|
||||
return "IP参数异常";
|
||||
}
|
||||
// if (StringUtils.isEmptyString(this.menu_type)) {
|
||||
// return "请选择[名单]";
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
206
comm/DDOS/src/project/web/admin/AdminIpMenuController.java
Executable file
206
comm/DDOS/src/project/web/admin/AdminIpMenuController.java
Executable file
@@ -0,0 +1,206 @@
|
||||
package project.web.admin;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.ddos.AdminIpMenuService;
|
||||
import project.ddos.IpMenuService;
|
||||
import project.ddos.model.IpMenu;
|
||||
|
||||
/**
|
||||
* IP名单管理
|
||||
*/
|
||||
@RestController
|
||||
public class AdminIpMenuController extends PageActionSupport {
|
||||
|
||||
private Logger logger = LogManager.getLogger(AdminIpMenuController.class);
|
||||
|
||||
@Autowired
|
||||
private AdminIpMenuService adminIpMenuService;
|
||||
@Autowired
|
||||
private IpMenuService ipMenuService;
|
||||
|
||||
private final String action = "normal/adminIpMenuAction!";
|
||||
|
||||
/**
|
||||
* 获取 IP名单 列表
|
||||
*/
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@RequestMapping(value =action + "list.action")
|
||||
public ModelAndView list(HttpServletRequest request) {
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
String ip = request.getParameter("ip");
|
||||
String startTime = request.getParameter("startTime");
|
||||
String endTime = request.getParameter("endTime");
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("ip_menu_list");
|
||||
try {
|
||||
this.checkAndSetPageNo(pageNo);
|
||||
this.pageSize = 20;
|
||||
this.page = this.adminIpMenuService.pagedQuery(this.pageNo, this.pageSize, ip,startTime,endTime);
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("pageNo", this.pageNo);
|
||||
modelAndView.addObject("pageSize", this.pageSize);
|
||||
modelAndView.addObject("page", this.page);
|
||||
modelAndView.addObject("ip", ip);
|
||||
modelAndView.addObject("startTime", startTime);
|
||||
modelAndView.addObject("endTime", endTime);
|
||||
modelAndView.addObject("message", message);
|
||||
modelAndView.addObject("error", error);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 IP名单
|
||||
*/
|
||||
@RequestMapping(action + "add.action")
|
||||
public ModelAndView add(HttpServletRequest request) {
|
||||
String menu_ip = request.getParameter("ip");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
String remark = request.getParameter("remark");
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("pageNo",pageNo);
|
||||
try {
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
IpMenu ipMenu = new IpMenu();
|
||||
ipMenu.setIp(menu_ip.trim());
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setCreate_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
ipMenu.setCreateName(this.getUsername_login());
|
||||
ipMenu.setRemark(remark);
|
||||
// 补充设值
|
||||
this.adminIpMenuService.save(ipMenu, this.getUsername_login(), login_safeword, this.getIp());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改 IP名单
|
||||
*/
|
||||
@RequestMapping(action + "update.action")
|
||||
public ModelAndView update(HttpServletRequest request) {
|
||||
String newIp = request.getParameter("newIp");
|
||||
String oldIp = request.getParameter("oldIp");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
String remark = request.getParameter("remark");
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("pageNo",pageNo);
|
||||
try {
|
||||
IpMenu ipMenu = new IpMenu();
|
||||
ipMenu.setIp(newIp.trim());
|
||||
ipMenu.setLast_opera_time(new Date());
|
||||
ipMenu.setDelete_status(0);
|
||||
ipMenu.setType(IpMenu.IP_BLACK);
|
||||
ipMenu.setRemark(remark);
|
||||
this.adminIpMenuService.updateIp(ipMenu,oldIp.trim(), this.getUsername_login(), login_safeword, this.getIp());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 IP名单 页面
|
||||
*/
|
||||
@RequestMapping(action + "toDelete.action")
|
||||
public ModelAndView toDelete(HttpServletRequest request) {
|
||||
String ip = request.getParameter("ip");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.addObject("pageNo",pageNo);
|
||||
try {
|
||||
|
||||
this.adminIpMenuService.delete(ip.trim(), this.getUsername_login(), login_safeword, this.getIp());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error("update error ", t);
|
||||
modelAndView.addObject("error", "程序错误");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
// private void check() {
|
||||
// String loginUserName = this.getUsername_login();
|
||||
// if (!("root".equals(loginUserName))) {
|
||||
// throw new BusinessException("权限不足,无法操作");
|
||||
// }
|
||||
// }
|
||||
|
||||
private String verif_add(String menu_ip, String menu_type) {
|
||||
if (StringUtils.isEmptyString(menu_ip)) {
|
||||
return "请输入[IP]";
|
||||
}
|
||||
if (StringUtils.isEmptyString(menu_type)) {
|
||||
return "请选择[名单]";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
270
comm/DDOS/src/project/web/admin/AdminUrlSpecialController.java
Executable file
270
comm/DDOS/src/project/web/admin/AdminUrlSpecialController.java
Executable file
@@ -0,0 +1,270 @@
|
||||
package project.web.admin;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.PageActionSupport;
|
||||
import project.ddos.AdminUrlSpecialService;
|
||||
import project.ddos.UrlSpecialService;
|
||||
import project.ddos.model.UrlSpecial;
|
||||
|
||||
/**
|
||||
* 特殊URL管理
|
||||
*/
|
||||
@RestController
|
||||
public class AdminUrlSpecialController extends PageActionSupport {
|
||||
|
||||
private Logger logger = LogManager.getLogger(AdminUrlSpecialController.class);
|
||||
|
||||
@Autowired
|
||||
private AdminUrlSpecialService adminUrlSpecialService;
|
||||
@Autowired
|
||||
private UrlSpecialService urlSpecialService;
|
||||
|
||||
private final String action = "normal/adminUrlSpecialAction!";
|
||||
|
||||
/**
|
||||
* 获取 特殊URL 列表
|
||||
*/
|
||||
@RequestMapping(action + "list.action")
|
||||
public ModelAndView list(HttpServletRequest request) {
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
String message = request.getParameter("message");
|
||||
String error = request.getParameter("error");
|
||||
String url_para = request.getParameter("url_para");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("url_special_list");
|
||||
|
||||
try {
|
||||
|
||||
this.checkAndSetPageNo(pageNo);
|
||||
|
||||
this.pageSize = 30;
|
||||
this.page = this.adminUrlSpecialService.pagedQuery(this.pageNo, this.pageSize, url_para);
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("pageNo", this.pageNo);
|
||||
modelAndView.addObject("pageSize", this.pageSize);
|
||||
modelAndView.addObject("page", this.page);
|
||||
modelAndView.addObject("message", message);
|
||||
modelAndView.addObject("error", error);
|
||||
modelAndView.addObject("url_para", url_para);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 特殊URL 页面
|
||||
*/
|
||||
@RequestMapping(action + "toAdd.action")
|
||||
public ModelAndView toAdd(HttpServletRequest request) {
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("url_special_add");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 特殊URL
|
||||
*/
|
||||
@RequestMapping(action + "add.action")
|
||||
public ModelAndView add(HttpServletRequest request) {
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
String url = request.getParameter("url");
|
||||
String remarks = request.getParameter("remarks");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
this.check();
|
||||
|
||||
String error = verif_add(url);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNullOrEmpty(login_safeword)) {
|
||||
throw new BusinessException("请输入登录人资金密码");
|
||||
}
|
||||
|
||||
UrlSpecial urlSpecial = new UrlSpecial();
|
||||
urlSpecial.setCreate_time(new Date());
|
||||
urlSpecial.setUrl(url);
|
||||
urlSpecial.setRemarks(remarks);
|
||||
|
||||
// 补充设值
|
||||
this.adminUrlSpecialService.save(urlSpecial, this.getUsername_login(), login_safeword, this.getIp());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.addObject("url", url);
|
||||
modelAndView.addObject("remarks", remarks);
|
||||
modelAndView.setViewName("url_special_add");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.addObject("url", url);
|
||||
modelAndView.addObject("remarks", remarks);
|
||||
modelAndView.setViewName("url_special_add");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 特殊URL 页面
|
||||
*/
|
||||
@RequestMapping(action + "toUpdate.action")
|
||||
public ModelAndView toUpdate(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
this.check();
|
||||
|
||||
UrlSpecial special = this.urlSpecialService.cacheById(id);
|
||||
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("url", special.getUrl());
|
||||
modelAndView.addObject("remarks", special.getRemarks());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.setViewName("url_special_update");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 特殊URL
|
||||
*/
|
||||
@RequestMapping(action + "update.action")
|
||||
public ModelAndView update(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
String url = request.getParameter("url");
|
||||
String remarks = request.getParameter("remarks");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
this.check();
|
||||
|
||||
String error = verif_add(url);
|
||||
if (!StringUtils.isNullOrEmpty(error)) {
|
||||
throw new BusinessException(error);
|
||||
}
|
||||
|
||||
UrlSpecial urlSpecial = new UrlSpecial();
|
||||
urlSpecial.setCreate_time(new Date());
|
||||
urlSpecial.setId(id);
|
||||
urlSpecial.setUrl(url);
|
||||
urlSpecial.setRemarks(remarks);
|
||||
|
||||
this.adminUrlSpecialService.update(urlSpecial, this.getUsername_login(), login_safeword, this.getIp());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("url", url);
|
||||
modelAndView.addObject("remarks", remarks);
|
||||
modelAndView.setViewName("url_special_update");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error(" error ", t);
|
||||
modelAndView.addObject("error", "[ERROR] " + t.getMessage());
|
||||
modelAndView.addObject("id", id);
|
||||
modelAndView.addObject("url", url);
|
||||
modelAndView.addObject("remarks", remarks);
|
||||
modelAndView.setViewName("url_special_update");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 特殊URL
|
||||
*/
|
||||
@RequestMapping(action + "toDelete.action")
|
||||
public ModelAndView toDelete(HttpServletRequest request) {
|
||||
String id = request.getParameter("id");
|
||||
String login_safeword = request.getParameter("login_safeword");
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
|
||||
try {
|
||||
|
||||
this.check();
|
||||
|
||||
this.adminUrlSpecialService.delete(id, this.getUsername_login(), login_safeword, this.getIp());
|
||||
|
||||
} catch (BusinessException e) {
|
||||
modelAndView.addObject("error", e.getMessage());
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
} catch (Throwable t) {
|
||||
logger.error("update error ", t);
|
||||
modelAndView.addObject("error", "程序错误");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
modelAndView.addObject("message", "操作成功");
|
||||
modelAndView.setViewName("redirect:/" + action + "list.action");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
private void check() {
|
||||
String loginUserName = this.getUsername_login();
|
||||
if (!("root".equals(loginUserName))) {
|
||||
throw new BusinessException("权限不足,无法操作");
|
||||
}
|
||||
}
|
||||
|
||||
private String verif_add(String url) {
|
||||
if (StringUtils.isEmptyString(url)) {
|
||||
return "请输入[URL]";
|
||||
}
|
||||
// if (StringUtils.isEmptyString(this.menu_type)) {
|
||||
// return "请选择[名单]";
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user