Authored by mlge

新增--恶意ip规则管理模块

@@ -283,6 +283,12 @@ public class HttpUriContants { @@ -283,6 +283,12 @@ public class HttpUriContants {
283 public static final String GET_MALICIOUS_REMOVEIP = "/maliciousIp/removeIp"; 283 public static final String GET_MALICIOUS_REMOVEIP = "/maliciousIp/removeIp";
284 public static final String GET_MALICIOUS_IP_BL = "/maliciousIp/getIpsBL"; 284 public static final String GET_MALICIOUS_IP_BL = "/maliciousIp/getIpsBL";
285 public static final String GET_MALICIOUS_IP_CS = "/maliciousIp/getIpsCS"; 285 public static final String GET_MALICIOUS_IP_CS = "/maliciousIp/getIpsCS";
  286 + public static final String GET_MALICIOUS_IP_RULES = "/maliciousIp/getIpRules";
  287 + public static final String SAVE_MALICIOUS_IP_RULES = "/maliciousIp/saveIpRules";
  288 + public static final String DEL_MALICIOUS_IP_RULE = "/maliciousIp/deleteIpRule";
  289 +
  290 +
  291 +
286 292
287 //告警组管理 293 //告警组管理
288 public static final String GET_ALARMGROUP_GET = "/alarmGroup/getAlarmGroup"; 294 public static final String GET_ALARMGROUP_GET = "/alarmGroup/getAlarmGroup";
  1 +package com.ui.model.domain;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * Created by meiling.ge on 2017/8/21.
  7 + */
  8 +@Data
  9 +public class MalIpRule {
  10 + private int id;
  11 + private String name;
  12 + private String rule;
  13 +}
@@ -25,5 +25,12 @@ @@ -25,5 +25,12 @@
25 <groupId>javax.servlet.jsp</groupId> 25 <groupId>javax.servlet.jsp</groupId>
26 <artifactId>jsp-api</artifactId> 26 <artifactId>jsp-api</artifactId>
27 </dependency> 27 </dependency>
  28 +
  29 + <dependency>
  30 + <groupId>com.google.collections</groupId>
  31 + <artifactId>google-collections</artifactId>
  32 + <version>1.0-rc2</version>
  33 + </dependency>
  34 +
28 </dependencies> 35 </dependencies>
29 </project> 36 </project>
  1 +package com.ui.common;
  2 +
  3 +import com.google.common.collect.Lists;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * Created by meiling.ge on 2017/8/21.
  9 + * 恶意ip规则管理 -----规则项连接符
  10 + */
  11 +public enum IpRuleConcatEnum {
  12 + AND("&&","与"),
  13 + OR("||","或");
  14 +
  15 + private String concat;//规则连接符
  16 + private String desc;//描述
  17 + IpRuleConcatEnum(String concat,String desc ){
  18 + this.concat = concat;
  19 + this.desc = desc;
  20 + }
  21 +
  22 + public static List<String> getAll(){
  23 + IpRuleConcatEnum[] values = IpRuleConcatEnum.values();
  24 + List<String> list = Lists.newArrayListWithCapacity(values.length);
  25 + for(IpRuleConcatEnum val : values){
  26 + list.add(val.concat);
  27 + }
  28 + return list;
  29 +
  30 + }
  31 +
  32 +
  33 +
  34 +
  35 +}
  1 +package com.ui.common;
  2 +
  3 +import com.google.common.collect.Lists;
  4 +
  5 +import java.util.HashMap;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +/**
  10 + * Created by meiling.ge on 2017/8/21.
  11 + * 恶意Ip管理---规则项
  12 + */
  13 +public enum IpRuleItemEnum {
  14 + QPS("qps","qps"),
  15 + DIFMETHODCOUNT("difMethodCount","访问接口个数"),
  16 + IMPCOUNT("impCount","敏感接口访问次数"),
  17 + IMPAPIPRECENT("impApiPrecent","敏感接口占比"),
  18 + UIDCOUNT("uidCount","uid个数"),
  19 + UDIDCOUNT("udidCount","udid个数"),
  20 + NOTEXSITUDIDCOUNT("notExsitUdidCount","不存在的udid个数"),
  21 + NOTEXISTUDIDPERCENT("notExistUdidPercent","不存在udid占比"),
  22 + DEVICETYPECOUNT("deviceTypeCount","设备类型总数");
  23 +
  24 + private String item;
  25 + private String desc;
  26 + IpRuleItemEnum(String item, String desc){
  27 + this.item = item;
  28 + this.desc = desc;
  29 + }
  30 +
  31 + public static List<Map<String,String>> getAll(){
  32 + IpRuleItemEnum[] values = IpRuleItemEnum.values();
  33 + List<Map<String,String>> list = Lists.newArrayListWithCapacity(values.length);
  34 + for(IpRuleItemEnum val : values){//前端 select的数据格式
  35 + Map<String,String> map = new HashMap<>();
  36 + map.put("value",val.item);
  37 + map.put("text",val.desc);
  38 + list.add(map);
  39 + }
  40 + return list;
  41 +
  42 + }
  43 +
  44 +
  45 +}
  1 +package com.ui.common;
  2 +
  3 +import com.google.common.collect.Lists;
  4 +
  5 +import java.util.ArrayList;
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * Created by meiling.ge on 2017/8/21.
  10 + * 恶意ip规则-----比较符
  11 + */
  12 +public enum IpRuleOperationEnum {
  13 + GT(">", "大于"),
  14 + GTE(">=", "大于等于"),
  15 + EQ("=", "等于"),
  16 + LT("<", "小于"),
  17 + LE("<=", "小于等于"),
  18 + NEQ("<>", "不等于");
  19 + private String op;
  20 + private String desc;
  21 +
  22 + IpRuleOperationEnum(String op,String desc){
  23 + this.op = op;
  24 + this.desc = desc;
  25 + }
  26 +
  27 + public static List<String> getAllOp(){
  28 + IpRuleOperationEnum[] values = IpRuleOperationEnum.values();
  29 + List<String> list = Lists.newArrayListWithCapacity(values.length);
  30 + for(IpRuleOperationEnum item : values){
  31 + list.add(item.op);
  32 + }
  33 + return list;
  34 + }
  35 +
  36 +}
1 - package com.ui.ctrl; 1 +package com.ui.ctrl;
2 2
  3 +import java.util.ArrayList;
  4 +import java.util.HashMap;
3 import java.util.List; 5 import java.util.List;
4 - 6 +import java.util.Map;
  7 +
  8 +import com.alibaba.fastjson.JSON;
  9 +import com.ui.common.IpRuleConcatEnum;
  10 +import com.ui.common.IpRuleItemEnum;
  11 +import com.ui.common.IpRuleOperationEnum;
  12 +import com.ui.model.domain.MalIpRule;
  13 +import com.ui.model.req.PageRequest;
5 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.stereotype.Controller; 15 import org.springframework.stereotype.Controller;
7 import org.springframework.ui.Model; 16 import org.springframework.ui.Model;
  17 +import org.springframework.web.bind.annotation.RequestBody;
8 import org.springframework.web.bind.annotation.RequestMapping; 18 import org.springframework.web.bind.annotation.RequestMapping;
9 import org.springframework.web.bind.annotation.ResponseBody; 19 import org.springframework.web.bind.annotation.ResponseBody;
10 import org.springframework.web.servlet.ModelAndView; 20 import org.springframework.web.servlet.ModelAndView;
@@ -89,7 +99,7 @@ public class MaliciousIpCtrl { @@ -89,7 +99,7 @@ public class MaliciousIpCtrl {
89 99
90 /** 100 /**
91 * 从黑名单中移除ip 101 * 从黑名单中移除ip
92 - * @param ip 102 + * @param ips
93 * @return 103 * @return
94 */ 104 */
95 @SuppressWarnings("unchecked") 105 @SuppressWarnings("unchecked")
@@ -128,4 +138,53 @@ public class MaliciousIpCtrl { @@ -128,4 +138,53 @@ public class MaliciousIpCtrl {
128 BaseResponse.class); 138 BaseResponse.class);
129 return response; 139 return response;
130 } 140 }
  141 +
  142 +
  143 + /**
  144 + * 恶意ip规则管理**/
  145 + @RequestMapping("/toMaliciousIpRules")
  146 + public ModelAndView toMaliciousIpRules(Model model) {
  147 + List<Map<String,String>> itemList = IpRuleItemEnum.getAll();//规则项
  148 + String items = JSON.toJSONString(itemList);
  149 + List<String> opList = IpRuleOperationEnum.getAllOp();//规则比较符 列表
  150 + String operations = JSON.toJSONString(opList);
  151 + List<String> concatList = IpRuleConcatEnum.getAll();//规则连接符
  152 + String concats = JSON.toJSONString(concatList);
  153 +
  154 + ModelAndView mv = new ModelAndView();
  155 + mv.setViewName("malicious/maliciousIpRulesList");
  156 + mv.addObject("items",items);
  157 + mv.addObject("operations",operations);
  158 + mv.addObject("concats",concats);
  159 + return mv;
  160 + }
  161 +
  162 + /***
  163 + * 查询 恶意ip规则列表*/
  164 + @RequestMapping("/getIpRules")
  165 + @ResponseBody
  166 + public BaseResponse getIpRules(PageRequest req) {
  167 + BaseResponse response = httpClient.defaultPost(HttpUriContants.GET_MALICIOUS_IP_RULES, req, BaseResponse.class);
  168 + return response;
  169 + }
  170 +
  171 + /***
  172 + * 新增 恶意ip规则*/
  173 + @RequestMapping("/saveIpRules")
  174 + @ResponseBody
  175 + public BaseResponse saveIpRules(@RequestBody MalIpRule malIpRule) {
  176 + BaseResponse response = httpClient.defaultPost(HttpUriContants.SAVE_MALICIOUS_IP_RULES, malIpRule, BaseResponse.class);
  177 + return response;
  178 + }
  179 +
  180 + /***
  181 + * 删除 恶意ip规则*/
  182 + @RequestMapping("/deleteIpRule")
  183 + @ResponseBody
  184 + public BaseResponse deleteIpRule(int id ) {
  185 + BaseResponse response = httpClient.defaultPost(HttpUriContants.DEL_MALICIOUS_IP_RULE + "?id="+id, null, BaseResponse.class);
  186 + return response;
  187 + }
  188 +
  189 +
131 } 190 }
  1 +<%@page language="java" contentType="text/html;charset=utf-8" %>
  2 +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3 +
  4 +<%
  5 + String path = request.getContextPath();
  6 + String basePath = request.getScheme() + "://"
  7 + + request.getServerName() + ":" + request.getServerPort()
  8 + + path + "/";
  9 +%>
  10 +
  11 +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  12 +<html>
  13 +<head>
  14 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  15 + <link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
  16 + <link rel="stylesheet" href="<%=basePath %>css/bootstrap-datetimepicker.css"/>
  17 + <link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen"/>
  18 + <link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
  19 + <link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/>
  20 + <link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
  21 + <link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
  22 + <link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
  23 + <link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
  24 + <link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
  25 + <link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>
  26 + <link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
  27 + <link rel="stylesheet" href="<%=basePath %>css/yoho.css"/>
  28 + <script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
  29 + <script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
  30 + <script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
  31 + <script src="<%=basePath %>/js/bootstrap.min.js"></script>
  32 + <script src="<%=basePath %>/js/unicorn.js"></script>
  33 + <script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
  34 + type="text/javascript"></script>
  35 + <script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
  36 + type="text/javascript"></script>
  37 + <script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
  38 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
  39 + type="text/javascript"></script>
  40 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
  41 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
  42 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
  43 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
  44 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
  45 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
  46 + type="text/javascript"></script>
  47 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
  48 + type="text/javascript"></script>
  49 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
  50 + type="text/javascript"></script>
  51 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
  52 + <script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
  53 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
  54 + <script src="<%=basePath %>js/jstree/jstree.min.js"></script>
  55 + <script src="<%=basePath %>js/jquery.toaster.js"></script>
  56 + <script>
  57 + var contextPath = '<%=basePath %>';
  58 + </script>
  59 + <title>YOHO!运维</title>
  60 +</head>
  61 +<body>
  62 +
  63 +<!-- 头部 -->
  64 +<div id="head">
  65 +</div>
  66 +<!-- 右侧具体内容 -->
  67 +<div id="content">
  68 +
  69 + <div id="breadcrumb">
  70 + <a href="#" title="Go to Home" class="tip-bottom"><i
  71 + class="icon-home"></i> Home</a> <a href="#" class="current">恶意ip规则管理</a>
  72 + </div>
  73 +
  74 + <div class="container-fluid">
  75 +
  76 +
  77 + <div class="widget-box">
  78 + <div class="widget-title">
  79 + <h5>恶意Ip规则查询</h5>
  80 + </div>
  81 + <div class="widget-content nopadding">
  82 + <div class="widget-title" style="height: 53px;">
  83 + <div>
  84 + <button id="addRuleBtn" class="btn btn-success" style="margin-top: 12px;margin-left: 10px;" onclick="editRuleInfo(0)">新增规则</button>
  85 + </div>
  86 + </div>
  87 + <div id="malIpRulesInfoTable">
  88 +
  89 + </div>
  90 + </div>
  91 + </div>
  92 + </div>
  93 +</div>
  94 +
  95 +<%--新增规则模态框--%>
  96 +<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
  97 + <div class="modal-dialog">
  98 + <div class="modal-content"style="width: 140%">
  99 + <div class="modal-header">
  100 + <button type="button" class="close" data-dismiss="modal"
  101 + aria-hidden="true">&times</button>
  102 + <h4 class="modal-title" id="myModalLabel"></h4>
  103 + </div>
  104 + <div class="modal-body" style="height: 600px;overflow :auto" >
  105 + <form id="editRuleForm" class="form-horizontal">
  106 +
  107 + <div class="form-group" >
  108 + <label class="col-sm-1 control-label"> <span style="color:red">*</span>规则名称:</label>
  109 + <div class="col-sm-9">
  110 + <input type="text" class="form-control " id="ruleName" name="ruleName" placeholder="规则名称" />
  111 + </div>
  112 + </div>
  113 +
  114 +
  115 +
  116 + <div class="form-group">
  117 + <label class=" col-sm-1 control-label">生成规则:</label>
  118 + <div class="col-sm-2">
  119 + <input type="button" value="新增规则项" id="ruleItem" class="form-control btn btn-success" onclick="addRuleItem()"/>
  120 + </div>
  121 + </div>
  122 +
  123 + <div class="form-group">
  124 + <label class=" col-sm-1 control-label"></label>
  125 + <div class="col-sm-9">
  126 + <table class="table table-striped table-hover table-bordered " id="table_rule_items" style="width: 100%">
  127 + <thead>
  128 + <tr>
  129 + <th style="width: 25%">规则</th>
  130 + <th style="width: 15%"> 比较符</th>
  131 + <th style="width: 15%"></th>
  132 + <th style="width: 15%">规则连接符号</th>
  133 + <th style="width: 15%">删除</th>
  134 + </tr>
  135 + </thead>
  136 + <tbody>
  137 + <tr>
  138 + <td><select name='item_rule' class="form-control" style="height:80%"></select></td>
  139 + <td><select name='item_op' class="form-control" style="height:80%"></select></td>
  140 + <td><input type="text" name='item_val' class="form-control" ></input></td>
  141 + <td><select name='item_concat' class="form-control" style="display:none;height:80%"></select></td>
  142 + <td><a href="javascript:void(0)" class="btn mini black metric_delete" onclick="removeItem(this)">删除</a></td>
  143 + </tr>
  144 + </tbody>
  145 + </table>
  146 + </div>
  147 + </div>
  148 +
  149 + <div class="form-group" >
  150 + <label class="col-sm-1 control-label"> <span style="color:red">*</span>所生成的规则:</label>
  151 + <div class="col-sm-9">
  152 + <textarea class="form-control " id="rule" name="rule" style="font-size: 15px" rows="4" disabled="true" ></textarea>
  153 + </div>
  154 + </div>
  155 +
  156 +
  157 + <div class="form-group">
  158 + <label class="col-sm-2 control-label"> </label>
  159 + <div class="col-sm-8" id="messageAlert"></div>
  160 + </div>
  161 + <input type="hidden" name="editGroupId"/>
  162 + </form>
  163 + </div>
  164 + <div class="modal-footer">
  165 + <button type="button" class="btn btn-danger" data-dismiss="modal" onclick="window.location.href='/maliciousIp/toMaliciousIpRules'">关闭</button>
  166 + <button type="button" class="btn btn-success" value="Validate" onclick="saveTask()">提交</button>
  167 + </div>
  168 + </div>
  169 + <!-- /.modal-content -->
  170 + </div>
  171 + <!-- /.modal -->
  172 +</div>
  173 +<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
  174 +<script>
  175 + $("#li_config").addClass("active open");
  176 + $("#li_malicious_ips").addClass("active");
  177 +</script>
  178 +<script>
  179 + var items = ${items};//规则项
  180 + var operations = ${operations};//规则---比较符
  181 + var concats = ${concats};//规则连接符
  182 +
  183 + $(function () {
  184 + initEvents();//初始化 绑定事件
  185 + initSelects(0);
  186 + //加载表格
  187 + $("#malIpRulesInfoTable").table({
  188 + columnAutoWidth : false,
  189 + url : "/maliciousIp/getIpRules",
  190 + striped : true,
  191 + title : "恶意ip规则列表",
  192 + dataType : "json",
  193 + pagination : true,
  194 + pageSize : 10,
  195 + loadFilter : function(data) {
  196 + return defaultLoadFilter(data);
  197 + },
  198 + columns : [{
  199 + title : "序号",
  200 + width : "12%",
  201 + formatter : function(value, rowData, rowIndex){
  202 + return rowIndex + 1;
  203 + }
  204 + },/*{
  205 + title : "id",
  206 + field : "id",
  207 + width : "12%"
  208 + },*/ {
  209 + title : "规则名称",
  210 + field : "name",
  211 + width : "20%"
  212 + }, {
  213 + title : "规则内容",
  214 + field : "rule",
  215 + width : "40%"
  216 + }, {
  217 + title : "操作",
  218 + field : "op",
  219 + formatter : function(value, rowData, rowIndex) {
  220 + var div = $("<div>");
  221 + var delBtn = $("<button>").addClass("btn btn-xs btn-danger").html("删除").appendTo(div);
  222 + delBtn.click(function() {
  223 + var dialog = $("<div>").appendTo($("body"));
  224 + dialog.dialog({
  225 + title : "你确定删除吗",
  226 + backdrop : "static",
  227 + content : "你确定要删除该条规则吗?",
  228 + buttons : [{
  229 + text : "否",
  230 + className : "btn-danger",
  231 + onclick : function() {
  232 + $(dialog).dialog("hide");
  233 + }
  234 + }, {
  235 + text : "是",
  236 + className : "btn-success",
  237 + onclick : function() {
  238 + $(dialog).dialog("hide");
  239 + $.ajax({
  240 + url : "/maliciousIp/deleteIpRule",
  241 + type : 'post',
  242 + async : false,
  243 + data : {
  244 + id : rowData.id
  245 + },
  246 + dataType : "json",
  247 + success : function(data) {
  248 + if (!data || data.code != 200) {
  249 + localAlert('删除失败',data.message);
  250 + }
  251 + $("#malIpRulesInfoTable").table("load");
  252 + },
  253 + error: function (data) {
  254 + localAlert('系统异常',data.message);
  255 + }
  256 + });
  257 + }
  258 + }]
  259 + });
  260 + });
  261 + return div;
  262 + },
  263 + width : "8%"
  264 + }]
  265 + });
  266 + $("#addRuleBtn").click(function() {
  267 + editRuleInfo(0);
  268 + });
  269 + });
  270 +
  271 +
  272 + //打开新增或修改页面
  273 + function editRuleInfo(id) {
  274 +
  275 + $("#editRuleForm #messageAlert").hide();
  276 + if (id == 0) {//新增页面
  277 + $("#myModalLabel").text("新增恶意ip规则");
  278 + }
  279 + $("#myModal").modal('show');
  280 + }
  281 +
  282 + //新增规则项
  283 + function addRuleItem(){
  284 + var contactTd = $("#table_rule_items").find("select[name='item_concat']").last();
  285 + contactTd.show();//展示拼接符
  286 + var tr = "<tr>" +
  287 + "<td><select name='item_rule' class='form-control' style='height:80%'></select></td>" +
  288 + "<td><select name='item_op' class='form-control'style='height:80%'></select></td>" +
  289 + "<td><input type='text' name='item_val' class='form-control'></input></td>" +
  290 + "<td><select name='item_concat' class='form-control'style='display:none;height:80%'></select></td>" +
  291 + "<td><a href='javascript:void(0)' class='btn mini black metric_delete' onclick='removeItem(this)'>删除</a></td>" +
  292 + "</tr>";
  293 + $("#table_rule_items tbody").append(tr);
  294 + initSelects(1);//给select赋值
  295 +
  296 + }
  297 +
  298 + //删除规则项
  299 + function removeItem(which){
  300 + var that = which;
  301 + $(that).closest("tr").remove();//移除
  302 + $("#table_rule_items").find("select[name='item_concat']").last().hide();//最后一个连接符设置为空并且隐藏
  303 + generateRules();//重新生成规则
  304 + }
  305 +
  306 + //按照行 对下拉列表 进行 数据绑定
  307 + function initSelects(initOradd){
  308 + var select_item = "";
  309 + var select_op = "";
  310 + var select_concat = "";
  311 +
  312 + if(initOradd == 0){//首次加载本页面--初始化 第一行
  313 + select_item = $("#table_rule_items tbody").find("select[name=\'item_rule\']").first();
  314 + select_op = $("#table_rule_items tbody").find("select[name=\'item_op\']").first();
  315 + select_concat = $("#table_rule_items tbody").find("select[name=\'item_concat\']").first();
  316 + }else{//新增规则项---最后一行
  317 + select_item = $("#table_rule_items tbody").find("select[name=\'item_rule\']").last();
  318 + select_op = $("#table_rule_items tbody").find("select[name=\'item_op\']").last();
  319 + select_concat = $("#table_rule_items tbody").find("select[name=\'item_concat\']").last();
  320 + }
  321 + //先清空
  322 + $(select_item).empty();
  323 +// $(select_item).append("<option ></option>");
  324 + $(select_op).empty();
  325 +// $(select_op).append("<option ></option>");
  326 + $(select_concat).empty();
  327 + /* $(select_concat).append("<option ></option>");*/
  328 + //再赋值
  329 + for(var i =0; i< items.length;i++){
  330 + $(select_item).append("<option value ='"+ items[i].value +"'>" + items[i].text + "</option>");
  331 + }
  332 + for(var i =0; i< operations.length;i++){
  333 + $(select_op).append("<option value ='"+ operations[i] +"'>" + operations[i] + "</option>");
  334 + }
  335 + for(var i =0; i<concats.length;i++){
  336 + $(select_concat).append("<option value ='"+ concats[i] +"'>" + concats[i] + "</option>");
  337 + }
  338 + }
  339 +
  340 + //初始化 绑定事件---动态展示 生成的规则
  341 + function initEvents(){
  342 +
  343 + $("#table_rule_items").on("change","select,input", function() {//下拉列表内容改变 绑定事件
  344 + generateRules();//生成规则文本
  345 + });
  346 + /* $("#table_rule_items").on("blur","input", function() {//文本框 获取焦点 绑定事件
  347 + generateRules();//生成规则文本
  348 + });*/
  349 + }
  350 + //生成规则文本
  351 + function generateRules(){
  352 + var ruleText = "";
  353 + var len = $("#table_rule_items").find("tr").length;
  354 + console.log("长度:"+len);
  355 + $("#table_rule_items").find("tr").each(function(i){//遍历table
  356 + if( i == 0 ) return true;//相当于continue
  357 +
  358 + var text_rule = $(this).find("select[name='item_rule']").val() ;
  359 + var text_op = $(this).find("select[name='item_op']").val() ;
  360 + var text_val = $(this).find("input[name='item_val']").val();
  361 + ruleText = ruleText + text_rule + text_op +text_val ;
  362 + if( i!= len -1){//不是最后一行
  363 + var text_con= $(this).find("select[name='item_concat']").val();
  364 + ruleText = ruleText + text_con;
  365 + }
  366 +
  367 +
  368 +
  369 +
  370 + });
  371 + $("#rule").val(ruleText);
  372 +
  373 + }
  374 + //提交保存
  375 + function saveTask(){
  376 + var ruleName = $("#ruleName").val();
  377 + var ruleContent = $("#rule").val();
  378 + //表单数据验证
  379 + if(ruleName == null || ruleName ==""){
  380 + $("#editRuleForm #messageAlert").alerts({
  381 + content: "请输入规则名称",
  382 + type: "danger"
  383 + });
  384 + return;
  385 + }
  386 +
  387 + if(ruleContent == null || ruleContent ==""){
  388 + $("#editRuleForm #messageAlert").alerts({
  389 + content: "规则不能为空",
  390 + type: "danger"
  391 + });
  392 + return;
  393 + }
  394 +
  395 + var param = {
  396 + name : ruleName,
  397 + rule : ruleContent
  398 + };
  399 + $.ajax({
  400 + url: '/maliciousIp/saveIpRules',
  401 +// type: 'POST',
  402 + dataType: 'json',
  403 + contentType: "application/json",
  404 + data: JSON.stringify(param),
  405 + success: function (data) {
  406 + if (!data || data.code != 200) {
  407 + $("#taskForm #messageAlert").alerts({
  408 + content: data.message,
  409 + type: "danger"
  410 + });
  411 + return;
  412 + } else {
  413 +// $("#myModal").modal('hide');
  414 + window.location.href = "/maliciousIp/toMaliciousIpRules";
  415 +// $("#malIpRulesInfoTable").table("load");
  416 + }
  417 + },
  418 + error: function (data) {
  419 + localAlert('系统异常', data.message);
  420 + }
  421 + });
  422 + }
  423 +</script>
  424 +
