This commit is contained in:
Yutousama 2023-03-06 15:25:41 +08:00
parent cf5e4f56e7
commit 10c6967869

View File

@ -6,12 +6,11 @@ import com.yutou.tools.ToolsApplication;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.UKey;
import com.yutou.tools.mybatis.model.UKeyExample;
import com.yutou.tools.utils.ConfigTools;
import com.yutou.tools.utils.HttpTools;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import lombok.SneakyThrows;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
@ -66,6 +65,7 @@ public class tools {
return ToolsApplication.version;
}
@SneakyThrows
@ResponseBody
@RequestMapping("/public/request.do")
public String testRequest(HttpServletRequest request) {
@ -81,11 +81,21 @@ public class tools {
cookies.add(ck);
}
}
BufferedInputStream stream = new BufferedInputStream(request.getInputStream());
byte[] bytes = new byte[1024];
int len = 0, size;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
while ((len = stream.read(bytes)) != -1) {
outputStream.write(bytes, 0, len);
outputStream.flush();
}
Enumeration<String> enumeration = request.getHeaderNames();
while (enumeration != null && enumeration.hasMoreElements()) {
String tmp = enumeration.nextElement();
header.put(tmp, request.getHeader(tmp));
}
String str = outputStream.toString(StandardCharsets.UTF_8);
System.out.println("str = " + str);
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("method", request.getMethod());
@ -95,7 +105,8 @@ public class tools {
json.put("params", params);
json.put("cookie", cookies);
json.put("header", header);
Tools.sendServer("打印请求", json.toJSONString());
System.out.println("json = " + json);
// Tools.sendServer("打印请求", json.toJSONString());
try {
switch (RedisTools.get("request")) {
case "success":
@ -148,12 +159,16 @@ public class tools {
Tools.sendServer(title, msg);
return "ok";
}
@ResponseBody
@RequestMapping(value = "/tools/clash/get.do", produces = "text/plain;charset=utf-8")
public String getClash(){
public String getClash(String ssr) {
StringBuilder builder = new StringBuilder();
String ssrUrl = RedisTools.get("ssr");
String url="http://127.0.0.1:25500/sub?target=clash&new_name=true&url="+URLEncoder.encode(ssrUrl, StandardCharsets.UTF_8) +"&insert=false&config=https%3A%2F%2Fgit.yutou233.cn%2Fyutou%2FACL4SSR%2Fraw%2Fmaster%2FClash%2Fconfig%2FACL4SSR.ini";
if (!StringUtils.isEmpty(ssr)) {
ssrUrl = ssr;
}
String url = "http://127.0.0.1:25500/sub?target=clash&new_name=true&url=" + URLEncoder.encode(ssrUrl, StandardCharsets.UTF_8) + "&insert=false&config=https%3A%2F%2Fgit.yutou233.cn%2Fyutou%2FACL4SSR%2Fraw%2Fbranch%2Fmaster%2FClash%2Fconfig%2FACL4SSR_Online_Full.ini";
String text = HttpTools.get(url);
if (text == null) {
System.out.println("ssr is Null = " + url);
@ -178,6 +193,7 @@ public class tools {
}
return builder.toString();
}
@ResponseBody
@RequestMapping("/tools/clash/ssr.do")
public JSONObject setClashSSR(String url) {
@ -186,6 +202,7 @@ public class tools {
json.put("msg", "OK~");
return json;
}
@ResponseBody
@RequestMapping("/tools/clash/getssr.do")
public JSONObject getClashSSR() {
@ -194,6 +211,7 @@ public class tools {
json.put("data", RedisTools.get("ssr"));
return json;
}
@ResponseBody
@RequestMapping("/tools/clash/list.do")
public JSONObject clashList() {
@ -211,6 +229,7 @@ public class tools {
json.put("data", array);
return json;
}
@ResponseBody
@RequestMapping("/tools/clash/add.do")
public JSONObject clashAddUrl(String url) {
@ -230,6 +249,7 @@ public class tools {
json.put("msg", "ok~");
return json;
}
@ResponseBody
@RequestMapping("/tools/clash/del.do")
public JSONObject clashDelUrl(String url) {
@ -257,6 +277,7 @@ public class tools {
json.put("msg", "ok~");
return json;
}
public int getUid(HttpServletRequest request) {
String token = request.getParameter("token");
if (StringUtils.isEmpty(token)) {