1.proxy日志
2.处理长字符串、转义
This commit is contained in:
112
src/main/java/com/nis/domain/log/PxyHttpLog.java
Normal file
112
src/main/java/com/nis/domain/log/PxyHttpLog.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.nis.domain.log;
|
||||
|
||||
public class PxyHttpLog extends BaseLogEntity<NtcIpLog> {
|
||||
|
||||
private static final long serialVersionUID = -3046458130302949428L;
|
||||
|
||||
private String url;
|
||||
private String reqLine;
|
||||
private String resLine;
|
||||
private String cookie;
|
||||
private String referer;
|
||||
private String userAgent;
|
||||
private String contentLen;
|
||||
private String contentType;
|
||||
private String setCookie;
|
||||
private String reqHeader;
|
||||
private String respHeader;
|
||||
private String reqBody;
|
||||
private String resBody;
|
||||
|
||||
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 getResBody() {
|
||||
return resBody;
|
||||
}
|
||||
public void setResBody(String resBody) {
|
||||
this.resBody = resBody;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"url\"=\"" + url + "\", \"reqLine\"=\"" + reqLine
|
||||
+ "\", \"resLine\"=\"" + resLine + "\", \"cookie\"=\"" + cookie
|
||||
+ "\", \"referer\"=\"" + referer + "\", \"userAgent\"=\""
|
||||
+ userAgent + "\", \"contentLen\"=\"" + contentLen
|
||||
+ "\", \"contentType\"=\"" + contentType
|
||||
+ "\", \"setCookie\"=\"" + setCookie + "\", \"reqHeader\"=\""
|
||||
+ reqHeader + "\", \"respHeader\"=\"" + respHeader
|
||||
+ "\", \"reqBody\"=\"" + reqBody + "\", \"resBody\"=\""
|
||||
+ resBody + "\"}";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -417,6 +417,7 @@ public final class Constants {
|
||||
public static final String NTC_MMPORNVIDEOLEVEL_LOG = Configurations.getStringProperty("mmPornVideoLevelLog", "");
|
||||
public static final String NTC_MMSAMPLEPIC_LOG = Configurations.getStringProperty("mmSamplePicLog", "");
|
||||
public static final String NTC_MMSAMPLEVOIP_LOG = Configurations.getStringProperty("mmSampleVoipLog", "");
|
||||
public static final String PXY_HTTP_LOG = Configurations.getStringProperty("pxyHttpLog", "");
|
||||
|
||||
//报表类型,1- 配置命中总量业务
|
||||
public static final Integer BUSINESSTYPE_CONFIG=Configurations.getIntProperty("businesstype_config", 1);
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.nis.web.controller.log.pxy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
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.support.RequestContext;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.log.PxyHttpLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/log/pxy")
|
||||
public class PxyHttpLogController extends BaseController {
|
||||
|
||||
@RequestMapping(value = {"list", "ipInterceptlogs", "domainInterceptlogs", "httpBlocklogs",
|
||||
"httpRedirectlogs", "httpReplacelogs", "httpMonitogs"})
|
||||
public String list(@ModelAttribute("log") PxyHttpLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
setLogInfo(request, model, log);
|
||||
|
||||
PageLog<PxyHttpLog> page = new PageLog<PxyHttpLog>(request, response);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.PXY_HTTP_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
logger.info("查询结果:" + recv);
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
LogRecvData<PxyHttpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<PxyHttpLog>>(){}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
page.setList(fromJson.getData().getList());
|
||||
List<PxyHttpLog> list = page.getList();
|
||||
for (PxyHttpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l);
|
||||
}
|
||||
model.addAttribute("page", page);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("查询失败", e);
|
||||
addMessage(model, e.getMessage());
|
||||
}
|
||||
|
||||
return "/log/pxy/pxyHttpList";
|
||||
}
|
||||
|
||||
private void setLogInfo(HttpServletRequest request, Model model, PxyHttpLog log) {
|
||||
int functionId = log.getFunctionId();
|
||||
|
||||
RequestContext requestContext = new RequestContext(request);
|
||||
|
||||
if (functionId == 200) {
|
||||
model.addAttribute("logTitle", requestContext.getMessage("ip_intercept"));
|
||||
log.setAction(1);
|
||||
} else if (functionId == 201) {
|
||||
model.addAttribute("logTitle", requestContext.getMessage("domain_intercept"));
|
||||
log.setAction(1);
|
||||
} else if (functionId == 207) {
|
||||
model.addAttribute("logTitle", requestContext.getMessage("http_block"));
|
||||
log.setAction(16);
|
||||
} else if (functionId == 208) {
|
||||
model.addAttribute("logTitle", requestContext.getMessage("http_redirect"));
|
||||
log.setAction(48);
|
||||
} else if (functionId == 209) {
|
||||
model.addAttribute("logTitle", requestContext.getMessage("http_replace"));
|
||||
log.setAction(80);
|
||||
} else if (functionId == 210) {
|
||||
model.addAttribute("logTitle", requestContext.getMessage("http_monit"));
|
||||
log.setAction(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user