banip操作需要二次确认
This commit is contained in:
parent
ec0e94feec
commit
35bc01f6d3
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.yutou</groupId>
|
<groupId>com.yutou</groupId>
|
||||||
<artifactId>tools</artifactId>
|
<artifactId>tools</artifactId>
|
||||||
<version>1.0.7</version>
|
<version>1.0.7.1</version>
|
||||||
<name>tools</name>
|
<name>tools</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
@ -91,7 +91,9 @@ public class Tools {
|
|||||||
inputStream.close();
|
inputStream.close();
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
if (UpdateIp.nas_ip != null) {
|
if (UpdateIp.nas_ip != null) {
|
||||||
connection = (HttpURLConnection) new URL("http://" + UpdateIp.nas_ip + ":8000/localhome/bot/send.do?msg=" + URLEncoder.encode((title + "\n" + msg), "UTF-8") + "&token=zIrsh9TUZP2lfRW753PannG49E7VJvor").openConnection();
|
String url="http://" + UpdateIp.nas_ip + ":8000/localhome/bot/send.do?msg=" + URLEncoder.encode((title + "\n" + msg), "UTF-8") + "&token=zIrsh9TUZP2lfRW753PannG49E7VJvor";
|
||||||
|
System.out.println(url);
|
||||||
|
connection = (HttpURLConnection) new URL(url).openConnection();
|
||||||
connection.connect();
|
connection.connect();
|
||||||
inputStream=connection.getInputStream();
|
inputStream=connection.getInputStream();
|
||||||
i=inputStream.read();
|
i=inputStream.read();
|
||||||
|
@ -14,6 +14,8 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -68,28 +70,37 @@ public class userController {
|
|||||||
cc += value;
|
cc += value;
|
||||||
}
|
}
|
||||||
RedisTools.set("login", cc, 5 * 60 * 1000);
|
RedisTools.set("login", cc, 5 * 60 * 1000);
|
||||||
String token=UUID.randomUUID().toString().replace("-","");
|
String token = UUID.randomUUID().toString().replace("-", "");
|
||||||
RedisTools.set(token,Tools.getRemoteAddress(request),10 * 60 * 1000);
|
RedisTools.set(token, Tools.getRemoteAddress(request), 10 * 60 * 1000);
|
||||||
String url="http://tools.yutou233.cn/login/ban.do?token="+token;
|
String url = "http://tools.yutou233.cn/login/ban.do?token=" + token;
|
||||||
Tools.sendServer("管理后台登录验证码", "本次登录验证码为:" + cc
|
Tools.sendServer("管理后台登录验证码", "本次登录验证码为:" + cc
|
||||||
+ ",登录IP:" + Tools.getRemoteAddress(request)
|
+ ",登录IP:" + Tools.getRemoteAddress(request)
|
||||||
+ ",非正常登录,封禁IP:"+url);
|
+ ",非正常登录,封禁IP:" + url);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/login/ban.do")
|
@RequestMapping("/login/ban.do")
|
||||||
@ResponseBody
|
public void banIp(HttpServletResponse response, String token, String model) throws IOException {
|
||||||
public String banIp(String token){
|
String ip = RedisTools.get(token);
|
||||||
String ip=RedisTools.get(token);
|
PrintWriter writer = response.getWriter();
|
||||||
if(ip!=null){
|
if (ip != null && model != null && model.equals("yes")) {
|
||||||
JSONArray array = new JSONArray();
|
JSONArray array = null;
|
||||||
if (RedisTools.get("ban") != null) {
|
if (RedisTools.get("ban") != null) {
|
||||||
array = JSONArray.parseArray(RedisTools.get("bean"));
|
array = JSONArray.parseArray(RedisTools.get("bean"));
|
||||||
}
|
}
|
||||||
|
if(array==null){
|
||||||
|
array=new JSONArray();
|
||||||
|
}
|
||||||
array.add(ip);
|
array.add(ip);
|
||||||
RedisTools.set("ban",array.toJSONString());
|
RedisTools.set("ban", array.toJSONString());
|
||||||
return "已封禁";
|
writer.write("已封禁");
|
||||||
|
} else {
|
||||||
|
String url = "http://tools.yutou233.cn/login/ban.do?token=" + token + "&model=yes";
|
||||||
|
String html = "<div><a href=" + url + ">click my is ban this IP :" + ip + "</a></div>";
|
||||||
|
writer.write(html);
|
||||||
}
|
}
|
||||||
return "ERROR";
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/login/login.do", method = RequestMethod.POST)
|
@RequestMapping(value = "/login/login.do", method = RequestMethod.POST)
|
||||||
|
Loading…
Reference in New Issue
Block a user