OuterIntfCtrl.java
4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package com.ui.ctrl;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.MonitAlarmInfo;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author yoho
* 对外提供接口
*
*/
@Controller
@RequestMapping("/outer")
public class OuterIntfCtrl {
Logger log = LoggerFactory.getLogger(OuterIntfCtrl.class);
@Autowired
private HttpRestClient httpClient;
/**
* 对外接口,提供报警
* @param info
* @return
*/
@RequestMapping("/recvMonitAlarm")
@ResponseBody
public BaseResponse recvMonitAlarm(@RequestBody MonitAlarmInfo info){
BaseResponse response=httpClient.defaultPost("/recvMonitAlarm",info,BaseResponse.class);
return response;
}
/**
* 对外接口,提供报警
* 举例
* http://www.yohops.com/outer/recvMonitAlarmInfo?info=短信内容&idc=yoho_aws&mobiles=15699999,18988888
*/
@RequestMapping(value="/recvMonitAlarmInfo" ,method= RequestMethod.POST,headers={"Accept=application/json","content-type=application/json"})
@ResponseBody
public BaseResponse recvMonitAlarmInfo(@RequestBody MonitAlarmInfo monitAlarmInfo,HttpServletRequest request ){
/*Enumeration e=request.getHeaderNames();
while(e.hasMoreElements()){
String key = (String)e.nextElement();//调用nextElement方法获得元素
System.out.println(key +"--->" +request.getHeader(key) );
}*/
log.info("recvMonitAlarmInfoPost {}",monitAlarmInfo);
BaseResponse response=httpClient.defaultPost("/recvMonitAlarmInfo",monitAlarmInfo,BaseResponse.class);
return response;
}
/**
* 对外接口,提供报警
* 举例
* http://www.yohops.com/outer/recvMonitAlarmInfo?info=短信内容&idc=yoho_aws&mobiles=15699999,18988888
*/
@RequestMapping(value="/recvMonitAlarmInfo")
@ResponseBody
public BaseResponse recvMonitAlarmInfoOther( MonitAlarmInfo monitAlarmInfo,HttpServletRequest request){
log.info("recvMonitAlarmInfoOther {}",monitAlarmInfo);
BaseResponse response=httpClient.defaultPost("/recvMonitAlarmInfo",monitAlarmInfo,BaseResponse.class);
return response;
}
/*@RequestMapping("/recvMonitAlarmInfo")
@ResponseBody
public BaseResponse recvMonitAlarmInfo(String info,String mobiles){
Map<String,String> map=new HashMap<>();
map.put("info",info);
map.put("mobiles",mobiles);
BaseResponse response=httpClient.defaultGet("/recvMonitAlarmInfo",BaseResponse.class,map);;
return response;
}*/
/**
* 捕获的恶意ip写入运维系统的redis
* 自动封杀和告警提示
* @return
*/
@RequestMapping("/writeMipsObjToOpsReids")
@ResponseBody
public void writeMipsObjToOpsReids(@RequestBody String ipsObjs) {
httpClient.defaultPostJson("/maliciousIp/writeMipsObjToOpsReids",ipsObjs,String.class);
}
/**
* 捕获的恶意ip写入运维系统的mysql
* 大数据算法
* @return
*/
@RequestMapping("/writeMipsInfoToOpsDb")
@ResponseBody
public void writeMipsInfoToOpsDb(@RequestBody String ipsObjs) {
httpClient.defaultPostJson("/maliciousIp/writeMipsInfoToOpsDb",ipsObjs,String.class);
}
/***
* DNS 更新接口
*/
@RequestMapping("/dnsJustForShell")
@ResponseBody
public String dnsJustForShell(String domain, String cloud, String type, String operate, String record, String value) {
if (StringUtils.isBlank(domain) || StringUtils.isBlank(cloud) || StringUtils.isBlank(operate)) {
return "param error";
}
Map<String, String> map=new HashMap<>();
map.put("domain",domain);
map.put("cloud",cloud);
map.put("operate",operate);
map.put("record",StringUtils.isBlank(record)?"":record);
map.put("type",StringUtils.isBlank(type)?"":type);
map.put("value",StringUtils.isBlank(value)?"":value);
return httpClient.defaultGet("/internalDns/justForShell",String.class,map);
}
/**
* 捕获的恶意ip写入运维系统的mysql
* 大数据算法
* @return
*/
@RequestMapping("/testsearch")
@ResponseBody
public BaseResponse testsearch() {
Map<String,String> map=new HashMap<>();
BaseResponse response=httpClient.get("http://search.yohoops.org/yohosearch/fuzzy/productList.json?query=卫衣&viewNum=30&uid=13420925",BaseResponse.class,map);
return response;
}
}