update
This commit is contained in:
parent
cf5e4f56e7
commit
10c6967869
@ -6,12 +6,11 @@ import com.yutou.tools.ToolsApplication;
|
|||||||
import com.yutou.tools.mybatis.dao.UKeyDao;
|
import com.yutou.tools.mybatis.dao.UKeyDao;
|
||||||
import com.yutou.tools.mybatis.model.UKey;
|
import com.yutou.tools.mybatis.model.UKey;
|
||||||
import com.yutou.tools.mybatis.model.UKeyExample;
|
import com.yutou.tools.mybatis.model.UKeyExample;
|
||||||
import com.yutou.tools.utils.ConfigTools;
|
|
||||||
import com.yutou.tools.utils.HttpTools;
|
import com.yutou.tools.utils.HttpTools;
|
||||||
import com.yutou.tools.utils.RedisTools;
|
import com.yutou.tools.utils.RedisTools;
|
||||||
import com.yutou.tools.utils.Tools;
|
import com.yutou.tools.utils.Tools;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@ -66,6 +65,7 @@ public class tools {
|
|||||||
return ToolsApplication.version;
|
return ToolsApplication.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/public/request.do")
|
@RequestMapping("/public/request.do")
|
||||||
public String testRequest(HttpServletRequest request) {
|
public String testRequest(HttpServletRequest request) {
|
||||||
@ -81,11 +81,21 @@ public class tools {
|
|||||||
cookies.add(ck);
|
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();
|
Enumeration<String> enumeration = request.getHeaderNames();
|
||||||
while (enumeration != null && enumeration.hasMoreElements()) {
|
while (enumeration != null && enumeration.hasMoreElements()) {
|
||||||
String tmp = enumeration.nextElement();
|
String tmp = enumeration.nextElement();
|
||||||
header.put(tmp, request.getHeader(tmp));
|
header.put(tmp, request.getHeader(tmp));
|
||||||
}
|
}
|
||||||
|
String str = outputStream.toString(StandardCharsets.UTF_8);
|
||||||
|
System.out.println("str = " + str);
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("code", 0);
|
json.put("code", 0);
|
||||||
json.put("method", request.getMethod());
|
json.put("method", request.getMethod());
|
||||||
@ -95,7 +105,8 @@ public class tools {
|
|||||||
json.put("params", params);
|
json.put("params", params);
|
||||||
json.put("cookie", cookies);
|
json.put("cookie", cookies);
|
||||||
json.put("header", header);
|
json.put("header", header);
|
||||||
Tools.sendServer("打印请求", json.toJSONString());
|
System.out.println("json = " + json);
|
||||||
|
// Tools.sendServer("打印请求", json.toJSONString());
|
||||||
try {
|
try {
|
||||||
switch (RedisTools.get("request")) {
|
switch (RedisTools.get("request")) {
|
||||||
case "success":
|
case "success":
|
||||||
@ -148,115 +159,125 @@ public class tools {
|
|||||||
Tools.sendServer(title, msg);
|
Tools.sendServer(title, msg);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping(value="/tools/clash/get.do",produces ="text/plain;charset=utf-8")
|
@RequestMapping(value = "/tools/clash/get.do", produces = "text/plain;charset=utf-8")
|
||||||
public String getClash(){
|
public String getClash(String ssr) {
|
||||||
StringBuilder builder=new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
String ssrUrl=RedisTools.get("ssr");
|
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)) {
|
||||||
String text= HttpTools.get(url);
|
ssrUrl = ssr;
|
||||||
if(text==null){
|
}
|
||||||
|
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);
|
System.out.println("ssr is Null = " + url);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String[] tmp=text.split("\n");
|
String[] tmp = text.split("\n");
|
||||||
text=RedisTools.get("clash");
|
text = RedisTools.get("clash");
|
||||||
builder.append("mixed-port: 7890").append("\n");
|
builder.append("mixed-port: 7890").append("\n");
|
||||||
for (String s : tmp) {
|
for (String s : tmp) {
|
||||||
if("port: 7890".equals(s)||"socks-port: 7891".equals(s)){
|
if ("port: 7890".equals(s) || "socks-port: 7891".equals(s)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
builder.append(s).append("\n");
|
builder.append(s).append("\n");
|
||||||
if("rules:".equals(s.trim())){
|
if ("rules:".equals(s.trim())) {
|
||||||
if(text!=null){
|
if (text != null) {
|
||||||
JSONArray array=JSONArray.parseArray(text);
|
JSONArray array = JSONArray.parseArray(text);
|
||||||
for (Object o : array) {
|
for (Object o : array) {
|
||||||
builder.append(" ").append(((JSONObject)o).getString("url").trim()).append("\n");
|
builder.append(" ").append(((JSONObject) o).getString("url").trim()).append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/tools/clash/ssr.do")
|
@RequestMapping("/tools/clash/ssr.do")
|
||||||
public JSONObject setClashSSR(String url){
|
public JSONObject setClashSSR(String url) {
|
||||||
RedisTools.set("ssr",url);
|
RedisTools.set("ssr", url);
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("msg","OK~");
|
json.put("msg", "OK~");
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/tools/clash/getssr.do")
|
@RequestMapping("/tools/clash/getssr.do")
|
||||||
public JSONObject getClashSSR(){
|
public JSONObject getClashSSR() {
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("code",0);
|
json.put("code", 0);
|
||||||
json.put("data",RedisTools.get("ssr"));
|
json.put("data", RedisTools.get("ssr"));
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/tools/clash/list.do")
|
@RequestMapping("/tools/clash/list.do")
|
||||||
public JSONObject clashList(){
|
public JSONObject clashList() {
|
||||||
String text=RedisTools.get("clash");
|
String text = RedisTools.get("clash");
|
||||||
JSONArray array;
|
JSONArray array;
|
||||||
if(text!=null){
|
if (text != null) {
|
||||||
array=JSONArray.parseArray(text);
|
array = JSONArray.parseArray(text);
|
||||||
}else{
|
} else {
|
||||||
array=new JSONArray();
|
array = new JSONArray();
|
||||||
}
|
}
|
||||||
RedisTools.set("clash",array.toJSONString());
|
RedisTools.set("clash", array.toJSONString());
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("code",0);
|
json.put("code", 0);
|
||||||
json.put("msg","ok~");
|
json.put("msg", "ok~");
|
||||||
json.put("data",array);
|
json.put("data", array);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/tools/clash/add.do")
|
@RequestMapping("/tools/clash/add.do")
|
||||||
public JSONObject clashAddUrl(String url){
|
public JSONObject clashAddUrl(String url) {
|
||||||
String text=RedisTools.get("clash");
|
String text = RedisTools.get("clash");
|
||||||
JSONArray array;
|
JSONArray array;
|
||||||
if(text!=null){
|
if (text != null) {
|
||||||
array=JSONArray.parseArray(text);
|
array = JSONArray.parseArray(text);
|
||||||
}else{
|
} else {
|
||||||
array=new JSONArray();
|
array = new JSONArray();
|
||||||
}
|
}
|
||||||
JSONObject data=new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
data.put("url",url);
|
data.put("url", url);
|
||||||
array.add(data);
|
array.add(data);
|
||||||
RedisTools.set("clash",array.toJSONString());
|
RedisTools.set("clash", array.toJSONString());
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("code",0);
|
json.put("code", 0);
|
||||||
json.put("msg","ok~");
|
json.put("msg", "ok~");
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/tools/clash/del.do")
|
@RequestMapping("/tools/clash/del.do")
|
||||||
public JSONObject clashDelUrl(String url){
|
public JSONObject clashDelUrl(String url) {
|
||||||
String text=RedisTools.get("clash");
|
String text = RedisTools.get("clash");
|
||||||
JSONArray array;
|
JSONArray array;
|
||||||
if(text!=null){
|
if (text != null) {
|
||||||
array=JSONArray.parseArray(text);
|
array = JSONArray.parseArray(text);
|
||||||
}else{
|
} else {
|
||||||
array=new JSONArray();
|
array = new JSONArray();
|
||||||
}
|
}
|
||||||
int delIndex=-1;
|
int delIndex = -1;
|
||||||
for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
JSONObject item=array.getJSONObject(i);
|
JSONObject item = array.getJSONObject(i);
|
||||||
if(item.getString("url").trim().equals(url.trim())){
|
if (item.getString("url").trim().equals(url.trim())) {
|
||||||
delIndex=i;
|
delIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(delIndex!=-1){
|
if (delIndex != -1) {
|
||||||
array.remove(delIndex);
|
array.remove(delIndex);
|
||||||
}
|
}
|
||||||
RedisTools.set("clash",array.toJSONString());
|
RedisTools.set("clash", array.toJSONString());
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("code",0);
|
json.put("code", 0);
|
||||||
json.put("msg","ok~");
|
json.put("msg", "ok~");
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUid(HttpServletRequest request) {
|
public int getUid(HttpServletRequest request) {
|
||||||
String token = request.getParameter("token");
|
String token = request.getParameter("token");
|
||||||
if (StringUtils.isEmpty(token)) {
|
if (StringUtils.isEmpty(token)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user