From 468054b5a4c9d90b440e3b9fe98d7a7cdfce2025 Mon Sep 17 00:00:00 2001 From: shangguanyanfei Date: Fri, 31 May 2019 14:40:26 +0800 Subject: [PATCH] =?UTF-8?q?HTPP(S)=E6=93=8D=E6=8E=A7=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/log/PxyHttpManipulationLog.java | 659 ++++++++++++++++++ src/main/java/com/nis/util/Constants.java | 4 + .../log/pxy/PxyHttpManipulLogController.java | 335 +++++++++ .../{ni1s.properties => nis.properties} | 4 +- src/main/resources/sql/20190531/add_dict.sql | 8 + .../views/dashboard/configStatisticList.jsp | 410 +++++++++++ .../views/log/pxy/pxyHttpManipulationList.jsp | 511 ++++++++++++++ 7 files changed, 1930 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/nis/domain/log/PxyHttpManipulationLog.java create mode 100644 src/main/java/com/nis/web/controller/log/pxy/PxyHttpManipulLogController.java rename src/main/resources/{ni1s.properties => nis.properties} (99%) create mode 100644 src/main/resources/sql/20190531/add_dict.sql create mode 100644 src/main/webapp/WEB-INF/views/dashboard/configStatisticList.jsp create mode 100644 src/main/webapp/WEB-INF/views/log/pxy/pxyHttpManipulationList.jsp diff --git a/src/main/java/com/nis/domain/log/PxyHttpManipulationLog.java b/src/main/java/com/nis/domain/log/PxyHttpManipulationLog.java new file mode 100644 index 000000000..0b1023f9f --- /dev/null +++ b/src/main/java/com/nis/domain/log/PxyHttpManipulationLog.java @@ -0,0 +1,659 @@ +package com.nis.domain.log; + +import com.google.gson.annotations.Expose; +import com.nis.domain.BaseEntity; +import com.nis.util.excel.ExcelField; +/** + * (日志 代理)HTTP 操控 实体类 + * + */ +public class PxyHttpManipulationLog extends BaseEntity{ + private static final long serialVersionUID = -3046458130302949428L; + + @ExcelField(title="found_time",sort=5) + protected String foundTime; //发现时间,timestamp + @ExcelField(title="recv_time",sort=6) + protected String recvTime; //接收时间,timestamp + @ExcelField(title="transport_layer_protocol",dictType="LOG_PROTOCOL",sort=30) + protected String transProto; //协议类型,从字典LOG_PROTOCOL取值 + @ExcelField(title="addr_type",dictType="IP_TYPE",sort=35) + protected Integer addrType; //ip地址类型,从字典IP_TYPE取值 + @ExcelField(title="URL",sort=8) + private String url; + @ExcelField(title="host",sort=8) + private String host;//主机地址 + @ExcelField(title="domain_name",sort=8) + private String domain;//域名 + @ExcelField(title="category",sort=8) + private String category;//域名分类 + @ExcelField(title="req_line",sort=9) + private String reqLine; + @ExcelField(title="res_line",sort=10) + private String resLine; + @ExcelField(title="PXY_CACHE_HTTP_COOKIE",sort=11) + private String cookie; + @ExcelField(title="referer",sort=12) + private String referer; + @ExcelField(title="user_agent",sort=13) + private String userAgent; + @ExcelField(title="content_len",sort=14) + private String contentLen; + @ExcelField(title="content_type",sort=15) + private String contentType; + @ExcelField(title="set_cookie",sort=16) + private String setCookie; + @ExcelField(title="req_header",sort=17) + private String reqHeader; + @ExcelField(title="resp_header",sort=18) + private String respHeader; + @ExcelField(title="req_body",sort=78) + private String reqBody; + @ExcelField(title="resp_body",sort=79) + private String respBody; +// @ExcelField(title="website",sort=8) +// private String website; + + private String policyId;// + @ExcelField(title="app_proto",sort=31) + private String appProto;//应用协议类型 + @ExcelField(title="startTime",sort=5) + private String startTime;//会话创建时间 + @ExcelField(title="endTime",sort=5) + private String endTime;//会话结束时间 + @Expose + @ExcelField(title="server_ip",sort=40) + protected String serverIp; //服务端ip地址 + @Expose + @ExcelField(title="client_ip",sort=41) + protected String clientIp; //客户端ip地址 + @Expose + @ExcelField(title="server_port",sort=42) + protected String serverPort; //服务端ip端口 + @Expose + @ExcelField(title="client_port",sort=43) + protected String clientPort; //客户端ip端口 + @ExcelField(title="entrance_id",dictType="ENTRANCE",sort=7) + protected Integer entranceId; //出入口编号 + @ExcelField(title="deviceid",dictType="DEVICE",sort=50) + protected Integer deviceId; //串联设备编号 + @ExcelField(title="direction",dictType="LOG_DIRECTION",sort=55) + protected Integer direction; //传输方向 0:域内->域外,1:域外->域内,从字典LOG_DIRECTION取值 + @ExcelField(title="stream_type",dictType="LOG_STREAM_TYPE",sort=65) + protected Integer streamDir; //流类型 0:c2s;1:s2c;2:double,从字典LOG_STREAMTYPE取值 + @ExcelField(title="clj_ip",sort=27) + protected String capIp; //处理机IP + @ExcelField(title="nest_addr_list",sort=66) + protected String addrList; //嵌套地址列表 + @ExcelField(title="server_locate",sort=67) + protected String serverLocation;// 服务端地址定位信息 + @ExcelField(title="client_locate",sort=68) + protected String clientLocation;// 客户端地址定位信息 + @ExcelField(title="s_asn",sort=70) + protected String clientAsn;//客户端ASN + @ExcelField(title="d_asn",sort=71) + protected String serverAsn;//服务端ASN + @ExcelField(title="s_subscribe_id",sort=73) + protected String subscribeId;//客户端用户名 + @ExcelField(title="scene_file",sort=77) + protected String sceneFile;//现场日志文件地址 + + @ExcelField(title="isp",sort=80) + protected String isp;//运营商 + protected Integer service; //配置表的serviceId + protected Integer functionId; + @ExcelField(title="action",dictType="SERVICE_ACTION",sort=2) + protected Integer action; + //新增字段 + @ExcelField(title="encap_type",dictType="ENCAP_TYPE",sort=52) + protected Integer encapType;//原始二层封装格式 + @ExcelField(title="link_id",dictType="LINK",sort=51) + protected Integer linkId;//串联设备链路号 + @ExcelField(title="inner_smac",sort=58) + protected String innerSmac;//MAC_IN_MAC的内层源MAC + @ExcelField(title="inner_dmac",sort=59) + protected String innerDmac;//MAC_IN_MAC的内层目标MAC + //自定义字段 + protected String date;//配置界面日志总量查询时间 + protected String seltype;//选中类型,页面搜索用 + protected String searchFoundStartTime;//开始时间,格式为yyyy-mm-dd hh24:mi:ss + protected String searchFoundEndTime;//结束时间,格式同上 + protected String isLogTotalSearch;//由配置界面跳转日志查询标识 + protected String orderBy;//排序参数 + + @ExcelField(title="cfg_id",sort=1) + protected Integer compileId;// + protected String startRecvTime;//开始时间 + protected String endRecvTime; //结束时间 + @ExcelField(title="con_duration_ms",sort=81) + protected Integer conDurationMs;//通信时长 + protected String reqBodyKey;//请求体转储文件KEY + protected String resBodyKey;//应答体转储文件KEY + @ExcelField(title="version",sort=82) + protected String version;//版本 + @ExcelField(title="sni",sort=83) + protected String sni;// + @ExcelField(title="san",sort=84) + protected String san; + @ExcelField(title="cn",sort=85) + protected String cn; +// @ExcelField(title="social_app",sort=86) + protected Integer appId;//app + @ExcelField(title="social_app",sort=86) + protected String appName;//app +// @ExcelField(title="protocol",sort=87) + protected Integer protocolId;//协议 + @ExcelField(title="protocol",sort=87) + protected String protocolName;//协议 + @ExcelField(title="con_latency_ms",sort=88) + protected Integer conLatencyMs;//握手延迟 + @ExcelField(title="pinning",dictType="PINNING",sort=89) + protected Integer pinningst;//pinning状态 + @ExcelField(title="c2s_pkt_num",sort=90) + protected Integer c2sPktNum;//c2s包数 + @ExcelField(title="s2c_pkt_num",sort=91) + protected Integer s2cPktNum;//s2c包数 + @ExcelField(title="c2s_byte_num",sort=92) + protected Integer c2sByteNum;//c2s字节数 + @ExcelField(title="s2c_byte_num",sort=93) + protected Integer s2cByteNum;//s2c字节数 + @ExcelField(title="nas_ip",sort=94) + protected String nasIp;//ISN接入的IP + @ExcelField(title="framed_ip",sort=95) + protected String framedIp;//用户IP地址 + @ExcelField(title="account",sort=96) + protected String account;//用户名 + @ExcelField(title="packet_type",dictType="MESSAGE_TYPE",sort=97) + protected Integer packetType;//报文类型 + + protected String dIp; + protected String sIp; + public String getProtocolName() { + return protocolName; + } + public void setProtocolName(String protocolName) { + this.protocolName = protocolName; + } + public String getAppName() { + return appName; + } + public void setAppName(String appName) { + this.appName = appName; + } + public String getdIp() { + return dIp; + } + public void setdIp(String dIp) { + this.dIp = dIp; + } + public String getsIp() { + return sIp; + } + public void setsIp(String sIp) { + this.sIp = sIp; + } + public String getAppProto() { + return appProto; + } + public void setAppProto(String appProto) { + this.appProto = appProto; + } + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + public String getReqLine() { + return reqLine; + } + public void setReqLine(String reqLine) { + this.reqLine = reqLine; + } + public String getResLine() { + return resLine; + } + public void setResLine(String resLine) { + this.resLine = resLine; + } + public String getCookie() { + return cookie; + } + public void setCookie(String cookie) { + this.cookie = cookie; + } + public String getReferer() { + return referer; + } + public void setReferer(String referer) { + this.referer = referer; + } + public String getUserAgent() { + return userAgent; + } + public void setUserAgent(String userAgent) { + this.userAgent = userAgent; + } + public String getContentLen() { + return contentLen; + } + public void setContentLen(String contentLen) { + this.contentLen = contentLen; + } + public String getContentType() { + return contentType; + } + public void setContentType(String contentType) { + this.contentType = contentType; + } + public String getSetCookie() { + return setCookie; + } + public void setSetCookie(String setCookie) { + this.setCookie = setCookie; + } + public String getReqHeader() { + return reqHeader; + } + public void setReqHeader(String reqHeader) { + this.reqHeader = reqHeader; + } + public String getRespHeader() { + return respHeader; + } + public void setRespHeader(String respHeader) { + this.respHeader = respHeader; + } + public String getReqBody() { + return reqBody; + } + public void setReqBody(String reqBody) { + this.reqBody = reqBody; + } + public String getRespBody() { + return respBody; + } + public void setRespBody(String respBody) { + this.respBody = respBody; + } +// public String getWebsite() { +// return website; +// } +// public void setWebsite(String website) { +// this.website = website; +// } + public String getHost() { + return host; + } + public void setHost(String host) { + this.host = host; + } + public String getDomain() { + return domain; + } + public void setDomain(String domain) { + this.domain = domain; + } + public String getCategory() { + return category; + } + public void setCategory(String category) { + this.category = category; + } + public String getIsp() { + return isp; + } + public void setIsp(String isp) { + this.isp = isp; + } + public String getPolicyId() { + return policyId; + } + public void setPolicyId(String policyId) { + this.policyId = policyId; + } + public String getStartTime() { + return startTime; + } + public void setStartTime(String startTime) { + this.startTime = startTime; + } + public String getEndTime() { + return endTime; + } + public void setEndTime(String endTime) { + this.endTime = endTime; + } + public String getServerIp() { + return serverIp; + } + public void setServerIp(String serverIp) { + this.serverIp = serverIp; + } + public String getClientIp() { + return clientIp; + } + public void setClientIp(String clientIp) { + this.clientIp = clientIp; + } + public String getServerPort() { + return serverPort; + } + public void setServerPort(String serverPort) { + this.serverPort = serverPort; + } + public String getClientPort() { + return clientPort; + } + public void setClientPort(String clientPort) { + this.clientPort = clientPort; + } + public String getServerLocation() { + return serverLocation; + } + public void setServerLocation(String serverLocation) { + this.serverLocation = serverLocation; + } + public String getClientLocation() { + return clientLocation; + } + public void setClientLocation(String clientLocation) { + this.clientLocation = clientLocation; + } + public String getClientAsn() { + return clientAsn; + } + public void setClientAsn(String clientAsn) { + this.clientAsn = clientAsn; + } + public String getServerAsn() { + return serverAsn; + } + public void setServerAsn(String serverAsn) { + this.serverAsn = serverAsn; + } + public String getSubscribeId() { + return subscribeId; + } + public void setSubscribeId(String subscribeId) { + this.subscribeId = subscribeId; + } + public Integer getConDurationMs() { + return conDurationMs; + } + public void setConDurationMs(Integer conDurationMs) { + this.conDurationMs = conDurationMs; + } + public String getReqBodyKey() { + return reqBodyKey; + } + public void setReqBodyKey(String reqBodyKey) { + this.reqBodyKey = reqBodyKey; + } + public String getResBodyKey() { + return resBodyKey; + } + public void setResBodyKey(String resBodyKey) { + this.resBodyKey = resBodyKey; + } + public String getVersion() { + return version; + } + public void setVersion(String version) { + this.version = version; + } + public String getSni() { + return sni; + } + public void setSni(String sni) { + this.sni = sni; + } + public String getSan() { + return san; + } + public void setSan(String san) { + this.san = san; + } + public String getCn() { + return cn; + } + public void setCn(String cn) { + this.cn = cn; + } + public Integer getAppId() { + return appId; + } + public void setAppId(Integer appId) { + this.appId = appId; + } + public Integer getProtocolId() { + return protocolId; + } + public void setProtocolId(Integer protocolId) { + this.protocolId = protocolId; + } + public Integer getConLatencyMs() { + return conLatencyMs; + } + public void setConLatencyMs(Integer conLatencyMs) { + this.conLatencyMs = conLatencyMs; + } + public Integer getPinningst() { + return pinningst; + } + public void setPinningst(Integer pinningst) { + this.pinningst = pinningst; + } + public Integer getC2sPktNum() { + return c2sPktNum; + } + public void setC2sPktNum(Integer c2sPktNum) { + this.c2sPktNum = c2sPktNum; + } + public Integer getS2cPktNum() { + return s2cPktNum; + } + public void setS2cPktNum(Integer s2cPktNum) { + this.s2cPktNum = s2cPktNum; + } + public Integer getC2sByteNum() { + return c2sByteNum; + } + public void setC2sByteNum(Integer c2sByteNum) { + this.c2sByteNum = c2sByteNum; + } + public Integer getS2cByteNum() { + return s2cByteNum; + } + public void setS2cByteNum(Integer s2cByteNum) { + this.s2cByteNum = s2cByteNum; + } + public String getNasIp() { + return nasIp; + } + public void setNasIp(String nasIp) { + this.nasIp = nasIp; + } + public String getFramedIp() { + return framedIp; + } + public void setFramedIp(String framedIp) { + this.framedIp = framedIp; + } + public String getAccount() { + return account; + } + public void setAccount(String account) { + this.account = account; + } + public Integer getPacketType() { + return packetType; + } + public void setPacketType(Integer packetType) { + this.packetType = packetType; + } + public Integer getCompileId() { + return compileId; + } + public void setCompileId(Integer compileId) { + this.compileId = compileId; + } + public String getStartRecvTime() { + return startRecvTime; + } + public void setStartRecvTime(String startRecvTime) { + this.startRecvTime = startRecvTime; + } + public String getEndRecvTime() { + return endRecvTime; + } + public void setEndRecvTime(String endRecvTime) { + this.endRecvTime = endRecvTime; + } + public String getFoundTime() { + return foundTime; + } + public void setFoundTime(String foundTime) { + this.foundTime = foundTime; + } + public String getRecvTime() { + return recvTime; + } + public void setRecvTime(String recvTime) { + this.recvTime = recvTime; + } + public String getTransProto() { + return transProto; + } + public void setTransProto(String transProto) { + this.transProto = transProto; + } + public Integer getAddrType() { + return addrType; + } + public void setAddrType(Integer addrType) { + this.addrType = addrType; + } + public Integer getEntranceId() { + return entranceId; + } + public void setEntranceId(Integer entranceId) { + this.entranceId = entranceId; + } + public Integer getDeviceId() { + return deviceId; + } + public void setDeviceId(Integer deviceId) { + this.deviceId = deviceId; + } + public Integer getDirection() { + return direction; + } + public void setDirection(Integer direction) { + this.direction = direction; + } + public Integer getStreamDir() { + return streamDir; + } + public void setStreamDir(Integer streamDir) { + this.streamDir = streamDir; + } + public String getCapIp() { + return capIp; + } + public void setCapIp(String capIp) { + this.capIp = capIp; + } + public String getAddrList() { + return addrList; + } + public void setAddrList(String addrList) { + this.addrList = addrList; + } + public String getSceneFile() { + return sceneFile; + } + public void setSceneFile(String sceneFile) { + this.sceneFile = sceneFile; + } + public Integer getService() { + return service; + } + public void setService(Integer service) { + this.service = service; + } + public Integer getFunctionId() { + return functionId; + } + public void setFunctionId(Integer functionId) { + this.functionId = functionId; + } + public Integer getAction() { + return action; + } + public void setAction(Integer action) { + this.action = action; + } + public Integer getEncapType() { + return encapType; + } + public void setEncapType(Integer encapType) { + this.encapType = encapType; + } + public Integer getLinkId() { + return linkId; + } + public void setLinkId(Integer linkId) { + this.linkId = linkId; + } + public String getInnerSmac() { + return innerSmac; + } + public void setInnerSmac(String innerSmac) { + this.innerSmac = innerSmac; + } + public String getInnerDmac() { + return innerDmac; + } + public void setInnerDmac(String innerDmac) { + this.innerDmac = innerDmac; + } + public String getDate() { + return date; + } + public void setDate(String date) { + this.date = date; + } + public String getSeltype() { + return seltype; + } + public void setSeltype(String seltype) { + this.seltype = seltype; + } + public String getSearchFoundStartTime() { + return searchFoundStartTime; + } + public void setSearchFoundStartTime(String searchFoundStartTime) { + this.searchFoundStartTime = searchFoundStartTime; + } + public String getSearchFoundEndTime() { + return searchFoundEndTime; + } + public void setSearchFoundEndTime(String searchFoundEndTime) { + this.searchFoundEndTime = searchFoundEndTime; + } + public String getIsLogTotalSearch() { + return isLogTotalSearch; + } + public void setIsLogTotalSearch(String isLogTotalSearch) { + this.isLogTotalSearch = isLogTotalSearch; + } + public String getOrderBy() { + return orderBy; + } + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + + +} diff --git a/src/main/java/com/nis/util/Constants.java b/src/main/java/com/nis/util/Constants.java index 7a57c1c84..e72de6877 100644 --- a/src/main/java/com/nis/util/Constants.java +++ b/src/main/java/com/nis/util/Constants.java @@ -831,6 +831,10 @@ public final class Constants { * 查询的是流量统计菜单-配置统计中SubscriberID统计的数据接口 */ public static final String TRAFFIC_SUBSCRIBER_ID_STATISTIC_NEW=Configurations.getStringProperty("trafficSubscriberIDStatisticNew","trafficSubscriberIDStatisticNew"); + /** + * HTTP(S)操控日志接口 + */ + public static final String POLICY_EVENT=Configurations.getStringProperty("policyevent","policyevent"); } diff --git a/src/main/java/com/nis/web/controller/log/pxy/PxyHttpManipulLogController.java b/src/main/java/com/nis/web/controller/log/pxy/PxyHttpManipulLogController.java new file mode 100644 index 000000000..aa44382c3 --- /dev/null +++ b/src/main/java/com/nis/web/controller/log/pxy/PxyHttpManipulLogController.java @@ -0,0 +1,335 @@ +package com.nis.web.controller.log.pxy; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.Page; +import com.nis.domain.PageLog; +import com.nis.domain.SysDataDictionaryItem; +import com.nis.domain.SysUser; +import com.nis.domain.configuration.AppIpCfg; +import com.nis.domain.log.BaseLogEntity; +import com.nis.domain.log.PxyHttpLog; +import com.nis.domain.log.PxyHttpManipulationLog; +import com.nis.domain.maat.LogRecvData; +import com.nis.domain.specific.SpecificServiceCfg; +import com.nis.util.CodeDicUtils; +import com.nis.util.Constants; +import com.nis.util.DateUtils; +import com.nis.util.DictUtils; +import com.nis.util.LogUtils; +import com.nis.util.StringUtil; +import com.nis.util.httpclient.HttpClientUtil; +import com.nis.web.controller.BaseController; +import com.nis.web.dao.dashboard.codedic.CodeResult; +import com.nis.web.security.UserUtils; + +@Controller +@RequestMapping("${adminPath}/log/pxy") +public class PxyHttpManipulLogController extends BaseController{ + + @RequestMapping(value = "/httpManipulList") + public String list(@ModelAttribute("log") PxyHttpManipulationLog log, Model model, HttpServletRequest request, + HttpServletResponse response) { + try { + + PageLog page = new PageLog(request, response); + Map params = new HashMap(); + params.put("pageSize", page.getPageSize()); + params.put("pageNo", page.getPageNo()); + if (StringUtils.isNotBlank(log.getDomain())) { + String domain = StringEscapeUtils.unescapeHtml(log.getDomain()); + params.put("searchDomain", domain); + } + if (StringUtils.isNotBlank(log.getUrl())) { + String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl()); + params.put("searchUrl", httpurl); + } + if (StringUtils.isNotBlank(log.getsIp())) { + log.setClientIp(log.getsIp()); + } + if (StringUtils.isNotBlank(log.getdIp())) { + log.setServerIp(log.getdIp()); + } + initLogSearchValues(log, params); + + List serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId()); + model.addAttribute("serviceList", serviceList); + String url = Constants.LOG_BASE_URL + Constants.POLICY_EVENT; + String recv = HttpClientUtil.getMsg(url, params, request); + + Gson gson = new GsonBuilder().create(); + + LogRecvData fromJson = gson.fromJson(recv, new TypeToken>() { + }.getType()); + if (fromJson.getStatus().intValue() == 200) { + Page data = fromJson.getData(); + page.setCount(data.getCount()); + page.setLast(data.getLast()); + page.setList(data.getList()); + List list = page.getList(); + List protocolCodeList = CodeDicUtils.getCodeList("protocolCode"); + List appCodeList = CodeDicUtils.getCodeList("appCode"); + for (PxyHttpManipulationLog l : list) { + l.setFunctionId(log.getFunctionId()); +// setLogAction(l, serviceList); + l.setStartTime(timeStamp2Date(l.getStartTime(),null)); + l.setEndTime(timeStamp2Date(l.getEndTime(),null)); + l.setRecvTime(timeStamp2Date(l.getRecvTime(),null)); + for (CodeResult code : appCodeList) { + Integer value3 = Integer.valueOf(code.getCode()); + if(l.getAppId().equals(value3)){ + l.setAppName(code.getItem()); + break; + } + } + for (CodeResult code : protocolCodeList) { + Integer value3 = Integer.valueOf(code.getCode()); + if(l.getProtocolId().equals(value3)){ + l.setProtocolName(code.getItem()); + break; + } + } + } + } + + model.addAttribute("page", page); + } catch (Exception e) { + logger.error("查询失败", e); + addMessageLog(model, e.getMessage()); + LogUtils.saveLog(request, null, e, null); + } + + return "/log/pxy/pxyHttpManipulationList"; + } + + // 导出 + @RequestMapping(value = "exportPxyHttpManipul") + public void exportPxy(@ModelAttribute("log") PxyHttpManipulationLog log, Model model, String hColumns, String type, + HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + List titleList = new ArrayList(); + Map> classMap = new HashMap>(); + Map dataMap = new HashMap(); + Map noExportMap = new HashMap(); + // --------------------------- + PageLog page = new PageLog(request, response); + page.setPageNo(1); + page.setPageSize(Constants.MAX_LOG_EXPORT_SIZE); + Map params = new HashMap(); + params.put("pageSize", page.getPageSize()); + params.put("pageNo", page.getPageNo()); + if (StringUtils.isNotBlank(log.getsIp())) { + log.setClientIp(log.getsIp()); + } + if (StringUtils.isNotBlank(log.getdIp())) { + log.setServerIp(log.getdIp()); + } + initLogSearchValues(log, params); + if (StringUtils.isNotBlank(log.getUrl())) { + String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl()); + params.put("searchUrl", httpurl); + } + if (StringUtils.isNotBlank(log.getDomain())) { + String domain = StringEscapeUtils.unescapeHtml(log.getDomain()); + params.put("searchDomain", domain); + } + List serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId()); + System.out.print(log.getFunctionId()); + model.addAttribute("serviceList", serviceList); + + + String url = Constants.LOG_BASE_URL + Constants.POLICY_EVENT; + String recv = HttpClientUtil.getMsg(url, params, request); + List list = new ArrayList(); + if (StringUtils.isNotBlank(recv)) { + Gson gson = new GsonBuilder().create(); + LogRecvData fromJson = gson.fromJson(recv, new TypeToken>() { + }.getType()); + if (fromJson.getStatus().intValue() == 200) { + Page data = fromJson.getData(); + list = data.getList(); + } + } + List protocolCodeList = CodeDicUtils.getCodeList("protocolCode"); + List appCodeList = CodeDicUtils.getCodeList("appCode"); + for (PxyHttpManipulationLog l : list) { + l.setFunctionId(log.getFunctionId()); + l.setStartTime(timeStamp2Date(l.getStartTime(),null)); + l.setEndTime(timeStamp2Date(l.getEndTime(),null)); + l.setRecvTime(timeStamp2Date(l.getRecvTime(),null)); + for (CodeResult code : appCodeList) { + Integer value3 = Integer.valueOf(code.getCode()); + if(l.getAppId().equals(value3)){ + l.setAppName(code.getItem()); + break; + } + } + for (CodeResult code : protocolCodeList) { + Integer value3 = Integer.valueOf(code.getCode()); + if(l.getProtocolId().equals(value3)){ + l.setProtocolName(code.getItem()); + break; + } + } + } + titleList.add("http_manipulation"); + classMap.put("http_manipulation", PxyHttpManipulationLog.class); + SysUser user = UserUtils.getUser(); + if (!user.isAdmin()) { + hColumns += ",scene_file,"; + } else { + hColumns += ","; + } + String cfgIndexInfoNoExport = ",req_header,resp_header,inner_smac,inner_dmac,nest_addr_list,scene_file," + + ",found_time," + + hColumns; + noExportMap.put("http_manipulation", cfgIndexInfoNoExport); + dataMap.put("http_manipulation", list); + String timeRange= initLogMaps(log,"http_manipulation"); + noExportMap.put("timeRange", timeRange); + if ("csv".equals(type)) { + this._exportCsv(model, request, response, redirectAttributes, "http_manipulation", titleList, classMap, + dataMap, noExportMap); + } else { + this._export(model, request, response, redirectAttributes, "http_manipulation", titleList, classMap, dataMap, + noExportMap); + } + } catch (Exception e) { + logger.error("Http Manipulation export failed", e); + addMessage(redirectAttributes, "error", "export_failed"); + LogUtils.saveLog(request, null, e, null); + } + } + public void initLogSearchValues(PxyHttpManipulationLog entry, Map params) { + + if (StringUtils.isNotBlank(entry.getSearchFoundStartTime()) + && StringUtils.isNotBlank(entry.getSearchFoundEndTime())) { + params.put("searchStartRecvTime", date2TimeStamp(entry.getSearchFoundStartTime(),"yyyy-MM-dd HH:mm:ss")); + params.put("searchEndRecvTime", date2TimeStamp(entry.getSearchFoundEndTime(),"yyyy-MM-dd HH:mm:ss")); + } else { + // 判断是否是从配置界面过来的日志查询 + if (StringUtils.isNotBlank(entry.getIsLogTotalSearch())) { + Calendar time = Calendar.getInstance(); + String searchEndTime = DateUtils.formatDateTime(time.getTime()); + time.add(Calendar.MINUTE, -(Constants.LOG_TIME_RANGE/1000/60)); + String searchStartTime = DateUtils.formatDateTime(time.getTime()); + + params.put("searchStartRecvTime", searchStartTime); + params.put("searchEndRecvTime", searchEndTime); + entry.setSearchFoundStartTime(searchStartTime); + entry.setSearchFoundEndTime(searchEndTime); + } else { + // 设置默认查询当前时间及前五分钟 + String endTime = DateUtils.getDateTime(); + Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_INTERVAL); + String startTime = DateUtils.formatDateTime(dateStart); + params.put("searchStartRecvTime", String.valueOf(dateStart.getTime()/1000)); + params.put("searchEndRecvTime", date2TimeStamp(endTime,"yyyy-MM-dd HH:mm:ss")); + entry.setSearchFoundStartTime(startTime); + entry.setSearchFoundEndTime(endTime); + } + logger.info("searchStartRecvTime:" + params.get("searchStartRecvTime")); + logger.info("searchEndRecvTime:" + params.get("searchEndRecvTime")); + } + + if (StringUtils.isNotBlank(entry.getTransProto())) { + params.put("searchTransProto", entry.getTransProto()); + } + if (entry.getService() != null) { + params.put("searchService", entry.getService()); + } else if (entry.getAction() != null) { + List serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId()); + for (FunctionServiceDict dict : serviceList) { + if (dict.getAction().intValue() == entry.getAction().intValue() + && dict.getFunctionId().intValue() == entry.getFunctionId().intValue()) { + entry.setService(dict.getServiceId()); + params.put("searchService", dict.getServiceId()); + } + } + } + if (StringUtils.isNotBlank(entry.getServerIp())) { + params.put("searchServerIp", entry.getServerIp()); + } + if (StringUtils.isNotBlank(entry.getClientIp())) { + params.put("searchClientIp", entry.getClientIp()); + } + if (StringUtils.isNotBlank(entry.getCapIp())) { + params.put("searchCapIp", entry.getCapIp()); + } + if (entry.getDirection() != null) { + params.put("searchDirection", entry.getDirection()); + } + if (entry.getEntranceId() != null) { + params.put("searchEntranceId", entry.getEntranceId()); + } + if (entry.getCompileId() != null) { + params.put("searchCompileId", entry.getCompileId()); + } + if (StringUtils.isNotBlank(entry.getOrderBy())) { + params.put("orderBy", entry.getOrderBy()); + } + } + + public String initLogMaps(PxyHttpManipulationLog log,String title){ + Properties msgProp = getMsgProp(); + String logTime=msgProp.getProperty(title,title);; + if(log.getSearchFoundStartTime()!=null){ + logTime+=" "+msgProp.getProperty("begin_date")+":"+log.getSearchFoundStartTime(); + } + if(log.getSearchFoundEndTime()!=null){ + logTime+=" "+msgProp.getProperty("end_date")+":"+log.getSearchFoundEndTime(); + } + return logTime; + } + /** + * 日期格式字符串转换成时间戳 + * @param date 字符串日期 + * @param format 如:yyyy-MM-dd HH:mm:ss + * @return + */ + public static String date2TimeStamp(String date_str,String format){ + try { + SimpleDateFormat sdf = new SimpleDateFormat(format); + return String.valueOf(sdf.parse(date_str).getTime()/1000); + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } + /** + * 时间戳转换成日期格式字符串 + * @param seconds 精确到秒的字符串 + * @param formatStr + * @return + */ + public static String timeStamp2Date(String seconds,String format) { + if(seconds == null || seconds.isEmpty() || seconds.equals("null")){ + return ""; + } + if(format == null || format.isEmpty()) format = "yyyy-MM-dd HH:mm:ss"; + SimpleDateFormat sdf = new SimpleDateFormat(format); + return sdf.format(new Date(Long.valueOf(seconds+"000"))); + } +} diff --git a/src/main/resources/ni1s.properties b/src/main/resources/nis.properties similarity index 99% rename from src/main/resources/ni1s.properties rename to src/main/resources/nis.properties index 97d22ee35..c51c5ed9e 100644 --- a/src/main/resources/ni1s.properties +++ b/src/main/resources/nis.properties @@ -538,4 +538,6 @@ trafficSourceIPStatisticNew=v2/trafficSourceIPStatistic #\u67e5\u8be2\u6d41\u91cf\u7edf\u8ba1\u83dc\u5355-\u7edf\u8ba1\u4e2dServerIP\u7edf\u8ba1\u7684\u6570\u636e\u63a5\u53e3 trafficDestIPStatisticNew=v2/trafficDestIPStatistic #\u67e5\u8be2\u6d41\u91cf\u7edf\u8ba1\u83dc\u5355-\u7edf\u8ba1\u4e2dSubscriberID\u7edf\u8ba1\u7684\u6570\u636e\u63a5\u53e3 -trafficSubscriberIDStatisticNew=v2/trafficSubscriberIDStatistic \ No newline at end of file +trafficSubscriberIDStatisticNew=v2/trafficSubscriberIDStatistic +#HTTP(S)\u64cd\u63a7\u65e5\u5fd7\u63a5\u53e3 +policyevent=v1/policyevent \ No newline at end of file diff --git a/src/main/resources/sql/20190531/add_dict.sql b/src/main/resources/sql/20190531/add_dict.sql new file mode 100644 index 000000000..cc462ddc0 --- /dev/null +++ b/src/main/resources/sql/20190531/add_dict.sql @@ -0,0 +1,8 @@ + +#添加HTTP(s)操控日志 pinningst字段的字典内容 +INSERT INTO `sys_data_dictionary_name` ( `module_name`, `mark`, `remark`, `revision`, `create_time`, `modify_time`, `status`) VALUES ( 'HTTP(S)操控日志', 'PINNING', 'pinning状态', 'user:ceiec,2019-05-31 10:02:51edit', '2019-05-31 10:02:13', '2019-05-31 10:02:51', '1'); +#sys_data_dictionary_item 表中的dictionary_id 为 sys_data_dictionary_name 表生成的主键ID的值 +INSERT INTO `sys_data_dictionary_item` ( `item_code`, `item_value`, `item_desc`, `item_sort`, `status`, `type`, `dictionary_id`) VALUES ('4143', '0', 'not pinning', '', '1', '1', '1', '161'); +INSERT INTO `sys_data_dictionary_item` ( `item_code`, `item_value`, `item_desc`, `item_sort`, `status`, `type`, `dictionary_id`) VALUES ('4144', '1', 'pinning', '', '2', '1', '1', '161'); +INSERT INTO `sys_data_dictionary_item` ( `item_code`, `item_value`, `item_desc`, `item_sort`, `status`, `type`, `dictionary_id`) VALUES ('4145', '2', 'maybe pinning', '', '3', '1', '1', '161'); + diff --git a/src/main/webapp/WEB-INF/views/dashboard/configStatisticList.jsp b/src/main/webapp/WEB-INF/views/dashboard/configStatisticList.jsp new file mode 100644 index 000000000..7caafac82 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/dashboard/configStatisticList.jsp @@ -0,0 +1,410 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="config_statistics"></spring:message> + + + + + + + + + + + + +
+ <%--

+ +

--%> + +
+
+
+ + + + +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+ + + + + +
+
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+
+ + +
+ +
+
+ + +
+
+ +
+ href="javascript:;"> + + +
+
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + +
${log.cfgId}${log.cfgDesc }${log.sum }
+
${page}
+ +
+ +
+
+
+
+ + + +<%-- --%> + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/log/pxy/pxyHttpManipulationList.jsp b/src/main/webapp/WEB-INF/views/log/pxy/pxyHttpManipulationList.jsp new file mode 100644 index 000000000..e3ddbae00 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/log/pxy/pxyHttpManipulationList.jsp @@ -0,0 +1,511 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + + + <spring:message code="http_manipulation"/><spring:message code="log"/> + + + + + +
+ +

+ +

+ +
+
+
+
+ + + + + + + + +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ + + +
+
+
+ + +
+ href="javascript:;"> + + +
+
+ + + +
+
+
+
+ + + + + + + +
+
+ +
+
+ + +
+
+
+
+ + + + + + + +
+
+
+
+ + +
+
+
+
+ + +
+
+ <%--
+
+ + + + + + + +
+
--%> +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ + + + + + + <%-- --%> + + + + + + + + + + + + + + + + + + + + + <%-- + --%> + <%-- + --%> + + + + + + + + + + + + + + + <%-- + --%> + + + <%-- --%> + + + + + + <%-- --%> + <%-- --%> + <%-- --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- --%> + + + + + + + + + + + + + + + + + + + + + <%-- + --%> + + + + + + + + + + + + + + + <%-- + --%> + + + <%-- --%> + + + + + + <%-- --%> + <%-- --%> + <%-- --%> +<%-- --%> +<%-- --%> + + + + + + + + + + + + + + + + + + + + + + + + +
URL        
+<%-- + --%> + ${log.compileId } + ${log.action } + + + ${dict.itemValue} + + + + ${log.foundTime }${log.startTime }${log.endTime }${log.recvTime } + ${log.entranceId } + + + ${dic.itemValue} + + + + + ${log.url} + <%-- + ${log.url} + + + http://${log.url} + --%> + ${log.host }${log.domain }${log.category }${log.reqLine }${log.resLine }${log.cookie }${log.referer }${log.userAgent }${log.contentLen }${log.contentType }${log.setCookie }${log.reqHeader }${log.respHeader }${log.capIp} + ${log.transProto } + + + ${dic.itemValue} + + + + ${log.appProto} + ${log.addrType } + + + ${dic.itemValue} + + + + ${log.serverIp}${log.clientIp}${log.serverPort }${log.clientPort } + ${log.deviceId } + + + ${device.itemValue} + + + + + ${log.linkId } + + + ${link.itemValue} + + + + + ${log.encapType } + + + ${encapType.itemValue} + + + + + ${log.direction } + + + ${direction.itemValue} + + + + ${log.innerSmac }${log.innerDmac } + ${log.streamDir } + + + ${streamType.itemValue} + + + + ${log.addrList }${log.serverLocation}${log.clientLocation}${log.clientAsn}${log.serverAsn}${log.subscribeId}${log.dSubscribeId}${log.userRegion}${log.sceneFile}${log.reqBody}${log.respBody} + + + ${fn:substring(log.reqBody,0,20) } + + + + + http://${fn:substring(log.reqBody,0,20) } + + + + + + ${fn:substring(log.respBody,0,20) } + + + + + http://${fn:substring(log.respBody,0,20) } + + + ${log.isp }${log.conDurationMs }${log.version }${log.sni }${log.san }${log.cn }${log.appName }${log.protocolName }${log.conLatencyMs } + ${log.pinningst } + + + ${pinningstType.itemValue} + + + + ${log.c2sPktNum }${log.s2cPktNum }${log.c2sByteNum }${log.s2cByteNum }${log.nasIp }${log.framedIp }${log.account } + ${log.packetType } + + + ${packetsType.itemValue} + + + +
+
${page}
+
+
+
+
+
+ + \ No newline at end of file