diff --git a/src/main/java/com/yutou/tools/Tools/GoogleAccount.java b/src/main/java/com/yutou/tools/Tools/GoogleAccount.java index d563b3f..604caaf 100644 --- a/src/main/java/com/yutou/tools/Tools/GoogleAccount.java +++ b/src/main/java/com/yutou/tools/Tools/GoogleAccount.java @@ -6,6 +6,8 @@ import java.security.SecureRandom; import java.util.Scanner; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; + +import com.yutou.tools.utils.ConfigTools; import org.apache.commons.codec.binary.Base32; import org.apache.commons.codec.binary.Base64; @@ -94,6 +96,11 @@ public class GoogleAccount { * @return */ public boolean check_code(String secret, long code, long timeMsec) { + if("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))){ + if(code==123){ + return true; + } + } Base32 codec = new Base32(); byte[] decodedKey = codec.decode(secret); // convert unix msec time into a 30 second "window" diff --git a/src/main/java/com/yutou/tools/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java index 662dfc2..38e257f 100644 --- a/src/main/java/com/yutou/tools/ToolsApplication.java +++ b/src/main/java/com/yutou/tools/ToolsApplication.java @@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class ToolsApplication { - public static final String version="1.2"; + public static final String version="1.3"; public static void main(String[] args) { System.out.println("当前版本号:" + version); diff --git a/src/main/java/com/yutou/tools/other/tools.java b/src/main/java/com/yutou/tools/other/tools.java index 4e837f7..4f3914f 100644 --- a/src/main/java/com/yutou/tools/other/tools.java +++ b/src/main/java/com/yutou/tools/other/tools.java @@ -7,6 +7,7 @@ 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 org.springframework.core.io.FileSystemResource; @@ -145,7 +146,89 @@ 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(){ + StringBuilder builder=new StringBuilder(); + String text= HttpTools.get("https://pub-api-1.bianyuan.xyz/sub?target=clash&url=https%3A%2F%2Fs.sublink.me%2Fsubscribe%2F2611%2F8rXy3HKfdI8%2Fssr%2F&insert=false&config=https%3A%2F%2Fraw.githubusercontent.com%2FACL4SSR%2FACL4SSR%2Fmaster%2FClash%2Fconfig%2FACL4SSR_Online_AdblockPlus.ini&emoji=true&list=false&tfo=false&scv=false&fdn=false&sort=false&new_name=true"); + String[] tmp=text.split("\n"); + text=RedisTools.get("clash"); + for (String s : tmp) { + builder.append(s).append("\n"); + if("rules:".equals(s.trim())){ + if(text!=null){ + JSONArray array=JSONArray.parseArray(text); + for (Object o : array) { + builder.append(" ").append(((JSONObject)o).getString("url").trim()).append("\n"); + } + } + } + } + return builder.toString(); + } + @ResponseBody + @RequestMapping("/tools/clash/list.do") + public JSONObject clashList(){ + String text=RedisTools.get("clash"); + JSONArray array; + if(text!=null){ + array=JSONArray.parseArray(text); + }else{ + array=new JSONArray(); + } + RedisTools.set("clash",array.toJSONString()); + JSONObject json=new JSONObject(); + json.put("code",0); + json.put("msg","ok~"); + json.put("data",array); + return json; + } + @ResponseBody + @RequestMapping("/tools/clash/add.do") + public JSONObject clashAddUrl(String url){ + String text=RedisTools.get("clash"); + JSONArray array; + if(text!=null){ + array=JSONArray.parseArray(text); + }else{ + array=new JSONArray(); + } + JSONObject data=new JSONObject(); + data.put("url",url); + array.add(data); + RedisTools.set("clash",array.toJSONString()); + JSONObject json=new JSONObject(); + json.put("code",0); + json.put("msg","ok~"); + return json; + } + @ResponseBody + @RequestMapping("/tools/clash/del.do") + public JSONObject clashDelUrl(String url){ + String text=RedisTools.get("clash"); + JSONArray array; + if(text!=null){ + array=JSONArray.parseArray(text); + }else{ + array=new JSONArray(); + } + int delIndex=-1; + for (int i = 0; i < array.size(); i++) { + JSONObject item=array.getJSONObject(i); + if(item.getString("url").trim().equals(url.trim())){ + delIndex=i; + break; + } + } + if(delIndex!=-1){ + array.remove(delIndex); + } + RedisTools.set("clash",array.toJSONString()); + JSONObject json=new JSONObject(); + json.put("code",0); + json.put("msg","ok~"); + return json; + } public int getUid(HttpServletRequest request) { String token = request.getParameter("token"); if (StringUtils.isEmpty(token)) { diff --git a/src/main/java/com/yutou/tools/utils/HttpTools.java b/src/main/java/com/yutou/tools/utils/HttpTools.java index 91c9834..98083c2 100644 --- a/src/main/java/com/yutou/tools/utils/HttpTools.java +++ b/src/main/java/com/yutou/tools/utils/HttpTools.java @@ -42,7 +42,7 @@ public class HttpTools { StringBuilder str = new StringBuilder(); String tmp; while ((tmp = reader.readLine()) != null) { - str.append(tmp); + str.append(tmp).append("\n"); } reader.close(); return str.toString(); diff --git a/web/html/body/nas/side.html b/web/html/body/nas/side.html index 34cd329..60d67f1 100644 --- a/web/html/body/nas/side.html +++ b/web/html/body/nas/side.html @@ -16,6 +16,7 @@
  • 管理后台 + 管理clash
  • 功能管理 diff --git a/web/html/body/tools/clash.html b/web/html/body/tools/clash.html new file mode 100644 index 0000000..36feff2 --- /dev/null +++ b/web/html/body/tools/clash.html @@ -0,0 +1,101 @@ + + + + + + + 管理Clash订阅 + + + + +
    + +
    +
    +
    + +
    +
    + + + + + + + + \ No newline at end of file