更换了Redis的库

新增了对机器人的操作(redis)
This commit is contained in:
2020-05-27 14:40:25 +08:00
parent 2a06117ec7
commit d247235ca5
10 changed files with 239 additions and 137 deletions

View File

@@ -21,8 +21,6 @@ import java.util.List;
@Controller
public class NasManager {
@Resource
RedisTools redisTools;
@Resource
NasAdminAddressDao adminAddressDao;
@ResponseBody
@@ -30,7 +28,7 @@ public class NasManager {
public String getAdminAddress(HttpServletRequest request){
JSONObject json=new JSONObject();
String address=redisTools.get("adminAddress");
String address=RedisTools.get("adminAddress");
if(address==null){
json.put("code",-1);
json.put("msg","暂未设置管理后台");
@@ -136,7 +134,7 @@ public class NasManager {
try {
NasAdminAddress address=adminAddressDao.selectByPrimaryKey(Integer.parseInt(id));
if(address!=null){
redisTools.set("adminAddress",JSONObject.toJSONString(address));
RedisTools.set("adminAddress",JSONObject.toJSONString(address));
}
json.put("code",0);
json.put("msg","ok");

View File

@@ -24,9 +24,6 @@ import java.util.regex.Pattern;
public class UpdateIp {
private static List<String> keys = new ArrayList<>();
public static String nas_ip=null;
@Resource
RedisTools redisTools;
/* static {
keys.add("nas.yutou233.cn;");
keys.add("bt.yutou233.cn;");
@@ -64,7 +61,7 @@ public class UpdateIp {
if (testIp != null) {
System.out.println("检测到目标:" + line + " 修改IP " + testIp + " > " + ip);
if(isNas){
String adminAddress=redisTools.get("adminAddress");
String adminAddress=RedisTools.get("adminAddress");
if(adminAddress!=null) {
JSONObject json=JSONObject.parseObject(adminAddress);
line = "proxy_pass http://" +ip+":"+json.getInteger("port")+"/;";
@@ -100,41 +97,12 @@ public class UpdateIp {
JSONObject json = new JSONObject();
json.put("code", -1);
json.put("msg", "未登录");
if (Tools.checkWebLogin(request, redisTools) != 1) {
if (Tools.checkWebLogin(request) != 1) {
// return json.toJSONString();
}
updateList();
File file = new File("/etc/nginx/nginx.conf");
//file = new File("D:\\nginx.conf");
if (file.exists()) {
String testIp = "0.0.0.0";
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
boolean isIp = false;
while ((line = reader.readLine()) != null) {
// System.out.println(line.trim().replace("server_name","").replace("upstream","").trim());
if (keys.contains(line.trim().replace("server_name", "").replace("upstream", "").replace("{", "").trim())) {
isIp = true;
}
if (isIp) {
testIp = testIp(line);
if (testIp != null)
break;
}
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
json.put("code", 0);
json.put("msg", "ok");
json.put("data", testIp);
} else {
json.put("code", 0);
json.put("msg", "没有找到ip");
json.put("data", "0.0.0.0");
}
json.put("code", 0);
json.put("msg", "ok");
json.put("data", nas_ip);
return json.toJSONString();
}