@@ -73,6 +73,7 @@ innerHTML += "<li id='li_hystrix_info'><a id='li_hystrix_info_a' href=''><i clas @@ -73,6 +73,7 @@ innerHTML += "<li id='li_hystrix_info'><a id='li_hystrix_info_a' href=''><i clas
73 innerHTML += "<li id='li_cache_info'><a id='li_cache_info_a' href=''><i class='icon icon-th'></i> <span>缓存时间配置</span></a></li>"; 73 innerHTML += "<li id='li_cache_info'><a id='li_cache_info_a' href=''><i class='icon icon-th'></i> <span>缓存时间配置</span></a></li>";
74 innerHTML += "<li id='li_aws_ebs'><a id='li_aws_ebs_a' href=''><i class='icon icon-th'></i> <span>AWS_EBS镜像任务</span></a></li>"; 74 innerHTML += "<li id='li_aws_ebs'><a id='li_aws_ebs_a' href=''><i class='icon icon-th'></i> <span>AWS_EBS镜像任务</span></a></li>";
75 innerHTML += "<li id='li_ips_compare'><a id='li_ips_compare_a' href=''><i class='icon icon-th'></i> <span>在线服务Ip配置对比</span></a></li>"; 75 innerHTML += "<li id='li_ips_compare'><a id='li_ips_compare_a' href=''><i class='icon icon-th'></i> <span>在线服务Ip配置对比</span></a></li>";
  76 +innerHTML += "<li id='li_malicious_ip_rules'><a id='li_malicious_ip_rules_a' href=''><i class='icon icon-th'></i> <span>恶意ip规则管理</span></a></li>";
76 innerHTML += "<li id='li_malicious_ips'><a id='li_malicious_ips_a' href=''><i class='icon icon-th'></i> <span>恶意ip管理</span></a></li>"; 77 innerHTML += "<li id='li_malicious_ips'><a id='li_malicious_ips_a' href=''><i class='icon icon-th'></i> <span>恶意ip管理</span></a></li>";
77 innerHTML += "<li id='li_malicious_ips_bl'><a id='li_malicious_ips_bl_a' href=''><i class='icon icon-th'></i> <span>恶意ip管理 | 敏感接口比例</span></a></li>"; 78 innerHTML += "<li id='li_malicious_ips_bl'><a id='li_malicious_ips_bl_a' href=''><i class='icon icon-th'></i> <span>恶意ip管理 | 敏感接口比例</span></a></li>";
78 innerHTML += "<li id='li_malicious_ips_cs'><a id='li_malicious_ips_cs_a' href=''><i class='icon icon-th'></i> <span>恶意ip管理 | 敏感接口次数</span></a></li>"; 79 innerHTML += "<li id='li_malicious_ips_cs'><a id='li_malicious_ips_cs_a' href=''><i class='icon icon-th'></i> <span>恶意ip管理 | 敏感接口次数</span></a></li>";
@@ -174,6 +175,7 @@ document.getElementById("li_memcachedMonitor_a").setAttribute("href", path + "/m @@ -174,6 +175,7 @@ document.getElementById("li_memcachedMonitor_a").setAttribute("href", path + "/m
174 document.getElementById("li_javarestart_a").setAttribute("href", path + "/javaRestart/toJavaRestart"); 175 document.getElementById("li_javarestart_a").setAttribute("href", path + "/javaRestart/toJavaRestart");
175 //document.getElementById("li_centerswitch_a").setAttribute("href", path + "/centerSwitch/toCenterSwitch"); 176 //document.getElementById("li_centerswitch_a").setAttribute("href", path + "/centerSwitch/toCenterSwitch");
176 document.getElementById("li_ips_compare_a").setAttribute("href", path + "/compareIps/toCompareIps"); 177 document.getElementById("li_ips_compare_a").setAttribute("href", path + "/compareIps/toCompareIps");
  178 +document.getElementById("li_malicious_ip_rules_a").setAttribute("href", path + "/maliciousIp/toMaliciousIpRules");
177 document.getElementById("li_malicious_ips_a").setAttribute("href", path + "/maliciousIp/toMaliciousIps"); 179 document.getElementById("li_malicious_ips_a").setAttribute("href", path + "/maliciousIp/toMaliciousIps");
178 document.getElementById("li_malicious_ips_bl_a").setAttribute("href", path + "/maliciousIp/toMaliciousIpsBL"); 180 document.getElementById("li_malicious_ips_bl_a").setAttribute("href", path + "/maliciousIp/toMaliciousIpsBL");
179 document.getElementById("li_malicious_ips_cs_a").setAttribute("href", path + "/maliciousIp/toMaliciousIpsCS"); 181 document.getElementById("li_malicious_ips_cs_a").setAttribute("href", path + "/maliciousIp/toMaliciousIpsCS");