From 2c7a17c3b0cab3a5a3458dcd2a3b84280aee51c3 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Thu, 20 Apr 2023 17:43:55 +0800 Subject: [PATCH 01/48] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..bd74bbb --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# lz-cow-api +蓝奏云-奶牛快传的直链解析的API服务 From 167149f41060ba5357ba2403ecd399ea0f4d0105 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Fri, 21 Apr 2023 00:41:57 +0800 Subject: [PATCH 02/48] =?UTF-8?q?=E5=BF=BD=E7=95=A5=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ logs/20230420/run.log | 0 web/logs/20230420/run.log | 0 3 files changed, 3 insertions(+) delete mode 100644 logs/20230420/run.log delete mode 100644 web/logs/20230420/run.log diff --git a/.gitignore b/.gitignore index e80c373..9cb41bc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ .idea/ /.idea/ */.idea/ +logs/ +*/logs/ +*/generated/ *.iws *.iml *.ipr diff --git a/logs/20230420/run.log b/logs/20230420/run.log deleted file mode 100644 index e69de29..0000000 diff --git a/web/logs/20230420/run.log b/web/logs/20230420/run.log deleted file mode 100644 index e69de29..0000000 From 54a1a6b7f45de2b0cc9233ddb6a313e43b008e4f Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Fri, 21 Apr 2023 01:21:56 +0800 Subject: [PATCH 03/48] init --- .../{com/yhinfo => qaiu/vx}/core/Deploy.java | 12 +- .../vx}/core/annotaions/DateFormat.java | 2 +- .../vx}/core/annotaions/RouteHandler.java | 2 +- .../vx}/core/annotaions/RouteMapping.java | 6 +- .../vx}/core/annotaions/Service.java | 2 +- .../vx}/core/annotaions/SockRouteMapper.java | 2 +- .../vx}/core/base/BaseAsyncService.java | 6 +- .../vx}/core/base/BaseHttpApi.java | 2 +- .../vx}/core/enums/MIMEType.java | 2 +- .../vx}/core/enums/RouteMethod.java | 2 +- .../handlerfactory/RouterHandlerFactory.java | 18 +-- .../vx}/core/interceptor/Interceptor.java | 2 +- .../vx}/core/model/JsonResult.java | 2 +- .../vx}/core/util/AsyncServiceUtil.java | 2 +- .../vx}/core/util/CastUtil.java | 4 +- .../vx}/core/util/CommonUtil.java | 2 +- .../vx}/core/util/ConfigUtil.java | 2 +- .../vx}/core/util/LocalConstant.java | 2 +- .../vx}/core/util/ParamUtil.java | 2 +- .../vx}/core/util/ReflectionUtil.java | 2 +- .../vx}/core/util/SharedDataUtil.java | 2 +- .../vx}/core/util/SnowflakeIdWorker.java | 2 +- .../vx}/core/util/StringCase.java | 4 +- .../vx}/core/util/VertxHolder.java | 2 +- .../core/verticle/ReverseProxyVerticle.java | 10 +- .../vx}/core/verticle/RouterVerticle.java | 11 +- .../vx}/core/verticle/ServiceVerticle.java | 12 +- web/pom.xml | 2 +- .../common/model/MyDataParametersMapper.java | 28 ---- .../real/common/model/MyDataRowMapper.java | 29 ---- .../model/UserInfoParametersMapper.java | 30 ---- .../real/common/model/UserInfoRowMapper.java | 35 ----- .../web/service/DbServiceVertxEBProxy.java | 89 ----------- .../service/DbServiceVertxProxyHandler.java | 140 ------------------ .../web/service/UserServiceVertxEBProxy.java | 76 ---------- .../service/UserServiceVertxProxyHandler.java | 135 ----------------- .../java/cn/com/yhinfo/real/package-info.java | 10 -- .../{com/yhinfo/real => qaiu/lz}/AppMain.java | 4 +- .../real => qaiu/lz}/common/ToJson.java | 2 +- .../interceptorImpl/DefaultInterceptor.java | 14 +- .../real => qaiu/lz}/common/model/MyData.java | 2 +- .../lz}/common/model/UserInfo.java | 4 +- .../lz}/common/util/ArrayUtil.java | 2 +- .../lz}/common/util/ConnectUtil.java | 2 +- .../main/java/cn/qaiu/lz/package-info.java | 10 ++ .../real => qaiu/lz}/web/http/ServerApi.java | 24 +-- .../real => qaiu/lz}/web/model/RealUser.java | 4 +- .../lz}/web/service/DbService.java | 6 +- .../lz}/web/service/JdkProxyFactory.java | 6 +- .../lz}/web/service/ServiceJdkProxy.java | 2 +- .../lz}/web/service/UserService.java | 6 +- .../lz}/web/service/impl/DbServiceImpl.java | 10 +- .../lz}/web/service/impl/UserServiceImpl.java | 8 +- web/src/main/resources/app-dev.yml | 9 +- .../yhinfo => qaiu/web}/test/StompTest.java | 2 +- .../{com/yhinfo => qaiu/web}/test/Test01.java | 2 +- .../{com/yhinfo => qaiu/web}/test/Test02.java | 4 +- .../{com/yhinfo => qaiu/web}/test/TestOS.java | 4 +- .../web}/test/WebProxyExamples.java | 2 +- 59 files changed, 128 insertions(+), 694 deletions(-) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/Deploy.java (95%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/annotaions/DateFormat.java (91%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/annotaions/RouteHandler.java (91%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/annotaions/RouteMapping.java (85%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/annotaions/Service.java (91%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/annotaions/SockRouteMapper.java (88%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/base/BaseAsyncService.java (94%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/base/BaseHttpApi.java (96%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/enums/MIMEType.java (96%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/enums/RouteMethod.java (87%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/handlerfactory/RouterHandlerFactory.java (97%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/interceptor/Interceptor.java (89%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/model/JsonResult.java (99%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/AsyncServiceUtil.java (94%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/CastUtil.java (90%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/CommonUtil.java (99%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/ConfigUtil.java (98%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/LocalConstant.java (96%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/ParamUtil.java (97%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/ReflectionUtil.java (99%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/SharedDataUtil.java (98%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/SnowflakeIdWorker.java (99%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/StringCase.java (99%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/util/VertxHolder.java (94%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/verticle/ReverseProxyVerticle.java (97%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/verticle/RouterVerticle.java (87%) rename core/src/main/java/cn/{com/yhinfo => qaiu/vx}/core/verticle/ServiceVerticle.java (87%) delete mode 100644 web/src/main/generated/cn/com/yhinfo/real/common/model/MyDataParametersMapper.java delete mode 100644 web/src/main/generated/cn/com/yhinfo/real/common/model/MyDataRowMapper.java delete mode 100644 web/src/main/generated/cn/com/yhinfo/real/common/model/UserInfoParametersMapper.java delete mode 100644 web/src/main/generated/cn/com/yhinfo/real/common/model/UserInfoRowMapper.java delete mode 100644 web/src/main/generated/cn/com/yhinfo/real/web/service/DbServiceVertxEBProxy.java delete mode 100644 web/src/main/generated/cn/com/yhinfo/real/web/service/DbServiceVertxProxyHandler.java delete mode 100644 web/src/main/generated/cn/com/yhinfo/real/web/service/UserServiceVertxEBProxy.java delete mode 100644 web/src/main/generated/cn/com/yhinfo/real/web/service/UserServiceVertxProxyHandler.java delete mode 100644 web/src/main/java/cn/com/yhinfo/real/package-info.java rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/AppMain.java (87%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/common/ToJson.java (91%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/common/interceptorImpl/DefaultInterceptor.java (78%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/common/model/MyData.java (94%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/common/model/UserInfo.java (92%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/common/util/ArrayUtil.java (92%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/common/util/ConnectUtil.java (87%) create mode 100644 web/src/main/java/cn/qaiu/lz/package-info.java rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/web/http/ServerApi.java (79%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/web/model/RealUser.java (85%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/web/service/DbService.java (74%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/web/service/JdkProxyFactory.java (81%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/web/service/ServiceJdkProxy.java (94%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/web/service/UserService.java (68%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/web/service/impl/DbServiceImpl.java (80%) rename web/src/main/java/cn/{com/yhinfo/real => qaiu/lz}/web/service/impl/UserServiceImpl.java (63%) rename web/src/test/java/cn/{com/yhinfo => qaiu/web}/test/StompTest.java (97%) rename web/src/test/java/cn/{com/yhinfo => qaiu/web}/test/Test01.java (99%) rename web/src/test/java/cn/{com/yhinfo => qaiu/web}/test/Test02.java (98%) rename web/src/test/java/cn/{com/yhinfo => qaiu/web}/test/TestOS.java (99%) rename web/src/test/java/cn/{com/yhinfo => qaiu/web}/test/WebProxyExamples.java (99%) diff --git a/core/src/main/java/cn/com/yhinfo/core/Deploy.java b/core/src/main/java/cn/qaiu/vx/core/Deploy.java similarity index 95% rename from core/src/main/java/cn/com/yhinfo/core/Deploy.java rename to core/src/main/java/cn/qaiu/vx/core/Deploy.java index eb0ce52..52690b8 100644 --- a/core/src/main/java/cn/com/yhinfo/core/Deploy.java +++ b/core/src/main/java/cn/qaiu/vx/core/Deploy.java @@ -1,10 +1,10 @@ -package cn.com.yhinfo.core; +package cn.qaiu.vx.core; -import cn.com.yhinfo.core.util.ConfigUtil; -import cn.com.yhinfo.core.util.VertxHolder; -import cn.com.yhinfo.core.verticle.ReverseProxyVerticle; -import cn.com.yhinfo.core.verticle.ServiceVerticle; -import cn.com.yhinfo.core.verticle.RouterVerticle; +import cn.qaiu.vx.core.util.ConfigUtil; +import cn.qaiu.vx.core.util.VertxHolder; +import cn.qaiu.vx.core.verticle.ReverseProxyVerticle; +import cn.qaiu.vx.core.verticle.ServiceVerticle; +import cn.qaiu.vx.core.verticle.RouterVerticle; import io.vertx.core.*; import io.vertx.core.json.JsonObject; import io.vertx.core.shareddata.LocalMap; diff --git a/core/src/main/java/cn/com/yhinfo/core/annotaions/DateFormat.java b/core/src/main/java/cn/qaiu/vx/core/annotaions/DateFormat.java similarity index 91% rename from core/src/main/java/cn/com/yhinfo/core/annotaions/DateFormat.java rename to core/src/main/java/cn/qaiu/vx/core/annotaions/DateFormat.java index b7e67f1..3daa603 100644 --- a/core/src/main/java/cn/com/yhinfo/core/annotaions/DateFormat.java +++ b/core/src/main/java/cn/qaiu/vx/core/annotaions/DateFormat.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.annotaions; +package cn.qaiu.vx.core.annotaions; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/core/src/main/java/cn/com/yhinfo/core/annotaions/RouteHandler.java b/core/src/main/java/cn/qaiu/vx/core/annotaions/RouteHandler.java similarity index 91% rename from core/src/main/java/cn/com/yhinfo/core/annotaions/RouteHandler.java rename to core/src/main/java/cn/qaiu/vx/core/annotaions/RouteHandler.java index e1e555a..9ae86fc 100644 --- a/core/src/main/java/cn/com/yhinfo/core/annotaions/RouteHandler.java +++ b/core/src/main/java/cn/qaiu/vx/core/annotaions/RouteHandler.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.annotaions; +package cn.qaiu.vx.core.annotaions; import java.lang.annotation.*; diff --git a/core/src/main/java/cn/com/yhinfo/core/annotaions/RouteMapping.java b/core/src/main/java/cn/qaiu/vx/core/annotaions/RouteMapping.java similarity index 85% rename from core/src/main/java/cn/com/yhinfo/core/annotaions/RouteMapping.java rename to core/src/main/java/cn/qaiu/vx/core/annotaions/RouteMapping.java index 97bb762..ac6a2b5 100644 --- a/core/src/main/java/cn/com/yhinfo/core/annotaions/RouteMapping.java +++ b/core/src/main/java/cn/qaiu/vx/core/annotaions/RouteMapping.java @@ -1,7 +1,7 @@ -package cn.com.yhinfo.core.annotaions; +package cn.qaiu.vx.core.annotaions; -import cn.com.yhinfo.core.enums.MIMEType; -import cn.com.yhinfo.core.enums.RouteMethod; +import cn.qaiu.vx.core.enums.MIMEType; +import cn.qaiu.vx.core.enums.RouteMethod; import java.lang.annotation.*; diff --git a/core/src/main/java/cn/com/yhinfo/core/annotaions/Service.java b/core/src/main/java/cn/qaiu/vx/core/annotaions/Service.java similarity index 91% rename from core/src/main/java/cn/com/yhinfo/core/annotaions/Service.java rename to core/src/main/java/cn/qaiu/vx/core/annotaions/Service.java index 4b2e396..847cfef 100644 --- a/core/src/main/java/cn/com/yhinfo/core/annotaions/Service.java +++ b/core/src/main/java/cn/qaiu/vx/core/annotaions/Service.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.annotaions; +package cn.qaiu.vx.core.annotaions; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/core/src/main/java/cn/com/yhinfo/core/annotaions/SockRouteMapper.java b/core/src/main/java/cn/qaiu/vx/core/annotaions/SockRouteMapper.java similarity index 88% rename from core/src/main/java/cn/com/yhinfo/core/annotaions/SockRouteMapper.java rename to core/src/main/java/cn/qaiu/vx/core/annotaions/SockRouteMapper.java index 7665c2e..de1be77 100644 --- a/core/src/main/java/cn/com/yhinfo/core/annotaions/SockRouteMapper.java +++ b/core/src/main/java/cn/qaiu/vx/core/annotaions/SockRouteMapper.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.annotaions; +package cn.qaiu.vx.core.annotaions; import java.lang.annotation.*; diff --git a/core/src/main/java/cn/com/yhinfo/core/base/BaseAsyncService.java b/core/src/main/java/cn/qaiu/vx/core/base/BaseAsyncService.java similarity index 94% rename from core/src/main/java/cn/com/yhinfo/core/base/BaseAsyncService.java rename to core/src/main/java/cn/qaiu/vx/core/base/BaseAsyncService.java index 1376398..5f5c73f 100644 --- a/core/src/main/java/cn/com/yhinfo/core/base/BaseAsyncService.java +++ b/core/src/main/java/cn/qaiu/vx/core/base/BaseAsyncService.java @@ -1,6 +1,6 @@ -package cn.com.yhinfo.core.base; +package cn.qaiu.vx.core.base; -import cn.com.yhinfo.core.util.CastUtil; +import cn.qaiu.vx.core.util.CastUtil; import java.util.Arrays; @@ -36,4 +36,4 @@ public interface BaseAsyncService { } return clazz; } -} \ No newline at end of file +} diff --git a/core/src/main/java/cn/com/yhinfo/core/base/BaseHttpApi.java b/core/src/main/java/cn/qaiu/vx/core/base/BaseHttpApi.java similarity index 96% rename from core/src/main/java/cn/com/yhinfo/core/base/BaseHttpApi.java rename to core/src/main/java/cn/qaiu/vx/core/base/BaseHttpApi.java index b3f47a5..6de5ad0 100644 --- a/core/src/main/java/cn/com/yhinfo/core/base/BaseHttpApi.java +++ b/core/src/main/java/cn/qaiu/vx/core/base/BaseHttpApi.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.base; +package cn.qaiu.vx.core.base; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; diff --git a/core/src/main/java/cn/com/yhinfo/core/enums/MIMEType.java b/core/src/main/java/cn/qaiu/vx/core/enums/MIMEType.java similarity index 96% rename from core/src/main/java/cn/com/yhinfo/core/enums/MIMEType.java rename to core/src/main/java/cn/qaiu/vx/core/enums/MIMEType.java index b480ac9..4b11341 100644 --- a/core/src/main/java/cn/com/yhinfo/core/enums/MIMEType.java +++ b/core/src/main/java/cn/qaiu/vx/core/enums/MIMEType.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.enums; +package cn.qaiu.vx.core.enums; /** * MIMEType: request or response head diff --git a/core/src/main/java/cn/com/yhinfo/core/enums/RouteMethod.java b/core/src/main/java/cn/qaiu/vx/core/enums/RouteMethod.java similarity index 87% rename from core/src/main/java/cn/com/yhinfo/core/enums/RouteMethod.java rename to core/src/main/java/cn/qaiu/vx/core/enums/RouteMethod.java index fc34d62..f0a7d20 100644 --- a/core/src/main/java/cn/com/yhinfo/core/enums/RouteMethod.java +++ b/core/src/main/java/cn/qaiu/vx/core/enums/RouteMethod.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.enums; +package cn.qaiu.vx.core.enums; /** * Router API 请求处理方式枚举 diff --git a/core/src/main/java/cn/com/yhinfo/core/handlerfactory/RouterHandlerFactory.java b/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java similarity index 97% rename from core/src/main/java/cn/com/yhinfo/core/handlerfactory/RouterHandlerFactory.java rename to core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java index 8b888a9..e491707 100644 --- a/core/src/main/java/cn/com/yhinfo/core/handlerfactory/RouterHandlerFactory.java +++ b/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java @@ -1,13 +1,13 @@ -package cn.com.yhinfo.core.handlerfactory; +package cn.qaiu.vx.core.handlerfactory; -import cn.com.yhinfo.core.annotaions.DateFormat; -import cn.com.yhinfo.core.annotaions.RouteHandler; -import cn.com.yhinfo.core.annotaions.RouteMapping; -import cn.com.yhinfo.core.annotaions.SockRouteMapper; -import cn.com.yhinfo.core.base.BaseHttpApi; -import cn.com.yhinfo.core.enums.MIMEType; -import cn.com.yhinfo.core.model.JsonResult; -import cn.com.yhinfo.core.util.*; +import cn.qaiu.vx.core.annotaions.DateFormat; +import cn.qaiu.vx.core.annotaions.RouteHandler; +import cn.qaiu.vx.core.annotaions.RouteMapping; +import cn.qaiu.vx.core.annotaions.SockRouteMapper; +import cn.qaiu.vx.core.enums.MIMEType; +import cn.qaiu.vx.core.model.JsonResult; +import cn.qaiu.vx.core.base.BaseHttpApi; +import cn.qaiu.vx.core.util.*; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.MultiMap; diff --git a/core/src/main/java/cn/com/yhinfo/core/interceptor/Interceptor.java b/core/src/main/java/cn/qaiu/vx/core/interceptor/Interceptor.java similarity index 89% rename from core/src/main/java/cn/com/yhinfo/core/interceptor/Interceptor.java rename to core/src/main/java/cn/qaiu/vx/core/interceptor/Interceptor.java index c5b327f..626f1b2 100644 --- a/core/src/main/java/cn/com/yhinfo/core/interceptor/Interceptor.java +++ b/core/src/main/java/cn/qaiu/vx/core/interceptor/Interceptor.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.interceptor; +package cn.qaiu.vx.core.interceptor; import io.vertx.core.Handler; import io.vertx.ext.web.RoutingContext; diff --git a/core/src/main/java/cn/com/yhinfo/core/model/JsonResult.java b/core/src/main/java/cn/qaiu/vx/core/model/JsonResult.java similarity index 99% rename from core/src/main/java/cn/com/yhinfo/core/model/JsonResult.java rename to core/src/main/java/cn/qaiu/vx/core/model/JsonResult.java index 0f32879..a4be124 100644 --- a/core/src/main/java/cn/com/yhinfo/core/model/JsonResult.java +++ b/core/src/main/java/cn/qaiu/vx/core/model/JsonResult.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.model; +package cn.qaiu.vx.core.model; import org.apache.commons.lang3.StringUtils; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/AsyncServiceUtil.java b/core/src/main/java/cn/qaiu/vx/core/util/AsyncServiceUtil.java similarity index 94% rename from core/src/main/java/cn/com/yhinfo/core/util/AsyncServiceUtil.java rename to core/src/main/java/cn/qaiu/vx/core/util/AsyncServiceUtil.java index 3bcb476..42572d3 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/AsyncServiceUtil.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/AsyncServiceUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import io.vertx.core.Vertx; import io.vertx.serviceproxy.ServiceProxyBuilder; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/CastUtil.java b/core/src/main/java/cn/qaiu/vx/core/util/CastUtil.java similarity index 90% rename from core/src/main/java/cn/com/yhinfo/core/util/CastUtil.java rename to core/src/main/java/cn/qaiu/vx/core/util/CastUtil.java index a87adc0..07331b3 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/CastUtil.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/CastUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; /** * 转换为任意类型 旨在消除泛型转换时的异常 @@ -15,4 +15,4 @@ public interface CastUtil { static T cast(Object object) { return (T) object; } -} \ No newline at end of file +} diff --git a/core/src/main/java/cn/com/yhinfo/core/util/CommonUtil.java b/core/src/main/java/cn/qaiu/vx/core/util/CommonUtil.java similarity index 99% rename from core/src/main/java/cn/com/yhinfo/core/util/CommonUtil.java rename to core/src/main/java/cn/qaiu/vx/core/util/CommonUtil.java index fcf83c6..23bae56 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/CommonUtil.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/CommonUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/ConfigUtil.java b/core/src/main/java/cn/qaiu/vx/core/util/ConfigUtil.java similarity index 98% rename from core/src/main/java/cn/com/yhinfo/core/util/ConfigUtil.java rename to core/src/main/java/cn/qaiu/vx/core/util/ConfigUtil.java index 07ef740..43ebb66 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/ConfigUtil.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/ConfigUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import io.vertx.config.ConfigRetriever; import io.vertx.config.ConfigRetrieverOptions; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/LocalConstant.java b/core/src/main/java/cn/qaiu/vx/core/util/LocalConstant.java similarity index 96% rename from core/src/main/java/cn/com/yhinfo/core/util/LocalConstant.java rename to core/src/main/java/cn/qaiu/vx/core/util/LocalConstant.java index 3fdc70c..0a7fa8c 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/LocalConstant.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/LocalConstant.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import java.util.HashMap; import java.util.Map; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/ParamUtil.java b/core/src/main/java/cn/qaiu/vx/core/util/ParamUtil.java similarity index 97% rename from core/src/main/java/cn/com/yhinfo/core/util/ParamUtil.java rename to core/src/main/java/cn/qaiu/vx/core/util/ParamUtil.java index 5cf557f..58bf7a3 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/ParamUtil.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/ParamUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import io.vertx.core.MultiMap; import org.apache.commons.beanutils.BeanUtils; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/ReflectionUtil.java b/core/src/main/java/cn/qaiu/vx/core/util/ReflectionUtil.java similarity index 99% rename from core/src/main/java/cn/com/yhinfo/core/util/ReflectionUtil.java rename to core/src/main/java/cn/qaiu/vx/core/util/ReflectionUtil.java index 70d0043..43b3e6d 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/ReflectionUtil.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/ReflectionUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import javassist.*; import javassist.bytecode.AccessFlag; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/SharedDataUtil.java b/core/src/main/java/cn/qaiu/vx/core/util/SharedDataUtil.java similarity index 98% rename from core/src/main/java/cn/com/yhinfo/core/util/SharedDataUtil.java rename to core/src/main/java/cn/qaiu/vx/core/util/SharedDataUtil.java index b9c4714..4d59956 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/SharedDataUtil.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/SharedDataUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/SnowflakeIdWorker.java b/core/src/main/java/cn/qaiu/vx/core/util/SnowflakeIdWorker.java similarity index 99% rename from core/src/main/java/cn/com/yhinfo/core/util/SnowflakeIdWorker.java rename to core/src/main/java/cn/qaiu/vx/core/util/SnowflakeIdWorker.java index 876a0ae..577e657 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/SnowflakeIdWorker.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/SnowflakeIdWorker.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; diff --git a/core/src/main/java/cn/com/yhinfo/core/util/StringCase.java b/core/src/main/java/cn/qaiu/vx/core/util/StringCase.java similarity index 99% rename from core/src/main/java/cn/com/yhinfo/core/util/StringCase.java rename to core/src/main/java/cn/qaiu/vx/core/util/StringCase.java index fe82540..fe2ae62 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/StringCase.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/StringCase.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import org.apache.commons.lang3.StringUtils; @@ -107,4 +107,4 @@ public class StringCase { System.out.println(toUnderlineUpperCase("__my_nameQaiu___")); } -} \ No newline at end of file +} diff --git a/core/src/main/java/cn/com/yhinfo/core/util/VertxHolder.java b/core/src/main/java/cn/qaiu/vx/core/util/VertxHolder.java similarity index 94% rename from core/src/main/java/cn/com/yhinfo/core/util/VertxHolder.java rename to core/src/main/java/cn/qaiu/vx/core/util/VertxHolder.java index 805287e..fad54fb 100644 --- a/core/src/main/java/cn/com/yhinfo/core/util/VertxHolder.java +++ b/core/src/main/java/cn/qaiu/vx/core/util/VertxHolder.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.core.util; +package cn.qaiu.vx.core.util; import io.vertx.core.Vertx; diff --git a/core/src/main/java/cn/com/yhinfo/core/verticle/ReverseProxyVerticle.java b/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java similarity index 97% rename from core/src/main/java/cn/com/yhinfo/core/verticle/ReverseProxyVerticle.java rename to core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java index d916f33..b7be725 100644 --- a/core/src/main/java/cn/com/yhinfo/core/verticle/ReverseProxyVerticle.java +++ b/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java @@ -1,9 +1,9 @@ -package cn.com.yhinfo.core.verticle; +package cn.qaiu.vx.core.verticle; -import cn.com.yhinfo.core.util.CastUtil; -import cn.com.yhinfo.core.util.ConfigUtil; -import cn.com.yhinfo.core.util.SharedDataUtil; -import cn.com.yhinfo.core.util.VertxHolder; +import cn.qaiu.vx.core.util.CastUtil; +import cn.qaiu.vx.core.util.ConfigUtil; +import cn.qaiu.vx.core.util.SharedDataUtil; +import cn.qaiu.vx.core.util.VertxHolder; import io.vertx.core.AbstractVerticle; import io.vertx.core.Future; import io.vertx.core.Promise; diff --git a/core/src/main/java/cn/com/yhinfo/core/verticle/RouterVerticle.java b/core/src/main/java/cn/qaiu/vx/core/verticle/RouterVerticle.java similarity index 87% rename from core/src/main/java/cn/com/yhinfo/core/verticle/RouterVerticle.java rename to core/src/main/java/cn/qaiu/vx/core/verticle/RouterVerticle.java index fa6677d..607c7cc 100644 --- a/core/src/main/java/cn/com/yhinfo/core/verticle/RouterVerticle.java +++ b/core/src/main/java/cn/qaiu/vx/core/verticle/RouterVerticle.java @@ -1,16 +1,13 @@ -package cn.com.yhinfo.core.verticle; +package cn.qaiu.vx.core.verticle; -import cn.com.yhinfo.core.handlerfactory.RouterHandlerFactory; -import cn.com.yhinfo.core.util.CommonUtil; -import cn.com.yhinfo.core.util.SharedDataUtil; +import cn.qaiu.vx.core.handlerfactory.RouterHandlerFactory; +import cn.qaiu.vx.core.util.CommonUtil; +import cn.qaiu.vx.core.util.SharedDataUtil; import io.vertx.core.AbstractVerticle; import io.vertx.core.Promise; import io.vertx.core.http.HttpServer; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; -import io.vertx.ext.stomp.StompServer; -import io.vertx.ext.stomp.StompServerHandler; -import io.vertx.ext.stomp.StompServerOptions; import io.vertx.ext.web.Router; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core/src/main/java/cn/com/yhinfo/core/verticle/ServiceVerticle.java b/core/src/main/java/cn/qaiu/vx/core/verticle/ServiceVerticle.java similarity index 87% rename from core/src/main/java/cn/com/yhinfo/core/verticle/ServiceVerticle.java rename to core/src/main/java/cn/qaiu/vx/core/verticle/ServiceVerticle.java index c91f050..148f0a3 100644 --- a/core/src/main/java/cn/com/yhinfo/core/verticle/ServiceVerticle.java +++ b/core/src/main/java/cn/qaiu/vx/core/verticle/ServiceVerticle.java @@ -1,9 +1,9 @@ -package cn.com.yhinfo.core.verticle; +package cn.qaiu.vx.core.verticle; -import cn.com.yhinfo.core.annotaions.Service; -import cn.com.yhinfo.core.base.BaseAsyncService; -import cn.com.yhinfo.core.util.ReflectionUtil; -import cn.com.yhinfo.core.util.SharedDataUtil; +import cn.qaiu.vx.core.annotaions.Service; +import cn.qaiu.vx.core.base.BaseAsyncService; +import cn.qaiu.vx.core.util.ReflectionUtil; +import cn.qaiu.vx.core.util.SharedDataUtil; import io.vertx.core.AbstractVerticle; import io.vertx.core.Promise; import io.vertx.serviceproxy.ServiceBinder; @@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicInteger; /** * 服务注册到EventBus *
Create date 2021-05-07 10:26:54 - * + * * @author QAIU */ public class ServiceVerticle extends AbstractVerticle { diff --git a/web/pom.xml b/web/pom.xml index 56de4ab..3824f8d 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -97,7 +97,7 @@ false - cn.com.yhinfo.real.AppMain + cn.qaiu.lz.AppMain diff --git a/web/src/main/generated/cn/com/yhinfo/real/common/model/MyDataParametersMapper.java b/web/src/main/generated/cn/com/yhinfo/real/common/model/MyDataParametersMapper.java deleted file mode 100644 index 476fc94..0000000 --- a/web/src/main/generated/cn/com/yhinfo/real/common/model/MyDataParametersMapper.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.com.yhinfo.real.common.model; - -/** - * Mapper for {@link MyData}. - * NOTE: This class has been automatically generated from the {@link MyData} original class using Vert.x codegen. - */ -@io.vertx.codegen.annotations.VertxGen -public interface MyDataParametersMapper extends io.vertx.sqlclient.templates.TupleMapper { - - MyDataParametersMapper INSTANCE = new MyDataParametersMapper() {}; - - default io.vertx.sqlclient.Tuple map(java.util.function.Function mapping, int size, MyData params) { - java.util.Map args = map(params); - Object[] array = new Object[size]; - for (int i = 0;i < array.length;i++) { - String column = mapping.apply(i); - array[i] = args.get(column); - } - return io.vertx.sqlclient.Tuple.wrap(array); - } - - default java.util.Map map(MyData obj) { - java.util.Map params = new java.util.HashMap<>(); - params.put("id", obj.getId()); - params.put("max_size", obj.getMaxSize()); - return params; - } -} diff --git a/web/src/main/generated/cn/com/yhinfo/real/common/model/MyDataRowMapper.java b/web/src/main/generated/cn/com/yhinfo/real/common/model/MyDataRowMapper.java deleted file mode 100644 index 82486ee..0000000 --- a/web/src/main/generated/cn/com/yhinfo/real/common/model/MyDataRowMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.com.yhinfo.real.common.model; - -/** - * Mapper for {@link MyData}. - * NOTE: This class has been automatically generated from the {@link MyData} original class using Vert.x codegen. - */ -@io.vertx.codegen.annotations.VertxGen -public interface MyDataRowMapper extends io.vertx.sqlclient.templates.RowMapper { - - @io.vertx.codegen.annotations.GenIgnore - MyDataRowMapper INSTANCE = new MyDataRowMapper() { }; - - @io.vertx.codegen.annotations.GenIgnore - java.util.stream.Collector> COLLECTOR = java.util.stream.Collectors.mapping(INSTANCE::map, java.util.stream.Collectors.toList()); - - @io.vertx.codegen.annotations.GenIgnore - default MyData map(io.vertx.sqlclient.Row row) { - MyData obj = new MyData(); - Object val; - int idx; - if ((idx = row.getColumnIndex("id")) != -1 && (val = row.getString(idx)) != null) { - obj.setId((java.lang.String)val); - } - if ((idx = row.getColumnIndex("max_size")) != -1 && (val = row.getString(idx)) != null) { - obj.setMaxSize((java.lang.String)val); - } - return obj; - } -} diff --git a/web/src/main/generated/cn/com/yhinfo/real/common/model/UserInfoParametersMapper.java b/web/src/main/generated/cn/com/yhinfo/real/common/model/UserInfoParametersMapper.java deleted file mode 100644 index 73f2e70..0000000 --- a/web/src/main/generated/cn/com/yhinfo/real/common/model/UserInfoParametersMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.com.yhinfo.real.common.model; - -/** - * Mapper for {@link UserInfo}. - * NOTE: This class has been automatically generated from the {@link UserInfo} original class using Vert.x codegen. - */ -@io.vertx.codegen.annotations.VertxGen -public interface UserInfoParametersMapper extends io.vertx.sqlclient.templates.TupleMapper { - - UserInfoParametersMapper INSTANCE = new UserInfoParametersMapper() {}; - - default io.vertx.sqlclient.Tuple map(java.util.function.Function mapping, int size, UserInfo params) { - java.util.Map args = map(params); - Object[] array = new Object[size]; - for (int i = 0;i < array.length;i++) { - String column = mapping.apply(i); - array[i] = args.get(column); - } - return io.vertx.sqlclient.Tuple.wrap(array); - } - - default java.util.Map map(UserInfo obj) { - java.util.Map params = new java.util.HashMap<>(); - params.put("permission", obj.getPermission()); - params.put("pwd_crc32", obj.getPwdCrc32()); - params.put("username", obj.getUsername()); - params.put("uuid", obj.getUuid()); - return params; - } -} diff --git a/web/src/main/generated/cn/com/yhinfo/real/common/model/UserInfoRowMapper.java b/web/src/main/generated/cn/com/yhinfo/real/common/model/UserInfoRowMapper.java deleted file mode 100644 index cce0233..0000000 --- a/web/src/main/generated/cn/com/yhinfo/real/common/model/UserInfoRowMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.com.yhinfo.real.common.model; - -/** - * Mapper for {@link UserInfo}. - * NOTE: This class has been automatically generated from the {@link UserInfo} original class using Vert.x codegen. - */ -@io.vertx.codegen.annotations.VertxGen -public interface UserInfoRowMapper extends io.vertx.sqlclient.templates.RowMapper { - - @io.vertx.codegen.annotations.GenIgnore - UserInfoRowMapper INSTANCE = new UserInfoRowMapper() { }; - - @io.vertx.codegen.annotations.GenIgnore - java.util.stream.Collector> COLLECTOR = java.util.stream.Collectors.mapping(INSTANCE::map, java.util.stream.Collectors.toList()); - - @io.vertx.codegen.annotations.GenIgnore - default UserInfo map(io.vertx.sqlclient.Row row) { - UserInfo obj = new UserInfo(); - Object val; - int idx; - if ((idx = row.getColumnIndex("permission")) != -1 && (val = row.getString(idx)) != null) { - obj.setPermission((java.lang.String)val); - } - if ((idx = row.getColumnIndex("pwd_crc32")) != -1 && (val = row.getString(idx)) != null) { - obj.setPwdCrc32((java.lang.String)val); - } - if ((idx = row.getColumnIndex("username")) != -1 && (val = row.getString(idx)) != null) { - obj.setUsername((java.lang.String)val); - } - if ((idx = row.getColumnIndex("uuid")) != -1 && (val = row.getString(idx)) != null) { - obj.setUuid((java.lang.String)val); - } - return obj; - } -} diff --git a/web/src/main/generated/cn/com/yhinfo/real/web/service/DbServiceVertxEBProxy.java b/web/src/main/generated/cn/com/yhinfo/real/web/service/DbServiceVertxEBProxy.java deleted file mode 100644 index b701bae..0000000 --- a/web/src/main/generated/cn/com/yhinfo/real/web/service/DbServiceVertxEBProxy.java +++ /dev/null @@ -1,89 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package cn.com.yhinfo.real.web.service; - -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.Vertx; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.function.Function; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.ProxyUtils; - -import cn.com.yhinfo.real.common.model.UserInfo; -import cn.com.yhinfo.core.base.BaseAsyncService; -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class DbServiceVertxEBProxy implements DbService { - private Vertx _vertx; - private String _address; - private DeliveryOptions _options; - private boolean closed; - - public DbServiceVertxEBProxy(Vertx vertx, String address) { - this(vertx, address, null); - } - - public DbServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { - this._vertx = vertx; - this._address = address; - this._options = options; - try { - this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) { - } - } - - @Override - public Future sayOk(String data){ - if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); - JsonObject _json = new JsonObject(); - _json.put("data", data); - - DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); - _deliveryOptions.addHeader("action", "sayOk"); - return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { - return msg.body(); - }); - } - @Override - public Future sayOk2(String data, UserInfo holder){ - if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); - JsonObject _json = new JsonObject(); - _json.put("data", data); - _json.put("holder", holder != null ? holder.toJson() : null); - - DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); - _deliveryOptions.addHeader("action", "sayOk2"); - return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { - return msg.body(); - }); - } -} diff --git a/web/src/main/generated/cn/com/yhinfo/real/web/service/DbServiceVertxProxyHandler.java b/web/src/main/generated/cn/com/yhinfo/real/web/service/DbServiceVertxProxyHandler.java deleted file mode 100644 index 1f573e9..0000000 --- a/web/src/main/generated/cn/com/yhinfo/real/web/service/DbServiceVertxProxyHandler.java +++ /dev/null @@ -1,140 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package cn.com.yhinfo.real.web.service; - -import cn.com.yhinfo.real.web.service.DbService; -import io.vertx.core.Vertx; -import io.vertx.core.Handler; -import io.vertx.core.AsyncResult; -import io.vertx.core.eventbus.EventBus; -import io.vertx.core.eventbus.Message; -import io.vertx.core.eventbus.MessageConsumer; -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.eventbus.ReplyException; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.Collection; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; -import io.vertx.serviceproxy.ProxyHandler; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.HelperUtils; -import io.vertx.serviceproxy.ServiceBinder; - -import cn.com.yhinfo.real.common.model.UserInfo; -import cn.com.yhinfo.core.base.BaseAsyncService; -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class DbServiceVertxProxyHandler extends ProxyHandler { - - public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes - private final Vertx vertx; - private final DbService service; - private final long timerID; - private long lastAccessed; - private final long timeoutSeconds; - private final boolean includeDebugInfo; - - public DbServiceVertxProxyHandler(Vertx vertx, DbService service){ - this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); - } - - public DbServiceVertxProxyHandler(Vertx vertx, DbService service, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond); - } - - public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond, false); - } - - public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { - this.vertx = vertx; - this.service = service; - this.includeDebugInfo = includeDebugInfo; - this.timeoutSeconds = timeoutSeconds; - try { - this.vertx.eventBus().registerDefaultCodec(ServiceException.class, - new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) {} - if (timeoutSeconds != -1 && !topLevel) { - long period = timeoutSeconds * 1000 / 2; - if (period > 10000) { - period = 10000; - } - this.timerID = vertx.setPeriodic(period, this::checkTimedOut); - } else { - this.timerID = -1; - } - accessed(); - } - - - private void checkTimedOut(long id) { - long now = System.nanoTime(); - if (now - lastAccessed > timeoutSeconds * 1000000000) { - close(); - } - } - - @Override - public void close() { - if (timerID != -1) { - vertx.cancelTimer(timerID); - } - super.close(); - } - - private void accessed() { - this.lastAccessed = System.nanoTime(); - } - - public void handle(Message msg) { - try{ - JsonObject json = msg.body(); - String action = msg.headers().get("action"); - if (action == null) throw new IllegalStateException("action not specified"); - accessed(); - switch (action) { - case "sayOk": { - service.sayOk((java.lang.String)json.getValue("data")).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); - break; - } - case "sayOk2": { - service.sayOk2((java.lang.String)json.getValue("data"), - json.getJsonObject("holder") != null ? new cn.com.yhinfo.real.common.model.UserInfo((JsonObject)json.getJsonObject("holder")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); - break; - } - default: throw new IllegalStateException("Invalid action: " + action); - } - } catch (Throwable t) { - if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); - else msg.reply(new ServiceException(500, t.getMessage())); - throw t; - } - } -} \ No newline at end of file diff --git a/web/src/main/generated/cn/com/yhinfo/real/web/service/UserServiceVertxEBProxy.java b/web/src/main/generated/cn/com/yhinfo/real/web/service/UserServiceVertxEBProxy.java deleted file mode 100644 index f395d4d..0000000 --- a/web/src/main/generated/cn/com/yhinfo/real/web/service/UserServiceVertxEBProxy.java +++ /dev/null @@ -1,76 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package cn.com.yhinfo.real.web.service; - -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.Vertx; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.function.Function; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.ProxyUtils; - -import cn.com.yhinfo.core.base.BaseAsyncService; -import cn.com.yhinfo.real.web.model.RealUser; -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class UserServiceVertxEBProxy implements UserService { - private Vertx _vertx; - private String _address; - private DeliveryOptions _options; - private boolean closed; - - public UserServiceVertxEBProxy(Vertx vertx, String address) { - this(vertx, address, null); - } - - public UserServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { - this._vertx = vertx; - this._address = address; - this._options = options; - try { - this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) { - } - } - - @Override - public Future login(RealUser user){ - if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); - JsonObject _json = new JsonObject(); - _json.put("user", user != null ? user.toJson() : null); - - DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); - _deliveryOptions.addHeader("action", "login"); - return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { - return msg.body(); - }); - } -} diff --git a/web/src/main/generated/cn/com/yhinfo/real/web/service/UserServiceVertxProxyHandler.java b/web/src/main/generated/cn/com/yhinfo/real/web/service/UserServiceVertxProxyHandler.java deleted file mode 100644 index dbac9d3..0000000 --- a/web/src/main/generated/cn/com/yhinfo/real/web/service/UserServiceVertxProxyHandler.java +++ /dev/null @@ -1,135 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package cn.com.yhinfo.real.web.service; - -import cn.com.yhinfo.real.web.service.UserService; -import io.vertx.core.Vertx; -import io.vertx.core.Handler; -import io.vertx.core.AsyncResult; -import io.vertx.core.eventbus.EventBus; -import io.vertx.core.eventbus.Message; -import io.vertx.core.eventbus.MessageConsumer; -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.eventbus.ReplyException; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.Collection; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; -import io.vertx.serviceproxy.ProxyHandler; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.HelperUtils; -import io.vertx.serviceproxy.ServiceBinder; - -import cn.com.yhinfo.core.base.BaseAsyncService; -import cn.com.yhinfo.real.web.model.RealUser; -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class UserServiceVertxProxyHandler extends ProxyHandler { - - public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes - private final Vertx vertx; - private final UserService service; - private final long timerID; - private long lastAccessed; - private final long timeoutSeconds; - private final boolean includeDebugInfo; - - public UserServiceVertxProxyHandler(Vertx vertx, UserService service){ - this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); - } - - public UserServiceVertxProxyHandler(Vertx vertx, UserService service, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond); - } - - public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond, false); - } - - public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { - this.vertx = vertx; - this.service = service; - this.includeDebugInfo = includeDebugInfo; - this.timeoutSeconds = timeoutSeconds; - try { - this.vertx.eventBus().registerDefaultCodec(ServiceException.class, - new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) {} - if (timeoutSeconds != -1 && !topLevel) { - long period = timeoutSeconds * 1000 / 2; - if (period > 10000) { - period = 10000; - } - this.timerID = vertx.setPeriodic(period, this::checkTimedOut); - } else { - this.timerID = -1; - } - accessed(); - } - - - private void checkTimedOut(long id) { - long now = System.nanoTime(); - if (now - lastAccessed > timeoutSeconds * 1000000000) { - close(); - } - } - - @Override - public void close() { - if (timerID != -1) { - vertx.cancelTimer(timerID); - } - super.close(); - } - - private void accessed() { - this.lastAccessed = System.nanoTime(); - } - - public void handle(Message msg) { - try{ - JsonObject json = msg.body(); - String action = msg.headers().get("action"); - if (action == null) throw new IllegalStateException("action not specified"); - accessed(); - switch (action) { - case "login": { - service.login(json.getJsonObject("user") != null ? new cn.com.yhinfo.real.web.model.RealUser((JsonObject)json.getJsonObject("user")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); - break; - } - default: throw new IllegalStateException("Invalid action: " + action); - } - } catch (Throwable t) { - if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); - else msg.reply(new ServiceException(500, t.getMessage())); - throw t; - } - } -} \ No newline at end of file diff --git a/web/src/main/java/cn/com/yhinfo/real/package-info.java b/web/src/main/java/cn/com/yhinfo/real/package-info.java deleted file mode 100644 index 86c05b1..0000000 --- a/web/src/main/java/cn/com/yhinfo/real/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * sinoreal2-web - *
Create date 2021/7/8 13:29 - * - * @author QAIU - */ -@ModuleGen(name = "proxy", groupPackage = "cn.com.yhinfo.real", useFutures = true) -package cn.com.yhinfo.real; - -import io.vertx.codegen.annotations.ModuleGen; \ No newline at end of file diff --git a/web/src/main/java/cn/com/yhinfo/real/AppMain.java b/web/src/main/java/cn/qaiu/lz/AppMain.java similarity index 87% rename from web/src/main/java/cn/com/yhinfo/real/AppMain.java rename to web/src/main/java/cn/qaiu/lz/AppMain.java index 715b46a..6b653dc 100644 --- a/web/src/main/java/cn/com/yhinfo/real/AppMain.java +++ b/web/src/main/java/cn/qaiu/lz/AppMain.java @@ -1,6 +1,6 @@ -package cn.com.yhinfo.real; +package cn.qaiu.lz; -import cn.com.yhinfo.core.Deploy; +import cn.qaiu.vx.core.Deploy; import io.vertx.core.json.JsonObject; diff --git a/web/src/main/java/cn/com/yhinfo/real/common/ToJson.java b/web/src/main/java/cn/qaiu/lz/common/ToJson.java similarity index 91% rename from web/src/main/java/cn/com/yhinfo/real/common/ToJson.java rename to web/src/main/java/cn/qaiu/lz/common/ToJson.java index b04cdf0..6e4d0ba 100644 --- a/web/src/main/java/cn/com/yhinfo/real/common/ToJson.java +++ b/web/src/main/java/cn/qaiu/lz/common/ToJson.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.real.common; +package cn.qaiu.lz.common; import io.vertx.core.json.JsonObject; diff --git a/web/src/main/java/cn/com/yhinfo/real/common/interceptorImpl/DefaultInterceptor.java b/web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java similarity index 78% rename from web/src/main/java/cn/com/yhinfo/real/common/interceptorImpl/DefaultInterceptor.java rename to web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java index b10cfc2..a0d1e9e 100644 --- a/web/src/main/java/cn/com/yhinfo/real/common/interceptorImpl/DefaultInterceptor.java +++ b/web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java @@ -1,11 +1,11 @@ -package cn.com.yhinfo.real.common.interceptorImpl; +package cn.qaiu.lz.common.interceptorImpl; -import cn.com.yhinfo.core.base.BaseHttpApi; -import cn.com.yhinfo.core.interceptor.Interceptor; -import cn.com.yhinfo.core.model.JsonResult; -import cn.com.yhinfo.core.util.CommonUtil; -import cn.com.yhinfo.core.util.SharedDataUtil; -import cn.com.yhinfo.core.util.VertxHolder; +import cn.qaiu.vx.core.base.BaseHttpApi; +import cn.qaiu.vx.core.interceptor.Interceptor; +import cn.qaiu.vx.core.model.JsonResult; +import cn.qaiu.vx.core.util.CommonUtil; +import cn.qaiu.vx.core.util.SharedDataUtil; +import cn.qaiu.vx.core.util.VertxHolder; import io.vertx.core.json.JsonArray; import io.vertx.core.shareddata.LocalMap; import io.vertx.ext.web.RoutingContext; diff --git a/web/src/main/java/cn/com/yhinfo/real/common/model/MyData.java b/web/src/main/java/cn/qaiu/lz/common/model/MyData.java similarity index 94% rename from web/src/main/java/cn/com/yhinfo/real/common/model/MyData.java rename to web/src/main/java/cn/qaiu/lz/common/model/MyData.java index 1b2409c..2b02228 100644 --- a/web/src/main/java/cn/com/yhinfo/real/common/model/MyData.java +++ b/web/src/main/java/cn/qaiu/lz/common/model/MyData.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.real.common.model; +package cn.qaiu.lz.common.model; import io.vertx.codegen.annotations.DataObject; import io.vertx.codegen.format.SnakeCase; diff --git a/web/src/main/java/cn/com/yhinfo/real/common/model/UserInfo.java b/web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java similarity index 92% rename from web/src/main/java/cn/com/yhinfo/real/common/model/UserInfo.java rename to web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java index 4c853f2..803cd49 100644 --- a/web/src/main/java/cn/com/yhinfo/real/common/model/UserInfo.java +++ b/web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java @@ -1,6 +1,6 @@ -package cn.com.yhinfo.real.common.model; +package cn.qaiu.lz.common.model; -import cn.com.yhinfo.real.common.ToJson; +import cn.qaiu.lz.common.ToJson; import io.vertx.codegen.annotations.DataObject; import io.vertx.codegen.format.SnakeCase; import io.vertx.core.json.JsonObject; diff --git a/web/src/main/java/cn/com/yhinfo/real/common/util/ArrayUtil.java b/web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java similarity index 92% rename from web/src/main/java/cn/com/yhinfo/real/common/util/ArrayUtil.java rename to web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java index 12ad6d9..7973d2f 100644 --- a/web/src/main/java/cn/com/yhinfo/real/common/util/ArrayUtil.java +++ b/web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.real.common.util; +package cn.qaiu.lz.common.util; public class ArrayUtil { diff --git a/web/src/main/java/cn/com/yhinfo/real/common/util/ConnectUtil.java b/web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java similarity index 87% rename from web/src/main/java/cn/com/yhinfo/real/common/util/ConnectUtil.java rename to web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java index 80e1fe9..0ea396a 100644 --- a/web/src/main/java/cn/com/yhinfo/real/common/util/ConnectUtil.java +++ b/web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.real.common.util; +package cn.qaiu.lz.common.util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/web/src/main/java/cn/qaiu/lz/package-info.java b/web/src/main/java/cn/qaiu/lz/package-info.java new file mode 100644 index 0000000..dec3921 --- /dev/null +++ b/web/src/main/java/cn/qaiu/lz/package-info.java @@ -0,0 +1,10 @@ +/** + * sinoreal2-web + *
Create date 2021/7/8 13:29 + * + * @author QAIU + */ +@ModuleGen(name = "proxy", groupPackage = "cn.qaiu.lz", useFutures = true) +package cn.qaiu.lz; + +import io.vertx.codegen.annotations.ModuleGen; diff --git a/web/src/main/java/cn/com/yhinfo/real/web/http/ServerApi.java b/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java similarity index 79% rename from web/src/main/java/cn/com/yhinfo/real/web/http/ServerApi.java rename to web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 918ef4b..a3f5b67 100644 --- a/web/src/main/java/cn/com/yhinfo/real/web/http/ServerApi.java +++ b/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -1,21 +1,21 @@ -package cn.com.yhinfo.real.web.http; +package cn.qaiu.lz.web.http; -import cn.com.yhinfo.core.annotaions.RouteHandler; -import cn.com.yhinfo.core.annotaions.RouteMapping; -import cn.com.yhinfo.core.annotaions.SockRouteMapper; -import cn.com.yhinfo.core.enums.RouteMethod; -import cn.com.yhinfo.core.model.JsonResult; -import cn.com.yhinfo.core.util.AsyncServiceUtil; -import cn.com.yhinfo.core.util.SnowflakeIdWorker; -import cn.com.yhinfo.core.util.VertxHolder; -import cn.com.yhinfo.real.web.model.RealUser; -import cn.com.yhinfo.real.web.service.UserService; +import cn.qaiu.lz.web.service.UserService; +import cn.qaiu.vx.core.annotaions.RouteHandler; +import cn.qaiu.vx.core.annotaions.RouteMapping; +import cn.qaiu.vx.core.annotaions.SockRouteMapper; +import cn.qaiu.vx.core.enums.RouteMethod; +import cn.qaiu.vx.core.model.JsonResult; +import cn.qaiu.vx.core.util.AsyncServiceUtil; +import cn.qaiu.vx.core.util.SnowflakeIdWorker; +import cn.qaiu.vx.core.util.VertxHolder; +import cn.qaiu.lz.web.model.RealUser; import io.vertx.core.Future; import io.vertx.ext.web.handler.sockjs.SockJSSocket; import lombok.extern.slf4j.Slf4j; /** - * 连接服务API + * 服务API *
Create date 2021/4/28 9:15 * * @author QAIU diff --git a/web/src/main/java/cn/com/yhinfo/real/web/model/RealUser.java b/web/src/main/java/cn/qaiu/lz/web/model/RealUser.java similarity index 85% rename from web/src/main/java/cn/com/yhinfo/real/web/model/RealUser.java rename to web/src/main/java/cn/qaiu/lz/web/model/RealUser.java index d57a19f..61e07ef 100644 --- a/web/src/main/java/cn/com/yhinfo/real/web/model/RealUser.java +++ b/web/src/main/java/cn/qaiu/lz/web/model/RealUser.java @@ -1,6 +1,6 @@ -package cn.com.yhinfo.real.web.model; +package cn.qaiu.lz.web.model; -import cn.com.yhinfo.real.common.ToJson; +import cn.qaiu.lz.common.ToJson; import io.vertx.codegen.annotations.DataObject; import io.vertx.core.json.JsonObject; import lombok.AllArgsConstructor; diff --git a/web/src/main/java/cn/com/yhinfo/real/web/service/DbService.java b/web/src/main/java/cn/qaiu/lz/web/service/DbService.java similarity index 74% rename from web/src/main/java/cn/com/yhinfo/real/web/service/DbService.java rename to web/src/main/java/cn/qaiu/lz/web/service/DbService.java index 0a4da83..28d6513 100644 --- a/web/src/main/java/cn/com/yhinfo/real/web/service/DbService.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/DbService.java @@ -1,7 +1,7 @@ -package cn.com.yhinfo.real.web.service; +package cn.qaiu.lz.web.service; -import cn.com.yhinfo.core.base.BaseAsyncService; -import cn.com.yhinfo.real.common.model.UserInfo; +import cn.qaiu.lz.common.model.UserInfo; +import cn.qaiu.vx.core.base.BaseAsyncService; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.core.Future; import io.vertx.core.json.JsonObject; diff --git a/web/src/main/java/cn/com/yhinfo/real/web/service/JdkProxyFactory.java b/web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java similarity index 81% rename from web/src/main/java/cn/com/yhinfo/real/web/service/JdkProxyFactory.java rename to web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java index 5000f5c..8cc40c4 100644 --- a/web/src/main/java/cn/com/yhinfo/real/web/service/JdkProxyFactory.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java @@ -1,6 +1,6 @@ -package cn.com.yhinfo.real.web.service; +package cn.qaiu.lz.web.service; -import cn.com.yhinfo.core.util.CastUtil; +import cn.qaiu.vx.core.util.CastUtil; import java.lang.reflect.Proxy; @@ -15,4 +15,4 @@ public class JdkProxyFactory { new ServiceJdkProxy<>(target)) ); } -} \ No newline at end of file +} diff --git a/web/src/main/java/cn/com/yhinfo/real/web/service/ServiceJdkProxy.java b/web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java similarity index 94% rename from web/src/main/java/cn/com/yhinfo/real/web/service/ServiceJdkProxy.java rename to web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java index 061ee6e..48bb435 100644 --- a/web/src/main/java/cn/com/yhinfo/real/web/service/ServiceJdkProxy.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.real.web.service; +package cn.qaiu.lz.web.service; import lombok.extern.slf4j.Slf4j; diff --git a/web/src/main/java/cn/com/yhinfo/real/web/service/UserService.java b/web/src/main/java/cn/qaiu/lz/web/service/UserService.java similarity index 68% rename from web/src/main/java/cn/com/yhinfo/real/web/service/UserService.java rename to web/src/main/java/cn/qaiu/lz/web/service/UserService.java index cfae4dc..deca2fd 100644 --- a/web/src/main/java/cn/com/yhinfo/real/web/service/UserService.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/UserService.java @@ -1,7 +1,7 @@ -package cn.com.yhinfo.real.web.service; +package cn.qaiu.lz.web.service; -import cn.com.yhinfo.core.base.BaseAsyncService; -import cn.com.yhinfo.real.web.model.RealUser; +import cn.qaiu.vx.core.base.BaseAsyncService; +import cn.qaiu.lz.web.model.RealUser; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.core.Future; diff --git a/web/src/main/java/cn/com/yhinfo/real/web/service/impl/DbServiceImpl.java b/web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java similarity index 80% rename from web/src/main/java/cn/com/yhinfo/real/web/service/impl/DbServiceImpl.java rename to web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java index 6b90534..a927697 100644 --- a/web/src/main/java/cn/com/yhinfo/real/web/service/impl/DbServiceImpl.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java @@ -1,9 +1,9 @@ -package cn.com.yhinfo.real.web.service.impl; +package cn.qaiu.lz.web.service.impl; -import cn.com.yhinfo.core.annotaions.Service; -import cn.com.yhinfo.core.model.JsonResult; -import cn.com.yhinfo.real.common.model.UserInfo; -import cn.com.yhinfo.real.web.service.DbService; +import cn.qaiu.lz.common.model.UserInfo; +import cn.qaiu.lz.web.service.DbService; +import cn.qaiu.vx.core.annotaions.Service; +import cn.qaiu.vx.core.model.JsonResult; import io.vertx.core.Future; import io.vertx.core.json.JsonObject; import lombok.extern.slf4j.Slf4j; diff --git a/web/src/main/java/cn/com/yhinfo/real/web/service/impl/UserServiceImpl.java b/web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java similarity index 63% rename from web/src/main/java/cn/com/yhinfo/real/web/service/impl/UserServiceImpl.java rename to web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java index 5315272..8ac2191 100644 --- a/web/src/main/java/cn/com/yhinfo/real/web/service/impl/UserServiceImpl.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java @@ -1,8 +1,8 @@ -package cn.com.yhinfo.real.web.service.impl; +package cn.qaiu.lz.web.service.impl; -import cn.com.yhinfo.core.annotaions.Service; -import cn.com.yhinfo.real.web.model.RealUser; -import cn.com.yhinfo.real.web.service.UserService; +import cn.qaiu.lz.web.model.RealUser; +import cn.qaiu.lz.web.service.UserService; +import cn.qaiu.vx.core.annotaions.Service; import io.vertx.core.Future; /** diff --git a/web/src/main/resources/app-dev.yml b/web/src/main/resources/app-dev.yml index 2c1cb7c..690a24c 100644 --- a/web/src/main/resources/app-dev.yml +++ b/web/src/main/resources/app-dev.yml @@ -12,15 +12,14 @@ vertx: workerPoolSize: 20 custom: asyncServiceInstances: 8 - routerLocations: cn.com.yhinfo.real.web.http - interceptorClassPath: cn.com.yhinfo.real.common.interceptorImpl.DefaultInterceptor - handlerLocations: cn.com.yhinfo.real.web.service + routerLocations: cn.qaiu.lz.web.http + interceptorClassPath: cn.qaiu.lz.common.interceptorImpl.DefaultInterceptor + handlerLocations: cn.qaiu.lz.web.service ignoresReg: - .*/login$ - .*/test.*$ entityPackagesReg: - - ^cn\.com\.yhinfo\.real\.web\.model\..* - - ^sinereal\.core\..* + - ^cn\.qaiu\.lz\.web\.model\..* otherConfig: - dictionaries.json errorPage404: /index.html diff --git a/web/src/test/java/cn/com/yhinfo/test/StompTest.java b/web/src/test/java/cn/qaiu/web/test/StompTest.java similarity index 97% rename from web/src/test/java/cn/com/yhinfo/test/StompTest.java rename to web/src/test/java/cn/qaiu/web/test/StompTest.java index 37f531d..c809d29 100644 --- a/web/src/test/java/cn/com/yhinfo/test/StompTest.java +++ b/web/src/test/java/cn/qaiu/web/test/StompTest.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.test; +package cn.qaiu.web.test; import io.vertx.core.Future; import io.vertx.core.Vertx; diff --git a/web/src/test/java/cn/com/yhinfo/test/Test01.java b/web/src/test/java/cn/qaiu/web/test/Test01.java similarity index 99% rename from web/src/test/java/cn/com/yhinfo/test/Test01.java rename to web/src/test/java/cn/qaiu/web/test/Test01.java index 910dd7d..a8b27dc 100644 --- a/web/src/test/java/cn/com/yhinfo/test/Test01.java +++ b/web/src/test/java/cn/qaiu/web/test/Test01.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.test; +package cn.qaiu.web.test; import io.vertx.ext.web.RoutingContext; import lombok.extern.slf4j.Slf4j; diff --git a/web/src/test/java/cn/com/yhinfo/test/Test02.java b/web/src/test/java/cn/qaiu/web/test/Test02.java similarity index 98% rename from web/src/test/java/cn/com/yhinfo/test/Test02.java rename to web/src/test/java/cn/qaiu/web/test/Test02.java index 413a9a0..c5f8ec9 100644 --- a/web/src/test/java/cn/com/yhinfo/test/Test02.java +++ b/web/src/test/java/cn/qaiu/web/test/Test02.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.test; +package cn.qaiu.web.test; import javassist.ClassPool; import javassist.CtClass; @@ -82,4 +82,4 @@ public class Test02 { System.out.println(map); } -} \ No newline at end of file +} diff --git a/web/src/test/java/cn/com/yhinfo/test/TestOS.java b/web/src/test/java/cn/qaiu/web/test/TestOS.java similarity index 99% rename from web/src/test/java/cn/com/yhinfo/test/TestOS.java rename to web/src/test/java/cn/qaiu/web/test/TestOS.java index 746fb77..324b663 100644 --- a/web/src/test/java/cn/com/yhinfo/test/TestOS.java +++ b/web/src/test/java/cn/qaiu/web/test/TestOS.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.test; +package cn.qaiu.web.test; import java.io.*; import java.net.InetAddress; @@ -158,4 +158,4 @@ public class TestOS { // new TestOS().showURL(); System.out.println(File.separator); } -} \ No newline at end of file +} diff --git a/web/src/test/java/cn/com/yhinfo/test/WebProxyExamples.java b/web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java similarity index 99% rename from web/src/test/java/cn/com/yhinfo/test/WebProxyExamples.java rename to web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java index 9a6b2e6..562cdaf 100644 --- a/web/src/test/java/cn/com/yhinfo/test/WebProxyExamples.java +++ b/web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java @@ -1,4 +1,4 @@ -package cn.com.yhinfo.test; +package cn.qaiu.web.test; import io.vertx.core.Vertx; import io.vertx.core.http.HttpClient; From 2457ded15891b0c293050a83c27b44dea6e3e724 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Fri, 21 Apr 2023 01:24:31 +0800 Subject: [PATCH 04/48] init --- web/src/main/java/cn/qaiu/lz/common/ToJson.java | 2 +- web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java | 2 +- web/src/main/java/cn/qaiu/lz/package-info.java | 2 +- web/src/main/java/cn/qaiu/lz/web/service/DbService.java | 2 +- web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java | 2 +- web/src/main/java/cn/qaiu/lz/web/service/UserService.java | 2 +- .../main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java | 2 +- .../main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java | 2 +- web/src/main/resources/curl/curl.sh | 2 +- web/src/test/java/cn/qaiu/web/test/StompTest.java | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web/src/main/java/cn/qaiu/lz/common/ToJson.java b/web/src/main/java/cn/qaiu/lz/common/ToJson.java index 6e4d0ba..dc90643 100644 --- a/web/src/main/java/cn/qaiu/lz/common/ToJson.java +++ b/web/src/main/java/cn/qaiu/lz/common/ToJson.java @@ -3,7 +3,7 @@ package cn.qaiu.lz.common; import io.vertx.core.json.JsonObject; /** - * sinoreal2-web
+ * lz-web
* 实现此接口 POJO转JSON对象 * * @author QAIU diff --git a/web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java b/web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java index 803cd49..c295556 100644 --- a/web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java +++ b/web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java @@ -11,7 +11,7 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * sinoreal2-web + * lz-web * * @author QAIU *
Create date 2021/8/10 11:10 diff --git a/web/src/main/java/cn/qaiu/lz/package-info.java b/web/src/main/java/cn/qaiu/lz/package-info.java index dec3921..ac0435c 100644 --- a/web/src/main/java/cn/qaiu/lz/package-info.java +++ b/web/src/main/java/cn/qaiu/lz/package-info.java @@ -1,5 +1,5 @@ /** - * sinoreal2-web + * lz-web *
Create date 2021/7/8 13:29 * * @author QAIU diff --git a/web/src/main/java/cn/qaiu/lz/web/service/DbService.java b/web/src/main/java/cn/qaiu/lz/web/service/DbService.java index 28d6513..b514f72 100644 --- a/web/src/main/java/cn/qaiu/lz/web/service/DbService.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/DbService.java @@ -7,7 +7,7 @@ import io.vertx.core.Future; import io.vertx.core.json.JsonObject; /** - * sinoreal2-web + * lz-web *
Create date 2021/7/12 17:16 * * @author QAIU diff --git a/web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java b/web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java index 48bb435..b2c9c77 100644 --- a/web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java @@ -7,7 +7,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** - * sinoreal2-web + * lz-web *
Create date 2021/8/25 14:28 * * @author QAIU diff --git a/web/src/main/java/cn/qaiu/lz/web/service/UserService.java b/web/src/main/java/cn/qaiu/lz/web/service/UserService.java index deca2fd..c4aafda 100644 --- a/web/src/main/java/cn/qaiu/lz/web/service/UserService.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/UserService.java @@ -6,7 +6,7 @@ import io.vertx.codegen.annotations.ProxyGen; import io.vertx.core.Future; /** - * sinoreal2-web + * lz-web *
Create date 2021/8/27 14:06 * * @author QAIU diff --git a/web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java b/web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java index a927697..dfd102a 100644 --- a/web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java @@ -9,7 +9,7 @@ import io.vertx.core.json.JsonObject; import lombok.extern.slf4j.Slf4j; /** - * sinoreal2-web + * lz-web *
Create date 2021/7/12 17:26 * * @author QAIU diff --git a/web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java b/web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java index 8ac2191..07f1170 100644 --- a/web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java +++ b/web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java @@ -6,7 +6,7 @@ import cn.qaiu.vx.core.annotaions.Service; import io.vertx.core.Future; /** - * sinoreal2-web + * lz-web *
Create date 2021/8/27 14:09 * * @author QAIU diff --git a/web/src/main/resources/curl/curl.sh b/web/src/main/resources/curl/curl.sh index 5aa1389..12c98d7 100644 --- a/web/src/main/resources/curl/curl.sh +++ b/web/src/main/resources/curl/curl.sh @@ -1,3 +1,3 @@ -curl -F "file=@C:\Users\qaiu\Desktop\real\sinoreal2-web\web\src\main\resources\logback.xml" -i -XPOST 127.0.0.1:8088/demo/basePointApi/importTags +curl -F "file=@C:\Users\qaiu\Desktop\real\lz-web\web\src\main\resources\logback.xml" -i -XPOST 127.0.0.1:8088/demo/basePointApi/importTags curl -F "file=@C:\Users\qaiu\Desktop\3.csv" -i -XPOST 127.0.0.1:8088/demo/basePointApi/importTags diff --git a/web/src/test/java/cn/qaiu/web/test/StompTest.java b/web/src/test/java/cn/qaiu/web/test/StompTest.java index c809d29..403c16e 100644 --- a/web/src/test/java/cn/qaiu/web/test/StompTest.java +++ b/web/src/test/java/cn/qaiu/web/test/StompTest.java @@ -11,7 +11,7 @@ import io.vertx.ext.stomp.StompServerOptions; import java.util.Arrays; /** - * sinoreal2-web + * lz-web *

create 2021/9/18 12:10

* * @author QAIU From 15b64683339a8a07d89aec65947e78a0727afcfc Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Fri, 21 Apr 2023 17:39:09 +0800 Subject: [PATCH 05/48] =?UTF-8?q?=E8=93=9D=E5=A5=8F=E4=BA=91API=20BUG?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handlerfactory/RouterHandlerFactory.java | 16 +- .../core/verticle/ReverseProxyVerticle.java | 13 +- web/pom.xml | 5 + .../java/cn/qaiu/lz/common/util/LzTool.java | 93 ++++++++++ .../java/cn/qaiu/lz/web/http/ServerApi.java | 52 ++---- web/src/main/resources/1.http | 163 +----------------- web/src/main/resources/server-proxy.yml | 42 ++--- 7 files changed, 148 insertions(+), 236 deletions(-) create mode 100644 web/src/main/java/cn/qaiu/lz/common/util/LzTool.java diff --git a/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java b/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java index e491707..eb30e42 100644 --- a/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java +++ b/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java @@ -4,14 +4,16 @@ import cn.qaiu.vx.core.annotaions.DateFormat; import cn.qaiu.vx.core.annotaions.RouteHandler; import cn.qaiu.vx.core.annotaions.RouteMapping; import cn.qaiu.vx.core.annotaions.SockRouteMapper; +import cn.qaiu.vx.core.base.BaseHttpApi; import cn.qaiu.vx.core.enums.MIMEType; import cn.qaiu.vx.core.model.JsonResult; -import cn.qaiu.vx.core.base.BaseHttpApi; import cn.qaiu.vx.core.util.*; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.MultiMap; import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.Route; @@ -46,7 +48,7 @@ import static io.vertx.core.http.HttpHeaders.*; public class RouterHandlerFactory implements BaseHttpApi { private static final Logger LOGGER = LoggerFactory.getLogger(RouterHandlerFactory.class); - private static final Set httpMethods = new HashSet() {{ + private static final Set httpMethods = new HashSet<>() {{ add(HttpMethod.GET); add(HttpMethod.POST); add(HttpMethod.OPTIONS); @@ -95,7 +97,7 @@ public class RouterHandlerFactory implements BaseHttpApi { return Integer.compare(routeHandler2.order(), routeHandler1.order()); }; // 获取处理器类列表 - List> sortedHandlers = handlers.stream().sorted(comparator).collect(Collectors.toList()); + List> sortedHandlers = handlers.stream().sorted(comparator).toList(); for (Class handler : sortedHandlers) { try { // 注册请求处理方法 @@ -292,11 +294,11 @@ public class RouterHandlerFactory implements BaseHttpApi { String fmt = getFmt(v.getLeft(), v.getRight()); String value = queryParams.get(k); parameterValueList.put(k, ReflectionUtil.conversion(v.getRight(), value, fmt)); - } else if ("io.vertx.ext.web.RoutingContext".equals(v.getRight().getName())) { + } else if (RoutingContext.class.getName().equals(v.getRight().getName())) { parameterValueList.put(k, ctx); - } else if ("io.vertx.core.http.HttpServerRequest".equals(v.getRight().getName())) { + } else if (HttpServerRequest.class.getName().equals(v.getRight().getName())) { parameterValueList.put(k, ctx.request()); - } else if ("io.vertx.core.http.HttpServerResponse".equals(v.getRight().getName())) { + } else if (HttpServerResponse.class.getName().equals(v.getRight().getName())) { parameterValueList.put(k, ctx.response()); } else if (CommonUtil.matchRegList(entityPackagesReg.getList(), v.getRight().getName())) { // 绑定实体类 @@ -371,7 +373,7 @@ public class RouterHandlerFactory implements BaseHttpApi { */ private String getFmt(Annotation[] parameterAnnotations, CtClass v) { String fmt = ""; - if ("java.util.Date".equals(v.getName())) { + if (Date.class.getName().equals(v.getName())) { for (Annotation annotation : parameterAnnotations) { if (annotation instanceof DateFormat) { fmt = ((DateFormat) annotation).value(); diff --git a/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java b/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java index b7be725..3a81cab 100644 --- a/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java +++ b/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java @@ -60,12 +60,13 @@ public class ReverseProxyVerticle extends AbstractVerticle { private void handleProxyConfList(JsonObject config) { serverName = config.getString("server-name"); JsonArray proxyConfList = config.getJsonArray("proxy"); - - proxyConfList.forEach(proxyConf -> { - if (proxyConf instanceof JsonObject) { - handleProxyConf((JsonObject) proxyConf); - } - }); + if (proxyConfList != null) { + proxyConfList.forEach(proxyConf -> { + if (proxyConf instanceof JsonObject) { + handleProxyConf((JsonObject) proxyConf); + } + }); + } } /** diff --git a/web/pom.xml b/web/pom.xml index 3824f8d..360bf63 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -48,6 +48,11 @@ 4.13.2 test + + org.jsoup + jsoup + 1.15.4 + diff --git a/web/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/web/src/main/java/cn/qaiu/lz/common/util/LzTool.java new file mode 100644 index 0000000..9178b56 --- /dev/null +++ b/web/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -0,0 +1,93 @@ +package cn.qaiu.lz.common.util; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.jsoup.Jsoup; + +import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author QAIU + * @version 1.0 update 2021/5/16 10:39 + */ +public class LzTool { + + public static String parse(String fullUrl) throws Exception { + String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.3"; + String url = fullUrl.substring(0, fullUrl.lastIndexOf('/') + 1); + String id = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); + Map header = new HashMap<>(); + header.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); + header.put("referer", url); + + + /* + // 部分链接需要设置安卓UA + sec-ch-ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111" + sec-ch-ua-mobile: ?1 + sec-ch-ua-platform: "Android" + */ + String userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; + + Map header2 = new HashMap<>(); + header2.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); + header2.put("sec-ch-ua-mobile", "sec-ch-ua-mobile"); + header2.put("sec-ch-ua-platform", "Android"); + header2.put("referer", url); + //第一次请求,获取iframe的地址 + String result = Jsoup.connect(url + id) + .userAgent(userAgent) + .get() + .select(".ifr2") + .attr("src"); + + //第二次请求得到js里的json数据里的sign + result = Jsoup.connect(url + result) + .headers(header) + .userAgent(userAgent) + .get() + .html(); + System.out.println(result); + Matcher matcher = Pattern.compile("'[\\w]+_c_c'").matcher(result); + Map params = new LinkedHashMap<>(); + if (matcher.find()) { + String sn = matcher.group().replace("'", ""); + params.put("action", "downprocess"); + params.put("sign", sn); + params.put("ves", "1"); + System.out.println(sn); + + } else { + throw new IOException(); + } + //第三次请求 通过参数发起post请求,返回json数据 + result = Jsoup + .connect(url + "ajaxm.php") + .headers(header) + .userAgent(userAgent) + .data(params) + .post() + .text() + .replace("\\", ""); + //json转为map + params = new ObjectMapper().readValue(result, new TypeReference>() {}); + System.out.println(params); + //通过json的数据拼接出最终的URL发起第最终请求,并得到响应信息头 + url = params.get("dom") + "/file/" + params.get("url"); + Map headers = Jsoup.connect(url) + .ignoreContentType(true) + .userAgent(userAgent2) + .headers(header2) + .followRedirects(false) + .execute() + .headers(); + //得到重定向的地址进行重定向 + url = headers.get("Location"); + return url; + } +} diff --git a/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index a3f5b67..cacbb75 100644 --- a/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -1,17 +1,15 @@ package cn.qaiu.lz.web.http; +import cn.qaiu.lz.common.util.LzTool; +import cn.qaiu.lz.web.model.RealUser; import cn.qaiu.lz.web.service.UserService; import cn.qaiu.vx.core.annotaions.RouteHandler; import cn.qaiu.vx.core.annotaions.RouteMapping; -import cn.qaiu.vx.core.annotaions.SockRouteMapper; import cn.qaiu.vx.core.enums.RouteMethod; import cn.qaiu.vx.core.model.JsonResult; import cn.qaiu.vx.core.util.AsyncServiceUtil; -import cn.qaiu.vx.core.util.SnowflakeIdWorker; -import cn.qaiu.vx.core.util.VertxHolder; -import cn.qaiu.lz.web.model.RealUser; import io.vertx.core.Future; -import io.vertx.ext.web.handler.sockjs.SockJSSocket; +import io.vertx.core.http.HttpServerResponse; import lombok.extern.slf4j.Slf4j; /** @@ -32,45 +30,17 @@ public class ServerApi { return userService.login(user); } - long sid = 0; - - @SockRouteMapper(value = "/test") - public void test02(SockJSSocket sock) { - String s = sock.writeHandlerID(); - System.out.println("客户端连接 --> " + s); - sock.handler(sock::write); - sock.endHandler(v -> System.out.println("客户端断开")); - String id = sock.writeHandlerID(); - System.out.println("客户端连接 --> " + id); -// sock.handler(sock::write); - sock.handler(buffer -> { - sock.write("服务端开始处理------->"); - final String msg = buffer.toString(); - if ("1".equals(msg)) { - sid = VertxHolder.getVertxInstance().setPeriodic(1000, v -> - sock.write(v + "-->" + SnowflakeIdWorker.idWorker().nextId())); - } else { - if (sid != 0) { - if (VertxHolder.getVertxInstance().cancelTimer(sid)) { - sock.write(sid + " -----> 定时推送取消"); - } - } else { - - sock.write(msg + "----- ok"); - } - } - }); - sock.endHandler(v -> { - System.out.println("客户端断开"); - if (VertxHolder.getVertxInstance().cancelTimer(sid)) { - sock.write(sid + " -----> 定时推送取消"); - } - }); - } - @RouteMapping(value = "/test2", method = RouteMethod.GET) public JsonResult test01() { return JsonResult.data("ok"); } + @RouteMapping(value = "/test3", method = RouteMethod.GET) + public void test03(HttpServerResponse response, String fullUrl) throws Exception { + String url = LzTool.parse(fullUrl); + log.info("url = {}", url); + + response.putHeader("location", "http://baidu.com").setStatusCode(302).end(); + } + } diff --git a/web/src/main/resources/1.http b/web/src/main/resources/1.http index a1c08ec..73f8b7b 100644 --- a/web/src/main/resources/1.http +++ b/web/src/main/resources/1.http @@ -1,163 +1,4 @@ - ### -POST http://127.0.0.1:8088/real/serverApi/login -Content-Type: application/x-www-form-urlencoded - -username=sa&password=sinoreal - +GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://wwp.lanzoux.com/iNvid035jgcb ### -POST http://47.114.185.111:8088/real/serverApi/login -Content-Type: application/x-www-form-urlencoded - -username=sa&password=sinoreal - -### - -GET http://127.0.0.1:8088/real/basePointApi/getTables -token: cab5bcd2fc250f27c3984205fbffc46e -Content-Type: application/json - -### - -GET http://127.0.0.1:8088/real/basePointApi/getTags?tablemask=JTdevice -token: 7670b1a3da5e22ffc42a1e738ea4f0f6 - -### -GET http://127.0.0.1:8088/real/basePointApi/getSnapshotDataByTag/adasd?aaa=3 -token: 7670b1a3da5e22ffc42a1e738ea4f0f6 - -### - -POST http://127.0.0.1:8088/real/serverApi/login -Content-Type: application/json - -{ - "username": "sa", - "password": "sinoreal" -} - -### - -POST http://127.0.0.1:8088/real/basePointApi/updateTag -token: cab5bcd2fc250f27c3984205fbffc46e -Content-Type: application/json - -{ - "userints": [123223,35356], - "id": 123, - "equation": "asd", - "trigger": "RTDB_EVENT_TRIGGER", - "shutdown": true -} - - - -### - -GET http://127.0.0.1:8088/real/basePointApi/getTagById/753 -token: eb7d391ad89d4bb4a81897af8829f0e8 - -### - -GET http://127.0.0.1:8088/real/basePointApi/aaaa -token: cab5bcd2fc250f27c3984205fbffc46e - -### - -GET http://127.0.0.1:8088/real/serverApi/test - -### - -POST http://127.0.0.1:8088/real/serverApi/addUser -Content-Type: application/x-www-form-urlencoded -token: 2b4769b63c90adb6490cfe6e449da90b - -username=sa1&password=sinoreal&permission=3 - - -### -POST http://127.0.0.1:8088/real/serverApi/removeUser -Content-Type: application/x-www-form-urlencoded -token: 2b4769b63c90adb6490cfe6e449da90b - -username=sa1 - - -### - -POST http://127.0.0.1:8088/real/serverApi/updatePassword -Content-Type: application/x-www-form-urlencoded -token: 33c21f7cf053b90a713f1f9e124d0335 - -oldPassword=sinoreal1&newPassword=sinoreal - - -### - -POST http://127.0.0.1:8088/real/serverApi/changePriv -Content-Type: application/x-www-form-urlencoded -token: 2b4769b63c90adb6490cfe6e449da90b - -username=sa1&permission=3 - - -### -POST http://127.0.0.1:8088/real/serverApi/addAuthorization -Content-Type: application/x-www-form-urlencoded -token: 2b4769b63c90adb6490cfe6e449da90b - -addr=192.168.1.56&mask=255.255.255.255&permission=3&description=测试信任666111 - - -### -POST http://127.0.0.1:8088/real/serverApi/removeAuthorization -Content-Type: application/x-www-form-urlencoded -token: 2b4769b63c90adb6490cfe6e449da90b - -addr=192.168.1.56&mask=255.255.255.255 - - -### -POST http://127.0.0.1:8088/real/historyApi/getHistory -Content-Type: application/x-www-form-urlencoded -token: 2b4769b63c90adb6490cfe6e449da90b - -startDate=2021-05-17 11:03&endDate=2021-05-17 11:04&interval=3 - -### -POST http://127.0.0.1:8088/real/historyApi/getHistory -Content-Type: application/x-www-form-urlencoded -token: 2b4769b63c90adb6490cfe6e449da90b - -startDate=2021-05-17 11:03 - -### -GET http://127.0.0.1:8088/real/dict/getDictByName?name=dict2 -token: 7670b1a3da5e22ffc42a1e738ea4f0f6 - -### -tagmask=*&desc=*&_PointType=Every&_ValueTypeString=*&_TimeAccuracy=-1&_SearchCondition=SEARCH_NULL&SearchMaskValue=*&source=*&instrument=*& - -### -http://127.0.0.1:8088/real/basePointApi/getTags?tablemask=demo02&tagmask=*&desc=*&_PointType=Every&_ValueTypeString=*&_TimeAccuracy=-1&_SearchCondition=SEARCH_NULL&SearchMaskValue=*&source=*&instrument=*&pageNumber=1&pageSize=10 -token: eb7d391ad89d4bb4a81897af8829f0e8 - -### -http://127.0.0.1:8088/real/serverApi/getFile?path=D: -token: 7670b1a3da5e22ffc42a1e738ea4f0f6 - -### -#http://127.0.0.1:8088/real/serverApi/hello1/:msg -http://127.0.0.1:8088/real/serverApi/hello1/ok1 -token: a3cada4c97be40d3bc35cfe6ec1288ab - -### -http://127.0.0.1:8088/real/serverApi/hello2/ok2 -token: a3cada4c97be40d3bc35cfe6ec1288ab - - - - -### -http://127.0.0.1:8085/real/basePointApi/getTags?tablemask=demo02&tagmask=*&desc=*&unit=*&pointType=Every&valueTypeString=*&timeAccuracy=-1&searchCondition=SEARCH_NULL&SearchMaskValue=*&source=*&instrument=*&pageNumber=1&pageSize=10&accurateSearch= -token: c423c04a55964571bd34aaa1683229e8 +GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://lanzoux.com/ia2cntg diff --git a/web/src/main/resources/server-proxy.yml b/web/src/main/resources/server-proxy.yml index 8ed4fdc..94ee9e6 100644 --- a/web/src/main/resources/server-proxy.yml +++ b/web/src/main/resources/server-proxy.yml @@ -1,27 +1,27 @@ # 反向代理 server-name: Vert.x-proxy-server(v4.1.2) -proxy: - - listen: 8085 - # 404的路径 - 404: webroot/real-html/index.html - static: - path: / -# add-headers: -# x-token: ABC - root: webroot/real-html/ - index: realIndex - location: - - path: /real/ - origin: 127.0.0.1:8088 - - path: /api/ - origin: 127.0.0.1:7070/demo/ - - - listen: 8086 - static: - path: /t2/ - root: webroot/test/ - index: sockTest.html +#proxy: +# - listen: 8085 +# # 404的路径 +# 404: webroot/real-html/index.html +# static: +# path: / +## add-headers: +## x-token: ABC +# root: webroot/real-html/ +# index: realIndex +# location: +# - path: /real/ +# origin: 127.0.0.1:8088 +# - path: /api/ +# origin: 127.0.0.1:7070/demo/ +# +# - listen: 8086 +# static: +# path: /t2/ +# root: webroot/test/ +# index: sockTest.html # location: # - path: /real/ # origin: 127.0.0.1:8088 From 07d8ed19b0afbf9f4b31ed6d48b37a8912f4ad1f Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Fri, 21 Apr 2023 23:30:50 +0800 Subject: [PATCH 06/48] 0.0.1 done --- README.md | 30 ++++++- core/pom.xml | 18 ---- {web => lz-cow-api-web}/assembly.xml | 0 {web => lz-cow-api-web}/pom.xml | 2 +- .../src/main/java/cn/qaiu/lz/AppMain.java | 0 .../main/java/cn/qaiu/lz/common/ToJson.java | 0 .../interceptorImpl/DefaultInterceptor.java | 18 +--- .../java/cn/qaiu/lz/common/model/MyData.java | 5 -- .../cn/qaiu/lz/common/model/UserInfo.java | 5 -- .../cn/qaiu/lz/common/util/ArrayUtil.java | 0 .../cn/qaiu/lz/common/util/ConnectUtil.java | 0 .../java/cn/qaiu/lz/common/util/CowTool.java | 82 +++++++++++++++++++ .../java/cn/qaiu/lz/common/util/LzTool.java | 6 +- .../main/java/cn/qaiu/lz/package-info.java | 0 .../java/cn/qaiu/lz/web/http/ServerApi.java | 80 ++++++++++++++++++ .../java/cn/qaiu/lz/web/model/RealUser.java | 0 .../cn/qaiu/lz/web/service/DbService.java | 0 .../qaiu/lz/web/service/JdkProxyFactory.java | 0 .../qaiu/lz/web/service/ServiceJdkProxy.java | 0 .../cn/qaiu/lz/web/service/UserService.java | 0 .../lz/web/service/impl/DbServiceImpl.java | 0 .../lz/web/service/impl/UserServiceImpl.java | 0 lz-cow-api-web/src/main/resources/1.http | 31 +++++++ .../src/main/resources/2.http | 0 .../src/main/resources/app-dev.yml | 2 +- .../src/main/resources/app.yml | 0 .../src/main/resources/conf/dictionaries.json | 0 .../src/main/resources/curl/curl.sh | 0 .../src/main/resources/server-proxy.yml | 0 .../test/java/cn/qaiu/web/test/Test01.java | 0 .../test/java/cn/qaiu/web/test/Test02.java | 0 .../test/java/cn/qaiu/web/test/TestJsoup.java | 66 +++++++++++++++ .../test/java/cn/qaiu/web/test/TestOS.java | 0 .../cn/qaiu/web/test/WebProxyExamples.java | 0 pom.xml | 4 +- .../java/cn/qaiu/lz/web/http/ServerApi.java | 46 ----------- web/src/main/resources/1.http | 4 - .../test/java/cn/qaiu/web/test/StompTest.java | 42 ---------- 38 files changed, 296 insertions(+), 145 deletions(-) rename {web => lz-cow-api-web}/assembly.xml (100%) rename {web => lz-cow-api-web}/pom.xml (99%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/AppMain.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/common/ToJson.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java (55%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/common/model/MyData.java (68%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/common/model/UserInfo.java (75%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java (100%) create mode 100644 lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/common/util/LzTool.java (96%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/package-info.java (100%) create mode 100644 lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/web/model/RealUser.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/web/service/DbService.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/web/service/UserService.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java (100%) rename {web => lz-cow-api-web}/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java (100%) create mode 100644 lz-cow-api-web/src/main/resources/1.http rename {web => lz-cow-api-web}/src/main/resources/2.http (100%) rename {web => lz-cow-api-web}/src/main/resources/app-dev.yml (97%) rename {web => lz-cow-api-web}/src/main/resources/app.yml (100%) rename {web => lz-cow-api-web}/src/main/resources/conf/dictionaries.json (100%) rename {web => lz-cow-api-web}/src/main/resources/curl/curl.sh (100%) rename {web => lz-cow-api-web}/src/main/resources/server-proxy.yml (100%) rename {web => lz-cow-api-web}/src/test/java/cn/qaiu/web/test/Test01.java (100%) rename {web => lz-cow-api-web}/src/test/java/cn/qaiu/web/test/Test02.java (100%) create mode 100644 lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestJsoup.java rename {web => lz-cow-api-web}/src/test/java/cn/qaiu/web/test/TestOS.java (100%) rename {web => lz-cow-api-web}/src/test/java/cn/qaiu/web/test/WebProxyExamples.java (100%) delete mode 100644 web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java delete mode 100644 web/src/main/resources/1.http delete mode 100644 web/src/test/java/cn/qaiu/web/test/StompTest.java diff --git a/README.md b/README.md index bd74bbb..482a816 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ # lz-cow-api -蓝奏云-奶牛快传的直链解析的API服务 +蓝奏云-奶牛快传的直链解析的API服务 + +示例: +``` +// 解析并重定向到直链 +### +# @no-redirect +GET http://127.0.0.1:6400/parse?url=https://lanzoux.com/ia2cntg +### +# @no-redirect +GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/core/api/transfer/share?uniqueUrl=9a644fe3e3a748 + +// Rest请求(只提供共享文件Id): cow 奶牛快传; lz 蓝奏云 +### +# @no-redirect +GET http://127.0.0.1:6400/cow/9a644fe3e3a748 + +// 解析返回json直链 +### +GET http://127.0.0.1:6400/json/cow/9a644fe3e3a748 +### +GET http://127.0.0.1:6400/json/lz/ia2cntg + +``` + +TODO: +解析蓝奏云加密链接 + + diff --git a/core/pom.xml b/core/pom.xml index 0a01d68..f765612 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -66,28 +66,10 @@ io.vertx vertx-service-proxy - - io.vertx - vertx-jdbc-client - - - - io.vertx - vertx-sql-client-templates - - - - io.vertx - vertx-auth-jwt - io.vertx vertx-web-proxy - - io.vertx - vertx-stomp - org.reflections reflections diff --git a/web/assembly.xml b/lz-cow-api-web/assembly.xml similarity index 100% rename from web/assembly.xml rename to lz-cow-api-web/assembly.xml diff --git a/web/pom.xml b/lz-cow-api-web/pom.xml similarity index 99% rename from web/pom.xml rename to lz-cow-api-web/pom.xml index 360bf63..4de1019 100644 --- a/web/pom.xml +++ b/lz-cow-api-web/pom.xml @@ -9,7 +9,7 @@ 4.0.0 0.0.1 - web + lz-cow-api-web ${project.basedir}/target/package diff --git a/web/src/main/java/cn/qaiu/lz/AppMain.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/AppMain.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java diff --git a/web/src/main/java/cn/qaiu/lz/common/ToJson.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/ToJson.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/common/ToJson.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/common/ToJson.java diff --git a/web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java similarity index 55% rename from web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java index a0d1e9e..6065941 100644 --- a/web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java @@ -24,22 +24,6 @@ public class DefaultInterceptor implements Interceptor, BaseHttpApi { @Override public void handle(RoutingContext ctx) { - - // 判断是否忽略 - if (CommonUtil.matchRegList(ignores.getList(), ctx.request().path())) { - ctx.next(); - return; - } - // 执行拦截 - val token = ctx.request().getHeader("token"); - - - LocalMap tokenMap = SharedDataUtil.getLocalMapWithCast("token"); - if (token != null && tokenMap != null && tokenMap.containsKey(token)) { - VertxHolder.getVertxInstance().getOrCreateContext().put("username", tokenMap.get(token)); - ctx.next(); - } else { - fireJsonResponse(ctx, JsonResult.error("没有权限", 401)); - } + ctx.next(); } } diff --git a/web/src/main/java/cn/qaiu/lz/common/model/MyData.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/MyData.java similarity index 68% rename from web/src/main/java/cn/qaiu/lz/common/model/MyData.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/MyData.java index 2b02228..4614000 100644 --- a/web/src/main/java/cn/qaiu/lz/common/model/MyData.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/MyData.java @@ -1,10 +1,7 @@ package cn.qaiu.lz.common.model; import io.vertx.codegen.annotations.DataObject; -import io.vertx.codegen.format.SnakeCase; import io.vertx.core.json.JsonObject; -import io.vertx.sqlclient.templates.annotations.ParametersMapped; -import io.vertx.sqlclient.templates.annotations.RowMapped; import lombok.Data; import lombok.NoArgsConstructor; @@ -16,8 +13,6 @@ import java.io.Serializable; *
Create date 2021/7/22 3:34 */ @DataObject -@RowMapped(formatter = SnakeCase.class) -@ParametersMapped(formatter = SnakeCase.class) @Data @NoArgsConstructor public class MyData implements Serializable { diff --git a/web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java similarity index 75% rename from web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java index c295556..1bb2efd 100644 --- a/web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java @@ -2,10 +2,7 @@ package cn.qaiu.lz.common.model; import cn.qaiu.lz.common.ToJson; import io.vertx.codegen.annotations.DataObject; -import io.vertx.codegen.format.SnakeCase; import io.vertx.core.json.JsonObject; -import io.vertx.sqlclient.templates.annotations.ParametersMapped; -import io.vertx.sqlclient.templates.annotations.RowMapped; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -20,8 +17,6 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor @DataObject -@RowMapped(formatter = SnakeCase.class) -@ParametersMapped(formatter = SnakeCase.class) public class UserInfo implements ToJson { private String username; diff --git a/web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java diff --git a/web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java new file mode 100644 index 0000000..10234fa --- /dev/null +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java @@ -0,0 +1,82 @@ +package cn.qaiu.lz.common.util; + +import cn.qaiu.vx.core.util.CastUtil; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.vertx.core.http.HttpClient; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.jsoup.Jsoup; + +import java.io.IOException; +import java.util.Map; + +/** + * @author QAIU + * @date 2023/4/21 21:19 + */ +@Slf4j +public class CowTool { + /* + First request: + { + "code": "0000", + "message": "success", + "data": { + "guid": "e4f41b51-b5da-4f60-9312-37aa10c0aad7", + "firstFile": { + "id": "23861191276513345", + } + } + } + + Then request: + { + "code": "0000", + "message": "success", + "tn": "TN:DE0E092E8A464521983780FBA21D0CD3", + "data": { + "downloadUrl": "https://download.cowcs.com..." + } + } + */ + public static String parse(String fullUrl) throws IOException { + String uniqueUrl = fullUrl.substring(fullUrl.lastIndexOf('=') + 1); + String baseUrl = "https://cowtransfer.com/core/api/transfer/share"; + String result = Jsoup + .connect(baseUrl + "?uniqueUrl=" + uniqueUrl).ignoreContentType(true) + .get() + .text(); + ObjectMapper objectMapper = new ObjectMapper(); + Map map = objectMapper.readValue(result, new TypeReference<>() { + }); + + if ("success".equals(map.get("message")) && map.containsKey("data")) { + Map data = CastUtil.cast(map.get("data")); + String guid = data.get("guid").toString(); + Map firstFile = CastUtil.cast(data.get("firstFile")); + String fileId = firstFile.get("id").toString(); + String result2 = Jsoup + .connect(baseUrl + "/download?transferGuid=" + guid + "&fileId=" + fileId) + .ignoreContentType(true) + .get() + .text(); + Map map2 = objectMapper.readValue(result2, new TypeReference<>() { + }); + + if ("success".equals(map2.get("message")) && map2.containsKey("data")) { + Map data2 = CastUtil.cast(map2.get("data")); + String downloadUrl = data2.get("downloadUrl").toString(); + if (StringUtils.isNotEmpty(downloadUrl)) { + log.info("cow parse success: {}", downloadUrl); + return downloadUrl; + } + } + + } + log.info("Cow parse field------------->end"); + return null; + } + + +} diff --git a/web/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java similarity index 96% rename from web/src/main/java/cn/qaiu/lz/common/util/LzTool.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java index 9178b56..668f3b4 100644 --- a/web/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -52,7 +52,7 @@ public class LzTool { .userAgent(userAgent) .get() .html(); - System.out.println(result); +// System.out.println(result); Matcher matcher = Pattern.compile("'[\\w]+_c_c'").matcher(result); Map params = new LinkedHashMap<>(); if (matcher.find()) { @@ -60,7 +60,7 @@ public class LzTool { params.put("action", "downprocess"); params.put("sign", sn); params.put("ves", "1"); - System.out.println(sn); +// System.out.println(sn); } else { throw new IOException(); @@ -76,7 +76,7 @@ public class LzTool { .replace("\\", ""); //json转为map params = new ObjectMapper().readValue(result, new TypeReference>() {}); - System.out.println(params); +// System.out.println(params); //通过json的数据拼接出最终的URL发起第最终请求,并得到响应信息头 url = params.get("dom") + "/file/" + params.get("url"); Map headers = Jsoup.connect(url) diff --git a/web/src/main/java/cn/qaiu/lz/package-info.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/package-info.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/package-info.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/package-info.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java new file mode 100644 index 0000000..ade96fe --- /dev/null +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -0,0 +1,80 @@ +package cn.qaiu.lz.web.http; + +import cn.qaiu.lz.common.util.CowTool; +import cn.qaiu.lz.common.util.LzTool; +import cn.qaiu.lz.web.model.RealUser; +import cn.qaiu.lz.web.service.UserService; +import cn.qaiu.vx.core.annotaions.RouteHandler; +import cn.qaiu.vx.core.annotaions.RouteMapping; +import cn.qaiu.vx.core.enums.RouteMethod; +import cn.qaiu.vx.core.model.JsonResult; +import cn.qaiu.vx.core.util.AsyncServiceUtil; +import io.vertx.core.Future; +import io.vertx.core.http.HttpServerResponse; +import lombok.extern.slf4j.Slf4j; + +/** + * 服务API + *
Create date 2021/4/28 9:15 + * + * @author QAIU + */ +@Slf4j +@RouteHandler("/") +public class ServerApi { + + private final UserService userService = AsyncServiceUtil.getAsyncServiceInstance(UserService.class); + + @RouteMapping(value = "/login", method = RouteMethod.POST) + public Future login(RealUser user) { + log.info("<------- login: {}", user.getUsername()); + return userService.login(user); + } + + @RouteMapping(value = "/test2", method = RouteMethod.GET) + public JsonResult test01() { + return JsonResult.data("ok"); + } + + @RouteMapping(value = "/parse", method = RouteMethod.GET) + public void parse(HttpServerResponse response, String url) throws Exception { + if (url.contains("lanzou")) { + String urlDownload = LzTool.parse(url); + log.info("url = {}", urlDownload); + response.putHeader("location", urlDownload).setStatusCode(302).end(); + } else if (url.contains("cowtransfer.com")) { + String urlDownload = CowTool.parse(url); + response.putHeader("location", urlDownload).setStatusCode(302).end(); + } + + } + + @RouteMapping(value = "/lz/:id", method = RouteMethod.GET) + public void lzParse(HttpServerResponse response, String id) throws Exception { + String url = "https://wwa.lanzoux.com/" + id; + String urlDownload = LzTool.parse(url); + log.info("url = {}", urlDownload); + response.putHeader("location", urlDownload).setStatusCode(302).end(); + } + + @RouteMapping(value = "/cow/:id", method = RouteMethod.GET) + public void cowParse(HttpServerResponse response, String id) throws Exception { + String url = "https://cowtransfer.com/core/api/transfer/share?uniqueUrl=" + id; + String urlDownload = CowTool.parse(url); + response.putHeader("location", urlDownload).setStatusCode(302).end(); + } + + @RouteMapping(value = "/json/lz/:id", method = RouteMethod.GET) + public JsonResult lzParseJson(HttpServerResponse response, String id) throws Exception { + String url = "https://wwa.lanzoux.com/" + id; + String urlDownload = LzTool.parse(url); + log.info("url = {}", urlDownload); + return JsonResult.data(urlDownload); + } + + @RouteMapping(value = "/json/cow/:id", method = RouteMethod.GET) + public JsonResult cowParseJson(HttpServerResponse response, String id) throws Exception { + String url = "https://cowtransfer.com/core/api/transfer/share?uniqueUrl=" + id; + return JsonResult.data(CowTool.parse(url)); + } +} diff --git a/web/src/main/java/cn/qaiu/lz/web/model/RealUser.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/web/model/RealUser.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java diff --git a/web/src/main/java/cn/qaiu/lz/web/service/DbService.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/DbService.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/web/service/DbService.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/DbService.java diff --git a/web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java diff --git a/web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java diff --git a/web/src/main/java/cn/qaiu/lz/web/service/UserService.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/UserService.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/web/service/UserService.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/UserService.java diff --git a/web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java diff --git a/web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java similarity index 100% rename from web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java diff --git a/lz-cow-api-web/src/main/resources/1.http b/lz-cow-api-web/src/main/resources/1.http new file mode 100644 index 0000000..3465131 --- /dev/null +++ b/lz-cow-api-web/src/main/resources/1.http @@ -0,0 +1,31 @@ +### +GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://wwp.lanzoux.com/iNvid035jgcb +### +# @no-redirect +GET http://127.0.0.1:6400/parse?url=https://lanzoux.com/ia2cntg +### +# @no-redirect +GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/core/api/transfer/share?uniqueUrl=9a644fe3e3a748 +### +# @no-redirect +GET http://127.0.0.1:6400/cow/9a644fe3e3a748 + +### +GET http://127.0.0.1:6400/lz/ia2cntg +### +GET http://127.0.0.1:6400/json/lz/ia2cntg + + +### +https://cowtransfer.com/core/api/transfer/share?uniqueUrl=9a644fe3e3a748 + +### +https://cowtransfer.com/core/api/transfer/share?uniqueUrl=e4f41b51b5da4f + +### +https://cowtransfer.com/core/api/transfer/share/download?transferGuid=e4f41b51-b5da-4f60-9312-37aa10c0aad7&fileId=23861191276513345 + + +//https://download.cowcs.com/cowtransfer/cowtransfer/29188/db32e132e69f490eb4a343b398990f4b.docx?auth_key=1682111861-7b9579fbebb84aaba6bca368d083ab12-0-cbf009f3ffbcbb86191b8cdbc103abce&biz_type=1&business_code=COW_TRANSFER&channel_code=COW_CN_WEB&response-content-disposition=attachment%3B%20filename%3D05-CGB-DB-MENU-V1.02.docx%3Bfilename*%3Dutf-8%27%2705-CGB-DB-MENU-V1.02.docx&user_id=1023860921943729188&x-verify=1 + + diff --git a/web/src/main/resources/2.http b/lz-cow-api-web/src/main/resources/2.http similarity index 100% rename from web/src/main/resources/2.http rename to lz-cow-api-web/src/main/resources/2.http diff --git a/web/src/main/resources/app-dev.yml b/lz-cow-api-web/src/main/resources/app-dev.yml similarity index 97% rename from web/src/main/resources/app-dev.yml rename to lz-cow-api-web/src/main/resources/app-dev.yml index 690a24c..eaa6d50 100644 --- a/web/src/main/resources/app-dev.yml +++ b/lz-cow-api-web/src/main/resources/app-dev.yml @@ -1,7 +1,7 @@ # 服务配置 server: port: 6400 - contextPath: /api + contextPath: / enableStaticHtmlService: false staticResourcePath: webroot/ # 反向代理服务器配置路径(不用加后缀) diff --git a/web/src/main/resources/app.yml b/lz-cow-api-web/src/main/resources/app.yml similarity index 100% rename from web/src/main/resources/app.yml rename to lz-cow-api-web/src/main/resources/app.yml diff --git a/web/src/main/resources/conf/dictionaries.json b/lz-cow-api-web/src/main/resources/conf/dictionaries.json similarity index 100% rename from web/src/main/resources/conf/dictionaries.json rename to lz-cow-api-web/src/main/resources/conf/dictionaries.json diff --git a/web/src/main/resources/curl/curl.sh b/lz-cow-api-web/src/main/resources/curl/curl.sh similarity index 100% rename from web/src/main/resources/curl/curl.sh rename to lz-cow-api-web/src/main/resources/curl/curl.sh diff --git a/web/src/main/resources/server-proxy.yml b/lz-cow-api-web/src/main/resources/server-proxy.yml similarity index 100% rename from web/src/main/resources/server-proxy.yml rename to lz-cow-api-web/src/main/resources/server-proxy.yml diff --git a/web/src/test/java/cn/qaiu/web/test/Test01.java b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/Test01.java similarity index 100% rename from web/src/test/java/cn/qaiu/web/test/Test01.java rename to lz-cow-api-web/src/test/java/cn/qaiu/web/test/Test01.java diff --git a/web/src/test/java/cn/qaiu/web/test/Test02.java b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/Test02.java similarity index 100% rename from web/src/test/java/cn/qaiu/web/test/Test02.java rename to lz-cow-api-web/src/test/java/cn/qaiu/web/test/Test02.java diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestJsoup.java b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestJsoup.java new file mode 100644 index 0000000..076e0c1 --- /dev/null +++ b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestJsoup.java @@ -0,0 +1,66 @@ +package cn.qaiu.web.test; + +import cn.qaiu.vx.core.util.CastUtil; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.jsoup.Jsoup; +import org.junit.Test; + +import java.io.IOException; +import java.util.Map; + +/** + * @author QAIU + * @date 2023/4/21 21:43 + */ +@Slf4j +public class TestJsoup { +/* + + + +2023-04-21 21:52:56.401 INFO -> [ main] cn.qaiu.web.test.TestJsoup : +{code=0000, message=success, tn=TN:19387A43A5564BB6B52B008071DD69B2, +data={payEnabled=false, payStatus=false, skuId=null, skuPrice=null, +guid=e4f41b51-b5da-4f60-9312-37aa10c0aad7, transferName=05-CGB-DB-MENU-V1.02, +transferMessage=null, uniqueUrl=e4f41b51b5da4f, needPassword=false, +expireAt=2099-12-31 23:59:59, validDays=-1, enableDownload=true, enablePreview=true, enableSaveto=true, +uploadState=1, deleted=false, tag=1, dataTag=1, status=0, fileAmount=1, folderAmount=0, size=962041, openId=1023860921943729188, +firstFile={id=23861191276513345, owner=1023860921943729188, recycle=false, need_pro=false, storage_class=standard, file_type=document, analysis_status=2, audit_status=2, repository_id=2004556995, created_at=1682081417000, created_by=1023860921943729188, updated_at=1682081416968, folder_id=2013607944, folder_name=, file_info={format=docx, size=962041, title=05-CGB-DB-MENU-V1.02, description=, preview={ext={"ratio":3}, height=2525, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/82ff6da4-67f9-4cdb-8495-24bcd97cd6ab69566.png?auth_key=1682099544-1f494837775a422d82f4e67006c720c1-0-0d1cc615dd3e5b7a900b75fc5f7edf21, width=1785}, colors=[], origin_url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/db32e132e69f490eb4a343b398990f4b.docx?auth_key=1682099544-d71aa67f5af843cba64a5dfff9ec3357-0-ec3e3325421d8f858c4a3cb33139553c, theme_color=, extend_previews=[{ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/312b7270-106a-480d-9deb-49df4c6539b069567.png?auth_key=1682099544-695f3060762c474d8312efc8205b85e3-0-a80564c120ff26c276cce769f091e9fa, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/6322a6a9-d1ea-4904-ada0-a0cfe504b32e69568.png?auth_key=1682099544-04e62f12cca94ad5a8f86c922d76b2f3-0-6efc5315f539691b378be42757a6d9f1, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/f6f37eb4-0be8-41e6-b362-07e2331237f369569.png?auth_key=1682099544-c28fd4178f9541938136ece965e8c6f0-0-71a0d0b9a7b7ea16be8d76294987ca48, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/f0f3d05d-7597-4235-b41d-2beb79fee1c869570.png?auth_key=1682099544-49825346ee864edfa855c05f65e11cdc-0-c511e3c9d18bb88a1044dc374f53b5e3, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/a85999d4-007e-4b68-882a-3f5ac593b6ce69571.png?auth_key=1682099544-898de7bce2a44413a297ec455a628f41-0-80f2b0bbcd4979e0c341ae629681825f, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/725f22ae-b7d3-4447-9408-df1da9a9c1bd69572.png?auth_key=1682099544-5b0b2f6b640a4e44936cacfbf1907d9c-0-8d0a7568bb13a93c0cb020f7f2498028, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/427cf5da-8d67-41b3-a429-37e8f3cc96b069573.png?auth_key=1682099544-fe5f7595fc0748868de59c19139dff3d-0-0078c6a395a89afdeef23df934636665, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/e2f489d3-7b28-4d9b-af0c-cbcc0e71fb3469574.png?auth_key=1682099544-85e4592f24e840f59ac0b5e51e39eb97-0-7211f254968e80f34680b530f06120d8, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/f885435e-2758-4dec-90e0-c7f6d55b8bff69575.png?auth_key=1682099544-96df86e45e5a4b02a1bd6197c292fe53-0-7d0af45b70b7e55ab383d0019a1dc5cd, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/f1570313-64ec-4547-9e9c-0af154cd8dc469576.png?auth_key=1682099544-4218db8e98f541a2ad8ad717958cc859-0-588626b81c407d1150319b4d76e2069b, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/7d9e7d47-a874-4c45-9bba-0687d2b4b36c69577.png?auth_key=1682099544-9322e74bc4694be386cc284ee1e4991a-0-2734f9d25bdee992255f0d410a57ad42, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/7a58264c-0b8d-4737-99e6-c336c59d5e9e69578.png?auth_key=1682099544-e80940a49de5408da1906bde7aeaadb9-0-0c471dc965e28fd7d8b12ce5a8d98317, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/fc452796-048e-4926-85cf-ec9fc62fd50369579.png?auth_key=1682099544-3fb431425b07484dae2479b6488ee1df-0-cfeecc56fb2cf5ca2a9148de3581056e, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/5aa0b694-b420-43b3-b0bd-616e34c7a84269580.png?auth_key=1682099544-00a8b57aeeb6436a82abcd44d027345c-0-9d7bc1319e4cbefa8017eaa7504f6ef7, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/e4d9be2e-00be-45f1-a6f2-e78e8aa9405469581.png?auth_key=1682099544-388d1436290e4cdca82a0852ba55c005-0-526df026b1359fe1d031b7ea2429d115, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/7878c6e6-8983-4ef4-9bc5-f0b6c40fbc3869582.png?auth_key=1682099544-a288c1b2f78945d3a2298d5b9a7806cd-0-2ee0cb7aeb8dac5a5dcd5a5e98a0dc4a, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/86b9fe4c-fd0b-4c66-9ca6-d7756573c7d769583.png?auth_key=1682099544-2d3022ff607840cd920c6ed6e8192718-0-d118921ce6d6332292836080105df7d4, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/1347bd4c-67ee-44e4-a8c7-2732422de33769584.png?auth_key=1682099544-0edbf55bab6e443a86c3f266942b2bb9-0-40ea5e075efa1d2bb9463ee3206945f3, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/2402bdcb-5cc3-4936-b433-780ee69d29d769585.png?auth_key=1682099544-6fbdd591672146efa58ca39f17cf4d90-0-c3317facaf27bb24990909797c8131bb, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/c66339b0-2896-4772-82e2-514c30b7007669586.png?auth_key=1682099544-13774a13171b41189464c5b08b51b230-0-0b592e6f0e921cbd6d3c8be98038fdc0, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/74611acd-fa00-4356-a526-6d5adccddb6169587.png?auth_key=1682099544-4f9edebf7ac449539d011e8f61d6b024-0-a7b60ddc5193b5efcc5da1760a1b5c6a, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/cf3462bd-fdbb-4e6d-8dd5-9ba4b0245a7869588.png?auth_key=1682099544-a970b0bbef744224898403bc4ea21025-0-8a0fa954736aa0018bf7f15f5eca8ff5, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/8b1bded3-7636-4b9a-aed4-27bdb5cac02969589.png?auth_key=1682099544-5510a830e0d54f1a869cee37f0120181-0-d387b63c2cefb5d6e234746c20d802a9, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/0f32ff8c-81a9-4a7f-8b47-7356b8f9708a69590.png?auth_key=1682099544-778e56b2660044879a64bd73cc3653d9-0-d09837511af37730045f240aace666f3, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/77da0e25-3155-4f5c-a382-ec066afacf8069591.png?auth_key=1682099544-f6753571d09d4f60b3bf52a6d1509471-0-890fc11cbff3f372847cde64cfce047e, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/b5ffa264-7a21-406e-9ba4-f306c252827669592.png?auth_key=1682099544-9e89ee064e77444dbc8efb8c58264ead-0-6e33b5e1628d3c76ce273ec1122943c8, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/90d39f4b-94d2-44fe-80f5-ff010ee11bd469593.png?auth_key=1682099544-99fc8ad1607d40449653aee22e899709-0-3e220bdfb3be8811d249a0d1ebc9c37c, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/affdc9b8-f3e6-4700-b5ff-bfbfa28c0f8f69594.png?auth_key=1682099544-fd9868d864864111b29a482ed1af913a-0-f72b6eb1de8f1a06a9978ae12ec530df, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/85a905c6-afe9-4079-85d6-ab5bb377f70869595.png?auth_key=1682099544-6ad4b40a3d2c4fb78a721d393174f584-0-a23d71ff3f03de11de77a0da9a8caa2b, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/6bf91741-bd1d-49ba-ba4b-4759831e364269596.png?auth_key=1682099544-7a1de1f120d74914a2620aeb099ba084-0-776b564c76ef2568ece044dfe2a192ff, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/d03f08dd-156c-45e7-8b94-afa13b8afcd469597.png?auth_key=1682099544-a4a53055c6aa4b4fb2f7d112a6429d77-0-a802f42a4671c2d7e13abe69233e9336, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/e80a0b67-122a-4276-a671-d9e5008d336e69598.png?auth_key=1682099544-8bfa620907534670834e40b9235baf69-0-500db05cf6cc42952dbb375cce9f361a, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/ba61d5c3-307e-4afd-95cd-d45412ae55da69599.png?auth_key=1682099544-f9bd3a4beede4723b9b3ac225e65c8c1-0-93f08328115bddbdf798f6df59381b3a, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/e56afec9-3c04-46c0-a1ed-ca5b8b20466d69600.png?auth_key=1682099544-397910a7945942f496800102b597b3a8-0-42dc09c2de91bef1c69e55a36163b65b, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/54d6b750-7b7a-4b91-950d-919d2449487469601.png?auth_key=1682099544-4eb6b7e6c6c443c6a1a7058179074300-0-6ac688110cd244102b19e41924717bae, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/15387dca-6ca9-422c-a775-4bcf9721fd4669602.png?auth_key=1682099544-436689971c234e67a806f9c7ebdc11c2-0-02dc01b03b941f378e5f708c599e6218, width=0}, {ext={"ratio":1}, height=0, url=https://download.cowcs.com/cowtransfer/cowtransfer/29188/90c577b1-7830-4365-a820-c83adaeaf00c69603.png?auth_key=1682099544-2323376ba3de435a84adb4a8b319aa5d-0-3d58a45a4e3d71599edda71ad1578b3d, width=0}], music_info=null, video_info=null}}, firstFolder=null, zipDownload=false}} +与目标 VM 断开连接, 地址为: ''127.0.0.1:57249',传输: '套接字'' + */ + @Test + public void test1() throws IOException { + String baseUrl = "https://cowtransfer.com/core/api/transfer/share"; + String result = Jsoup + .connect(baseUrl+"?uniqueUrl=e4f41b51b5da4").ignoreContentType(true) + .get() + .text(); + ObjectMapper objectMapper = new ObjectMapper(); + Map map = objectMapper.readValue(result, new TypeReference<>() {}); + if ("success".equals(map.get("message")) && map.containsKey("data")) { + Map data = CastUtil.cast(map.get("data")); + String guid = data.get("guid").toString(); + Map firstFile = CastUtil.cast(data.get("firstFile")); + String fileId = firstFile.get("id").toString(); + String result2 = Jsoup + .connect(baseUrl+"/download?transferGuid="+guid+"&fileId="+fileId) + .ignoreContentType(true) + .get() + .text(); + Map map2 = objectMapper.readValue(result2, new TypeReference<>() {}); + + if ("success".equals(map2.get("message")) && map2.containsKey("data")) { + Map data2 = CastUtil.cast(map2.get("data")); + String downloadUrl = data2.get("downloadUrl").toString(); + if (StringUtils.isNotEmpty(downloadUrl)) { + log.info(downloadUrl); + } + } + + } + log.info("OK------------->end"); + } +} diff --git a/web/src/test/java/cn/qaiu/web/test/TestOS.java b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestOS.java similarity index 100% rename from web/src/test/java/cn/qaiu/web/test/TestOS.java rename to lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestOS.java diff --git a/web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java similarity index 100% rename from web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java rename to lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java diff --git a/pom.xml b/pom.xml index 6c53375..52eece4 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ core - web + lz-cow-api-web @@ -19,7 +19,7 @@ 17 UTF-8 4.1.3 - ${project.basedir}/web/target/package + ${project.basedir}/lz-cow-api-web/target/package diff --git a/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java deleted file mode 100644 index cacbb75..0000000 --- a/web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.qaiu.lz.web.http; - -import cn.qaiu.lz.common.util.LzTool; -import cn.qaiu.lz.web.model.RealUser; -import cn.qaiu.lz.web.service.UserService; -import cn.qaiu.vx.core.annotaions.RouteHandler; -import cn.qaiu.vx.core.annotaions.RouteMapping; -import cn.qaiu.vx.core.enums.RouteMethod; -import cn.qaiu.vx.core.model.JsonResult; -import cn.qaiu.vx.core.util.AsyncServiceUtil; -import io.vertx.core.Future; -import io.vertx.core.http.HttpServerResponse; -import lombok.extern.slf4j.Slf4j; - -/** - * 服务API - *
Create date 2021/4/28 9:15 - * - * @author QAIU - */ -@Slf4j -@RouteHandler("serverApi") -public class ServerApi { - - private final UserService userService = AsyncServiceUtil.getAsyncServiceInstance(UserService.class); - - @RouteMapping(value = "/login", method = RouteMethod.POST) - public Future login(RealUser user) { - log.info("<------- login: {}", user.getUsername()); - return userService.login(user); - } - - @RouteMapping(value = "/test2", method = RouteMethod.GET) - public JsonResult test01() { - return JsonResult.data("ok"); - } - - @RouteMapping(value = "/test3", method = RouteMethod.GET) - public void test03(HttpServerResponse response, String fullUrl) throws Exception { - String url = LzTool.parse(fullUrl); - log.info("url = {}", url); - - response.putHeader("location", "http://baidu.com").setStatusCode(302).end(); - } - -} diff --git a/web/src/main/resources/1.http b/web/src/main/resources/1.http deleted file mode 100644 index 73f8b7b..0000000 --- a/web/src/main/resources/1.http +++ /dev/null @@ -1,4 +0,0 @@ -### -GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://wwp.lanzoux.com/iNvid035jgcb -### -GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://lanzoux.com/ia2cntg diff --git a/web/src/test/java/cn/qaiu/web/test/StompTest.java b/web/src/test/java/cn/qaiu/web/test/StompTest.java deleted file mode 100644 index 403c16e..0000000 --- a/web/src/test/java/cn/qaiu/web/test/StompTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.qaiu.web.test; - -import io.vertx.core.Future; -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServer; -import io.vertx.core.http.HttpServerOptions; -import io.vertx.ext.stomp.StompServer; -import io.vertx.ext.stomp.StompServerHandler; -import io.vertx.ext.stomp.StompServerOptions; - -import java.util.Arrays; - -/** - * lz-web - *

create 2021/9/18 12:10

- * - * @author QAIU - */ -public class StompTest { - - - - public static void main(String[] args) { - - Vertx vertx = Vertx.vertx(); - - StompServer stompServer = StompServer.create(vertx, new StompServerOptions() - .setPort(-1) // 禁用 tcp 端口,这一项是可选的 - .setWebsocketBridge(true) // 开启 websocket 支持 - .setWebsocketPath("/stomp")) // 配置 websocket 路径,默认是 /stomp - .handler(StompServerHandler.create(vertx)); - Future http = vertx.createHttpServer( - new HttpServerOptions().setWebSocketSubProtocols(Arrays.asList("v10.stomp", "v11.stomp")) - ) - .webSocketHandler(stompServer.webSocketHandler()) - .listen(8080); - http.onSuccess(res->{ - System.out.println("okk"); - }); - - } -} From 5ba38f4f1d3b7a3c70780bc98dbe45dd4a0f20e5 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Fri, 21 Apr 2023 23:42:22 +0800 Subject: [PATCH 07/48] 0.0.1 fixed done --- README.md | 2 +- .../src/main/java/cn/qaiu/lz/common/util/CowTool.java | 2 +- .../src/main/java/cn/qaiu/lz/web/http/ServerApi.java | 4 ++-- lz-cow-api-web/src/main/resources/1.http | 9 ++++++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 482a816..6e64616 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ GET http://127.0.0.1:6400/parse?url=https://lanzoux.com/ia2cntg ### # @no-redirect -GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/core/api/transfer/share?uniqueUrl=9a644fe3e3a748 +GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/s/9a644fe3e3a748 // Rest请求(只提供共享文件Id): cow 奶牛快传; lz 蓝奏云 ### diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java index 10234fa..3585386 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java @@ -41,7 +41,7 @@ public class CowTool { } */ public static String parse(String fullUrl) throws IOException { - String uniqueUrl = fullUrl.substring(fullUrl.lastIndexOf('=') + 1); + String uniqueUrl = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); String baseUrl = "https://cowtransfer.com/core/api/transfer/share"; String result = Jsoup .connect(baseUrl + "?uniqueUrl=" + uniqueUrl).ignoreContentType(true) diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index ade96fe..12c07cc 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -59,7 +59,7 @@ public class ServerApi { @RouteMapping(value = "/cow/:id", method = RouteMethod.GET) public void cowParse(HttpServerResponse response, String id) throws Exception { - String url = "https://cowtransfer.com/core/api/transfer/share?uniqueUrl=" + id; + String url = "https://cowtransfer.com/s/" + id; String urlDownload = CowTool.parse(url); response.putHeader("location", urlDownload).setStatusCode(302).end(); } @@ -74,7 +74,7 @@ public class ServerApi { @RouteMapping(value = "/json/cow/:id", method = RouteMethod.GET) public JsonResult cowParseJson(HttpServerResponse response, String id) throws Exception { - String url = "https://cowtransfer.com/core/api/transfer/share?uniqueUrl=" + id; + String url = "https://cowtransfer.com/s/" + id; return JsonResult.data(CowTool.parse(url)); } } diff --git a/lz-cow-api-web/src/main/resources/1.http b/lz-cow-api-web/src/main/resources/1.http index 3465131..93d5962 100644 --- a/lz-cow-api-web/src/main/resources/1.http +++ b/lz-cow-api-web/src/main/resources/1.http @@ -5,18 +5,25 @@ GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://wwp.lanzoux.com/iN GET http://127.0.0.1:6400/parse?url=https://lanzoux.com/ia2cntg ### # @no-redirect -GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/core/api/transfer/share?uniqueUrl=9a644fe3e3a748 +GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/s/9a644fe3e3a748 ### # @no-redirect GET http://127.0.0.1:6400/cow/9a644fe3e3a748 ### +# @no-redirect GET http://127.0.0.1:6400/lz/ia2cntg + ### GET http://127.0.0.1:6400/json/lz/ia2cntg +### +GET http://127.0.0.1:6400/json/cow/9a644fe3e3a748 + ### +//https://cowtransfer.com/s/9a644fe3e3a748 + https://cowtransfer.com/core/api/transfer/share?uniqueUrl=9a644fe3e3a748 ### From 1799763f7f2bf9f2b77a3ef0fdaba5bdd9b2f46e Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Sat, 22 Apr 2023 11:34:05 +0800 Subject: [PATCH 08/48] =?UTF-8?q?vert.x=E5=8D=87=E7=BA=A7=E5=88=B04.4.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++-- bin/lz-api.service | 18 +++++++++++++ bin/service-install.sh | 10 ++++++++ core/pom.xml | 6 ++--- .../src/main/java/cn/qaiu/vx/core/Deploy.java | 25 +++++++++++-------- .../src/main/java/cn/qaiu/lz/AppMain.java | 3 ++- .../java/cn/qaiu/lz/common/util/CowTool.java | 20 +++++++-------- .../java/cn/qaiu/lz/common/util/LzTool.java | 15 ++++++----- .../java/cn/qaiu/lz/web/http/ServerApi.java | 20 +++++++-------- lz-cow-api-web/src/main/resources/1.http | 4 +-- 10 files changed, 79 insertions(+), 48 deletions(-) create mode 100644 bin/lz-api.service create mode 100644 bin/service-install.sh diff --git a/README.md b/README.md index 6e64616..a4215c1 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ # lz-cow-api 蓝奏云-奶牛快传的直链解析的API服务 +使用Jdk17+Vert.x4.4.1+Jsoup +Core模块集成Vert.x实现声明式路由API 示例: ``` // 解析并重定向到直链 ### # @no-redirect -GET http://127.0.0.1:6400/parse?url=https://lanzoux.com/ia2cntg +GET http://127.0.0.1:6400/parser?url=https://lanzoux.com/ia2cntg ### # @no-redirect -GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/s/9a644fe3e3a748 +GET http://127.0.0.1:6400/parser?url=https://cowtransfer.com/s/9a644fe3e3a748 // Rest请求(只提供共享文件Id): cow 奶牛快传; lz 蓝奏云 ### diff --git a/bin/lz-api.service b/bin/lz-api.service new file mode 100644 index 0000000..7d7188e --- /dev/null +++ b/bin/lz-api.service @@ -0,0 +1,18 @@ +[Unit] +Description=lz-api +Documentation=https://qaiu.top +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +# User=USER +ExecStart=/usr/bin/java -server -Xmx128m -jar /root/java/lz-cow-api-web/lz-cow-api-web-0.0.1.jar +ExecStop=/bin/kill -s QUIT $MAINPID +Restart=always +StandOutput=syslog + +StandError=inherit + +[Install] +WantedBy=multi-user.target diff --git a/bin/service-install.sh b/bin/service-install.sh new file mode 100644 index 0000000..cb21cf6 --- /dev/null +++ b/bin/service-install.sh @@ -0,0 +1,10 @@ +cp ./lz-api.service /etc/systemd/system/ + +# 重新加载 systemd +systemctl daemon-reload + +# 运行服务 +systemctl start lz-api + +# 在系统启动时启动服务 +systemctl enable lz-api diff --git a/core/pom.xml b/core/pom.xml index f765612..0503ff2 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -14,11 +14,11 @@ 17 UTF-8 - 4.1.3 - 0.9.12 + 4.4.1 + 0.10.2 1.18.12 2.0.5 - 3.8.1 + 3.12.0 2.11.3 diff --git a/core/src/main/java/cn/qaiu/vx/core/Deploy.java b/core/src/main/java/cn/qaiu/vx/core/Deploy.java index 52690b8..aae1198 100644 --- a/core/src/main/java/cn/qaiu/vx/core/Deploy.java +++ b/core/src/main/java/cn/qaiu/vx/core/Deploy.java @@ -67,18 +67,21 @@ public final class Deploy { * 打印logo */ private void outLogo(JsonObject conf) { - Date date = new Date(); Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - int year = calendar.get(Calendar.YEAR); - String logoTemplete = "\nWeb Server powered by: \n" + - " ____ ____ _ _ _ \n" + - "|_^^_| |_^^_| / |_ | | | | \n" + - " \\ \\ / /.---. _ .--.`| |-' _ __ | |__| |_ \n" + - " \\ \\ / // /__\\\\[ `/'`\\]| | [ \\ [ ]|____ _| \n" + - " \\ V / | \\__., | | | |, _ > ' < _| |_ \n" + - " \\_/ '.__.'[___] \\__/(_)[__]`\\_] |_____| \n" + - " Version: %s; Framework version: %s; %s©%d.\n\n"; + calendar.setTime(new Date()); + var year = calendar.get(Calendar.YEAR); + var logoTemplete = """ + + Web Server powered by:\s + ____ ____ _ _ _ \s + |_^^_| |_^^_| / |_ | | | | \s + \\ \\ / /.---. _ .--.`| |-' _ __ | |__| |_ \s + \\ \\ / // /__\\\\[ `/'`\\]| | [ \\ [ ]|____ _|\s + \\ V / | \\__., | | | |, _ > ' < _| |_ \s + \\_/ '.__.'[___] \\__/(_)[__]`\\_] |_____|\s + Version: %s; Framework version: %s; %s©%d. + + """; System.out.printf(logoTemplete, conf.getString("version_app"), diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java index 6b653dc..c47f966 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java @@ -1,7 +1,9 @@ package cn.qaiu.lz; import cn.qaiu.vx.core.Deploy; +import cn.qaiu.vx.core.util.VertxHolder; import io.vertx.core.json.JsonObject; +import lombok.val; /** @@ -22,7 +24,6 @@ public class AppMain { * @param jsonObject 配置 */ private static void exec(JsonObject jsonObject) { - // } diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java index 3585386..a0e969c 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java @@ -41,38 +41,36 @@ public class CowTool { } */ public static String parse(String fullUrl) throws IOException { - String uniqueUrl = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); - String baseUrl = "https://cowtransfer.com/core/api/transfer/share"; - String result = Jsoup + var uniqueUrl = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); + var baseUrl = "https://cowtransfer.com/core/api/transfer/share"; + var result = Jsoup .connect(baseUrl + "?uniqueUrl=" + uniqueUrl).ignoreContentType(true) .get() .text(); - ObjectMapper objectMapper = new ObjectMapper(); + var objectMapper = new ObjectMapper(); Map map = objectMapper.readValue(result, new TypeReference<>() { }); if ("success".equals(map.get("message")) && map.containsKey("data")) { Map data = CastUtil.cast(map.get("data")); - String guid = data.get("guid").toString(); + var guid = data.get("guid").toString(); Map firstFile = CastUtil.cast(data.get("firstFile")); - String fileId = firstFile.get("id").toString(); - String result2 = Jsoup + var fileId = firstFile.get("id").toString(); + var result2 = Jsoup .connect(baseUrl + "/download?transferGuid=" + guid + "&fileId=" + fileId) .ignoreContentType(true) .get() .text(); - Map map2 = objectMapper.readValue(result2, new TypeReference<>() { - }); + Map map2 = objectMapper.readValue(result2, new TypeReference<>() {}); if ("success".equals(map2.get("message")) && map2.containsKey("data")) { Map data2 = CastUtil.cast(map2.get("data")); - String downloadUrl = data2.get("downloadUrl").toString(); + var downloadUrl = data2.get("downloadUrl").toString(); if (StringUtils.isNotEmpty(downloadUrl)) { log.info("cow parse success: {}", downloadUrl); return downloadUrl; } } - } log.info("Cow parse field------------->end"); return null; diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java index 668f3b4..2f8d3a4 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -18,27 +18,26 @@ import java.util.regex.Pattern; public class LzTool { public static String parse(String fullUrl) throws Exception { - String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.3"; - String url = fullUrl.substring(0, fullUrl.lastIndexOf('/') + 1); - String id = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); + var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.3"; + var url = fullUrl.substring(0, fullUrl.lastIndexOf('/') + 1); + var id = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); Map header = new HashMap<>(); header.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); header.put("referer", url); - /* // 部分链接需要设置安卓UA sec-ch-ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111" sec-ch-ua-mobile: ?1 sec-ch-ua-platform: "Android" */ - String userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; - + var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; Map header2 = new HashMap<>(); header2.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); header2.put("sec-ch-ua-mobile", "sec-ch-ua-mobile"); header2.put("sec-ch-ua-platform", "Android"); header2.put("referer", url); + //第一次请求,获取iframe的地址 String result = Jsoup.connect(url + id) .userAgent(userAgent) @@ -75,11 +74,11 @@ public class LzTool { .text() .replace("\\", ""); //json转为map - params = new ObjectMapper().readValue(result, new TypeReference>() {}); + params = new ObjectMapper().readValue(result, new TypeReference<>() {}); // System.out.println(params); //通过json的数据拼接出最终的URL发起第最终请求,并得到响应信息头 url = params.get("dom") + "/file/" + params.get("url"); - Map headers = Jsoup.connect(url) + var headers = Jsoup.connect(url) .ignoreContentType(true) .userAgent(userAgent2) .headers(header2) diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 12c07cc..8791fa6 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -36,14 +36,14 @@ public class ServerApi { return JsonResult.data("ok"); } - @RouteMapping(value = "/parse", method = RouteMethod.GET) + @RouteMapping(value = "/parser", method = RouteMethod.GET) public void parse(HttpServerResponse response, String url) throws Exception { if (url.contains("lanzou")) { - String urlDownload = LzTool.parse(url); + var urlDownload = LzTool.parse(url); log.info("url = {}", urlDownload); response.putHeader("location", urlDownload).setStatusCode(302).end(); } else if (url.contains("cowtransfer.com")) { - String urlDownload = CowTool.parse(url); + var urlDownload = CowTool.parse(url); response.putHeader("location", urlDownload).setStatusCode(302).end(); } @@ -51,30 +51,30 @@ public class ServerApi { @RouteMapping(value = "/lz/:id", method = RouteMethod.GET) public void lzParse(HttpServerResponse response, String id) throws Exception { - String url = "https://wwa.lanzoux.com/" + id; - String urlDownload = LzTool.parse(url); + var url = "https://wwa.lanzoux.com/" + id; + var urlDownload = LzTool.parse(url); log.info("url = {}", urlDownload); response.putHeader("location", urlDownload).setStatusCode(302).end(); } @RouteMapping(value = "/cow/:id", method = RouteMethod.GET) public void cowParse(HttpServerResponse response, String id) throws Exception { - String url = "https://cowtransfer.com/s/" + id; - String urlDownload = CowTool.parse(url); + var url = "https://cowtransfer.com/s/" + id; + var urlDownload = CowTool.parse(url); response.putHeader("location", urlDownload).setStatusCode(302).end(); } @RouteMapping(value = "/json/lz/:id", method = RouteMethod.GET) public JsonResult lzParseJson(HttpServerResponse response, String id) throws Exception { - String url = "https://wwa.lanzoux.com/" + id; - String urlDownload = LzTool.parse(url); + var url = "https://wwa.lanzoux.com/" + id; + var urlDownload = LzTool.parse(url); log.info("url = {}", urlDownload); return JsonResult.data(urlDownload); } @RouteMapping(value = "/json/cow/:id", method = RouteMethod.GET) public JsonResult cowParseJson(HttpServerResponse response, String id) throws Exception { - String url = "https://cowtransfer.com/s/" + id; + var url = "https://cowtransfer.com/s/" + id; return JsonResult.data(CowTool.parse(url)); } } diff --git a/lz-cow-api-web/src/main/resources/1.http b/lz-cow-api-web/src/main/resources/1.http index 93d5962..555b552 100644 --- a/lz-cow-api-web/src/main/resources/1.http +++ b/lz-cow-api-web/src/main/resources/1.http @@ -2,10 +2,10 @@ GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://wwp.lanzoux.com/iNvid035jgcb ### # @no-redirect -GET http://127.0.0.1:6400/parse?url=https://lanzoux.com/ia2cntg +GET http://127.0.0.1:6400/parser?url=https://lanzoux.com/ia2cntg ### # @no-redirect -GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/s/9a644fe3e3a748 +GET http://127.0.0.1:6400/parser?url=https://cowtransfer.com/s/9a644fe3e3a748 ### # @no-redirect GET http://127.0.0.1:6400/cow/9a644fe3e3a748 From f7ccc3c3e33616e1cb91df9b8db8d0ff30d12163 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Sat, 22 Apr 2023 12:46:42 +0800 Subject: [PATCH 09/48] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96=20co?= =?UTF-8?q?w=E8=A7=A3=E6=9E=90=E5=A4=B1=E8=B4=A5=E6=97=B6=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/qaiu/lz/common/util/CowTool.java | 6 +-- lz-cow-api-web/src/main/resources/2.http | 47 ------------------- 2 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 lz-cow-api-web/src/main/resources/2.http diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java index a0e969c..74721f9 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java @@ -3,12 +3,10 @@ package cn.qaiu.lz.common.util; import cn.qaiu.vx.core.util.CastUtil; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import io.vertx.core.http.HttpClient; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jsoup.Jsoup; -import java.io.IOException; import java.util.Map; /** @@ -40,7 +38,7 @@ public class CowTool { } } */ - public static String parse(String fullUrl) throws IOException { + public static String parse(String fullUrl) throws Exception { var uniqueUrl = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); var baseUrl = "https://cowtransfer.com/core/api/transfer/share"; var result = Jsoup @@ -73,7 +71,7 @@ public class CowTool { } } log.info("Cow parse field------------->end"); - return null; + throw new Exception("Cow解析失败"); } diff --git a/lz-cow-api-web/src/main/resources/2.http b/lz-cow-api-web/src/main/resources/2.http deleted file mode 100644 index c5871d5..0000000 --- a/lz-cow-api-web/src/main/resources/2.http +++ /dev/null @@ -1,47 +0,0 @@ -### -http://127.0.0.1:8088/real/test - -### -POST http://127.0.0.1:8088/real/serverApi/login -Content-Type: application/x-www-form-urlencoded - -username=sa&password=sinoreal -### -POST http://47.114.185.111:8070/real/serverApi/login -Content-Type: application/x-www-form-urlencoded - -username=sa&password=sinoreal - -### -http://127.0.0.1:8088/real/serverApi/hello2/ok2 -token: 11f1a7ad9dd907bf1fa6a9e79277d053 - - - -### -http://127.0.0.1:8088/real/test2 - - -### -POST http://127.0.0.1:8088/real/serverApi/getConnections -token: 370ba165d3164049b7704e8b3d595930 - -### -POST http://127.0.0.1:8085/real/serverApi/getConnectionInfo -token: 21f99c6080074ae79cda2e988ab2bdb8 - -### -http://127.0.0.1:7070/demo/foo - -### -http://127.0.0.1:8085/api/foo - - -### -http://127.0.0.1:8085/real/serverApi/thread-test -token: c1b89b3193bd4498be77b6e782e0df38 - - -### -http://127.0.0.1:8085/ -Accept: application/json From 678866f654b7fda496b376fe92218f867f2dd77d Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Sat, 22 Apr 2023 13:19:21 +0800 Subject: [PATCH 10/48] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4215c1..7e2aa47 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # lz-cow-api 蓝奏云-奶牛快传的直链解析的API服务 使用Jdk17+Vert.x4.4.1+Jsoup -Core模块集成Vert.x实现声明式路由API +Core模块集成Vert.x实现类spring的注解式路由API 示例: ``` From 94cde1e953ba984f2fc08710cfa3f8152e5c9594 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Tue, 25 Apr 2023 08:44:30 +0800 Subject: [PATCH 11/48] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96=20co?= =?UTF-8?q?w=E8=A7=A3=E6=9E=90=E5=A4=B1=E8=B4=A5=E6=97=B6=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/main/resources/logback.xml | 3 +- .../java/cn/qaiu/lz/common/util/LzTool.java | 17 +++++-- lz-cow-api-web/src/main/resources/logback.xml | 45 +++++++++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 lz-cow-api-web/src/main/resources/logback.xml diff --git a/core/src/main/resources/logback.xml b/core/src/main/resources/logback.xml index cb5856f..ccc90e8 100644 --- a/core/src/main/resources/logback.xml +++ b/core/src/main/resources/logback.xml @@ -6,10 +6,8 @@ - - @@ -55,5 +53,6 @@ + diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java index 2f8d3a4..24d4eef 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -46,18 +46,29 @@ public class LzTool { .attr("src"); //第二次请求得到js里的json数据里的sign + /* + data : { 'action':'downprocess','signs':ajaxdata, + 'sign':'UDZSbAg5BDUIAQE_bAjJVaQBrVGAAbVRlADBRYAVrVmUFNFcmCyIEbQdgAWFWOldkBm8OM1A_bU2AANQYy', + 'websign':ws_sign,'websignkey':wsk_sign,'ves':1 }, + */ result = Jsoup.connect(url + result) .headers(header) .userAgent(userAgent) .get() .html(); // System.out.println(result); - Matcher matcher = Pattern.compile("'[\\w]+_c_c'").matcher(result); + Matcher matcher = Pattern.compile("\\s+data\\s*:\\s*.*(\\{.*})").matcher(result); Map params = new LinkedHashMap<>(); if (matcher.find()) { - String sn = matcher.group().replace("'", ""); + Map ov1 = new ObjectMapper().readValue( + matcher.group(matcher.groupCount()).replaceAll("'","\""), new TypeReference>() { + }); + // { 'action':'downprocess','signs':ajaxdata, + // 'sign':'VzFWaAg5U2JSW1FuV2ddYVA7BDBTPgEwCzsAMVc5ATIENVQlWXAFbFUyBGRQPFNgAGlUaQRoBDZXYlRg','websign':ws_sign, + // 'websignkey':wsk_sign,'ves':1 } + params.put("action", "downprocess"); - params.put("sign", sn); + params.put("sign", ov1.get("sign")); params.put("ves", "1"); // System.out.println(sn); diff --git a/lz-cow-api-web/src/main/resources/logback.xml b/lz-cow-api-web/src/main/resources/logback.xml new file mode 100644 index 0000000..48c2245 --- /dev/null +++ b/lz-cow-api-web/src/main/resources/logback.xml @@ -0,0 +1,45 @@ + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) -> %magenta([%15.15thread]) %cyan(%-40.40logger{39}) : %msg%n + + + + + + + ${LOG_HOME}/LzApiWeb.%d{yyyy-MM-dd}.log + + 30 + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + + 10MB + + + + + + + 0 + + 256 + + + + + + + + + + From 91845cc08c8af249d00dd5f7e14703feb08f8cf2 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Tue, 25 Apr 2023 09:32:55 +0800 Subject: [PATCH 12/48] =?UTF-8?q?=E8=93=9D=E5=A5=8F=E4=BA=91API=20?= =?UTF-8?q?=E6=AD=A3=E5=88=99=E8=A7=A3=E6=9E=90=E8=A7=84=E5=88=99=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/qaiu/lz/common/util/LzTool.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java index 2f8d3a4..c9f5325 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -52,10 +52,11 @@ public class LzTool { .get() .html(); // System.out.println(result); - Matcher matcher = Pattern.compile("'[\\w]+_c_c'").matcher(result); + // 'sign':'AWcGOFprUGFWX1BvBTVXawdrBDZTOAU_bV2FTZFU7W2sBJ1t4DW0FYFIyBmgDZVJgUjAFNV41UGQFNg_c_c' 改下正则TMD 最近上传竟然没_c_c + Matcher matcher = Pattern.compile("'sign'\s*:\s*'([0-9a-zA-Z_]+)'").matcher(result); Map params = new LinkedHashMap<>(); if (matcher.find()) { - String sn = matcher.group().replace("'", ""); + String sn = matcher.group(1).replace("'", ""); params.put("action", "downprocess"); params.put("sign", sn); params.put("ves", "1"); From e7e3888b1380a2f5e9d6008092121cd61cfbd09d Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Tue, 25 Apr 2023 09:41:10 +0800 Subject: [PATCH 13/48] =?UTF-8?q?=E8=93=9D=E5=A5=8F=E4=BA=91API=20?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E6=94=B9=E4=B8=BAwwsd.lanzoue.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 8791fa6..4dabeb7 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -66,7 +66,7 @@ public class ServerApi { @RouteMapping(value = "/json/lz/:id", method = RouteMethod.GET) public JsonResult lzParseJson(HttpServerResponse response, String id) throws Exception { - var url = "https://wwa.lanzoux.com/" + id; + var url = "https://wwsd.lanzoue.com/" + id; var urlDownload = LzTool.parse(url); log.info("url = {}", urlDownload); return JsonResult.data(urlDownload); From fc233bcea3847c31c6264426b8430ff936ef36b3 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Tue, 25 Apr 2023 09:43:45 +0800 Subject: [PATCH 14/48] =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lz-cow-api-web/logback.xml | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 lz-cow-api-web/logback.xml diff --git a/lz-cow-api-web/logback.xml b/lz-cow-api-web/logback.xml new file mode 100644 index 0000000..289db29 --- /dev/null +++ b/lz-cow-api-web/logback.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + ${LOG_HOME}/%d{yyyyMMdd}/run.log + + 15 + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + utf8 + + + + 100MB + + + + + + + 0 + + 256 + + + + + + + + ${CUSTOMER_PATTERN2} + + + + + + + + + From 11a054dc2c59c5972e17779d245c69004b86cd07 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Tue, 25 Apr 2023 09:45:48 +0800 Subject: [PATCH 15/48] =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lz-cow-api-web/{ => src/main/resources}/logback.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lz-cow-api-web/{ => src/main/resources}/logback.xml (100%) diff --git a/lz-cow-api-web/logback.xml b/lz-cow-api-web/src/main/resources/logback.xml similarity index 100% rename from lz-cow-api-web/logback.xml rename to lz-cow-api-web/src/main/resources/logback.xml From 1651f1ea93cd2042cd2817d461ac28eb1e9ee0b4 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Tue, 25 Apr 2023 17:51:39 +0800 Subject: [PATCH 16/48] do var --- bin/run.bat | 4 ++-- bin/run.sh | 4 ++-- .../src/main/java/cn/qaiu/vx/core/Deploy.java | 23 +++++++++---------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/bin/run.bat b/bin/run.bat index bf1e123..21d188e 100644 --- a/bin/run.bat +++ b/bin/run.bat @@ -1,5 +1,5 @@ @echo off && @chcp 65001 > nul pushd %~dp0 set LIB_DIR=%~dp0 -for /f "delims=X" %%i in ('dir /b %LIB_DIR%\web-*.jar') do set LAUNCH_JAR=%LIB_DIR%\%%i -"%JAVA_HOME%\bin\java.exe" -Xmx512M -Dfile.encoding=utf8 -jar %LAUNCH_JAR% %* \ No newline at end of file +for /f "delims=X" %%i in ('dir /b %LIB_DIR%\lz-cow-api-web-*.jar') do set LAUNCH_JAR=%LIB_DIR%\%%i +"%JAVA_HOME%\bin\java.exe" -Xmx512M -Dfile.encoding=utf8 -jar %LAUNCH_JAR% %* diff --git a/bin/run.sh b/bin/run.sh index 3d3f13c..45f81b8 100644 --- a/bin/run.sh +++ b/bin/run.sh @@ -1,5 +1,5 @@ #!/bin/sh # set -x -LAUNCH_JAR="web-*.jar" +LAUNCH_JAR="lz-cow-api-web-*.jar" nohup java -Xmx512M -jar "$LAUNCH_JAR" "$@" >startup.log 2>&1 & -tail -f startup.log \ No newline at end of file +tail -f startup.log diff --git a/core/src/main/java/cn/qaiu/vx/core/Deploy.java b/core/src/main/java/cn/qaiu/vx/core/Deploy.java index aae1198..e152e66 100644 --- a/core/src/main/java/cn/qaiu/vx/core/Deploy.java +++ b/core/src/main/java/cn/qaiu/vx/core/Deploy.java @@ -3,12 +3,11 @@ package cn.qaiu.vx.core; import cn.qaiu.vx.core.util.ConfigUtil; import cn.qaiu.vx.core.util.VertxHolder; import cn.qaiu.vx.core.verticle.ReverseProxyVerticle; -import cn.qaiu.vx.core.verticle.ServiceVerticle; import cn.qaiu.vx.core.verticle.RouterVerticle; +import cn.qaiu.vx.core.verticle.ServiceVerticle; import io.vertx.core.*; import io.vertx.core.json.JsonObject; import io.vertx.core.shareddata.LocalMap; -import io.vertx.core.shareddata.SharedData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,7 +52,7 @@ public final class Deploy { private void readConf(JsonObject conf) { outLogo(conf); - String activeMode = conf.getString("active"); + var activeMode = conf.getString("active"); if ("dev".equals(activeMode)) { LOGGER.info("---------------> development environment <--------------\n"); System.setProperty("vertxweb.environment","dev"); @@ -67,7 +66,7 @@ public final class Deploy { * 打印logo */ private void outLogo(JsonObject conf) { - Calendar calendar = Calendar.getInstance(); + var calendar = Calendar.getInstance(); calendar.setTime(new Date()); var year = calendar.get(Calendar.YEAR); var logoTemplete = """ @@ -101,20 +100,20 @@ public final class Deploy { LOGGER.info("配置读取成功"); customConfig = globalConfig.getJsonObject("custom"); - VertxOptions vertxOptions = new VertxOptions(globalConfig.getJsonObject("vertx")); - Vertx vertx = Vertx.vertx(vertxOptions); + var vertxOptions = new VertxOptions(globalConfig.getJsonObject("vertx")); + var vertx = Vertx.vertx(vertxOptions); VertxHolder.init(vertx); //配置保存在共享数据中 - SharedData sharedData = vertx.sharedData(); + var sharedData = vertx.sharedData(); LocalMap localMap = sharedData.getLocalMap("local"); localMap.put("globalConfig", globalConfig); localMap.put("customConfig", customConfig); localMap.put("server", globalConfig.getJsonObject("server")); handle.handle(globalConfig); - Future future1 = vertx.deployVerticle(RouterVerticle.class, getWorkDeploymentOptions("Router")); - Future future2 = vertx.deployVerticle(ServiceVerticle.class, getWorkDeploymentOptions("Service")); - Future future3 = vertx.deployVerticle(ReverseProxyVerticle.class, getWorkDeploymentOptions("proxy")); + var future1 = vertx.deployVerticle(RouterVerticle.class, getWorkDeploymentOptions("Router")); + var future2 = vertx.deployVerticle(ServiceVerticle.class, getWorkDeploymentOptions("Service")); + var future3 = vertx.deployVerticle(ReverseProxyVerticle.class, getWorkDeploymentOptions("proxy")); CompositeFuture.all(future1, future2, future3) .onSuccess(this::deployWorkVerticalSuccess) @@ -137,8 +136,8 @@ public final class Deploy { * @param compositeFuture future wraps a list */ private void deployWorkVerticalSuccess(CompositeFuture compositeFuture) { - double t1 = ((double) (System.currentTimeMillis() - startTime)) / 1000; - double t2 = ((double) System.currentTimeMillis() - ManagementFactory.getRuntimeMXBean().getStartTime()) / 1000; + var t1 = ((double) (System.currentTimeMillis() - startTime)) / 1000; + var t2 = ((double) System.currentTimeMillis() - ManagementFactory.getRuntimeMXBean().getStartTime()) / 1000; LOGGER.info("web服务启动成功 -> 用时: {}s, jvm启动用时: {}s", t1, t2); } From d4586b342e46700a37b6aa0da0e8a7351dd78e86 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Sat, 6 May 2023 17:38:56 +0800 Subject: [PATCH 17/48] do db --- core-database/pom.xml | 65 +++++++ .../java/cn/qaiu/StartH2DatabaseServer.java | 7 + .../main/java/cn/qaiu/db/ddl/Constraint.java | 45 +++++ .../main/java/cn/qaiu/db/ddl/CreateTable.java | 170 ++++++++++++++++++ .../src/main/java/cn/qaiu/db/ddl/Length.java | 16 ++ .../src/main/java/cn/qaiu/db/ddl/Table.java | 17 ++ .../java/cn/qaiu/db/ddl/TableGenIgnore.java | 16 ++ .../java/cn/qaiu/db/pool/JDBCPoolInit.java | 140 +++++++++++++++ .../cn/qaiu/db/server/H2ServerHolder.java | 26 +++ lz-cow-api-web/pom.xml | 6 + .../lz/web/service/DbServiceVertxEBProxy.java | 91 ++++++++++ .../service/DbServiceVertxProxyHandler.java | 140 +++++++++++++++ .../web/service/UserServiceVertxEBProxy.java | 77 ++++++++ .../service/UserServiceVertxProxyHandler.java | 135 ++++++++++++++ .../src/main/java/cn/qaiu/lz/AppMain.java | 5 +- .../java/cn/qaiu/lz/web/model/RealUser.java | 4 + lz-cow-api-web/src/main/resources/1.http | 4 + lz-cow-api-web/src/main/resources/logback.xml | 4 +- pom.xml | 1 + 19 files changed, 964 insertions(+), 5 deletions(-) create mode 100644 core-database/pom.xml create mode 100644 core-database/src/main/java/cn/qaiu/StartH2DatabaseServer.java create mode 100644 core-database/src/main/java/cn/qaiu/db/ddl/Constraint.java create mode 100644 core-database/src/main/java/cn/qaiu/db/ddl/CreateTable.java create mode 100644 core-database/src/main/java/cn/qaiu/db/ddl/Length.java create mode 100644 core-database/src/main/java/cn/qaiu/db/ddl/Table.java create mode 100644 core-database/src/main/java/cn/qaiu/db/ddl/TableGenIgnore.java create mode 100644 core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java create mode 100644 core-database/src/main/java/cn/qaiu/db/server/H2ServerHolder.java create mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java create mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java create mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java create mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java diff --git a/core-database/pom.xml b/core-database/pom.xml new file mode 100644 index 0000000..c2b4c47 --- /dev/null +++ b/core-database/pom.xml @@ -0,0 +1,65 @@ + + + + lz-cow-api + cn.qaiu + 0.0.1 + + 4.0.0 + + core-database + + + 17 + UTF-8 + 2.0.5 + 3.12.0 + 4.4.1 + + + + + cn.qaiu + core + 1.0.8 + + + + + com.h2database + h2 + 2.1.214 + + + + + com.zaxxer + HikariCP + 5.0.1 + + + org.apache.commons + commons-lang3 + 3.12.0 + + + io.vertx + vertx-codegen + compile + ${vertx.version} + + + io.vertx + vertx-sql-client-templates + ${vertx.version} + + + io.vertx + vertx-jdbc-client + ${vertx.version} + + + + diff --git a/core-database/src/main/java/cn/qaiu/StartH2DatabaseServer.java b/core-database/src/main/java/cn/qaiu/StartH2DatabaseServer.java new file mode 100644 index 0000000..5c52135 --- /dev/null +++ b/core-database/src/main/java/cn/qaiu/StartH2DatabaseServer.java @@ -0,0 +1,7 @@ +package cn.qaiu; + +public class StartH2DatabaseServer { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} diff --git a/core-database/src/main/java/cn/qaiu/db/ddl/Constraint.java b/core-database/src/main/java/cn/qaiu/db/ddl/Constraint.java new file mode 100644 index 0000000..3b234bf --- /dev/null +++ b/core-database/src/main/java/cn/qaiu/db/ddl/Constraint.java @@ -0,0 +1,45 @@ +package cn.qaiu.db.ddl; + +import java.lang.annotation.*; + +/** + * 建表约束类型 + * + *
Create date 2021/7/22 0:42 + * @author QAIU + */ +@Documented +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD}) +public @interface Constraint { + + /** + * 非空约束 + * @return false 可以为空 + */ + boolean notNull() default false; + + /** + * 唯一键约束 TODO 待实现 + * @return 唯一键约束 + */ + String uniqueKey() default ""; + + /** + * 默认值约束 + * @return 默认值约束 + */ + String defaultValue() default ""; + /** + * 默认值是否是函数 + * @return false 不是函数 + */ + boolean defaultValueIsFunction() default false; + + /** + * 是否自增 只能用于int或long类型上 + * @return false 不自增 + */ + boolean autoIncrement() default false; +} diff --git a/core-database/src/main/java/cn/qaiu/db/ddl/CreateTable.java b/core-database/src/main/java/cn/qaiu/db/ddl/CreateTable.java new file mode 100644 index 0000000..063ad69 --- /dev/null +++ b/core-database/src/main/java/cn/qaiu/db/ddl/CreateTable.java @@ -0,0 +1,170 @@ +package cn.qaiu.db.ddl; + +import cn.qaiu.vx.core.util.ReflectionUtil; +import io.vertx.codegen.format.CamelCase; +import io.vertx.codegen.format.Case; +import io.vertx.codegen.format.LowerCamelCase; +import io.vertx.codegen.format.SnakeCase; +import io.vertx.jdbcclient.JDBCPool; +import io.vertx.sqlclient.templates.annotations.Column; +import io.vertx.sqlclient.templates.annotations.RowMapped; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * 创建表 + * + * @author QAIU + */ +public class CreateTable { + public static Map, String> javaProperty2SqlColumnMap = new HashMap<>(); + + private static final Logger LOGGER = LoggerFactory.getLogger(CreateTable.class); + + static { + javaProperty2SqlColumnMap.put(Integer.class, "INT"); + javaProperty2SqlColumnMap.put(Short.class, "SMALLINT"); + javaProperty2SqlColumnMap.put(Byte.class, "TINYINT"); + javaProperty2SqlColumnMap.put(Long.class, "BIGINT"); + javaProperty2SqlColumnMap.put(java.math.BigDecimal.class, "DECIMAL"); + javaProperty2SqlColumnMap.put(Double.class, "DOUBLE"); + javaProperty2SqlColumnMap.put(Float.class, "REAL"); + javaProperty2SqlColumnMap.put(Boolean.class, "BOOLEAN"); + javaProperty2SqlColumnMap.put(String.class, "VARCHAR"); + javaProperty2SqlColumnMap.put(java.util.Date.class, "TIMESTAMP"); + javaProperty2SqlColumnMap.put(java.sql.Timestamp.class, "TIMESTAMP"); + javaProperty2SqlColumnMap.put(java.sql.Date.class, "DATE"); + javaProperty2SqlColumnMap.put(java.sql.Time.class, "TIME"); + + javaProperty2SqlColumnMap.put(int.class, "INT"); + javaProperty2SqlColumnMap.put(short.class, "SMALLINT"); + javaProperty2SqlColumnMap.put(byte.class, "TINYINT"); + javaProperty2SqlColumnMap.put(long.class, "BIGINT"); + javaProperty2SqlColumnMap.put(double.class, "DOUBLE"); + javaProperty2SqlColumnMap.put(float.class, "REAL"); + javaProperty2SqlColumnMap.put(boolean.class, "BOOLEAN"); + } + + private static Case getCase(Class clz) { + switch (clz.getName()) { + case "io.vertx.codegen.format.CamelCase": + return CamelCase.INSTANCE; + case "io.vertx.codegen.format.SnakeCase": + return SnakeCase.INSTANCE; + case "io.vertx.codegen.format.LowerCamelCase": + return LowerCamelCase.INSTANCE; + default: + throw new UnsupportedOperationException(); + } + } + + public static String getCreateTableSQL(Class clz) { + // 判断类上是否有次注解 + String primaryKey = null; // 主键 + String tableName = null; // 表名 + Case caseFormat = SnakeCase.INSTANCE; + if (clz.isAnnotationPresent(RowMapped.class)) { + RowMapped annotation = clz.getAnnotation(RowMapped.class); + Class formatter = annotation.formatter(); + caseFormat = getCase(formatter); + } + + if (clz.isAnnotationPresent(Table.class)) { + // 获取类上的注解 + Table annotation = clz.getAnnotation(Table.class); + // 输出注解上的类名 + String tableNameAnnotation = annotation.value(); + if (StringUtils.isNotEmpty(tableNameAnnotation)) { + tableName = tableNameAnnotation; + } else { + tableName = LowerCamelCase.INSTANCE.to(caseFormat, clz.getSimpleName()); + } + primaryKey = annotation.keyFields(); + } + Field[] fields = clz.getDeclaredFields(); + String column; + int[] decimalSize = {22, 2}; + int varcharSize = 255; + StringBuilder sb = new StringBuilder(50); + sb.append("CREATE TABLE IF NOT EXISTS \"").append(tableName).append("\" ( \r\n "); + boolean firstId = true; + for (Field f : fields) { + Class paramType = f.getType(); + String sqlType = javaProperty2SqlColumnMap.get(paramType); + if (f.getName().equals("serialVersionUID") || StringUtils.isEmpty(sqlType) || f.isAnnotationPresent(TableGenIgnore.class)) { + continue; + } + column = LowerCamelCase.INSTANCE.to(caseFormat, f.getName()); + if (f.isAnnotationPresent(Column.class)) { + Column columnAnnotation = f.getAnnotation(Column.class); + //输出注解属性 + if (StringUtils.isNotBlank(columnAnnotation.name())) { + column = columnAnnotation.name(); + } + } + if (f.isAnnotationPresent(Length.class)) { + Length fieldAnnotation = f.getAnnotation(Length.class); + decimalSize = fieldAnnotation.decimalSize(); + varcharSize = fieldAnnotation.varcharSize(); + } + sb.append("\"").append(column).append("\""); + sb.append(" ").append(sqlType); + // 添加类型长度 + if (sqlType.equals("DECIMAL")) { + sb.append("(").append(decimalSize[0]).append(",").append(decimalSize[1]).append(")"); + } + if (sqlType.equals("VARCHAR")) { + sb.append("(").append(varcharSize).append(")"); + } + if (f.isAnnotationPresent(Constraint.class)) { + Constraint constraintAnnotation = f.getAnnotation(Constraint.class); + if (constraintAnnotation.notNull()) { + //非空约束 + sb.append(" NOT NULL"); + } + String apostrophe = constraintAnnotation.defaultValueIsFunction() ? "" : "'"; + if (StringUtils.isNotEmpty(constraintAnnotation.defaultValue())) { + //默认值约束 + sb.append(" DEFAULT ").append(apostrophe).append(constraintAnnotation.defaultValue()).append(apostrophe); + } + if (constraintAnnotation.autoIncrement() && paramType.equals(Integer.class) || paramType.equals(Long.class)) { + ////自增 + sb.append(" AUTO_INCREMENT"); + } + } + if (StringUtils.isEmpty(primaryKey)) { + if (firstId) {//类型转换 + sb.append(" PRIMARY KEY"); + firstId = false; + } + } else { + if (primaryKey.equals(column.toLowerCase())) { + sb.append(" PRIMARY KEY"); + } + } + sb.append(",\n "); + } + String sql = sb.toString(); + //去掉最后一个逗号 + int lastIndex = sql.lastIndexOf(","); + sql = sql.substring(0, lastIndex) + sql.substring(lastIndex + 1); + return sql.substring(0, sql.length() - 1) + ");\r\n"; + } + + public static void createTable(JDBCPool pool, String tableClassPath) { + Set> tableClassList = ReflectionUtil.getReflections(tableClassPath).getTypesAnnotatedWith(Table.class); + if (tableClassList.isEmpty()) LOGGER.info("Table model class not fount"); + tableClassList.forEach(clazz -> { + String createTableSQL = getCreateTableSQL(clazz); + pool.query(createTableSQL).execute().onSuccess( + rs -> LOGGER.info("\n" + createTableSQL + "create table --> ok") + ).onFailure(Throwable::printStackTrace); + }); + } +} diff --git a/core-database/src/main/java/cn/qaiu/db/ddl/Length.java b/core-database/src/main/java/cn/qaiu/db/ddl/Length.java new file mode 100644 index 0000000..7962ee0 --- /dev/null +++ b/core-database/src/main/java/cn/qaiu/db/ddl/Length.java @@ -0,0 +1,16 @@ +package cn.qaiu.db.ddl; + +import java.lang.annotation.*; + +/** + * 字段长度属性 + * @author QAIU + */ +@Documented +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD}) +public @interface Length { + int[] decimalSize() default {22,2}; //bigDecimal精度 + int varcharSize() default 255; //varchar大小 +} diff --git a/core-database/src/main/java/cn/qaiu/db/ddl/Table.java b/core-database/src/main/java/cn/qaiu/db/ddl/Table.java new file mode 100644 index 0000000..ba1836d --- /dev/null +++ b/core-database/src/main/java/cn/qaiu/db/ddl/Table.java @@ -0,0 +1,17 @@ +package cn.qaiu.db.ddl; + +import java.lang.annotation.*; + +/** + * 标注建表的实体类和主键字段 + * + * @author QAIU + */ +@Documented +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD})//次注解作用于类和字段上 +public @interface Table { + String value() default ""; //默认表名为空 + String keyFields() default "id"; //默认主键为id +} diff --git a/core-database/src/main/java/cn/qaiu/db/ddl/TableGenIgnore.java b/core-database/src/main/java/cn/qaiu/db/ddl/TableGenIgnore.java new file mode 100644 index 0000000..2f4af30 --- /dev/null +++ b/core-database/src/main/java/cn/qaiu/db/ddl/TableGenIgnore.java @@ -0,0 +1,16 @@ +package cn.qaiu.db.ddl; + +import java.lang.annotation.*; + +/** + * 建表时忽略字段 + *
Create date 2021/8/27 15:49 + * + * @author QAIU + */ +@Documented +@Inherited +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD}) +public @interface TableGenIgnore { +} diff --git a/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java b/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java new file mode 100644 index 0000000..ce32f56 --- /dev/null +++ b/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java @@ -0,0 +1,140 @@ +package cn.qaiu.db.pool; + +import cn.qaiu.db.ddl.CreateTable; +import cn.qaiu.db.server.H2ServerHolder; +import cn.qaiu.vx.core.util.VertxHolder; +import io.vertx.core.Promise; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; +import io.vertx.jdbcclient.JDBCPool; +import org.h2.tools.Server; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.sql.SQLException; + +/** + * 初始化JDBC + *
Create date 2021/8/10 12:04 + * + * @author QAIU + */ +public class JDBCPoolInit { + + private static final Logger LOGGER = LoggerFactory.getLogger(JDBCPoolInit.class); + private JDBCPool pool = null; + JsonObject dbConfig; + Vertx vertx = VertxHolder.getVertxInstance(); + String url; + + private static JDBCPoolInit instance; + + public JDBCPoolInit(Builder builder) { + this.dbConfig = builder.dbConfig; + this.url = builder.url; + } + + public static Builder builder() { + return new Builder(); + } + + public static JDBCPoolInit instance() { + return instance; + } + + public static class Builder { + private JsonObject dbConfig; + private String url; + + public Builder config(JsonObject dbConfig) { + this.dbConfig = dbConfig; + this.url = dbConfig.getString("jdbcUrl"); + return this; + } + + public JDBCPoolInit build() { + if (JDBCPoolInit.instance == null) { + JDBCPoolInit.instance = new JDBCPoolInit(this); + } + return JDBCPoolInit.instance; + } + } + + + /** + * init h2db
+ * 这个方法只允许调用一次 + */ + public void initPool() { + if (pool != null) { + LOGGER.error("pool 重复初始化"); + return; + } + + // 异步启动H2服务 + vertx.createSharedWorkerExecutor("h2-server", 1, Long.MAX_VALUE) + .executeBlocking(this::h2serverExecute) + .onSuccess(LOGGER::info) + .onFailure(Throwable::printStackTrace); + + // 初始化数据库连接 + vertx.createSharedWorkerExecutor("sql-pool-init") + .executeBlocking(this::poolInitExecute) + .onSuccess(LOGGER::info) + .onFailure(Throwable::printStackTrace); + + } + + private void poolInitExecute(Promise promise) { + // 初始化H2db, 创建本地db文件 + LOGGER.info("init sql start"); + String[] path = url.split("\\./"); + path[1] = path[1].split(";")[0]; + path[1] += ".mv.db"; + File file = new File(path[1]); + if (!file.exists()) { + if (!file.getParentFile().exists()) { + if (file.getParentFile().mkdirs()) { + LOGGER.info("mkdirs -> {}", file.getParentFile().getAbsolutePath()); + } + } + try { + if (file.createNewFile()) { + LOGGER.info("create file -> {}", file.getAbsolutePath()); + } + } catch (IOException e) { + LOGGER.error(e.getMessage()); + throw new RuntimeException("file create failed"); + } + } + // 初始化连接池 + pool = JDBCPool.pool(vertx, dbConfig); + CreateTable.createTable(pool, dbConfig.getString("tableClassPath")); + promise.complete("init jdbc pool success"); + + } + + private void h2serverExecute(Promise promise) { + try { + String url = dbConfig.getString("jdbcUrl"); + String[] portStr = url.split(":"); + String port = portStr[portStr.length - 1].split("[/\\\\]")[0]; + LOGGER.info("H2server listen port to {}", port); + H2ServerHolder.init(Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", port).start()); + promise.complete("Start h2Server success"); + } catch (SQLException e) { + throw new RuntimeException("Start h2Server failed: " + e.getMessage()); + } + } + + /** + * 获取连接池 + * + * @return pool + */ + public JDBCPool getPool() { + return pool; + } +} diff --git a/core-database/src/main/java/cn/qaiu/db/server/H2ServerHolder.java b/core-database/src/main/java/cn/qaiu/db/server/H2ServerHolder.java new file mode 100644 index 0000000..5e2bb00 --- /dev/null +++ b/core-database/src/main/java/cn/qaiu/db/server/H2ServerHolder.java @@ -0,0 +1,26 @@ +package cn.qaiu.db.server; + +import org.h2.tools.Server; + +import java.util.Objects; + +/** + * h2db server + *
Create date 2021/7/23 2:44 + * + * @author QAIU + */ +public class H2ServerHolder { + + private static Server h2Server; + + public static synchronized void init(Server server) { + Objects.requireNonNull(server, "未初始化h2Server"); + h2Server = server; + } + + public static Server getH2Server() { + Objects.requireNonNull(h2Server, "等待h2Server初始化"); + return h2Server; + } +} diff --git a/lz-cow-api-web/pom.xml b/lz-cow-api-web/pom.xml index 4de1019..0053f51 100644 --- a/lz-cow-api-web/pom.xml +++ b/lz-cow-api-web/pom.xml @@ -53,6 +53,12 @@ jsoup 1.15.4
+ + cn.qaiu + core-database + 0.0.1 + compile + diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java new file mode 100644 index 0000000..648d7cc --- /dev/null +++ b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java @@ -0,0 +1,91 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you under the Apache License, version 2.0 +* (the "License"); you may not use this file except in compliance with the +* License. You may obtain a copy of the License at: +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ + +package cn.qaiu.lz.web.service; + +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.Vertx; +import io.vertx.core.Future; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.function.Function; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.serviceproxy.ProxyUtils; + +import cn.qaiu.lz.common.model.UserInfo; +import cn.qaiu.vx.core.base.BaseAsyncService; +import io.vertx.core.Future; +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ + +@SuppressWarnings({"unchecked", "rawtypes"}) +public class DbServiceVertxEBProxy implements DbService { + private Vertx _vertx; + private String _address; + private DeliveryOptions _options; + private boolean closed; + + public DbServiceVertxEBProxy(Vertx vertx, String address) { + this(vertx, address, null); + } + + public DbServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { + this._vertx = vertx; + this._address = address; + this._options = options; + try { + this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) { + } + } + + @Override + public Future sayOk(String data){ + if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); + JsonObject _json = new JsonObject(); + _json.put("data", data); + + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "sayOk"); + _deliveryOptions.getHeaders().set("action", "sayOk"); + return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { + return msg.body(); + }); + } + @Override + public Future sayOk2(String data, UserInfo holder){ + if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); + JsonObject _json = new JsonObject(); + _json.put("data", data); + _json.put("holder", holder != null ? holder.toJson() : null); + + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "sayOk2"); + _deliveryOptions.getHeaders().set("action", "sayOk2"); + return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { + return msg.body(); + }); + } +} diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java new file mode 100644 index 0000000..a1d47d8 --- /dev/null +++ b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java @@ -0,0 +1,140 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you under the Apache License, version 2.0 +* (the "License"); you may not use this file except in compliance with the +* License. You may obtain a copy of the License at: +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ + +package cn.qaiu.lz.web.service; + +import cn.qaiu.lz.web.service.DbService; +import io.vertx.core.Vertx; +import io.vertx.core.Handler; +import io.vertx.core.AsyncResult; +import io.vertx.core.eventbus.EventBus; +import io.vertx.core.eventbus.Message; +import io.vertx.core.eventbus.MessageConsumer; +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.eventbus.ReplyException; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.Collection; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import io.vertx.serviceproxy.ProxyHandler; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.serviceproxy.HelperUtils; +import io.vertx.serviceproxy.ServiceBinder; + +import cn.qaiu.lz.common.model.UserInfo; +import cn.qaiu.vx.core.base.BaseAsyncService; +import io.vertx.core.Future; +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ + +@SuppressWarnings({"unchecked", "rawtypes"}) +public class DbServiceVertxProxyHandler extends ProxyHandler { + + public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes + private final Vertx vertx; + private final DbService service; + private final long timerID; + private long lastAccessed; + private final long timeoutSeconds; + private final boolean includeDebugInfo; + + public DbServiceVertxProxyHandler(Vertx vertx, DbService service){ + this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); + } + + public DbServiceVertxProxyHandler(Vertx vertx, DbService service, long timeoutInSecond){ + this(vertx, service, true, timeoutInSecond); + } + + public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutInSecond){ + this(vertx, service, true, timeoutInSecond, false); + } + + public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { + this.vertx = vertx; + this.service = service; + this.includeDebugInfo = includeDebugInfo; + this.timeoutSeconds = timeoutSeconds; + try { + this.vertx.eventBus().registerDefaultCodec(ServiceException.class, + new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) {} + if (timeoutSeconds != -1 && !topLevel) { + long period = timeoutSeconds * 1000 / 2; + if (period > 10000) { + period = 10000; + } + this.timerID = vertx.setPeriodic(period, this::checkTimedOut); + } else { + this.timerID = -1; + } + accessed(); + } + + + private void checkTimedOut(long id) { + long now = System.nanoTime(); + if (now - lastAccessed > timeoutSeconds * 1000000000) { + close(); + } + } + + @Override + public void close() { + if (timerID != -1) { + vertx.cancelTimer(timerID); + } + super.close(); + } + + private void accessed() { + this.lastAccessed = System.nanoTime(); + } + + public void handle(Message msg) { + try{ + JsonObject json = msg.body(); + String action = msg.headers().get("action"); + if (action == null) throw new IllegalStateException("action not specified"); + accessed(); + switch (action) { + case "sayOk": { + service.sayOk((java.lang.String)json.getValue("data")).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); + break; + } + case "sayOk2": { + service.sayOk2((java.lang.String)json.getValue("data"), + json.getJsonObject("holder") != null ? new cn.qaiu.lz.common.model.UserInfo((JsonObject)json.getJsonObject("holder")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); + break; + } + default: throw new IllegalStateException("Invalid action: " + action); + } + } catch (Throwable t) { + if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); + else msg.reply(new ServiceException(500, t.getMessage())); + throw t; + } + } +} \ No newline at end of file diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java new file mode 100644 index 0000000..c5ab8ea --- /dev/null +++ b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java @@ -0,0 +1,77 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you under the Apache License, version 2.0 +* (the "License"); you may not use this file except in compliance with the +* License. You may obtain a copy of the License at: +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ + +package cn.qaiu.lz.web.service; + +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.Vertx; +import io.vertx.core.Future; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.function.Function; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.serviceproxy.ProxyUtils; + +import cn.qaiu.lz.web.model.RealUser; +import cn.qaiu.vx.core.base.BaseAsyncService; +import io.vertx.core.Future; +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ + +@SuppressWarnings({"unchecked", "rawtypes"}) +public class UserServiceVertxEBProxy implements UserService { + private Vertx _vertx; + private String _address; + private DeliveryOptions _options; + private boolean closed; + + public UserServiceVertxEBProxy(Vertx vertx, String address) { + this(vertx, address, null); + } + + public UserServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { + this._vertx = vertx; + this._address = address; + this._options = options; + try { + this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) { + } + } + + @Override + public Future login(RealUser user){ + if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); + JsonObject _json = new JsonObject(); + _json.put("user", user != null ? user.toJson() : null); + + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "login"); + _deliveryOptions.getHeaders().set("action", "login"); + return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { + return msg.body(); + }); + } +} diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java new file mode 100644 index 0000000..4b430ac --- /dev/null +++ b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java @@ -0,0 +1,135 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you under the Apache License, version 2.0 +* (the "License"); you may not use this file except in compliance with the +* License. You may obtain a copy of the License at: +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ + +package cn.qaiu.lz.web.service; + +import cn.qaiu.lz.web.service.UserService; +import io.vertx.core.Vertx; +import io.vertx.core.Handler; +import io.vertx.core.AsyncResult; +import io.vertx.core.eventbus.EventBus; +import io.vertx.core.eventbus.Message; +import io.vertx.core.eventbus.MessageConsumer; +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.eventbus.ReplyException; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.Collection; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import io.vertx.serviceproxy.ProxyHandler; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.serviceproxy.HelperUtils; +import io.vertx.serviceproxy.ServiceBinder; + +import cn.qaiu.lz.web.model.RealUser; +import cn.qaiu.vx.core.base.BaseAsyncService; +import io.vertx.core.Future; +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ + +@SuppressWarnings({"unchecked", "rawtypes"}) +public class UserServiceVertxProxyHandler extends ProxyHandler { + + public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes + private final Vertx vertx; + private final UserService service; + private final long timerID; + private long lastAccessed; + private final long timeoutSeconds; + private final boolean includeDebugInfo; + + public UserServiceVertxProxyHandler(Vertx vertx, UserService service){ + this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); + } + + public UserServiceVertxProxyHandler(Vertx vertx, UserService service, long timeoutInSecond){ + this(vertx, service, true, timeoutInSecond); + } + + public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutInSecond){ + this(vertx, service, true, timeoutInSecond, false); + } + + public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { + this.vertx = vertx; + this.service = service; + this.includeDebugInfo = includeDebugInfo; + this.timeoutSeconds = timeoutSeconds; + try { + this.vertx.eventBus().registerDefaultCodec(ServiceException.class, + new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) {} + if (timeoutSeconds != -1 && !topLevel) { + long period = timeoutSeconds * 1000 / 2; + if (period > 10000) { + period = 10000; + } + this.timerID = vertx.setPeriodic(period, this::checkTimedOut); + } else { + this.timerID = -1; + } + accessed(); + } + + + private void checkTimedOut(long id) { + long now = System.nanoTime(); + if (now - lastAccessed > timeoutSeconds * 1000000000) { + close(); + } + } + + @Override + public void close() { + if (timerID != -1) { + vertx.cancelTimer(timerID); + } + super.close(); + } + + private void accessed() { + this.lastAccessed = System.nanoTime(); + } + + public void handle(Message msg) { + try{ + JsonObject json = msg.body(); + String action = msg.headers().get("action"); + if (action == null) throw new IllegalStateException("action not specified"); + accessed(); + switch (action) { + case "login": { + service.login(json.getJsonObject("user") != null ? new cn.qaiu.lz.web.model.RealUser((JsonObject)json.getJsonObject("user")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); + break; + } + default: throw new IllegalStateException("Invalid action: " + action); + } + } catch (Throwable t) { + if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); + else msg.reply(new ServiceException(500, t.getMessage())); + throw t; + } + } +} \ No newline at end of file diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java index c47f966..a7f5acd 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java @@ -1,9 +1,7 @@ package cn.qaiu.lz; import cn.qaiu.vx.core.Deploy; -import cn.qaiu.vx.core.util.VertxHolder; import io.vertx.core.json.JsonObject; -import lombok.val; /** @@ -15,15 +13,16 @@ import lombok.val; public class AppMain { public static void main(String[] args) { - // 注册枚举类型转换器 Deploy.instance().start(args, AppMain::exec); } /** + * 初始化数据库 * * @param jsonObject 配置 */ private static void exec(JsonObject jsonObject) { +// JDBCPoolInit.builder().config(jsonObject.getJsonObject("dataSource")).build().initPool(); } diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java index 61e07ef..16db7e4 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java @@ -1,5 +1,6 @@ package cn.qaiu.lz.web.model; +import cn.qaiu.db.ddl.Table; import cn.qaiu.lz.common.ToJson; import io.vertx.codegen.annotations.DataObject; import io.vertx.core.json.JsonObject; @@ -11,7 +12,10 @@ import lombok.NoArgsConstructor; @NoArgsConstructor @AllArgsConstructor @DataObject +@Table("t_user") public class RealUser implements ToJson { + private String id; + private String username; private String password; diff --git a/lz-cow-api-web/src/main/resources/1.http b/lz-cow-api-web/src/main/resources/1.http index 555b552..1b29e34 100644 --- a/lz-cow-api-web/src/main/resources/1.http +++ b/lz-cow-api-web/src/main/resources/1.http @@ -35,4 +35,8 @@ https://cowtransfer.com/core/api/transfer/share/download?transferGuid=e4f41b51-b //https://download.cowcs.com/cowtransfer/cowtransfer/29188/db32e132e69f490eb4a343b398990f4b.docx?auth_key=1682111861-7b9579fbebb84aaba6bca368d083ab12-0-cbf009f3ffbcbb86191b8cdbc103abce&biz_type=1&business_code=COW_TRANSFER&channel_code=COW_CN_WEB&response-content-disposition=attachment%3B%20filename%3D05-CGB-DB-MENU-V1.02.docx%3Bfilename*%3Dutf-8%27%2705-CGB-DB-MENU-V1.02.docx&user_id=1023860921943729188&x-verify=1 +#V2 api +### +https://cowtransfer.com/core/api/dam/asset/files/download/23890683765739569/url/v2 +authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDc1OTMwNGItMDEwZS00MGJiLTlhNDUtZTczY2Q5ODYzMDQwIiwiZXhwIjoxNjgzNzkzOTExfQ.rE9z0vhogPjUC0I92MqU8U_PKe4j_mGn7lGgPFMGt5c diff --git a/lz-cow-api-web/src/main/resources/logback.xml b/lz-cow-api-web/src/main/resources/logback.xml index 289db29..3745f53 100644 --- a/lz-cow-api-web/src/main/resources/logback.xml +++ b/lz-cow-api-web/src/main/resources/logback.xml @@ -54,7 +54,7 @@ - - + + diff --git a/pom.xml b/pom.xml index 52eece4..15c4ba2 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,7 @@ core lz-cow-api-web + core-database From 34f26707003f639d0608b148fc4b8b8124919b4c Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Sun, 7 May 2023 17:18:43 +0800 Subject: [PATCH 18/48] zz --- .../lz/web/service/DbServiceVertxEBProxy.java | 91 ++++++++++++ .../service/DbServiceVertxProxyHandler.java | 140 ++++++++++++++++++ .../web/service/UserServiceVertxEBProxy.java | 77 ++++++++++ .../service/UserServiceVertxProxyHandler.java | 135 +++++++++++++++++ 4 files changed, 443 insertions(+) create mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java create mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java create mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java create mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java new file mode 100644 index 0000000..648d7cc --- /dev/null +++ b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java @@ -0,0 +1,91 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you under the Apache License, version 2.0 +* (the "License"); you may not use this file except in compliance with the +* License. You may obtain a copy of the License at: +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ + +package cn.qaiu.lz.web.service; + +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.Vertx; +import io.vertx.core.Future; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.function.Function; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.serviceproxy.ProxyUtils; + +import cn.qaiu.lz.common.model.UserInfo; +import cn.qaiu.vx.core.base.BaseAsyncService; +import io.vertx.core.Future; +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ + +@SuppressWarnings({"unchecked", "rawtypes"}) +public class DbServiceVertxEBProxy implements DbService { + private Vertx _vertx; + private String _address; + private DeliveryOptions _options; + private boolean closed; + + public DbServiceVertxEBProxy(Vertx vertx, String address) { + this(vertx, address, null); + } + + public DbServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { + this._vertx = vertx; + this._address = address; + this._options = options; + try { + this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) { + } + } + + @Override + public Future sayOk(String data){ + if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); + JsonObject _json = new JsonObject(); + _json.put("data", data); + + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "sayOk"); + _deliveryOptions.getHeaders().set("action", "sayOk"); + return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { + return msg.body(); + }); + } + @Override + public Future sayOk2(String data, UserInfo holder){ + if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); + JsonObject _json = new JsonObject(); + _json.put("data", data); + _json.put("holder", holder != null ? holder.toJson() : null); + + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "sayOk2"); + _deliveryOptions.getHeaders().set("action", "sayOk2"); + return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { + return msg.body(); + }); + } +} diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java new file mode 100644 index 0000000..a1d47d8 --- /dev/null +++ b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java @@ -0,0 +1,140 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you under the Apache License, version 2.0 +* (the "License"); you may not use this file except in compliance with the +* License. You may obtain a copy of the License at: +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ + +package cn.qaiu.lz.web.service; + +import cn.qaiu.lz.web.service.DbService; +import io.vertx.core.Vertx; +import io.vertx.core.Handler; +import io.vertx.core.AsyncResult; +import io.vertx.core.eventbus.EventBus; +import io.vertx.core.eventbus.Message; +import io.vertx.core.eventbus.MessageConsumer; +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.eventbus.ReplyException; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.Collection; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import io.vertx.serviceproxy.ProxyHandler; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.serviceproxy.HelperUtils; +import io.vertx.serviceproxy.ServiceBinder; + +import cn.qaiu.lz.common.model.UserInfo; +import cn.qaiu.vx.core.base.BaseAsyncService; +import io.vertx.core.Future; +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ + +@SuppressWarnings({"unchecked", "rawtypes"}) +public class DbServiceVertxProxyHandler extends ProxyHandler { + + public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes + private final Vertx vertx; + private final DbService service; + private final long timerID; + private long lastAccessed; + private final long timeoutSeconds; + private final boolean includeDebugInfo; + + public DbServiceVertxProxyHandler(Vertx vertx, DbService service){ + this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); + } + + public DbServiceVertxProxyHandler(Vertx vertx, DbService service, long timeoutInSecond){ + this(vertx, service, true, timeoutInSecond); + } + + public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutInSecond){ + this(vertx, service, true, timeoutInSecond, false); + } + + public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { + this.vertx = vertx; + this.service = service; + this.includeDebugInfo = includeDebugInfo; + this.timeoutSeconds = timeoutSeconds; + try { + this.vertx.eventBus().registerDefaultCodec(ServiceException.class, + new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) {} + if (timeoutSeconds != -1 && !topLevel) { + long period = timeoutSeconds * 1000 / 2; + if (period > 10000) { + period = 10000; + } + this.timerID = vertx.setPeriodic(period, this::checkTimedOut); + } else { + this.timerID = -1; + } + accessed(); + } + + + private void checkTimedOut(long id) { + long now = System.nanoTime(); + if (now - lastAccessed > timeoutSeconds * 1000000000) { + close(); + } + } + + @Override + public void close() { + if (timerID != -1) { + vertx.cancelTimer(timerID); + } + super.close(); + } + + private void accessed() { + this.lastAccessed = System.nanoTime(); + } + + public void handle(Message msg) { + try{ + JsonObject json = msg.body(); + String action = msg.headers().get("action"); + if (action == null) throw new IllegalStateException("action not specified"); + accessed(); + switch (action) { + case "sayOk": { + service.sayOk((java.lang.String)json.getValue("data")).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); + break; + } + case "sayOk2": { + service.sayOk2((java.lang.String)json.getValue("data"), + json.getJsonObject("holder") != null ? new cn.qaiu.lz.common.model.UserInfo((JsonObject)json.getJsonObject("holder")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); + break; + } + default: throw new IllegalStateException("Invalid action: " + action); + } + } catch (Throwable t) { + if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); + else msg.reply(new ServiceException(500, t.getMessage())); + throw t; + } + } +} \ No newline at end of file diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java new file mode 100644 index 0000000..c5ab8ea --- /dev/null +++ b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java @@ -0,0 +1,77 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you under the Apache License, version 2.0 +* (the "License"); you may not use this file except in compliance with the +* License. You may obtain a copy of the License at: +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ + +package cn.qaiu.lz.web.service; + +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.Vertx; +import io.vertx.core.Future; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.function.Function; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.serviceproxy.ProxyUtils; + +import cn.qaiu.lz.web.model.RealUser; +import cn.qaiu.vx.core.base.BaseAsyncService; +import io.vertx.core.Future; +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ + +@SuppressWarnings({"unchecked", "rawtypes"}) +public class UserServiceVertxEBProxy implements UserService { + private Vertx _vertx; + private String _address; + private DeliveryOptions _options; + private boolean closed; + + public UserServiceVertxEBProxy(Vertx vertx, String address) { + this(vertx, address, null); + } + + public UserServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { + this._vertx = vertx; + this._address = address; + this._options = options; + try { + this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) { + } + } + + @Override + public Future login(RealUser user){ + if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); + JsonObject _json = new JsonObject(); + _json.put("user", user != null ? user.toJson() : null); + + DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); + _deliveryOptions.addHeader("action", "login"); + _deliveryOptions.getHeaders().set("action", "login"); + return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { + return msg.body(); + }); + } +} diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java new file mode 100644 index 0000000..4b430ac --- /dev/null +++ b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java @@ -0,0 +1,135 @@ +/* +* Copyright 2014 Red Hat, Inc. +* +* Red Hat licenses this file to you under the Apache License, version 2.0 +* (the "License"); you may not use this file except in compliance with the +* License. You may obtain a copy of the License at: +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +*/ + +package cn.qaiu.lz.web.service; + +import cn.qaiu.lz.web.service.UserService; +import io.vertx.core.Vertx; +import io.vertx.core.Handler; +import io.vertx.core.AsyncResult; +import io.vertx.core.eventbus.EventBus; +import io.vertx.core.eventbus.Message; +import io.vertx.core.eventbus.MessageConsumer; +import io.vertx.core.eventbus.DeliveryOptions; +import io.vertx.core.eventbus.ReplyException; +import io.vertx.core.json.JsonObject; +import io.vertx.core.json.JsonArray; +import java.util.Collection; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; +import io.vertx.serviceproxy.ProxyHandler; +import io.vertx.serviceproxy.ServiceException; +import io.vertx.serviceproxy.ServiceExceptionMessageCodec; +import io.vertx.serviceproxy.HelperUtils; +import io.vertx.serviceproxy.ServiceBinder; + +import cn.qaiu.lz.web.model.RealUser; +import cn.qaiu.vx.core.base.BaseAsyncService; +import io.vertx.core.Future; +/* + Generated Proxy code - DO NOT EDIT + @author Roger the Robot +*/ + +@SuppressWarnings({"unchecked", "rawtypes"}) +public class UserServiceVertxProxyHandler extends ProxyHandler { + + public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes + private final Vertx vertx; + private final UserService service; + private final long timerID; + private long lastAccessed; + private final long timeoutSeconds; + private final boolean includeDebugInfo; + + public UserServiceVertxProxyHandler(Vertx vertx, UserService service){ + this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); + } + + public UserServiceVertxProxyHandler(Vertx vertx, UserService service, long timeoutInSecond){ + this(vertx, service, true, timeoutInSecond); + } + + public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutInSecond){ + this(vertx, service, true, timeoutInSecond, false); + } + + public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { + this.vertx = vertx; + this.service = service; + this.includeDebugInfo = includeDebugInfo; + this.timeoutSeconds = timeoutSeconds; + try { + this.vertx.eventBus().registerDefaultCodec(ServiceException.class, + new ServiceExceptionMessageCodec()); + } catch (IllegalStateException ex) {} + if (timeoutSeconds != -1 && !topLevel) { + long period = timeoutSeconds * 1000 / 2; + if (period > 10000) { + period = 10000; + } + this.timerID = vertx.setPeriodic(period, this::checkTimedOut); + } else { + this.timerID = -1; + } + accessed(); + } + + + private void checkTimedOut(long id) { + long now = System.nanoTime(); + if (now - lastAccessed > timeoutSeconds * 1000000000) { + close(); + } + } + + @Override + public void close() { + if (timerID != -1) { + vertx.cancelTimer(timerID); + } + super.close(); + } + + private void accessed() { + this.lastAccessed = System.nanoTime(); + } + + public void handle(Message msg) { + try{ + JsonObject json = msg.body(); + String action = msg.headers().get("action"); + if (action == null) throw new IllegalStateException("action not specified"); + accessed(); + switch (action) { + case "login": { + service.login(json.getJsonObject("user") != null ? new cn.qaiu.lz.web.model.RealUser((JsonObject)json.getJsonObject("user")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); + break; + } + default: throw new IllegalStateException("Invalid action: " + action); + } + } catch (Throwable t) { + if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); + else msg.reply(new ServiceException(500, t.getMessage())); + throw t; + } + } +} \ No newline at end of file From 2270a056314892d2edb729c7a50e930dc56ae222 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Sun, 7 May 2023 17:21:48 +0800 Subject: [PATCH 19/48] zz --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9cb41bc..10be014 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ */.idea/ logs/ */logs/ -*/generated/ +*/generated/* *.iws *.iml *.ipr @@ -37,3 +37,4 @@ sdkTest.log gradlew gradlew.bat unused.txt +/lz-cow-api-web/src/main/generated/ From b3beb61337aa1592674e70d314cbdd10a9d377f0 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Sun, 7 May 2023 18:05:43 +0800 Subject: [PATCH 20/48] =?UTF-8?q?=E6=B8=85=E7=90=86=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lz/web/service/DbServiceVertxEBProxy.java | 91 ------------ .../service/DbServiceVertxProxyHandler.java | 140 ------------------ .../web/service/UserServiceVertxEBProxy.java | 77 ---------- .../service/UserServiceVertxProxyHandler.java | 135 ----------------- 4 files changed, 443 deletions(-) delete mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java delete mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java delete mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java delete mode 100644 lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java deleted file mode 100644 index 648d7cc..0000000 --- a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxEBProxy.java +++ /dev/null @@ -1,91 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package cn.qaiu.lz.web.service; - -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.Vertx; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.function.Function; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.ProxyUtils; - -import cn.qaiu.lz.common.model.UserInfo; -import cn.qaiu.vx.core.base.BaseAsyncService; -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class DbServiceVertxEBProxy implements DbService { - private Vertx _vertx; - private String _address; - private DeliveryOptions _options; - private boolean closed; - - public DbServiceVertxEBProxy(Vertx vertx, String address) { - this(vertx, address, null); - } - - public DbServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { - this._vertx = vertx; - this._address = address; - this._options = options; - try { - this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) { - } - } - - @Override - public Future sayOk(String data){ - if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); - JsonObject _json = new JsonObject(); - _json.put("data", data); - - DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); - _deliveryOptions.addHeader("action", "sayOk"); - _deliveryOptions.getHeaders().set("action", "sayOk"); - return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { - return msg.body(); - }); - } - @Override - public Future sayOk2(String data, UserInfo holder){ - if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); - JsonObject _json = new JsonObject(); - _json.put("data", data); - _json.put("holder", holder != null ? holder.toJson() : null); - - DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); - _deliveryOptions.addHeader("action", "sayOk2"); - _deliveryOptions.getHeaders().set("action", "sayOk2"); - return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { - return msg.body(); - }); - } -} diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java deleted file mode 100644 index a1d47d8..0000000 --- a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/DbServiceVertxProxyHandler.java +++ /dev/null @@ -1,140 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package cn.qaiu.lz.web.service; - -import cn.qaiu.lz.web.service.DbService; -import io.vertx.core.Vertx; -import io.vertx.core.Handler; -import io.vertx.core.AsyncResult; -import io.vertx.core.eventbus.EventBus; -import io.vertx.core.eventbus.Message; -import io.vertx.core.eventbus.MessageConsumer; -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.eventbus.ReplyException; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.Collection; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; -import io.vertx.serviceproxy.ProxyHandler; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.HelperUtils; -import io.vertx.serviceproxy.ServiceBinder; - -import cn.qaiu.lz.common.model.UserInfo; -import cn.qaiu.vx.core.base.BaseAsyncService; -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class DbServiceVertxProxyHandler extends ProxyHandler { - - public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes - private final Vertx vertx; - private final DbService service; - private final long timerID; - private long lastAccessed; - private final long timeoutSeconds; - private final boolean includeDebugInfo; - - public DbServiceVertxProxyHandler(Vertx vertx, DbService service){ - this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); - } - - public DbServiceVertxProxyHandler(Vertx vertx, DbService service, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond); - } - - public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond, false); - } - - public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { - this.vertx = vertx; - this.service = service; - this.includeDebugInfo = includeDebugInfo; - this.timeoutSeconds = timeoutSeconds; - try { - this.vertx.eventBus().registerDefaultCodec(ServiceException.class, - new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) {} - if (timeoutSeconds != -1 && !topLevel) { - long period = timeoutSeconds * 1000 / 2; - if (period > 10000) { - period = 10000; - } - this.timerID = vertx.setPeriodic(period, this::checkTimedOut); - } else { - this.timerID = -1; - } - accessed(); - } - - - private void checkTimedOut(long id) { - long now = System.nanoTime(); - if (now - lastAccessed > timeoutSeconds * 1000000000) { - close(); - } - } - - @Override - public void close() { - if (timerID != -1) { - vertx.cancelTimer(timerID); - } - super.close(); - } - - private void accessed() { - this.lastAccessed = System.nanoTime(); - } - - public void handle(Message msg) { - try{ - JsonObject json = msg.body(); - String action = msg.headers().get("action"); - if (action == null) throw new IllegalStateException("action not specified"); - accessed(); - switch (action) { - case "sayOk": { - service.sayOk((java.lang.String)json.getValue("data")).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); - break; - } - case "sayOk2": { - service.sayOk2((java.lang.String)json.getValue("data"), - json.getJsonObject("holder") != null ? new cn.qaiu.lz.common.model.UserInfo((JsonObject)json.getJsonObject("holder")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); - break; - } - default: throw new IllegalStateException("Invalid action: " + action); - } - } catch (Throwable t) { - if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); - else msg.reply(new ServiceException(500, t.getMessage())); - throw t; - } - } -} \ No newline at end of file diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java deleted file mode 100644 index c5ab8ea..0000000 --- a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxEBProxy.java +++ /dev/null @@ -1,77 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package cn.qaiu.lz.web.service; - -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.Vertx; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.function.Function; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.ProxyUtils; - -import cn.qaiu.lz.web.model.RealUser; -import cn.qaiu.vx.core.base.BaseAsyncService; -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class UserServiceVertxEBProxy implements UserService { - private Vertx _vertx; - private String _address; - private DeliveryOptions _options; - private boolean closed; - - public UserServiceVertxEBProxy(Vertx vertx, String address) { - this(vertx, address, null); - } - - public UserServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) { - this._vertx = vertx; - this._address = address; - this._options = options; - try { - this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) { - } - } - - @Override - public Future login(RealUser user){ - if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed"); - JsonObject _json = new JsonObject(); - _json.put("user", user != null ? user.toJson() : null); - - DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); - _deliveryOptions.addHeader("action", "login"); - _deliveryOptions.getHeaders().set("action", "login"); - return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> { - return msg.body(); - }); - } -} diff --git a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java b/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java deleted file mode 100644 index 4b430ac..0000000 --- a/lz-cow-api-web/src/main/generated/cn/qaiu/lz/web/service/UserServiceVertxProxyHandler.java +++ /dev/null @@ -1,135 +0,0 @@ -/* -* Copyright 2014 Red Hat, Inc. -* -* Red Hat licenses this file to you under the Apache License, version 2.0 -* (the "License"); you may not use this file except in compliance with the -* License. You may obtain a copy of the License at: -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -* License for the specific language governing permissions and limitations -* under the License. -*/ - -package cn.qaiu.lz.web.service; - -import cn.qaiu.lz.web.service.UserService; -import io.vertx.core.Vertx; -import io.vertx.core.Handler; -import io.vertx.core.AsyncResult; -import io.vertx.core.eventbus.EventBus; -import io.vertx.core.eventbus.Message; -import io.vertx.core.eventbus.MessageConsumer; -import io.vertx.core.eventbus.DeliveryOptions; -import io.vertx.core.eventbus.ReplyException; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import java.util.Collection; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.stream.Collectors; -import io.vertx.serviceproxy.ProxyHandler; -import io.vertx.serviceproxy.ServiceException; -import io.vertx.serviceproxy.ServiceExceptionMessageCodec; -import io.vertx.serviceproxy.HelperUtils; -import io.vertx.serviceproxy.ServiceBinder; - -import cn.qaiu.lz.web.model.RealUser; -import cn.qaiu.vx.core.base.BaseAsyncService; -import io.vertx.core.Future; -/* - Generated Proxy code - DO NOT EDIT - @author Roger the Robot -*/ - -@SuppressWarnings({"unchecked", "rawtypes"}) -public class UserServiceVertxProxyHandler extends ProxyHandler { - - public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes - private final Vertx vertx; - private final UserService service; - private final long timerID; - private long lastAccessed; - private final long timeoutSeconds; - private final boolean includeDebugInfo; - - public UserServiceVertxProxyHandler(Vertx vertx, UserService service){ - this(vertx, service, DEFAULT_CONNECTION_TIMEOUT); - } - - public UserServiceVertxProxyHandler(Vertx vertx, UserService service, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond); - } - - public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutInSecond){ - this(vertx, service, true, timeoutInSecond, false); - } - - public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) { - this.vertx = vertx; - this.service = service; - this.includeDebugInfo = includeDebugInfo; - this.timeoutSeconds = timeoutSeconds; - try { - this.vertx.eventBus().registerDefaultCodec(ServiceException.class, - new ServiceExceptionMessageCodec()); - } catch (IllegalStateException ex) {} - if (timeoutSeconds != -1 && !topLevel) { - long period = timeoutSeconds * 1000 / 2; - if (period > 10000) { - period = 10000; - } - this.timerID = vertx.setPeriodic(period, this::checkTimedOut); - } else { - this.timerID = -1; - } - accessed(); - } - - - private void checkTimedOut(long id) { - long now = System.nanoTime(); - if (now - lastAccessed > timeoutSeconds * 1000000000) { - close(); - } - } - - @Override - public void close() { - if (timerID != -1) { - vertx.cancelTimer(timerID); - } - super.close(); - } - - private void accessed() { - this.lastAccessed = System.nanoTime(); - } - - public void handle(Message msg) { - try{ - JsonObject json = msg.body(); - String action = msg.headers().get("action"); - if (action == null) throw new IllegalStateException("action not specified"); - accessed(); - switch (action) { - case "login": { - service.login(json.getJsonObject("user") != null ? new cn.qaiu.lz.web.model.RealUser((JsonObject)json.getJsonObject("user")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo)); - break; - } - default: throw new IllegalStateException("Invalid action: " + action); - } - } catch (Throwable t) { - if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t))); - else msg.reply(new ServiceException(500, t.getMessage())); - throw t; - } - } -} \ No newline at end of file From c9e714418e17a6c955186abe27bf5af871f4e2e3 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Thu, 11 May 2023 17:51:00 +0800 Subject: [PATCH 21/48] =?UTF-8?q?=E5=A4=B8=E5=85=8BHttp=20API=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lz-cow-api-web/src/main/resources/1.http | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lz-cow-api-web/src/main/resources/1.http b/lz-cow-api-web/src/main/resources/1.http index 1b29e34..bbea166 100644 --- a/lz-cow-api-web/src/main/resources/1.http +++ b/lz-cow-api-web/src/main/resources/1.http @@ -40,3 +40,18 @@ https://cowtransfer.com/core/api/transfer/share/download?transferGuid=e4f41b51-b https://cowtransfer.com/core/api/dam/asset/files/download/23890683765739569/url/v2 authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDc1OTMwNGItMDEwZS00MGJiLTlhNDUtZTczY2Q5ODYzMDQwIiwiZXhwIjoxNjgzNzkzOTExfQ.rE9z0vhogPjUC0I92MqU8U_PKe4j_mGn7lGgPFMGt5c +### +POST https://drive-pc.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc +content-type: application/json;charset=UTF-8 +cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; + +{"fids":["347f9589e0cd4294beeaaab2efac59e1"]} + + +### +POST https://drive.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc&ve=2.1.5 +content-type: application/json;charset=UTF-8 +cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; +user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch + +{"fids":["b3faf7f72ac64f94b4749588fc197816"]} From 7fa2ea59a52bf177850414b31ead85ed09132031 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Fri, 12 May 2023 17:30:10 +0800 Subject: [PATCH 22/48] do db --- README.md | 10 +++ .../java/cn/qaiu/db/pool/JDBCPoolInit.java | 17 +++-- lz-cow-api-web/pom.xml | 6 ++ lz-cow-api-web/src/main/resources/1.http | 65 +++++++++++++++++++ lz-cow-api-web/src/main/resources/app-dev.yml | 10 ++- 5 files changed, 100 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7e2aa47..872bce3 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,13 @@ TODO: 解析蓝奏云加密链接 +# 网盘对比 + +| 网盘名称 | 可直接下载分享 | 加密分享 | 初始网盘空间 | 单文件大小限制 | 登录接口 | +|------|-------------|------|----------|----------------|------| +| 蓝奏云 | √ | √ | 不限空间 | 100M | √ | +| 奶牛快传 | √ | X | 10G | 不限大小 | √ | +| 夸克网盘 | X(>10M需要登录) | √ | 10G(20G) | 不限大小(>10M需要登录) | X | +| 天翼云盘 | | | | | | +| 阿里云盘 | | | | | | + diff --git a/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java b/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java index ce32f56..2f899e7 100644 --- a/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java +++ b/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java @@ -88,7 +88,14 @@ public class JDBCPoolInit { } private void poolInitExecute(Promise promise) { - // 初始化H2db, 创建本地db文件 + // 初始化连接池 + pool = JDBCPool.pool(vertx, dbConfig); + CreateTable.createTable(pool, dbConfig.getString("tableClassPath")); + promise.complete("init jdbc pool success"); + + } + + private void checkOrCreateDBFile() { LOGGER.info("init sql start"); String[] path = url.split("\\./"); path[1] = path[1].split(";")[0]; @@ -109,14 +116,12 @@ public class JDBCPoolInit { throw new RuntimeException("file create failed"); } } - // 初始化连接池 - pool = JDBCPool.pool(vertx, dbConfig); - CreateTable.createTable(pool, dbConfig.getString("tableClassPath")); - promise.complete("init jdbc pool success"); - } private void h2serverExecute(Promise promise) { + // 初始化H2db, 创建本地db文件 + checkOrCreateDBFile(); + try { String url = dbConfig.getString("jdbcUrl"); String[] portStr = url.split(":"); diff --git a/lz-cow-api-web/pom.xml b/lz-cow-api-web/pom.xml index 0053f51..0e454ce 100644 --- a/lz-cow-api-web/pom.xml +++ b/lz-cow-api-web/pom.xml @@ -53,6 +53,12 @@ jsoup 1.15.4 + + io.vertx + vertx-web-client + 4.4.1 + + cn.qaiu core-database diff --git a/lz-cow-api-web/src/main/resources/1.http b/lz-cow-api-web/src/main/resources/1.http index bbea166..5a2f23e 100644 --- a/lz-cow-api-web/src/main/resources/1.http +++ b/lz-cow-api-web/src/main/resources/1.http @@ -40,6 +40,55 @@ https://cowtransfer.com/core/api/transfer/share/download?transferGuid=e4f41b51-b https://cowtransfer.com/core/api/dam/asset/files/download/23890683765739569/url/v2 authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDc1OTMwNGItMDEwZS00MGJiLTlhNDUtZTczY2Q5ODYzMDQwIiwiZXhwIjoxNjgzNzkzOTExfQ.rE9z0vhogPjUC0I92MqU8U_PKe4j_mGn7lGgPFMGt5c +### +POST https://cowtransfer.com/api/user/emaillogin +Content-Type: multipart/form-data; boundary=WebAppBoundary + +--WebAppBoundary +Content-Disposition: form-data; name="email" + +736226400@qq.com +--WebAppBoundary +Content-Disposition: form-data; name="password" + +4458225ff +--WebAppBoundary-- +# eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDc1OTMwNGItMDEwZS00MGJiLTlhNDUtZTczY2Q5ODYzMDQwIiwiZXhwIjoxNjg0NDYyMjMzfQ.AeuB5-aQUlgudoLDRgvFodlHx2qKiPFx3BAqGA0R-eE +# eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDc1OTMwNGItMDEwZS00MGJiLTlhNDUtZTczY2Q5ODYzMDQwIiwiZXhwIjoxNjg0NDYyMjMzfQ.AeuB5-aQUlgudoLDRgvFodlHx2qKiPFx3BAqGA0R-eE + + +### +POST https://cowtransfer.com/api/user/register/emailregistrationcheck +Content-Type: multipart/form-data; boundary=WebAppBoundary + +--WebAppBoundary +Content-Disposition: form-data; name="email" + +736226400@qq.com +--WebAppBoundary +Content-Disposition: form-data; name="joinProToken" + + +--WebAppBoundary-- + + + +### Send a form with the text and file fields +POST https://httpbin.org/post +Content-Type: multipart/form-data; boundary=WebAppBoundary + +--WebAppBoundary +Content-Disposition: form-data; name="element-name" +Content-Type: text/plain + +Name +--WebAppBoundary +Content-Disposition: form-data; name="data"; filename="data.json" +Content-Type: application/json + +< ./request-form-data.json +--WebAppBoundary-- + ### POST https://drive-pc.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc content-type: application/json;charset=UTF-8 @@ -55,3 +104,19 @@ cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2 user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch {"fids":["b3faf7f72ac64f94b4749588fc197816"]} + +### quark_pan +# 我用夸克网盘分享了「C# Shell (C# Offline Compiler)_2.5.16.apk」,点击链接即可保存。打开「夸克APP」,无需下载在线播放视频,畅享原画5倍速,支持电视投屏。 +#链接:https://pan.quark.cn/s/8f816f506409 +# step1 获取stoken +POST https://drive-pc.quark.cn/1/clouddrive/share/sharepage/token?pr=ucpro&fr=pc +accept: application/json, text/plain, */* +content-type: application/json + +{"pwd_id":"8f816f506409","passcode":""} + +### quark_pan +# step2 获取fid +https://drive-pc.quark.cn/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd_id=8f816f506409&stoken=TMJG1MBehHvDvuZgVZ%2FazmtOi0rGiw2v1O6%2FKCQwu%2Bc%3D&pdir_fid=0&force=0&_page=1&_size=50&_fetch_banner=1&_fetch_share=1&_fetch_total=1&_sort=file_type:asc,updated_at:desc + + diff --git a/lz-cow-api-web/src/main/resources/app-dev.yml b/lz-cow-api-web/src/main/resources/app-dev.yml index eaa6d50..81d2859 100644 --- a/lz-cow-api-web/src/main/resources/app-dev.yml +++ b/lz-cow-api-web/src/main/resources/app-dev.yml @@ -20,13 +20,19 @@ custom: - .*/test.*$ entityPackagesReg: - ^cn\.qaiu\.lz\.web\.model\..* - otherConfig: - - dictionaries.json errorPage404: /index.html indexPage: /test2 sharedLogin: true lzConfig: config: '111' +dataSource: + provider_class: io.vertx.ext.jdbc.spi.impl.HikariCPDataSourceProvider + jdbcUrl: jdbc:h2:tcp://127.0.0.1:9095/./db/myData;MODE=MySQL;DATABASE_TO_LOWER=FALSE + driverClassName: org.h2.Driver + username: root + password: '123456' + tableClassPath: cn.qaiu.lz.web.model + cowConfig: config: '111' From 804266d5afe667f450490ef07278d6e6622f3b81 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Mon, 15 May 2023 17:42:29 +0800 Subject: [PATCH 23/48] do cow login api --- .../java/cn/qaiu/lz/web/http/ServerApi.java | 2 +- lz-cow-api-web/src/main/resources/1.http | 10 ++++- .../cn/qaiu/web/test/WebClientExample.java | 44 +++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebClientExample.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 4dabeb7..9df2486 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -51,7 +51,7 @@ public class ServerApi { @RouteMapping(value = "/lz/:id", method = RouteMethod.GET) public void lzParse(HttpServerResponse response, String id) throws Exception { - var url = "https://wwa.lanzoux.com/" + id; + var url = "https://wwsd.lanzoue.com/" + id; var urlDownload = LzTool.parse(url); log.info("url = {}", urlDownload); response.putHeader("location", urlDownload).setStatusCode(302).end(); diff --git a/lz-cow-api-web/src/main/resources/1.http b/lz-cow-api-web/src/main/resources/1.http index 5a2f23e..62f63a3 100644 --- a/lz-cow-api-web/src/main/resources/1.http +++ b/lz-cow-api-web/src/main/resources/1.http @@ -94,7 +94,7 @@ POST https://drive-pc.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc content-type: application/json;charset=UTF-8 cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; -{"fids":["347f9589e0cd4294beeaaab2efac59e1"]} +{"fids":["b3faf7f72ac64f94b4749588fc197816"]} ### @@ -105,6 +105,12 @@ user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, {"fids":["b3faf7f72ac64f94b4749588fc197816"]} +### +https://dl-pc-zb-cf.pds.quark.cn/KTb1G4Lr/623810984/645b44ef8d9c47afbd2f4947b4b89d098f725188/645b44ef1eb3ebc1a8b448eb992b0e9195dfb646?Expires=1684137387&OSSAccessKeyId=LTAIyYfxTqY7YZsg&Signature=M5X1La7lpOJLRGZioFIMHRujuPs%3D&x-oss-traffic-limit=503316480&response-content-disposition=attachment%3B%20filename%3DC%23%20Shell%20%28C%23%20Offline%20Compiler%29_2.5.16.apk&u5=489aa5c778a51f717585a253ce8290a1&callback=eyJjYWxsYmFja0JvZHlUeXBlIjoiYXBwbGljYXRpb24vanNvbiIsImNhbGxiYWNrU3RhZ2UiOiJiZWZvcmUtZXhlY3V0ZSIsImNhbGxiYWNrRmFpbHVyZUFjdGlvbiI6Imlnbm9yZSIsImNhbGxiYWNrVXJsIjoiaHR0cHM6Ly9hdXRoLWNkbi51Yy5jbi9vdXRlci9vc3MvY2hlY2twbGF5IiwiY2FsbGJhY2tCb2R5Ijoie1wiaG9zdFwiOiR7aHR0cEhlYWRlci5ob3N0fSxcInNpemVcIjoke3NpemV9LFwicmFuZ2VcIjoke2h0dHBIZWFkZXIucmFuZ2V9LFwicmVmZXJlclwiOiR7aHR0cEhlYWRlci5yZWZlcmVyfSxcImNvb2tpZVwiOiR7aHR0cEhlYWRlci5jb29raWV9LFwibWV0aG9kXCI6JHtodHRwSGVhZGVyLm1ldGhvZH0sXCJpcFwiOiR7Y2xpZW50SXB9LFwib2JqZWN0XCI6JHtvYmplY3R9LFwic3BcIjoke3g6c3B9LFwidG9rZW5cIjoke3g6dG9rZW59LFwidHRsXCI6JHt4OnR0bH0sXCJjbGllbnRfdG9rZW5cIjoke3F1ZXJ5U3RyaW5nLmNsaWVudF90b2tlbn19In0%3D&callback-var=eyJ4OnNwIjoiMzc4IiwieDp0b2tlbiI6IjItNDg5YWE1Yzc3OGE1MWY3MTc1ODVhMjUzY2U4MjkwYTEtOC0xLTIwNDgtNDNiNGMxMzk4NTBjNDkyZWFmMTIwNTA2MWI5NjZiYTEtYTk2MDhlNTFlMjUwMDJlNTkyODJkYzNmMjA3MGU0M2EiLCJ4OnR0bCI6IjIxNjAwIn0%3D +cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; +user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch + + ### quark_pan # 我用夸克网盘分享了「C# Shell (C# Offline Compiler)_2.5.16.apk」,点击链接即可保存。打开「夸克APP」,无需下载在线播放视频,畅享原画5倍速,支持电视投屏。 #链接:https://pan.quark.cn/s/8f816f506409 @@ -117,6 +123,6 @@ content-type: application/json ### quark_pan # step2 获取fid -https://drive-pc.quark.cn/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd_id=8f816f506409&stoken=TMJG1MBehHvDvuZgVZ%2FazmtOi0rGiw2v1O6%2FKCQwu%2Bc%3D&pdir_fid=0&force=0&_page=1&_size=50&_fetch_banner=1&_fetch_share=1&_fetch_total=1&_sort=file_type:asc,updated_at:desc +https://drive-pc.quark.cn/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd_id=8f816f506409&stoken=JX6p1XFG5hD2VaUJFxazvE72u9TuhcKiXd81%2BXaFFsI%3D&pdir_fid=0&force=0&_page=1&_size=50&_fetch_banner=1&_fetch_share=1&_fetch_total=1&_sort=file_type:asc,updated_at:desc diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebClientExample.java b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebClientExample.java new file mode 100644 index 0000000..0b2384b --- /dev/null +++ b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebClientExample.java @@ -0,0 +1,44 @@ +package cn.qaiu.web.test; + +import io.vertx.core.MultiMap; +import io.vertx.core.Vertx; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpHeaders; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.client.HttpResponse; +import io.vertx.ext.web.client.WebClient; +import io.vertx.ext.web.multipart.MultipartForm; +import io.vertx.ext.web.multipart.impl.MultipartFormImpl; + +public class WebClientExample { + + public static void main(String[] args) { + Vertx vertx = Vertx.vertx(); + WebClient client = WebClient.create(vertx); + + MultipartForm form = new MultipartFormImpl() + .attribute("email", "736226400@qq.com") + .attribute("password", ""); + + client.postAbs("https://cowtransfer.com/api/user/emaillogin") + .putHeader(HttpHeaders.CONTENT_TYPE.toString(), "multipart/form-data; boundary=WebAppBoundary") + .sendMultipartForm(form, ar -> { + if (ar.succeeded()) { + HttpResponse response = ar.result(); + System.out.println("Response status code: " + response.statusCode()); + + // Print all response headers + MultiMap headers = response.headers(); + headers.names().forEach(name -> { + System.out.println(name + ": " + headers.getAll(name)); + }); + + JsonObject responseBody = response.bodyAsJsonObject(); + System.out.println("Response body: " + responseBody.encodePrettily()); + } else { + System.out.println("Something went wrong: " + ar.cause().getMessage()); + } + vertx.close(); + }); + } +} From 25534452aeaa1b4cfe4218d72675e1a9bd82ad64 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Tue, 23 May 2023 17:34:11 +0800 Subject: [PATCH 24/48] =?UTF-8?q?UCpan=E5=92=8C=E7=A7=BB=E5=8A=A8=E4=BA=91?= =?UTF-8?q?=E7=A9=BA=E9=97=B4API=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/qaiu/db/pool/JDBCPoolInit.java | 14 +- core/pom.xml | 2 +- .../src/main/java/cn/qaiu/vx/core/Deploy.java | 38 ++-- .../cn/qaiu/vx/core/util/ConfigConstant.java | 11 + .../core/verticle/ReverseProxyVerticle.java | 9 +- .../src/main/java/cn/qaiu/lz/AppMain.java | 3 +- .../java/cn/qaiu/lz/common/util/CowTool.java | 2 + .../java/cn/qaiu/lz/common/util/EcTool.java | 36 +++ .../java/cn/qaiu/lz/common/util/LzTool.java | 2 + .../java/cn/qaiu/lz/web/http/ServerApi.java | 4 +- .../java/cn/qaiu/lz/web/model/CowUser.java | 4 + .../java/cn/qaiu/lz/web/model/LzUser.java | 4 + .../web/model/{RealUser.java => SysUser.java} | 4 +- .../cn/qaiu/lz/web/service/UserService.java | 4 +- .../lz/web/service/impl/UserServiceImpl.java | 4 +- lz-cow-api-web/src/main/resources/1.http | 208 ++++++++++++++++++ lz-cow-api-web/src/main/resources/logback.xml | 1 + .../java/cn/qaiu/web/test/TestWebClient2.java | 16 ++ 18 files changed, 332 insertions(+), 34 deletions(-) create mode 100644 core/src/main/java/cn/qaiu/vx/core/util/ConfigConstant.java create mode 100644 lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/EcTool.java create mode 100644 lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/CowUser.java create mode 100644 lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/LzUser.java rename lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/{RealUser.java => SysUser.java} (86%) create mode 100644 lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestWebClient2.java diff --git a/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java b/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java index 2f899e7..3931192 100644 --- a/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java +++ b/core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java @@ -76,14 +76,16 @@ public class JDBCPoolInit { // 异步启动H2服务 vertx.createSharedWorkerExecutor("h2-server", 1, Long.MAX_VALUE) .executeBlocking(this::h2serverExecute) - .onSuccess(LOGGER::info) + .onSuccess(res->{ + LOGGER.info(res); + // 初始化数据库连接 + vertx.createSharedWorkerExecutor("sql-pool-init") + .executeBlocking(this::poolInitExecute) + .onSuccess(LOGGER::info) + .onFailure(Throwable::printStackTrace); + }) .onFailure(Throwable::printStackTrace); - // 初始化数据库连接 - vertx.createSharedWorkerExecutor("sql-pool-init") - .executeBlocking(this::poolInitExecute) - .onSuccess(LOGGER::info) - .onFailure(Throwable::printStackTrace); } diff --git a/core/pom.xml b/core/pom.xml index 0503ff2..1809066 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -19,7 +19,7 @@ 1.18.12 2.0.5 3.12.0 - 2.11.3 + 2.14.2 diff --git a/core/src/main/java/cn/qaiu/vx/core/Deploy.java b/core/src/main/java/cn/qaiu/vx/core/Deploy.java index e152e66..034483f 100644 --- a/core/src/main/java/cn/qaiu/vx/core/Deploy.java +++ b/core/src/main/java/cn/qaiu/vx/core/Deploy.java @@ -1,5 +1,6 @@ package cn.qaiu.vx.core; +import cn.qaiu.vx.core.util.ConfigConstant; import cn.qaiu.vx.core.util.ConfigUtil; import cn.qaiu.vx.core.util.VertxHolder; import cn.qaiu.vx.core.verticle.ReverseProxyVerticle; @@ -14,6 +15,7 @@ import org.slf4j.LoggerFactory; import java.lang.management.ManagementFactory; import java.util.Calendar; import java.util.Date; +import java.util.concurrent.locks.LockSupport; /** * vertx启动类 需要在主启动类完成回调 @@ -31,13 +33,17 @@ public final class Deploy { StringBuilder path = new StringBuilder("app"); private JsonObject customConfig; + private JsonObject globalConfig; private Handler handle; + private Thread mainThread; + public static Deploy instance() { return INSTANCE; } public void start(String[] args, Handler handle) { + this.mainThread = Thread.currentThread(); this.handle = handle; if (args.length > 0) { // 启动参数dev或者prod @@ -48,6 +54,8 @@ public final class Deploy { ConfigUtil.readYamlConfig(path.toString(), tempVertx) .onSuccess(this::readConf) .onFailure(Throwable::printStackTrace); + LockSupport.park(); + deployVerticle(); } private void readConf(JsonObject conf) { @@ -59,7 +67,10 @@ public final class Deploy { } else { LOGGER.info("---------------> Production environment <--------------\n"); } - ConfigUtil.readYamlConfig(path + "-" + activeMode, tempVertx).onSuccess(this::deployVerticle); + ConfigUtil.readYamlConfig(path + "-" + activeMode, tempVertx).onSuccess(res -> { + this.globalConfig = res; + LockSupport.unpark(mainThread); + }); } /** @@ -92,30 +103,31 @@ public final class Deploy { /** * 部署Verticle - * - * @param globalConfig 配置 */ - private void deployVerticle(JsonObject globalConfig) { + private void deployVerticle() { tempVertx.close(); LOGGER.info("配置读取成功"); - customConfig = globalConfig.getJsonObject("custom"); + customConfig = globalConfig.getJsonObject(ConfigConstant.CUSTOM); - var vertxOptions = new VertxOptions(globalConfig.getJsonObject("vertx")); + var vertxOptions = new VertxOptions(globalConfig.getJsonObject(ConfigConstant.VERTX)); var vertx = Vertx.vertx(vertxOptions); VertxHolder.init(vertx); //配置保存在共享数据中 var sharedData = vertx.sharedData(); - LocalMap localMap = sharedData.getLocalMap("local"); - localMap.put("globalConfig", globalConfig); - localMap.put("customConfig", customConfig); - localMap.put("server", globalConfig.getJsonObject("server")); - handle.handle(globalConfig); + LocalMap localMap = sharedData.getLocalMap(ConfigConstant.LOCAL); + localMap.put(ConfigConstant.GLOBAL_CONFIG, globalConfig); + localMap.put(ConfigConstant.CUSTOM_CONFIG, customConfig); + localMap.put(ConfigConstant.SERVER, globalConfig.getJsonObject(ConfigConstant.SERVER)); + var future0 = vertx.createSharedWorkerExecutor("other-handle").executeBlocking(bch -> { + handle.handle(globalConfig); + bch.complete("other handle complete"); + }); var future1 = vertx.deployVerticle(RouterVerticle.class, getWorkDeploymentOptions("Router")); var future2 = vertx.deployVerticle(ServiceVerticle.class, getWorkDeploymentOptions("Service")); var future3 = vertx.deployVerticle(ReverseProxyVerticle.class, getWorkDeploymentOptions("proxy")); - CompositeFuture.all(future1, future2, future3) + CompositeFuture.all(future1, future2, future3, future0) .onSuccess(this::deployWorkVerticalSuccess) .onFailure(this::deployVerticalFailed); } @@ -148,7 +160,7 @@ public final class Deploy { * @return Deployment Options */ private DeploymentOptions getWorkDeploymentOptions(String name) { - return getWorkDeploymentOptions(name, customConfig.getInteger("asyncServiceInstances")); + return getWorkDeploymentOptions(name, customConfig.getInteger(ConfigConstant.ASYNC_SERVICE_INSTANCES)); } private DeploymentOptions getWorkDeploymentOptions(String name, int ins) { diff --git a/core/src/main/java/cn/qaiu/vx/core/util/ConfigConstant.java b/core/src/main/java/cn/qaiu/vx/core/util/ConfigConstant.java new file mode 100644 index 0000000..dfa83d9 --- /dev/null +++ b/core/src/main/java/cn/qaiu/vx/core/util/ConfigConstant.java @@ -0,0 +1,11 @@ +package cn.qaiu.vx.core.util; + +public interface ConfigConstant { + String CUSTOM = "custom"; + String VERTX = "vertx"; + String LOCAL = "local"; + String SERVER = "server"; + String GLOBAL_CONFIG = "globalConfig"; + String CUSTOM_CONFIG = "customConfig"; + String ASYNC_SERVICE_INSTANCES = "asyncServiceInstances"; +} diff --git a/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java b/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java index 3a81cab..e084ec0 100644 --- a/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java +++ b/core/src/main/java/cn/qaiu/vx/core/verticle/ReverseProxyVerticle.java @@ -1,9 +1,6 @@ package cn.qaiu.vx.core.verticle; -import cn.qaiu.vx.core.util.CastUtil; -import cn.qaiu.vx.core.util.ConfigUtil; -import cn.qaiu.vx.core.util.SharedDataUtil; -import cn.qaiu.vx.core.util.VertxHolder; +import cn.qaiu.vx.core.util.*; import io.vertx.core.AbstractVerticle; import io.vertx.core.Future; import io.vertx.core.Promise; @@ -39,7 +36,9 @@ public class ReverseProxyVerticle extends AbstractVerticle { private static final Logger LOGGER = LoggerFactory.getLogger(ReverseProxyVerticle.class); - private static final String PATH_PROXY_CONFIG = SharedDataUtil.getJsonConfig("globalConfig").getString("proxyConf"); + private static final String PATH_PROXY_CONFIG = SharedDataUtil + .getJsonConfig(ConfigConstant.GLOBAL_CONFIG) + .getString("proxyConf"); private static final Future CONFIG = ConfigUtil.readYamlConfig(PATH_PROXY_CONFIG); private static final String DEFAULT_PATH_404 = "webroot/err/404.html"; diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java index a7f5acd..3f24a12 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java @@ -1,5 +1,6 @@ package cn.qaiu.lz; +import cn.qaiu.db.pool.JDBCPoolInit; import cn.qaiu.vx.core.Deploy; import io.vertx.core.json.JsonObject; @@ -22,7 +23,7 @@ public class AppMain { * @param jsonObject 配置 */ private static void exec(JsonObject jsonObject) { -// JDBCPoolInit.builder().config(jsonObject.getJsonObject("dataSource")).build().initPool(); + JDBCPoolInit.builder().config(jsonObject.getJsonObject("dataSource")).build().initPool(); } diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java index 74721f9..cdc4191 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java @@ -10,6 +10,8 @@ import org.jsoup.Jsoup; import java.util.Map; /** + * 奶牛快传解析工具 + * * @author QAIU * @date 2023/4/21 21:19 */ diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/EcTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/EcTool.java new file mode 100644 index 0000000..0e61efb --- /dev/null +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/EcTool.java @@ -0,0 +1,36 @@ +package cn.qaiu.lz.common.util; + +import io.vertx.core.Vertx; +import io.vertx.ext.web.client.WebClient; + +/** + * 移动云空间解析 + */ +public class EcTool { + public static String FULL_URL_PREFIX = "https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https:%2F%2Fwww.ecpan.cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&parentId=-1&data="; + + + public static String parse(String dataKey) throws Exception { + Vertx vertx = Vertx.vertx(); + WebClient client = WebClient.create(vertx); + try { + + client.getAbs(FULL_URL_PREFIX+dataKey).send().onSuccess( + res -> { + System.out.println(res.bodyAsString()); + } + ).onFailure(t -> { + throw new RuntimeException("解析失败"); + }); + + } catch (RuntimeException e) { + throw new Exception(e); + } + return ""; + } + + public static void main(String[] args) throws Exception { + parse("81027a5c99af5b11ca004966c945cce6W9Bf2"); + System.out.println("222222"); + } +} diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java index c9f5325..497a971 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -12,6 +12,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** + * 蓝奏云解析工具 + * * @author QAIU * @version 1.0 update 2021/5/16 10:39 */ diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 9df2486..d32c788 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -2,7 +2,7 @@ package cn.qaiu.lz.web.http; import cn.qaiu.lz.common.util.CowTool; import cn.qaiu.lz.common.util.LzTool; -import cn.qaiu.lz.web.model.RealUser; +import cn.qaiu.lz.web.model.SysUser; import cn.qaiu.lz.web.service.UserService; import cn.qaiu.vx.core.annotaions.RouteHandler; import cn.qaiu.vx.core.annotaions.RouteMapping; @@ -26,7 +26,7 @@ public class ServerApi { private final UserService userService = AsyncServiceUtil.getAsyncServiceInstance(UserService.class); @RouteMapping(value = "/login", method = RouteMethod.POST) - public Future login(RealUser user) { + public Future login(SysUser user) { log.info("<------- login: {}", user.getUsername()); return userService.login(user); } diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/CowUser.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/CowUser.java new file mode 100644 index 0000000..a594aff --- /dev/null +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/CowUser.java @@ -0,0 +1,4 @@ +package cn.qaiu.lz.web.model; + +public class CowUser { +} diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/LzUser.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/LzUser.java new file mode 100644 index 0000000..b8205b0 --- /dev/null +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/LzUser.java @@ -0,0 +1,4 @@ +package cn.qaiu.lz.web.model; + +public class LzUser { +} diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/SysUser.java similarity index 86% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java rename to lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/SysUser.java index 16db7e4..113d515 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/RealUser.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/SysUser.java @@ -13,13 +13,13 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @DataObject @Table("t_user") -public class RealUser implements ToJson { +public class SysUser implements ToJson { private String id; private String username; private String password; - public RealUser(JsonObject json) { + public SysUser(JsonObject json) { this.username = json.getString("username"); this.password = json.getString("password"); } diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/UserService.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/UserService.java index c4aafda..ae25cf9 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/UserService.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/UserService.java @@ -1,7 +1,7 @@ package cn.qaiu.lz.web.service; +import cn.qaiu.lz.web.model.SysUser; import cn.qaiu.vx.core.base.BaseAsyncService; -import cn.qaiu.lz.web.model.RealUser; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.core.Future; @@ -13,5 +13,5 @@ import io.vertx.core.Future; */ @ProxyGen public interface UserService extends BaseAsyncService { - Future login(RealUser user); + Future login(SysUser user); } diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java index 07f1170..5de4ff3 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java +++ b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java @@ -1,6 +1,6 @@ package cn.qaiu.lz.web.service.impl; -import cn.qaiu.lz.web.model.RealUser; +import cn.qaiu.lz.web.model.SysUser; import cn.qaiu.lz.web.service.UserService; import cn.qaiu.vx.core.annotaions.Service; import io.vertx.core.Future; @@ -15,7 +15,7 @@ import io.vertx.core.Future; public class UserServiceImpl implements UserService { @Override - public Future login(RealUser user) { + public Future login(SysUser user) { return Future.succeededFuture("111"); } diff --git a/lz-cow-api-web/src/main/resources/1.http b/lz-cow-api-web/src/main/resources/1.http index 62f63a3..50aaebf 100644 --- a/lz-cow-api-web/src/main/resources/1.http +++ b/lz-cow-api-web/src/main/resources/1.http @@ -126,3 +126,211 @@ content-type: application/json https://drive-pc.quark.cn/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd_id=8f816f506409&stoken=JX6p1XFG5hD2VaUJFxazvE72u9TuhcKiXd81%2BXaFFsI%3D&pdir_fid=0&force=0&_page=1&_size=50&_fetch_banner=1&_fetch_share=1&_fetch_total=1&_sort=file_type:asc,updated_at:desc +### quark_pan +https://drive-pc.quark.cn/1/clouddrive/auth/pc/flush?pr=ucpro&fr=pc +cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; + +# https://fast.uc.cn/s/33197dd53ace4 +### UCpan +https://fast.uc.cn/api/info?st=&fr=pc&pr=UCBrowser + +### UCpan 第一步 获取stoken POST json传入pwd_id(分享id),passcode(分享密码) +POST https://pc-api.uc.cn/1/clouddrive/share/sharepage/token?entry=ft&fr=pc&pr=UCBrowser +content-type: application/json + +{"pwd_id":"33197dd53ace4","passcode":"","share_for_transfer":true} + +### UCpan 第二步 获取fid,share_fid_token GET传参pwd_id,passcode,stoken +https://pc-api.uc.cn/1/clouddrive/transfer_share/detail?pwd_id=33197dd53ace4&passcode=&stoken=oPz47hsgQXQdDYimsP4kBMi8aLv40X378IZOiBsnfLU%3D +content-type: application/json + +### UCpan 第二步获取下载链接 POST json传入fids(fid),pwd_id,stoken,fids_token(share_fid_token) +POST https://pc-api.uc.cn/1/clouddrive/file/download?entry=ft&fr=pc&pr=UCBrowser +content-type: application/json + +{ + "fids": [ + "54c3cd90ed3e45119bb96ed99a562d40" + ], + "pwd_id": "33197dd53ace4", + "stoken": "oPz47hsgQXQdDYimsP4kBMi8aLv40X378IZOiBsnfLU=", + "fids_token": [ + "ff9f5b5c94df9d08c8dd3b7948fc5e20" + ] +} + +### https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare=1 +### ecpan(移动云空间) +https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https:%2F%2Fwww.ecpan.cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&parentId=-1 + + +### +POST https://www.ecpan.cn/drive/sharedownload.do +Accept: application/json +Content-Type: application/json + +{ + "extCodeFlag": 0, + "isIp": 0, + "shareId": 2404807, + "groupId": "c27b53c4f91b11ed86b3b026287b20b1", + "fileIdList": [{ + "tableName": "cloudp_file_52", + "appFileId": "2d06ad61f91c11ed86b3b026287b20b1", + "dfsFileId": "3080817de83747698ff5747e25f97e50", + "fileName": "fonts.zip", + "filePath": "个人盘", + "fileLevel": 0, + "fileCount": 0, + "fileType": 2, + "fileSort": 99, + "fileSize": 19115063, + "uploadSize": 19115063, + "parentId": "c27b53c4f91b11ed86b3b026287b20b1", + "usn": 11364252, + "userName": "157****1073", + "userId": "", + "corpId": 13260232, + "createDate": 1684813492000, + "modifyDate": 1684813492000, + "status": 1, + "version": 0, + "comeFrom": 21, + "isShare": 0, + "folderType": 0, + "groupDesc": null, + "groupId": "c27b53c4f91b11ed86b3b026287b20b1", + "groupName": null, + "permission": null, + "userInfo": null, + "diskType": 1, + "historyKey": null, + "oldAppFileId": null, + "fileRealPath": null, + "fileExt": null, + "oldFileName": null, + "key": null, + "isUpperCase": null, + "isSubDir": null, + "isViewFolder": null, + "uploadTimeType": null, + "startUploadTime": null, + "endUploadTime": null, + "sizeOperator": null, + "orderField": null, + "orderBy": null, + "oldFilePath": null, + "statusStr": null, + "rootUsn": 11364252, + "createdByUsn": null, + "attentionCount": 0, + "fileMd5": "86c1ff32437ca0ccaca24f7ea197e34a", + "fileLabel": null, + "fileDesc": null, + "fileExtends": "00", + "deviceId": null, + "fileNamePinyin": "fonts.zip", + "modifyUser": "157****1073", + "fileExFileds": { + "shareRoot": "", + "isLock": 0, + "isEncrypt": 0 + }, + "security": 0, + "createdDate": null, + "modifiedDate1": null, + "modifiedDate2": null, + "createdDate1": null, + "createdDate2": null, + "deleteUsn": null, + "toShares": null, + "firstLevel": null + }] +} + +### +https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https:%2F%2Fwww.ecpan.cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&data=aa0cae0164d8885e6d35826b5b2901eckbWJBalM&parentId=-1 + +### +POST https://www.ecpan.cn/drive/sharedownload.do +Accept: application/json +Content-Type: application/json + +{ + "extCodeFlag": 0, + "isIp": 0, + "shareId": 2404807, + "groupId": "c27b53c4f91b11ed86b3b026287b20b1", + "fileIdList": [{ + "tableName": "cloudp_file_52", + "appFileId": "fe4ea2d0f92011ed86b3b026287b20b1", + "dfsFileId": "a81bdef5a9614d30b7f856755c985cf8", + "fileName": "readline-7.0-rc1.tar.gz", + "filePath": "个人盘\\app", + "fileLevel": 1, + "fileCount": 0, + "fileType": 2, + "fileSort": 99, + "fileSize": 2897058, + "uploadSize": 2897058, + "parentId": "ed008146f92011ed86b3b026287b20b1", + "usn": 11364252, + "userName": "157****1073", + "userId": "", + "corpId": 13260232, + "createDate": 1684815561000, + "modifyDate": 1684815561000, + "status": 1, + "version": 0, + "comeFrom": 21, + "isShare": 0, + "folderType": 0, + "groupDesc": null, + "groupId": "c27b53c4f91b11ed86b3b026287b20b1", + "groupName": null, + "permission": null, + "userInfo": null, + "diskType": 1, + "historyKey": null, + "oldAppFileId": null, + "fileRealPath": null, + "fileExt": null, + "oldFileName": null, + "key": null, + "isUpperCase": null, + "isSubDir": null, + "isViewFolder": null, + "uploadTimeType": null, + "startUploadTime": null, + "endUploadTime": null, + "sizeOperator": null, + "orderField": null, + "orderBy": null, + "oldFilePath": null, + "statusStr": null, + "rootUsn": 11364252, + "createdByUsn": null, + "attentionCount": 0, + "fileMd5": "c5ed4d0fd48ec6c940d6da375e3f1b50", + "fileLabel": null, + "fileDesc": null, + "fileExtends": "00", + "deviceId": null, + "fileNamePinyin": "readline-7.0-rc1.tar.gz", + "modifyUser": "157****1073", + "fileExFileds": { + "shareRoot": "", + "isLock": 0, + "isEncrypt": 0 + }, + "security": 0, + "createdDate": null, + "modifiedDate1": null, + "modifiedDate2": null, + "createdDate1": null, + "createdDate2": null, + "deleteUsn": null, + "toShares": null, + "firstLevel": null + }] +} diff --git a/lz-cow-api-web/src/main/resources/logback.xml b/lz-cow-api-web/src/main/resources/logback.xml index 3745f53..079e9c7 100644 --- a/lz-cow-api-web/src/main/resources/logback.xml +++ b/lz-cow-api-web/src/main/resources/logback.xml @@ -53,6 +53,7 @@ + diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestWebClient2.java b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestWebClient2.java new file mode 100644 index 0000000..7b7aca0 --- /dev/null +++ b/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestWebClient2.java @@ -0,0 +1,16 @@ +package cn.qaiu.web.test; + +import io.vertx.core.Vertx; +import io.vertx.ext.web.client.WebClient; + +public class TestWebClient2 { + + public static void main(String[] args) { + Vertx vertx = Vertx.vertx(); + WebClient client = WebClient.create(vertx); + client.getAbs("https://qaiu.top").send().onSuccess(res -> { + System.out.println(res.bodyAsString()); + client.close(); + }); + } +} From 00af483239920a24ed6cefc13bdd3629251c97ab Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Wed, 24 May 2023 16:20:06 +0800 Subject: [PATCH 25/48] =?UTF-8?q?1.=20=E9=A1=B9=E7=9B=AE=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D=202.=20=E6=B7=BB=E5=8A=A0UC=E7=BD=91=E7=9B=98?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=203.=20=E6=B7=BB=E5=8A=A0=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E4=BA=91=E7=A9=BA=E9=97=B4=E8=A7=A3=E6=9E=90=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- README.md | 53 ++++- bin/lz-api.service | 2 +- bin/run.bat | 2 +- bin/run.sh | 2 +- core-database/pom.xml | 4 +- core/pom.xml | 4 +- .../handlerfactory/RouterHandlerFactory.java | 14 +- .../java/cn/qaiu/lz/common/util/EcTool.java | 36 --- .../java/cn/qaiu/lz/web/http/ServerApi.java | 80 ------- pom.xml | 9 +- {lz-cow-api-web => web-service}/assembly.xml | 0 {lz-cow-api-web => web-service}/pom.xml | 11 +- .../src/main/java/cn/qaiu/lz/AppMain.java | 5 +- .../main/java/cn/qaiu/lz/common/ToJson.java | 0 .../interceptorImpl/DefaultInterceptor.java | 0 .../java/cn/qaiu/lz/common/model/MyData.java | 0 .../cn/qaiu/lz/common/model/UserInfo.java | 0 .../cn/qaiu/lz/common/util/ArrayUtil.java | 0 .../cn/qaiu/lz/common/util/ConnectUtil.java | 0 .../java/cn/qaiu/lz/common/util/CowTool.java | 0 .../java/cn/qaiu/lz/common/util/EcTool.java | 65 ++++++ .../java/cn/qaiu/lz/common/util/LzTool.java | 0 .../java/cn/qaiu/lz/common/util/UcTool.java | 87 +++++++ .../main/java/cn/qaiu/lz/package-info.java | 0 .../java/cn/qaiu/lz/web/http/ServerApi.java | 158 +++++++++++++ .../java/cn/qaiu/lz/web/model/CowUser.java | 0 .../java/cn/qaiu/lz/web/model/LzUser.java | 0 .../java/cn/qaiu/lz/web/model/SysUser.java | 0 .../cn/qaiu/lz/web/service/DbService.java | 0 .../qaiu/lz/web/service/JdkProxyFactory.java | 0 .../qaiu/lz/web/service/ServiceJdkProxy.java | 0 .../cn/qaiu/lz/web/service/UserService.java | 0 .../lz/web/service/impl/DbServiceImpl.java | 0 .../lz/web/service/impl/UserServiceImpl.java | 0 .../src/main/resources/app-dev.yml | 3 + .../src/main/resources/app.yml | 0 .../src/main/resources/conf/dictionaries.json | 0 .../src/main/resources/http-tools}/curl.sh | 0 .../src/main/resources/http-tools/ecpan.http | 88 +++++++ .../src/main/resources/http-tools/test.http | 218 ++---------------- .../src/main/resources/http-tools/ucpan.http | 29 +++ .../src/main/resources/logback.xml | 0 .../src/main/resources/server-proxy.yml | 0 .../test/java/cn/qaiu/web/test/Test01.java | 0 .../test/java/cn/qaiu/web/test/Test02.java | 0 .../test/java/cn/qaiu/web/test/TestJsoup.java | 0 .../test/java/cn/qaiu/web/test/TestOS.java | 3 + .../java/cn/qaiu/web/test/TestWebClient2.java | 0 .../cn/qaiu/web/test/WebClientExample.java | 0 .../cn/qaiu/web/test/WebProxyExamples.java | 0 51 files changed, 526 insertions(+), 349 deletions(-) delete mode 100644 lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/EcTool.java delete mode 100644 lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java rename {lz-cow-api-web => web-service}/assembly.xml (100%) rename {lz-cow-api-web => web-service}/pom.xml (97%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/AppMain.java (66%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/common/ToJson.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/common/model/MyData.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/common/model/UserInfo.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/common/util/CowTool.java (100%) create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/EcTool.java rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/common/util/LzTool.java (100%) create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/package-info.java (100%) create mode 100644 web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/model/CowUser.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/model/LzUser.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/model/SysUser.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/service/DbService.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/service/UserService.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java (100%) rename {lz-cow-api-web => web-service}/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java (100%) rename {lz-cow-api-web => web-service}/src/main/resources/app-dev.yml (93%) rename {lz-cow-api-web => web-service}/src/main/resources/app.yml (100%) rename {lz-cow-api-web => web-service}/src/main/resources/conf/dictionaries.json (100%) rename {lz-cow-api-web/src/main/resources/curl => web-service/src/main/resources/http-tools}/curl.sh (100%) create mode 100644 web-service/src/main/resources/http-tools/ecpan.http rename lz-cow-api-web/src/main/resources/1.http => web-service/src/main/resources/http-tools/test.http (53%) create mode 100644 web-service/src/main/resources/http-tools/ucpan.http rename {lz-cow-api-web => web-service}/src/main/resources/logback.xml (100%) rename {lz-cow-api-web => web-service}/src/main/resources/server-proxy.yml (100%) rename {lz-cow-api-web => web-service}/src/test/java/cn/qaiu/web/test/Test01.java (100%) rename {lz-cow-api-web => web-service}/src/test/java/cn/qaiu/web/test/Test02.java (100%) rename {lz-cow-api-web => web-service}/src/test/java/cn/qaiu/web/test/TestJsoup.java (100%) rename {lz-cow-api-web => web-service}/src/test/java/cn/qaiu/web/test/TestOS.java (97%) rename {lz-cow-api-web => web-service}/src/test/java/cn/qaiu/web/test/TestWebClient2.java (100%) rename {lz-cow-api-web => web-service}/src/test/java/cn/qaiu/web/test/WebClientExample.java (100%) rename {lz-cow-api-web => web-service}/src/test/java/cn/qaiu/web/test/WebProxyExamples.java (100%) diff --git a/.gitignore b/.gitignore index 10be014..82d6349 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,4 @@ sdkTest.log gradlew gradlew.bat unused.txt -/lz-cow-api-web/src/main/generated/ +/web-service/src/main/generated/ diff --git a/README.md b/README.md index 872bce3..a7c58ff 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,39 @@ -# lz-cow-api -蓝奏云-奶牛快传的直链解析的API服务 -使用Jdk17+Vert.x4.4.1+Jsoup +# netdisk-fast-download +# 网盘快速下载器--直链解析 + +## 网盘支持情况: +` 网盘名称(网盘标识): ` +- 蓝奏云 (lz) + - [ ] 登录, 上传, 下载, 分享 + - [x] 直链解析 +- 奶牛快传 (cow) + - [ ] 登录, 上传, 下载, 分享 + - [x] 直链解析 +- 移动云空间 (ec) + - [ ] 登录, 上传, 下载, 分享 + - [x] 直链解析 +- UC网盘 (uc) + - [ ] 登录, 上传, 下载, 分享 + - [x] 直链解析 +- 夸克网盘 (qk) +- TODO + +技术栈: +Jdk17+Vert.x4.4.1+Jsoup Core模块集成Vert.x实现类spring的注解式路由API +API接口 +```shell +(括号内表示可选内容) +1. 解析并自动302跳转 : + http(s)://you_host/parser?url=分享链接 + http(s)://you_host/网盘标识/分享id(#分享密码) +2. 获取解析后的直链--JSON格式 + http(s)://you_host/网盘标识/分享id(#分享密码) + +``` + + 示例: ``` // 解析并重定向到直链 @@ -13,7 +44,7 @@ GET http://127.0.0.1:6400/parser?url=https://lanzoux.com/ia2cntg # @no-redirect GET http://127.0.0.1:6400/parser?url=https://cowtransfer.com/s/9a644fe3e3a748 -// Rest请求(只提供共享文件Id): cow 奶牛快传; lz 蓝奏云 +// Rest请求(只提供共享文件Id): ### # @no-redirect GET http://127.0.0.1:6400/cow/9a644fe3e3a748 @@ -32,11 +63,11 @@ TODO: # 网盘对比 -| 网盘名称 | 可直接下载分享 | 加密分享 | 初始网盘空间 | 单文件大小限制 | 登录接口 | -|------|-------------|------|----------|----------------|------| -| 蓝奏云 | √ | √ | 不限空间 | 100M | √ | -| 奶牛快传 | √ | X | 10G | 不限大小 | √ | -| 夸克网盘 | X(>10M需要登录) | √ | 10G(20G) | 不限大小(>10M需要登录) | X | -| 天翼云盘 | | | | | | -| 阿里云盘 | | | | | | +| 网盘名称 | 可直接下载分享 | 加密分享 | 初始网盘空间 | 单文件大小限制 | 登录接口 | +|-------|-------------|----------|----------|----------------|------| +| 蓝奏云 | √ | √ | 不限空间 | 100M | TODO | +| 奶牛快传 | √ | X | 10G | 不限大小 | TODO | +| 移动云空间 | √ | √(密码可忽略) | 5G(个人) | 不限大小 | TODO | +| UC网盘 | √ | √ | 10G | 不限大小 | TODO | +| 夸克网盘 | √(>10M需要登录) | √ | 10G(20G) | 不限大小(>10M需要登录) | X | diff --git a/bin/lz-api.service b/bin/lz-api.service index 7d7188e..91ad871 100644 --- a/bin/lz-api.service +++ b/bin/lz-api.service @@ -7,7 +7,7 @@ Wants=network-online.target [Service] Type=simple # User=USER -ExecStart=/usr/bin/java -server -Xmx128m -jar /root/java/lz-cow-api-web/lz-cow-api-web-0.0.1.jar +ExecStart=/usr/bin/java -server -Xmx128m -jar /root/java/netdisk-fast-download/netdisk-fast-download-0.0.1.jar ExecStop=/bin/kill -s QUIT $MAINPID Restart=always StandOutput=syslog diff --git a/bin/run.bat b/bin/run.bat index 21d188e..29680f2 100644 --- a/bin/run.bat +++ b/bin/run.bat @@ -1,5 +1,5 @@ @echo off && @chcp 65001 > nul pushd %~dp0 set LIB_DIR=%~dp0 -for /f "delims=X" %%i in ('dir /b %LIB_DIR%\lz-cow-api-web-*.jar') do set LAUNCH_JAR=%LIB_DIR%\%%i +for /f "delims=X" %%i in ('dir /b %LIB_DIR%\netdisk-fast-download-*.jar') do set LAUNCH_JAR=%LIB_DIR%\%%i "%JAVA_HOME%\bin\java.exe" -Xmx512M -Dfile.encoding=utf8 -jar %LAUNCH_JAR% %* diff --git a/bin/run.sh b/bin/run.sh index 45f81b8..ec7bf36 100644 --- a/bin/run.sh +++ b/bin/run.sh @@ -1,5 +1,5 @@ #!/bin/sh # set -x -LAUNCH_JAR="lz-cow-api-web-*.jar" +LAUNCH_JAR="netdisk-fast-download-*.jar" nohup java -Xmx512M -jar "$LAUNCH_JAR" "$@" >startup.log 2>&1 & tail -f startup.log diff --git a/core-database/pom.xml b/core-database/pom.xml index c2b4c47..0d45ec8 100644 --- a/core-database/pom.xml +++ b/core-database/pom.xml @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - lz-cow-api + netdisk-fast-download cn.qaiu - 0.0.1 + 0.1.3 4.0.0 diff --git a/core/pom.xml b/core/pom.xml index 1809066..bfe2b7d 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - lz-cow-api + netdisk-fast-download cn.qaiu - 0.0.1 + 0.1.3 4.0.0 1.0.8 diff --git a/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java b/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java index eb30e42..4729432 100644 --- a/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java +++ b/core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java @@ -83,7 +83,7 @@ public class RouterHandlerFactory implements BaseHttpApi { ctx.next(); }); // 添加跨域的方法 - router.route().handler(CorsHandler.create("*").allowCredentials(true).allowedMethods(httpMethods)); + router.route().handler(CorsHandler.create().addRelativeOrigin(".*").allowCredentials(true).allowedMethods(httpMethods)); // 配置文件上传路径 router.route().handler(BodyHandler.create().setUploadsDirectory("uploads")); @@ -104,6 +104,7 @@ public class RouterHandlerFactory implements BaseHttpApi { registerNewHandler(router, handler); } catch (Throwable e) { LOGGER.error("Error register {}, Error details:", handler, e.getCause()); + } } } catch (Exception e) { @@ -181,7 +182,10 @@ public class RouterHandlerFactory implements BaseHttpApi { e.printStackTrace(); } }); - router.mountSubRouter(url, route); + if (url.endsWith("*")) { + throw new IllegalArgumentException("Don't include * when mounting a sub router"); + } + router.route(url + "*").subRouter(route); } } } @@ -312,8 +316,8 @@ public class RouterHandlerFactory implements BaseHttpApi { } }); // 解析body-json参数 - if ("application/json".equals(ctx.parsedHeaders().contentType().value()) && ctx.getBodyAsJson() != null) { - JsonObject body = ctx.getBodyAsJson(); + if ("application/json".equals(ctx.parsedHeaders().contentType().value()) && ctx.body().asJsonObject() != null) { + JsonObject body = ctx.body().asJsonObject(); if (body != null) { methodParametersTemp.forEach((k, v) -> { // 只解析已配置包名前缀的实体类 @@ -345,7 +349,7 @@ public class RouterHandlerFactory implements BaseHttpApi { ((Future) data).onSuccess(res -> { if (res instanceof JsonObject) { fireJsonResponse(ctx, res); - } else { + } else if (res != null){ fireJsonResponse(ctx, JsonResult.data(res)); } }).onFailure(e -> fireJsonResponse(ctx, JsonResult.error(e.getMessage()))); diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/EcTool.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/EcTool.java deleted file mode 100644 index 0e61efb..0000000 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/EcTool.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.qaiu.lz.common.util; - -import io.vertx.core.Vertx; -import io.vertx.ext.web.client.WebClient; - -/** - * 移动云空间解析 - */ -public class EcTool { - public static String FULL_URL_PREFIX = "https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https:%2F%2Fwww.ecpan.cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&parentId=-1&data="; - - - public static String parse(String dataKey) throws Exception { - Vertx vertx = Vertx.vertx(); - WebClient client = WebClient.create(vertx); - try { - - client.getAbs(FULL_URL_PREFIX+dataKey).send().onSuccess( - res -> { - System.out.println(res.bodyAsString()); - } - ).onFailure(t -> { - throw new RuntimeException("解析失败"); - }); - - } catch (RuntimeException e) { - throw new Exception(e); - } - return ""; - } - - public static void main(String[] args) throws Exception { - parse("81027a5c99af5b11ca004966c945cce6W9Bf2"); - System.out.println("222222"); - } -} diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java deleted file mode 100644 index d32c788..0000000 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.qaiu.lz.web.http; - -import cn.qaiu.lz.common.util.CowTool; -import cn.qaiu.lz.common.util.LzTool; -import cn.qaiu.lz.web.model.SysUser; -import cn.qaiu.lz.web.service.UserService; -import cn.qaiu.vx.core.annotaions.RouteHandler; -import cn.qaiu.vx.core.annotaions.RouteMapping; -import cn.qaiu.vx.core.enums.RouteMethod; -import cn.qaiu.vx.core.model.JsonResult; -import cn.qaiu.vx.core.util.AsyncServiceUtil; -import io.vertx.core.Future; -import io.vertx.core.http.HttpServerResponse; -import lombok.extern.slf4j.Slf4j; - -/** - * 服务API - *
Create date 2021/4/28 9:15 - * - * @author QAIU - */ -@Slf4j -@RouteHandler("/") -public class ServerApi { - - private final UserService userService = AsyncServiceUtil.getAsyncServiceInstance(UserService.class); - - @RouteMapping(value = "/login", method = RouteMethod.POST) - public Future login(SysUser user) { - log.info("<------- login: {}", user.getUsername()); - return userService.login(user); - } - - @RouteMapping(value = "/test2", method = RouteMethod.GET) - public JsonResult test01() { - return JsonResult.data("ok"); - } - - @RouteMapping(value = "/parser", method = RouteMethod.GET) - public void parse(HttpServerResponse response, String url) throws Exception { - if (url.contains("lanzou")) { - var urlDownload = LzTool.parse(url); - log.info("url = {}", urlDownload); - response.putHeader("location", urlDownload).setStatusCode(302).end(); - } else if (url.contains("cowtransfer.com")) { - var urlDownload = CowTool.parse(url); - response.putHeader("location", urlDownload).setStatusCode(302).end(); - } - - } - - @RouteMapping(value = "/lz/:id", method = RouteMethod.GET) - public void lzParse(HttpServerResponse response, String id) throws Exception { - var url = "https://wwsd.lanzoue.com/" + id; - var urlDownload = LzTool.parse(url); - log.info("url = {}", urlDownload); - response.putHeader("location", urlDownload).setStatusCode(302).end(); - } - - @RouteMapping(value = "/cow/:id", method = RouteMethod.GET) - public void cowParse(HttpServerResponse response, String id) throws Exception { - var url = "https://cowtransfer.com/s/" + id; - var urlDownload = CowTool.parse(url); - response.putHeader("location", urlDownload).setStatusCode(302).end(); - } - - @RouteMapping(value = "/json/lz/:id", method = RouteMethod.GET) - public JsonResult lzParseJson(HttpServerResponse response, String id) throws Exception { - var url = "https://wwsd.lanzoue.com/" + id; - var urlDownload = LzTool.parse(url); - log.info("url = {}", urlDownload); - return JsonResult.data(urlDownload); - } - - @RouteMapping(value = "/json/cow/:id", method = RouteMethod.GET) - public JsonResult cowParseJson(HttpServerResponse response, String id) throws Exception { - var url = "https://cowtransfer.com/s/" + id; - return JsonResult.data(CowTool.parse(url)); - } -} diff --git a/pom.xml b/pom.xml index 15c4ba2..27b9dd8 100644 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ 4.0.0 cn.qaiu - lz-cow-api + netdisk-fast-download pom - 0.0.1 + 0.1.3 core - lz-cow-api-web + web-service core-database @@ -19,8 +19,7 @@ 17 17 UTF-8 - 4.1.3 - ${project.basedir}/lz-cow-api-web/target/package + ${project.basedir}/netdisk-fast-download/target/package diff --git a/lz-cow-api-web/assembly.xml b/web-service/assembly.xml similarity index 100% rename from lz-cow-api-web/assembly.xml rename to web-service/assembly.xml diff --git a/lz-cow-api-web/pom.xml b/web-service/pom.xml similarity index 97% rename from lz-cow-api-web/pom.xml rename to web-service/pom.xml index 0e454ce..9c1cd5e 100644 --- a/lz-cow-api-web/pom.xml +++ b/web-service/pom.xml @@ -3,13 +3,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - lz-cow-api + netdisk-fast-download cn.qaiu - 0.0.1 + 0.1.3 4.0.0 - 0.0.1 - lz-cow-api-web + 0.1.3 + web-service ${project.basedir}/target/package @@ -62,7 +62,7 @@ cn.qaiu core-database - 0.0.1 + 0.1.3 compile @@ -70,6 +70,7 @@ + compile ${project.basedir}/target/ ${project.build.directory}/classes ${project.artifactId}-${project.version} diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java b/web-service/src/main/java/cn/qaiu/lz/AppMain.java similarity index 66% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java rename to web-service/src/main/java/cn/qaiu/lz/AppMain.java index 3f24a12..5a9ae1c 100644 --- a/lz-cow-api-web/src/main/java/cn/qaiu/lz/AppMain.java +++ b/web-service/src/main/java/cn/qaiu/lz/AppMain.java @@ -2,6 +2,7 @@ package cn.qaiu.lz; import cn.qaiu.db.pool.JDBCPoolInit; import cn.qaiu.vx.core.Deploy; +import cn.qaiu.vx.core.util.ConfigConstant; import io.vertx.core.json.JsonObject; @@ -23,7 +24,9 @@ public class AppMain { * @param jsonObject 配置 */ private static void exec(JsonObject jsonObject) { - JDBCPoolInit.builder().config(jsonObject.getJsonObject("dataSource")).build().initPool(); + if (jsonObject.getJsonObject(ConfigConstant.SERVER).getBoolean("enableDatabase")) { + JDBCPoolInit.builder().config(jsonObject.getJsonObject("dataSource")).build().initPool(); + } } diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/ToJson.java b/web-service/src/main/java/cn/qaiu/lz/common/ToJson.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/common/ToJson.java rename to web-service/src/main/java/cn/qaiu/lz/common/ToJson.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java b/web-service/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java rename to web-service/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/MyData.java b/web-service/src/main/java/cn/qaiu/lz/common/model/MyData.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/MyData.java rename to web-service/src/main/java/cn/qaiu/lz/common/model/MyData.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java b/web-service/src/main/java/cn/qaiu/lz/common/model/UserInfo.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/common/model/UserInfo.java rename to web-service/src/main/java/cn/qaiu/lz/common/model/UserInfo.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java b/web-service/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java rename to web-service/src/main/java/cn/qaiu/lz/common/util/ArrayUtil.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java b/web-service/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java rename to web-service/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/CowTool.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/CowTool.java rename to web-service/src/main/java/cn/qaiu/lz/common/util/CowTool.java diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/EcTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/EcTool.java new file mode 100644 index 0000000..8697146 --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/EcTool.java @@ -0,0 +1,65 @@ +package cn.qaiu.lz.common.util; + +import cn.qaiu.vx.core.util.VertxHolder; +import io.vertx.core.Future; +import io.vertx.core.Promise; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.client.WebClient; +import io.vertx.uritemplate.UriTemplate; +import lombok.extern.slf4j.Slf4j; + +/** + * 移动云空间解析 + */ +@Slf4j +public class EcTool { + private static final String FULL_URL_PREFIX = "https://www.ecpan.cn/drive/fileextoverrid" + + ".do?chainUrlTemplate=https:%2F%2Fwww.ecpan" + + ".cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&parentId=-1&data={dataKey}"; + + private static final String DOWNLOAD_REQUEST_URL = "https://www.ecpan.cn/drive/sharedownload.do"; + + public static final String EC_HOST = "www.ecpan.cn"; + + public static Future parse(String dataKey) { + Promise promise = Promise.promise(); + WebClient client = WebClient.create(VertxHolder.getVertxInstance()); + // 第一次请求 获取文件信息 + client.getAbs(UriTemplate.of(FULL_URL_PREFIX)).setTemplateParam("dataKey", dataKey).send().onSuccess(res -> { + JsonObject jsonObject = res.bodyAsJsonObject(); + log.debug("ecPan get file info -> {}", jsonObject); + JsonObject fileInfo = jsonObject + .getJsonObject("var") + .getJsonObject("chainFileInfo"); + if (!fileInfo.containsKey("errMesg")) { + JsonObject cloudpFile = fileInfo.getJsonObject("cloudpFile"); + JsonArray fileIdList = JsonArray.of(cloudpFile); + // 构造请求JSON {"extCodeFlag":0,"isIp":0} + JsonObject requestBodyJson = JsonObject.of("extCodeFlag", 0, "isIp", 0); + requestBodyJson.put("shareId", Integer.parseInt(fileInfo.getString("shareId"))); // 注意shareId + // 数据类型 + requestBodyJson.put("groupId", cloudpFile.getString("groupId")); + requestBodyJson.put("fileIdList", fileInfo.getJsonArray("cloudpFileList")); + + // 第二次请求 获取下载链接 + client.postAbs(DOWNLOAD_REQUEST_URL) + .sendJsonObject(requestBodyJson).onSuccess(res2 -> { + JsonObject jsonRes = res2.bodyAsJsonObject(); + log.debug("ecPan get download url -> {}", res2.body().toString()); + promise.complete(jsonRes.getJsonObject("var").getString("downloadUrl")); + }).onFailure(t -> { + promise.fail(new RuntimeException("解析异常: key = " + dataKey, t.fillInStackTrace())); + }); + + } else { + promise.fail(new RuntimeException(DOWNLOAD_REQUEST_URL + " 解析失败: " + + fileInfo.getString("errMesg")) + " key = " + dataKey); + } + } + ).onFailure(t -> { + promise.fail(new RuntimeException("解析异常: key = " + dataKey, t.fillInStackTrace())); + }); + return promise.future(); + } +} diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/common/util/LzTool.java rename to web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java new file mode 100644 index 0000000..4a7f688 --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java @@ -0,0 +1,87 @@ +package cn.qaiu.lz.common.util; + +import cn.qaiu.vx.core.util.VertxHolder; +import io.vertx.core.Future; +import io.vertx.core.Promise; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.client.WebClient; +import io.vertx.uritemplate.UriTemplate; +import lombok.extern.slf4j.Slf4j; + +/** + * 移动云空间解析 + */ +@Slf4j +public class UcTool { + private static final String API_URL_PREFIX = "https://pc-api.uc.cn/1/clouddrive/"; + + public static final String FULL_URL_PREFIX = "https://fast.uc.cn/s/"; + + private static final String FIRST_REQUEST_URL = API_URL_PREFIX + "share/sharepage/token?entry=ft&fr=pc&pr" + + "=UCBrowser"; + + private static final String SECOND_REQUEST_URL = API_URL_PREFIX + "transfer_share/detail?pwd_id={pwd_id}&passcode" + + "={passcode}&stoken={stoken}"; + + private static final String THIRD_REQUEST_URL = API_URL_PREFIX + "file/download?entry=ft&fr=pc&pr=UCBrowser"; + + public static Future parse(String data, String code) { + if (!data.startsWith(FULL_URL_PREFIX)) { + data = FULL_URL_PREFIX + data; + } + var passcode = (code == null) ? "" : code; + var dataKey = data.substring(FULL_URL_PREFIX.length()); + Promise promise = Promise.promise(); + var client = WebClient.create(VertxHolder.getVertxInstance()); + var jsonObject = JsonObject.of("share_for_transfer", true); + jsonObject.put("pwd_id", dataKey); + jsonObject.put("passcode", passcode); + // 第一次请求 获取文件信息 + client.postAbs(FIRST_REQUEST_URL).sendJsonObject(jsonObject).onSuccess(res -> { + log.debug("第一阶段 {}", res.body()); + var resJson = res.bodyAsJsonObject(); + if (resJson.getInteger("code") != 0) { + promise.fail(FIRST_REQUEST_URL + " 返回异常: " + resJson); + return; + } + var stoken = resJson.getJsonObject("data").getString("stoken"); + // 第二次请求 + client.getAbs(UriTemplate.of(SECOND_REQUEST_URL)) + .setTemplateParam("pwd_id", dataKey) + .setTemplateParam("passcode", passcode) + .setTemplateParam("stoken", stoken) + .send().onSuccess(res2 -> { + log.debug("第二阶段 {}", res2.body()); + JsonObject resJson2 = res2.bodyAsJsonObject(); + if (resJson2.getInteger("code") != 0) { + promise.fail(FIRST_REQUEST_URL + " 返回异常: " + resJson2); + return; + } + // 文件信息 + var info = resJson2.getJsonObject("data").getJsonArray("list").getJsonObject(0); + // 第二次请求 + var bodyJson = JsonObject.of() + .put("fids", JsonArray.of(info.getString("fid"))) + .put("pwd_id", dataKey) + .put("stoken", stoken) + .put("fids_token", JsonArray.of(info.getString("share_fid_token"))); + client.postAbs(THIRD_REQUEST_URL).sendJsonObject(bodyJson) + .onSuccess(res3 -> { + log.debug("第三阶段 {}", res3.body()); + var resJson3 = res3.bodyAsJsonObject(); + if (resJson3.getInteger("code") != 0) { + promise.fail(FIRST_REQUEST_URL + " 返回异常: " + resJson2); + return; + } + promise.complete(resJson3.getJsonArray("data").getJsonObject(0).getString("download_url")); + }) + .onFailure(t -> promise + .fail(new RuntimeException("解析异常: ", t.fillInStackTrace()))); + + }).onFailure(t -> promise.fail(new RuntimeException("解析异常: ", t.fillInStackTrace()))); + } + ).onFailure(t -> promise.fail(new RuntimeException("解析异常: key = " + dataKey, t.fillInStackTrace()))); + return promise.future(); + } +} diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/package-info.java b/web-service/src/main/java/cn/qaiu/lz/package-info.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/package-info.java rename to web-service/src/main/java/cn/qaiu/lz/package-info.java diff --git a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java new file mode 100644 index 0000000..9bd0b6b --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -0,0 +1,158 @@ +package cn.qaiu.lz.web.http; + +import cn.qaiu.lz.common.util.CowTool; +import cn.qaiu.lz.common.util.EcTool; +import cn.qaiu.lz.common.util.LzTool; +import cn.qaiu.lz.common.util.UcTool; +import cn.qaiu.lz.web.model.SysUser; +import cn.qaiu.lz.web.service.UserService; +import cn.qaiu.vx.core.annotaions.RouteHandler; +import cn.qaiu.vx.core.annotaions.RouteMapping; +import cn.qaiu.vx.core.enums.RouteMethod; +import cn.qaiu.vx.core.model.JsonResult; +import cn.qaiu.vx.core.util.AsyncServiceUtil; +import io.vertx.core.Future; +import io.vertx.core.Promise; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import lombok.extern.slf4j.Slf4j; + +import static io.vertx.core.http.HttpHeaders.CONTENT_TYPE; + +/** + * 服务API + *
Create date 2021/4/28 9:15 + * + * @author QAIU + */ +@Slf4j +@RouteHandler("/") +public class ServerApi { + + private final UserService userService = AsyncServiceUtil.getAsyncServiceInstance(UserService.class); + + @RouteMapping(value = "/login", method = RouteMethod.POST) + public Future login(SysUser user) { + log.info("<------- login: {}", user.getUsername()); + return userService.login(user); + } + + @RouteMapping(value = "/test2", method = RouteMethod.GET) + public JsonResult test01() { + return JsonResult.data("ok"); + } + + @RouteMapping(value = "/parser", method = RouteMethod.GET) + public Future parse(HttpServerResponse response, HttpServerRequest request, String url, String pwd) { + Promise promise = Promise.promise(); + if (url.contains("lanzou")) { + String urlDownload = null; + try { + urlDownload = LzTool.parse(url); + log.info("url = {}", urlDownload); + response.putHeader("location", urlDownload).setStatusCode(302).end(); + promise.complete(); + } catch (Exception e) { + promise.fail(e); + } + } else if (url.contains("cowtransfer.com")) { + String urlDownload = null; + try { + urlDownload = CowTool.parse(url); + response.putHeader("location", urlDownload).setStatusCode(302).end(); + promise.complete(); + } catch (Exception e) { + promise.fail(e); + } + + } else if (url.contains(EcTool.EC_HOST)) { + // 默认读取Url参数会被截断手动获取一下其他参数 + String data = request.getParam("data"); + EcTool.parse(data).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> { + promise.fail(t.fillInStackTrace()); + }); + } else if (url.contains(UcTool.FULL_URL_PREFIX)) { + UcTool.parse(url, pwd).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> { + promise.fail(t.fillInStackTrace()); + }); + } + return promise.future(); + } + + @RouteMapping(value = "/lz/:id", method = RouteMethod.GET) + public void lzParse(HttpServerResponse response, String id) throws Exception { + var url = "https://wwsd.lanzoue.com/" + id; + var urlDownload = LzTool.parse(url); + log.info("url = {}", urlDownload); + response.putHeader("location", urlDownload).setStatusCode(302).end(); + } + + @RouteMapping(value = "/cow/:id", method = RouteMethod.GET) + public void cowParse(HttpServerResponse response, String id) throws Exception { + var url = "https://cowtransfer.com/s/" + id; + var urlDownload = CowTool.parse(url); + response.putHeader("location", urlDownload).setStatusCode(302).end(); + } + + @RouteMapping(value = "/json/lz/:id", method = RouteMethod.GET) + public JsonResult lzParseJson(HttpServerResponse response, String id) throws Exception { + var url = "https://wwsd.lanzoue.com/" + id; + var urlDownload = LzTool.parse(url); + log.info("url = {}", urlDownload); + return JsonResult.data(urlDownload); + } + + @RouteMapping(value = "/json/cow/:id", method = RouteMethod.GET) + public JsonResult cowParseJson(HttpServerResponse response, String id) throws Exception { + var url = "https://cowtransfer.com/s/" + id; + return JsonResult.data(CowTool.parse(url)); + } + + @RouteMapping(value = "/ec/:id", method = RouteMethod.GET) + public void ecParse(HttpServerResponse response, String id) { + EcTool.parse(id).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + }).onFailure(t -> { + response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); + response.end(t.getMessage()); + }); + } + + @RouteMapping(value = "/json/ec/:id", method = RouteMethod.GET) + public Future ecParseJson(HttpServerResponse response, String id) { + return EcTool.parse(id); + } + + @RouteMapping(value = "/uc/:id", method = RouteMethod.GET) + public void ucParse(HttpServerResponse response, String id) { + String code = ""; + if (id.contains("#")) { + String[] ids = id.split("#"); + id = ids[0]; + code = ids[1]; + } + UcTool.parse(id, code).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + }).onFailure(t -> { + response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); + response.end(t.getMessage()); + }); + } + + @RouteMapping(value = "/json/uc/:id", method = RouteMethod.GET) + public Future ucParseJson(String id) { + String code = ""; + if (id.contains("#")) { + String[] ids = id.split("#"); + id = ids[0]; + code = ids[1]; + } + return UcTool.parse(id, code); + } +} diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/CowUser.java b/web-service/src/main/java/cn/qaiu/lz/web/model/CowUser.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/CowUser.java rename to web-service/src/main/java/cn/qaiu/lz/web/model/CowUser.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/LzUser.java b/web-service/src/main/java/cn/qaiu/lz/web/model/LzUser.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/LzUser.java rename to web-service/src/main/java/cn/qaiu/lz/web/model/LzUser.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/SysUser.java b/web-service/src/main/java/cn/qaiu/lz/web/model/SysUser.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/model/SysUser.java rename to web-service/src/main/java/cn/qaiu/lz/web/model/SysUser.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/DbService.java b/web-service/src/main/java/cn/qaiu/lz/web/service/DbService.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/DbService.java rename to web-service/src/main/java/cn/qaiu/lz/web/service/DbService.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java b/web-service/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java rename to web-service/src/main/java/cn/qaiu/lz/web/service/JdkProxyFactory.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java b/web-service/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java rename to web-service/src/main/java/cn/qaiu/lz/web/service/ServiceJdkProxy.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/UserService.java b/web-service/src/main/java/cn/qaiu/lz/web/service/UserService.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/UserService.java rename to web-service/src/main/java/cn/qaiu/lz/web/service/UserService.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java b/web-service/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java rename to web-service/src/main/java/cn/qaiu/lz/web/service/impl/DbServiceImpl.java diff --git a/lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java b/web-service/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java similarity index 100% rename from lz-cow-api-web/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java rename to web-service/src/main/java/cn/qaiu/lz/web/service/impl/UserServiceImpl.java diff --git a/lz-cow-api-web/src/main/resources/app-dev.yml b/web-service/src/main/resources/app-dev.yml similarity index 93% rename from lz-cow-api-web/src/main/resources/app-dev.yml rename to web-service/src/main/resources/app-dev.yml index 81d2859..d036e8c 100644 --- a/lz-cow-api-web/src/main/resources/app-dev.yml +++ b/web-service/src/main/resources/app-dev.yml @@ -2,7 +2,10 @@ server: port: 6400 contextPath: / + # 使用静态页面 enableStaticHtmlService: false + # 使用数据库 + enableDatabase: false staticResourcePath: webroot/ # 反向代理服务器配置路径(不用加后缀) proxyConf: server-proxy diff --git a/lz-cow-api-web/src/main/resources/app.yml b/web-service/src/main/resources/app.yml similarity index 100% rename from lz-cow-api-web/src/main/resources/app.yml rename to web-service/src/main/resources/app.yml diff --git a/lz-cow-api-web/src/main/resources/conf/dictionaries.json b/web-service/src/main/resources/conf/dictionaries.json similarity index 100% rename from lz-cow-api-web/src/main/resources/conf/dictionaries.json rename to web-service/src/main/resources/conf/dictionaries.json diff --git a/lz-cow-api-web/src/main/resources/curl/curl.sh b/web-service/src/main/resources/http-tools/curl.sh similarity index 100% rename from lz-cow-api-web/src/main/resources/curl/curl.sh rename to web-service/src/main/resources/http-tools/curl.sh diff --git a/web-service/src/main/resources/http-tools/ecpan.http b/web-service/src/main/resources/http-tools/ecpan.http new file mode 100644 index 0000000..fb9b872 --- /dev/null +++ b/web-service/src/main/resources/http-tools/ecpan.http @@ -0,0 +1,88 @@ + +### https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare=1 +### ecpan(移动云空间) +https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https:%2F%2Fwww.ecpan.cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&parentId=-1 + + +### +POST https://www.ecpan.cn/drive/sharedownload.do +Content-Type: application/json + +{ + "extCodeFlag": 0, + "isIp": 0, + "shareId": 2404783, + "groupId": "c27b53c4f91b11ed86b3b026287b20b1", + "fileIdList": [{ + "tableName": "cloudp_file_52", + "appFileId": "2d06ad61f91c11ed86b3b026287b20b1", + "dfsFileId": "3080817de83747698ff5747e25f97e50", + "fileName": "fonts.zip", + "filePath": "个人盘", + "fileLevel": 0, + "fileCount": 0, + "fileType": 2, + "fileSort": 99, + "fileSize": 19115063, + "uploadSize": 19115063, + "parentId": "c27b53c4f91b11ed86b3b026287b20b1", + "usn": 11364252, + "userName": "157****1073", + "userId": "", + "corpId": 13260232, + "createDate": 1684813492000, + "modifyDate": 1684813492000, + "status": 1, + "version": 0, + "comeFrom": 21, + "isShare": 0, + "folderType": 0, + "groupDesc": null, + "groupId": "c27b53c4f91b11ed86b3b026287b20b1", + "groupName": null, + "permission": null, + "userInfo": null, + "diskType": 1, + "historyKey": null, + "oldAppFileId": null, + "fileRealPath": null, + "fileExt": null, + "oldFileName": null, + "key": null, + "isUpperCase": null, + "isSubDir": null, + "isViewFolder": null, + "uploadTimeType": null, + "startUploadTime": null, + "endUploadTime": null, + "sizeOperator": null, + "orderField": null, + "orderBy": null, + "oldFilePath": null, + "statusStr": null, + "rootUsn": 11364252, + "createdByUsn": null, + "attentionCount": 0, + "fileMd5": "86c1ff32437ca0ccaca24f7ea197e34a", + "fileLabel": null, + "fileDesc": null, + "fileExtends": "00", + "deviceId": null, + "fileNamePinyin": "fonts.zip", + "modifyUser": "157****1073", + "fileExFileds": { + "shareRoot": "", + "isLock": 0, + "isEncrypt": 0 + }, + "security": 0, + "createdDate": null, + "modifiedDate1": null, + "modifiedDate2": null, + "createdDate1": null, + "createdDate2": null, + "deleteUsn": null, + "toShares": null, + "firstLevel": null + }] +} diff --git a/lz-cow-api-web/src/main/resources/1.http b/web-service/src/main/resources/http-tools/test.http similarity index 53% rename from lz-cow-api-web/src/main/resources/1.http rename to web-service/src/main/resources/http-tools/test.http index 50aaebf..50ea3e0 100644 --- a/lz-cow-api-web/src/main/resources/1.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -130,207 +130,29 @@ https://drive-pc.quark.cn/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd https://drive-pc.quark.cn/1/clouddrive/auth/pc/flush?pr=ucpro&fr=pc cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; -# https://fast.uc.cn/s/33197dd53ace4 -### UCpan -https://fast.uc.cn/api/info?st=&fr=pc&pr=UCBrowser - -### UCpan 第一步 获取stoken POST json传入pwd_id(分享id),passcode(分享密码) -POST https://pc-api.uc.cn/1/clouddrive/share/sharepage/token?entry=ft&fr=pc&pr=UCBrowser -content-type: application/json - -{"pwd_id":"33197dd53ace4","passcode":"","share_for_transfer":true} - -### UCpan 第二步 获取fid,share_fid_token GET传参pwd_id,passcode,stoken -https://pc-api.uc.cn/1/clouddrive/transfer_share/detail?pwd_id=33197dd53ace4&passcode=&stoken=oPz47hsgQXQdDYimsP4kBMi8aLv40X378IZOiBsnfLU%3D -content-type: application/json - -### UCpan 第二步获取下载链接 POST json传入fids(fid),pwd_id,stoken,fids_token(share_fid_token) -POST https://pc-api.uc.cn/1/clouddrive/file/download?entry=ft&fr=pc&pr=UCBrowser -content-type: application/json - -{ - "fids": [ - "54c3cd90ed3e45119bb96ed99a562d40" - ], - "pwd_id": "33197dd53ace4", - "stoken": "oPz47hsgQXQdDYimsP4kBMi8aLv40X378IZOiBsnfLU=", - "fids_token": [ - "ff9f5b5c94df9d08c8dd3b7948fc5e20" - ] -} - -### https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare=1 -### ecpan(移动云空间) -https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https:%2F%2Fwww.ecpan.cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&parentId=-1 - - -### -POST https://www.ecpan.cn/drive/sharedownload.do -Accept: application/json -Content-Type: application/json - -{ - "extCodeFlag": 0, - "isIp": 0, - "shareId": 2404807, - "groupId": "c27b53c4f91b11ed86b3b026287b20b1", - "fileIdList": [{ - "tableName": "cloudp_file_52", - "appFileId": "2d06ad61f91c11ed86b3b026287b20b1", - "dfsFileId": "3080817de83747698ff5747e25f97e50", - "fileName": "fonts.zip", - "filePath": "个人盘", - "fileLevel": 0, - "fileCount": 0, - "fileType": 2, - "fileSort": 99, - "fileSize": 19115063, - "uploadSize": 19115063, - "parentId": "c27b53c4f91b11ed86b3b026287b20b1", - "usn": 11364252, - "userName": "157****1073", - "userId": "", - "corpId": 13260232, - "createDate": 1684813492000, - "modifyDate": 1684813492000, - "status": 1, - "version": 0, - "comeFrom": 21, - "isShare": 0, - "folderType": 0, - "groupDesc": null, - "groupId": "c27b53c4f91b11ed86b3b026287b20b1", - "groupName": null, - "permission": null, - "userInfo": null, - "diskType": 1, - "historyKey": null, - "oldAppFileId": null, - "fileRealPath": null, - "fileExt": null, - "oldFileName": null, - "key": null, - "isUpperCase": null, - "isSubDir": null, - "isViewFolder": null, - "uploadTimeType": null, - "startUploadTime": null, - "endUploadTime": null, - "sizeOperator": null, - "orderField": null, - "orderBy": null, - "oldFilePath": null, - "statusStr": null, - "rootUsn": 11364252, - "createdByUsn": null, - "attentionCount": 0, - "fileMd5": "86c1ff32437ca0ccaca24f7ea197e34a", - "fileLabel": null, - "fileDesc": null, - "fileExtends": "00", - "deviceId": null, - "fileNamePinyin": "fonts.zip", - "modifyUser": "157****1073", - "fileExFileds": { - "shareRoot": "", - "isLock": 0, - "isEncrypt": 0 - }, - "security": 0, - "createdDate": null, - "modifiedDate1": null, - "modifiedDate2": null, - "createdDate1": null, - "createdDate2": null, - "deleteUsn": null, - "toShares": null, - "firstLevel": null - }] -} ### https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https:%2F%2Fwww.ecpan.cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&data=aa0cae0164d8885e6d35826b5b2901eckbWJBalM&parentId=-1 ### -POST https://www.ecpan.cn/drive/sharedownload.do -Accept: application/json -Content-Type: application/json +# @no-redirect +GET http://127.0.0.1:6400/parser?url=https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare= +# https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=aa0cae0164d8885e6d35826b5b2901eckbWJBalM&parentId=-1 -{ - "extCodeFlag": 0, - "isIp": 0, - "shareId": 2404807, - "groupId": "c27b53c4f91b11ed86b3b026287b20b1", - "fileIdList": [{ - "tableName": "cloudp_file_52", - "appFileId": "fe4ea2d0f92011ed86b3b026287b20b1", - "dfsFileId": "a81bdef5a9614d30b7f856755c985cf8", - "fileName": "readline-7.0-rc1.tar.gz", - "filePath": "个人盘\\app", - "fileLevel": 1, - "fileCount": 0, - "fileType": 2, - "fileSort": 99, - "fileSize": 2897058, - "uploadSize": 2897058, - "parentId": "ed008146f92011ed86b3b026287b20b1", - "usn": 11364252, - "userName": "157****1073", - "userId": "", - "corpId": 13260232, - "createDate": 1684815561000, - "modifyDate": 1684815561000, - "status": 1, - "version": 0, - "comeFrom": 21, - "isShare": 0, - "folderType": 0, - "groupDesc": null, - "groupId": "c27b53c4f91b11ed86b3b026287b20b1", - "groupName": null, - "permission": null, - "userInfo": null, - "diskType": 1, - "historyKey": null, - "oldAppFileId": null, - "fileRealPath": null, - "fileExt": null, - "oldFileName": null, - "key": null, - "isUpperCase": null, - "isSubDir": null, - "isViewFolder": null, - "uploadTimeType": null, - "startUploadTime": null, - "endUploadTime": null, - "sizeOperator": null, - "orderField": null, - "orderBy": null, - "oldFilePath": null, - "statusStr": null, - "rootUsn": 11364252, - "createdByUsn": null, - "attentionCount": 0, - "fileMd5": "c5ed4d0fd48ec6c940d6da375e3f1b50", - "fileLabel": null, - "fileDesc": null, - "fileExtends": "00", - "deviceId": null, - "fileNamePinyin": "readline-7.0-rc1.tar.gz", - "modifyUser": "157****1073", - "fileExFileds": { - "shareRoot": "", - "isLock": 0, - "isEncrypt": 0 - }, - "security": 0, - "createdDate": null, - "modifiedDate1": null, - "modifiedDate2": null, - "createdDate1": null, - "createdDate2": null, - "deleteUsn": null, - "toShares": null, - "firstLevel": null - }] -} +### +# @no-redirect +GET http://127.0.0.1:6400/ec/aa0cae0164d8885e6d35826b5b2901eckbWJBalM1 + +### +GET http://127.0.0.1:6400/json/ec/aa0cae0164d8885e6d35826b5b2901eckbWJBalM + +### +# @no-redirect +GET http://127.0.0.1:6400/uc/33197dd53ace4 + +### +GET http://127.0.0.1:6400/json/uc/33197dd53ace4 + +### +# @no-redirect +GET http://127.0.0.1:6400/parser?url=https://fast.uc.cn/s/33197dd53ace4 diff --git a/web-service/src/main/resources/http-tools/ucpan.http b/web-service/src/main/resources/http-tools/ucpan.http new file mode 100644 index 0000000..b4c5ad8 --- /dev/null +++ b/web-service/src/main/resources/http-tools/ucpan.http @@ -0,0 +1,29 @@ + +# https://fast.uc.cn/s/33197dd53ace4 +### UCpan +https://fast.uc.cn/api/info?st=&fr=pc&pr=UCBrowser + +### UCpan 第一步 获取stoken POST json传入pwd_id(分享id),passcode(分享密码) +POST https://pc-api.uc.cn/1/clouddrive/share/sharepage/token?entry=ft&fr=pc&pr=UCBrowser +content-type: application/json + +{"pwd_id":"33197dd53ace4","passcode":"","share_for_transfer":true} + +### UCpan 第二步 获取fid,share_fid_token GET传参pwd_id,passcode,stoken +https://pc-api.uc.cn/1/clouddrive/transfer_share/detail?pwd_id=33197dd53ace4&passcode=&stoken=oPz47hsgQXQdDYimsP4kBMi8aLv40X378IZOiBsnfLU%3D +content-type: application/json + +### UCpan 第二步获取下载链接 POST json传入fids(fid),pwd_id,stoken,fids_token(share_fid_token) +POST https://pc-api.uc.cn/1/clouddrive/file/download?entry=ft&fr=pc&pr=UCBrowser +content-type: application/json + +{ + "fids": [ + "54c3cd90ed3e45119bb96ed99a562d40" + ], + "pwd_id": "33197dd53ace4", + "stoken": "oPz47hsgQXQdDYimsP4kBMi8aLv40X378IZOiBsnfLU=", + "fids_token": [ + "ff9f5b5c94df9d08c8dd3b7948fc5e20" + ] +} diff --git a/lz-cow-api-web/src/main/resources/logback.xml b/web-service/src/main/resources/logback.xml similarity index 100% rename from lz-cow-api-web/src/main/resources/logback.xml rename to web-service/src/main/resources/logback.xml diff --git a/lz-cow-api-web/src/main/resources/server-proxy.yml b/web-service/src/main/resources/server-proxy.yml similarity index 100% rename from lz-cow-api-web/src/main/resources/server-proxy.yml rename to web-service/src/main/resources/server-proxy.yml diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/Test01.java b/web-service/src/test/java/cn/qaiu/web/test/Test01.java similarity index 100% rename from lz-cow-api-web/src/test/java/cn/qaiu/web/test/Test01.java rename to web-service/src/test/java/cn/qaiu/web/test/Test01.java diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/Test02.java b/web-service/src/test/java/cn/qaiu/web/test/Test02.java similarity index 100% rename from lz-cow-api-web/src/test/java/cn/qaiu/web/test/Test02.java rename to web-service/src/test/java/cn/qaiu/web/test/Test02.java diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestJsoup.java b/web-service/src/test/java/cn/qaiu/web/test/TestJsoup.java similarity index 100% rename from lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestJsoup.java rename to web-service/src/test/java/cn/qaiu/web/test/TestJsoup.java diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestOS.java b/web-service/src/test/java/cn/qaiu/web/test/TestOS.java similarity index 97% rename from lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestOS.java rename to web-service/src/test/java/cn/qaiu/web/test/TestOS.java index 324b663..d1dc92e 100644 --- a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestOS.java +++ b/web-service/src/test/java/cn/qaiu/web/test/TestOS.java @@ -4,6 +4,8 @@ import java.io.*; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.*; public class TestOS { @@ -157,5 +159,6 @@ public class TestOS { // all(); // new TestOS().showURL(); System.out.println(File.separator); + System.out.println(URLEncoder.encode("https://www.ecpan.cn/web/#/yunpanProxy", StandardCharsets.UTF_8)); } } diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestWebClient2.java b/web-service/src/test/java/cn/qaiu/web/test/TestWebClient2.java similarity index 100% rename from lz-cow-api-web/src/test/java/cn/qaiu/web/test/TestWebClient2.java rename to web-service/src/test/java/cn/qaiu/web/test/TestWebClient2.java diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebClientExample.java b/web-service/src/test/java/cn/qaiu/web/test/WebClientExample.java similarity index 100% rename from lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebClientExample.java rename to web-service/src/test/java/cn/qaiu/web/test/WebClientExample.java diff --git a/lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java b/web-service/src/test/java/cn/qaiu/web/test/WebProxyExamples.java similarity index 100% rename from lz-cow-api-web/src/test/java/cn/qaiu/web/test/WebProxyExamples.java rename to web-service/src/test/java/cn/qaiu/web/test/WebProxyExamples.java From d0d5c96b9e02566668dc747f1053cd31d15ae992 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Wed, 24 May 2023 16:24:51 +0800 Subject: [PATCH 26/48] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a7c58ff..0f65e23 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ API接口 http(s)://you_host/parser?url=分享链接 http(s)://you_host/网盘标识/分享id(#分享密码) 2. 获取解析后的直链--JSON格式 - http(s)://you_host/网盘标识/分享id(#分享密码) + http(s)://you_host/json/网盘标识/分享id(#分享密码) ``` From a257cd2f694779d915b19120c1294d042c365433 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Wed, 24 May 2023 16:57:24 +0800 Subject: [PATCH 27/48] Create maven.yml --- .github/workflows/maven.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..e5247f5 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,35 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 From 2c243650f6e1aeae4d112c730ba07c4c3a3807df Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Wed, 24 May 2023 17:01:26 +0800 Subject: [PATCH 28/48] Update maven.yml --- .github/workflows/maven.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e5247f5..248298e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,5 +31,5 @@ jobs: run: mvn -B package --file pom.xml # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 + # - name: Update dependency graph + # uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 From 2ca7a78920c7463dcc93820115bfd2fac0005296 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Wed, 24 May 2023 17:18:30 +0800 Subject: [PATCH 29/48] 1. change actions maven.yml --- .github/workflows/maven.yml | 8 ++++++-- web-service/pom.xml | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 248298e..4f2cbe0 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,5 +31,9 @@ jobs: run: mvn -B package --file pom.xml # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - # - name: Update dependency graph - # uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@multi-module + +# - uses: release-drafter/release-drafter@v5 +# env: +# GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} diff --git a/web-service/pom.xml b/web-service/pom.xml index 9c1cd5e..946a915 100644 --- a/web-service/pom.xml +++ b/web-service/pom.xml @@ -70,7 +70,6 @@ - compile ${project.basedir}/target/ ${project.build.directory}/classes ${project.artifactId}-${project.version} From eebce94e88574223e32e71871f75288c71e31437 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Wed, 24 May 2023 17:20:45 +0800 Subject: [PATCH 30/48] 1. change actions maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4f2cbe0..7b5d9cd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -32,7 +32,7 @@ jobs: # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@multi-module + uses: advanced-security/maven-dependency-submission-action@v3 # - uses: release-drafter/release-drafter@v5 # env: From 3e31e97c35605d713a17fefe34055fc9c5e5d0dc Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Wed, 24 May 2023 17:28:05 +0800 Subject: [PATCH 31/48] 1. change actions maven.yml --- .github/workflows/maven.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7b5d9cd..0eedd3e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -8,6 +8,10 @@ name: Java CI with Maven +# The API requires write permission on the repository to submit dependencies +permissions: + contents: write + on: push: branches: [ "main" ] From d98751b0e3d83ba8e0a7fe8ad1ba4f46920ad3d9 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Wed, 24 May 2023 17:31:00 +0800 Subject: [PATCH 32/48] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f65e23..6e68812 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # netdisk-fast-download # 网盘快速下载器--直链解析 - +[![Java CI with Maven](https://github.com/qaiu/netdisk-fast-download/actions/workflows/maven.yml/badge.svg)](https://github.com/qaiu/netdisk-fast-download/actions/workflows/maven.yml) ## 网盘支持情况: ` 网盘名称(网盘标识): ` - 蓝奏云 (lz) From 2155c3e0c0d9b58dcf0c0bbb2a4ef1f0457f0945 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Thu, 25 May 2023 15:15:56 +0800 Subject: [PATCH 33/48] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...z-api.service => netdisk-fast-download.service} | 2 +- bin/service-install.sh | 4 ++-- pom.xml | 2 +- web-service/pom.xml | 4 ++-- .../src/test/java/cn/qaiu/web/test/Test01.java | 14 +++++--------- 5 files changed, 11 insertions(+), 15 deletions(-) rename bin/{lz-api.service => netdisk-fast-download.service} (91%) diff --git a/bin/lz-api.service b/bin/netdisk-fast-download.service similarity index 91% rename from bin/lz-api.service rename to bin/netdisk-fast-download.service index 91ad871..da107c4 100644 --- a/bin/lz-api.service +++ b/bin/netdisk-fast-download.service @@ -1,5 +1,5 @@ [Unit] -Description=lz-api +Description=netdisk-fast-download Documentation=https://qaiu.top After=network-online.target Wants=network-online.target diff --git a/bin/service-install.sh b/bin/service-install.sh index cb21cf6..5a3027c 100644 --- a/bin/service-install.sh +++ b/bin/service-install.sh @@ -4,7 +4,7 @@ cp ./lz-api.service /etc/systemd/system/ systemctl daemon-reload # 运行服务 -systemctl start lz-api +systemctl start netdisk-fast-download # 在系统启动时启动服务 -systemctl enable lz-api +systemctl enable netdisk-fast-download diff --git a/pom.xml b/pom.xml index 27b9dd8..c130663 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 17 17 UTF-8 - ${project.basedir}/netdisk-fast-download/target/package + ${project.basedir}/web-service/target/package
diff --git a/web-service/pom.xml b/web-service/pom.xml index 946a915..0006f36 100644 --- a/web-service/pom.xml +++ b/web-service/pom.xml @@ -17,6 +17,7 @@ UTF-8 2.0.5 6.1.0 + netdisk-fast-download-${project.version} @@ -63,7 +64,6 @@ cn.qaiu core-database 0.1.3 - compile @@ -72,7 +72,7 @@ ${project.basedir}/target/ ${project.build.directory}/classes - ${project.artifactId}-${project.version} + ${finalName} org.apache.maven.plugins diff --git a/web-service/src/test/java/cn/qaiu/web/test/Test01.java b/web-service/src/test/java/cn/qaiu/web/test/Test01.java index a8b27dc..8e50cf1 100644 --- a/web-service/src/test/java/cn/qaiu/web/test/Test01.java +++ b/web-service/src/test/java/cn/qaiu/web/test/Test01.java @@ -1,7 +1,6 @@ package cn.qaiu.web.test; import io.vertx.ext.web.RoutingContext; -import lombok.extern.slf4j.Slf4j; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; @@ -17,10 +16,8 @@ import java.util.Map; /** *
Create date 2021/4/29 15:27 - * * @author QAIU */ -@Slf4j public class Test01 { public static class A { @@ -30,7 +27,6 @@ public class Test01 { String num3; Integer num5; - public Integer getNum5() { return num5; } @@ -73,7 +69,7 @@ public class Test01 { } - public static class B0 { + public static class B0{ int num; public int getNum() { @@ -86,7 +82,7 @@ public class Test01 { } - public static class B extends B0 { + public static class B extends B0{ String name; boolean flag; @@ -210,14 +206,14 @@ public class Test01 { //日期->字符串 try { return (T) DateFormatUtils.format((Date) value, "yyyy-MM-dd"); - } catch (Exception e) { - return (T) value; + }catch (Exception e){ + return (T)value; } } }, String.class); BeanUtils.populate(b1, map); - log.info("---------> {}", b1); + System.out.println(b1); } } From 34c6d265816070abe789e6a1a1d1ccfa9ed538d3 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Thu, 25 May 2023 17:44:55 +0800 Subject: [PATCH 34/48] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=93=9D=E5=A5=8F?= =?UTF-8?q?=E4=BA=91=E5=AF=86=E7=A0=81=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/http-tools/test.http | 16 +++++++ .../java/cn/qaiu/web/test/TestWebClient2.java | 47 +++++++++++++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/web-service/src/main/resources/http-tools/test.http b/web-service/src/main/resources/http-tools/test.http index 50ea3e0..a309a05 100644 --- a/web-service/src/main/resources/http-tools/test.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -1,10 +1,14 @@ ### +# @no-redirect GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://wwp.lanzoux.com/iNvid035jgcb ### # @no-redirect GET http://127.0.0.1:6400/parser?url=https://lanzoux.com/ia2cntg ### # @no-redirect +GET http://127.0.0.1:6400/parser?url=https://lanzoux.com/iNvid035jgcb +### +# @no-redirect GET http://127.0.0.1:6400/parser?url=https://cowtransfer.com/s/9a644fe3e3a748 ### # @no-redirect @@ -156,3 +160,15 @@ GET http://127.0.0.1:6400/json/uc/33197dd53ace4 ### # @no-redirect GET http://127.0.0.1:6400/parser?url=https://fast.uc.cn/s/33197dd53ace4 + +### +POST https://wwsd.lanzoue.com/ajaxm.php +Accept: application/json, text/javascript, */* +Content-Type: application/x-www-form-urlencoded + +action=downprocess&sign=AGYHOQk4BjdTWgQ7BzcGOlU_bATVSNQMxBDFQZgZoBj4HMFEgWnMOZ1I1A2NWOgUxB20HMlM_aUGoLOgQz&p=e4k4 + +### +https://developer.lanzoug.com/file/?VDJbZVxtADFSWwY+U2YHa1FuU2tTYgBnBnUGZFNmWylSOVMpCTJQZQQhBSdQKQFkBjMOfAMyA21VPVs8V28BLVRkWyJcMAB6UjcGfVNlB29RZVN4U3YAawZxBiZTaVszUj5TYQkLUG0ENgVuUDUBMQZkDjsDbgMxVWBbZFc8ASZUMlt/XDwAZVIyBmFTNwc3UTtTYFM8ACQGcQZwUzJbaFJiUzYJZ1ArBGIFZlArATIGaQ4kAz8DMlVnWz9XMwE1VGZbOFw3AG1SPQY0UzcHMVFqUzdTbwBmBjEGMVNsW2NSM1MzCWxQNwRkBWVQNwEwBmQOPwNyA3tVO1stVy0BdVQnW2lccwA9UmAGbVM2BzZRPlNvUzgAOwY5BiZTe1szUj9TYQkyUDkEYwVjUDQBMAZsDiUDcgMnVTRbMVd8AT1UZVs6XDkAYVI0BmBTNQc/UTlTZVMqAHcGcQZ3UzJba1JkUzwJYVA0BGIFYVA0ATAGaw4tAykDaFUiW2BXOgExVGZbIlwzAGdSNgZ%2BUzYHMlE9U3hTOwA6 +### +https://developer.lanzoug.com/file/?VTNVa1tqAjMFDAM7BDEAbAE+U2tfbgZhBnVbOQUwVCYEb1IoAToCNwQhVnRXLlcyVWAEdl9uVzkEbFYxVm5VeVVlVSxbNwJ4BWADeAQyAGgBNVN4X3oGbQZxW3sFP1Q8BGhSYAEDAj8ENlY9VzJXZ1U3BDFfMldlBDFWaVY9VXJVM1VxWzsCZwVlA2QEYAAwAWtTYF8wBiIGcVstBWRUZwQ0UjcBbwJ5BGJWNVcsV2RVOgQuX2NXZgQ2VjJWMlVhVWdVNlswAm8FagMxBGAANgE6UzdfYwZgBjFbbAU6VGwEZVIyAWQCZQRkVjZXMFdmVTcENV8uVy8EalYgVixVIVUmVWdbdAI/BTcDaARhADEBblNvXzQGPQY5W3sFLVQ8BGlSYAE6AmsEY1Y2VztXY1U/BDFfM1dnBDRWZFYkVXpVc1VkW2oCIQVuA2QEZgA5AW5TZl8wBjYGMFtkBWFUcwRxUnUBKwJrBGNWNlc7V2NVPwQxXzJXZQQzVmdWLFUhVTxVcls7AmcFYgNnBH4AMwFoU2RfLgY1BjVbawV3VGIEPA== diff --git a/web-service/src/test/java/cn/qaiu/web/test/TestWebClient2.java b/web-service/src/test/java/cn/qaiu/web/test/TestWebClient2.java index 7b7aca0..bfb48ed 100644 --- a/web-service/src/test/java/cn/qaiu/web/test/TestWebClient2.java +++ b/web-service/src/test/java/cn/qaiu/web/test/TestWebClient2.java @@ -1,16 +1,55 @@ package cn.qaiu.web.test; +import io.vertx.core.MultiMap; import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; import io.vertx.ext.web.client.WebClient; +import org.apache.commons.lang3.RegExUtils; +import org.junit.Test; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class TestWebClient2 { - public static void main(String[] args) { + @Test + public void matcherHtml() { + + Pattern compile = Pattern.compile("class=\"ifr2\" name=.+src=\"(/fn\\?[a-zA-Z0-9_+/=]{16,})\""); + var text = """ +
+"""; + System.out.println(text); + Matcher matcher = compile.matcher(text); + if (matcher.find()) { + System.out.println(matcher.group(0)); + System.out.println(matcher.group(1)); + } + } + + @Test + public void lzClient() { Vertx vertx = Vertx.vertx(); WebClient client = WebClient.create(vertx); - client.getAbs("https://qaiu.top").send().onSuccess(res -> { - System.out.println(res.bodyAsString()); - client.close(); + MultiMap form = MultiMap.caseInsensitiveMultiMap(); + + + // action=downprocess&sign=AGYHOQk4BjdTWgQ7BzcGOlU_bATVSNQMxBDFQZgZoBj4HMFEgWnMOZ1I1A2NWOgUxB20HMlM_aUGoLOgQz&p=e4k4 + form.set("action", "downprocess"); + form.set("sign", "VzFWaA4_aBzYIAQI9ADBUaARvATVRNlNhUGUBNwBuATkDNFEgXHVVPAZhB2dTP1ZiVD5UYQBpV2EBPwA3"); + form.set("p", "e4k4"); + client.postAbs("https://wwsd.lanzoue.com/ajaxm.php") + .putHeader("referer", "https://wwsd.lanzoue.com/iFhd00x8k0kh") + .sendForm(form).onSuccess(res -> { + JsonObject jsonObject = res.bodyAsJsonObject(); + System.out.println(jsonObject); + + vertx.close(); }); + + // + // https://developer.lanzoug.com/file/?VTMBPwEwU2IGD1dvV2ICblBvU2sENQZhVSZSMAA1WihSOVYsDTZTZlN2UXMFfAZjBzJXJQAxAG5XP1UyXGQGKlVlAXgBbVMpBmNXLFdhAmpQZFN4BCEGbVUiUnIAOloyUj5WZA0PU25TYVE6BWAGNgdlV2IAbQAyV2JValw3BiFVMwElAWFTNgZmVzBXMwIyUDpTYARrBiJVIlIkAGFaaVJiVjMNY1MoUzVRMgV+BjUHaFd9ADwAMVdlVTFcOAYyVWcBYgFqUz4GaVdlVzMCNFBrUzcEOAZgVWJSZQA/WmJSM1Y2DWhTNFMzUTEFYgY3B2VXZgBxAHhXOVUjXCYGclUmATMBLlNuBjRXPFcyAjNQP1NvBG8GPVVqUnIAKFoyUj9WZA02UzpTNFExBWkGMgdtV2IAaQAxV2FVYFwuBilVcwEwATBTcAZtVzBXNQI7UD9TZgRrBjFVY1JlAGlafVInVnENJ1M6UzRRMQVpBjIHbVdiAG0AMldgVWRcJgZyVTwBJgFhUzYGYVczVy0CMVA5U2QEdQY1VWZSYgByWmxSag== + // https://developer.lanzoug.com/file/?B2FWaA4/BDVTWgc/UWRVOQQ7BT1VZFYxUSJUNgE0UiAEbwJ4CDMOOwInU3EKc1w5ATRSIAIzUz1ROVcwATkDLwc3Vi8OYgR+UzYHfFFnVT0EMAUuVXBWPVEmVHQBO1I6BGgCMAgKDjMCMFM4Cm9cbAFjUmcCb1NhUWRXaAFqAyQHYVZyDm4EYVMzB2BRNVVlBG4FNlU6VnJRJlQiAWBSYQQ0AmcIZg51AmRTMApxXG8BblJ4Aj5TYlFjVzMBZQM3BzVWNQ5lBGlTPAc1UTVVYwQ/BWFVaVYwUWZUYwE+UmoEZQJiCG0OaQJiUzMKbVxtAWNSYwJzUytRP1chAXsDdwd0VmQOIQQ5U2EHbFE0VWQEawU5VT5WbVFuVHQBKVI6BGkCMAgzDmcCZVMzCmZcaAFrUmcCaFNlUWNXZwFzAywHIVZnDj8EJ1M4B2BRM1VsBGsFMFU6VmZRb1RgAW5SdQRxAiUIIg5nAmVTMwpmXGgBa1JnAm9TYVFmV2YBewN3B25WcQ5uBGFTNAdjUStVZgRtBTJVJFZlUWJUZAFzUmQEPA== + // https://developer.lanzoug.com/file/?CW9WaAk4BzZUXVRsCz5cMAE+Bj5UZVM0USJUNlRhA3FUPwJ4CTJUYQInASMHflI3ATQGdFdmAW9ROQFmVGwEKAk5Vi8JZQd9VDFULws9XDQBNQYtVHFTOFEmVHRUbgNrVDgCMAkLVGkCMAFqB2JSYgFjBjNXOgEzUWQBPlQ/BCMJb1ZyCWkHYlQ0VDMLb1xsAWsGNVQ7U3dRJlQiVDUDMFRkAmcJZ1QvAmQBYgd8UmEBbgYsV2sBMFFjAWVUMAQwCTtWNQliB2pUO1RmC29cagE6BmJUaFM1UWZUY1RrAztUNQJiCWxUMwJiAWEHYFJjAWMGN1cmAXlRPwF3VC4EcAl6VmQJJgc6VGZUPwtuXG0BbgY6VD9TaFFuVHRUfANrVDkCMAkyVD0CZQFhB2tSZgFrBjNXPgE6UWABM1QmBCsJL1ZnCTgHJFQ/VDMLaVxlAW4GM1Q7U2RRb1RmVDgDJFQhAiUJI1Q9AmUBYQdrUmYBawYzVzoBM1FmATBULgRwCWBWcQlpB2JUM1QwC3FcbwFoBjFUJVNgUWJUZFQmAzVUbA== } } From 11decadb4c69b9e4f4767d11a22deff92da28e33 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Thu, 25 May 2023 18:14:55 +0800 Subject: [PATCH 35/48] Update service-install.sh --- bin/service-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/service-install.sh b/bin/service-install.sh index 5a3027c..ce173f9 100644 --- a/bin/service-install.sh +++ b/bin/service-install.sh @@ -1,4 +1,4 @@ -cp ./lz-api.service /etc/systemd/system/ +cp ./netdisk-fast-download.service /etc/systemd/system/ # 重新加载 systemd systemctl daemon-reload From e7ebb7c8c3905706bcfc42413ebbdcfbdf570a65 Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Mon, 29 May 2023 00:29:50 +0800 Subject: [PATCH 36/48] change logo show version --- web-service/src/main/resources/app.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web-service/src/main/resources/app.yml b/web-service/src/main/resources/app.yml index cb7bef5..ef12697 100644 --- a/web-service/src/main/resources/app.yml +++ b/web-service/src/main/resources/app.yml @@ -1,7 +1,7 @@ # 要激活的配置: dev--连接本地数据库; prod连接线上数据库 active: dev # 框架版本号 和主版本号 -version_vertx: 4.1.3 -version_app: 0.0.1 +version_vertx: 4.4.1 +version_app: 0.1.3 # 公司名称 -> LOGO版权文字 copyright: QAIU From 37f5f2a30dca15cd4b376502e1467f5fbe09a3ff Mon Sep 17 00:00:00 2001 From: qaiu <736226400@qq.com> Date: Mon, 29 May 2023 01:14:40 +0800 Subject: [PATCH 37/48] add lzpan login api test --- web-service/src/main/resources/http-tools/lz.http | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 web-service/src/main/resources/http-tools/lz.http diff --git a/web-service/src/main/resources/http-tools/lz.http b/web-service/src/main/resources/http-tools/lz.http new file mode 100644 index 0000000..8408aa3 --- /dev/null +++ b/web-service/src/main/resources/http-tools/lz.http @@ -0,0 +1,12 @@ +### lanzou login +POST https://pc.woozooo.com/mlogin.php +content-type: application/x-www-form-urlencoded; + +task=3&uid=&pwd=&formhash=7202fced + +### File list +POST https://pc.woozooo.com/doupload.php?uid=1059498 +content-type: application/x-www-form-urlencoded; + +task=5&folder_id=-1 + From a14db13485e453239ce015d02aa5728ae46a5413 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Thu, 8 Jun 2023 17:33:42 +0800 Subject: [PATCH 38/48] =?UTF-8?q?=E5=85=B6=E4=BB=96=E7=BD=91=E7=9B=98API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qaiu/lz/common/util/IFuturePanTool.java | 7 ++ .../java/cn/qaiu/lz/common/util/QkTool.java | 12 ++ .../java/cn/qaiu/lz/common/util/WoTools.java | 6 + .../resources/http-tools/http-client.env.json | 5 + .../src/main/resources/http-tools/pan-fc.http | 25 ++++ .../src/main/resources/http-tools/pan-fj.http | 22 ++++ .../src/main/resources/http-tools/pan-qk.http | 107 ++++++++++++++++++ .../http-tools/{ucpan.http => pan-uc.http} | 0 .../src/main/resources/http-tools/pan-ws.http | 53 +++++++++ .../src/main/resources/http-tools/test.http | 45 -------- 10 files changed, 237 insertions(+), 45 deletions(-) create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/IFuturePanTool.java create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/QkTool.java create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/WoTools.java create mode 100644 web-service/src/main/resources/http-tools/http-client.env.json create mode 100644 web-service/src/main/resources/http-tools/pan-fc.http create mode 100644 web-service/src/main/resources/http-tools/pan-fj.http create mode 100644 web-service/src/main/resources/http-tools/pan-qk.http rename web-service/src/main/resources/http-tools/{ucpan.http => pan-uc.http} (100%) create mode 100644 web-service/src/main/resources/http-tools/pan-ws.http diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/IFuturePanTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/IFuturePanTool.java new file mode 100644 index 0000000..5d871cd --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/IFuturePanTool.java @@ -0,0 +1,7 @@ +package cn.qaiu.lz.common.util; + +public interface IFuturePanTool { + + + +} diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/QkTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/QkTool.java new file mode 100644 index 0000000..e9e8fa7 --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/QkTool.java @@ -0,0 +1,12 @@ +package cn.qaiu.lz.common.util; + +import io.vertx.core.Future; +import io.vertx.core.Promise; + +public class QkTool { + public static Future parse(String data, String code) { + Promise promise = Promise.promise(); + + return promise.future(); + } +} diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/WoTools.java b/web-service/src/main/java/cn/qaiu/lz/common/util/WoTools.java new file mode 100644 index 0000000..6fcef6c --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/WoTools.java @@ -0,0 +1,6 @@ +package cn.qaiu.lz.common.util; + +public class WoTools { + + +} diff --git a/web-service/src/main/resources/http-tools/http-client.env.json b/web-service/src/main/resources/http-tools/http-client.env.json new file mode 100644 index 0000000..eb09210 --- /dev/null +++ b/web-service/src/main/resources/http-tools/http-client.env.json @@ -0,0 +1,5 @@ +{ + "dev": { + "token": "fcfb5e91-0adb-41b4-bc24-6eb92661d46a" + } +} diff --git a/web-service/src/main/resources/http-tools/pan-fc.http b/web-service/src/main/resources/http-tools/pan-fc.http new file mode 100644 index 0000000..3029de5 --- /dev/null +++ b/web-service/src/main/resources/http-tools/pan-fc.http @@ -0,0 +1,25 @@ +### 亿方云分享 重定向 +# @no-redirect +https://v2.fangcloud.com/sharing/9cbe4b73521ba4d65a8cd38a8c + +### get重定向 set-cookie: fc_session +https://share-d94258c2ebfde2a83a7d5931e8da5221.fangcloud.cn/share/9cbe4b73521ba4d65a8cd38a8c + +### cookie: fc_session=xxx 获取file_id +# @no-cookie-jar +https://share-d94258c2ebfde2a83a7d5931e8da5221.fangcloud.cn/apps/files/get_info?scenario=share&item_typed_id=file_559003251828 +Cookie:fc_session=eyJpdiI6Im9hQ0Njc1pKczNsaDl4Z2pubHRDVnc9PSIsInZhbHVlIjoieDAwRUc4NkNMSHZkMzZsVzVwWGJKd0M2dFNKcEM5elpsWFZONURRYkFqTm9maDN6aXpsMWNwR0ZydXliSDBENE1Cclh2SzNyNXNmS2ttOHBKakxzSVE9PSIsIm1hYyI6IjRkNzg5ZDQwOTIzOGRiZDYyNjg2ZDE3ZDgzZDg2OWViNWRmNGIwZDFjNjQ0ODdkYTc0MjljZjI1YzU5NDY4ZGQifQ%3D%3D + +#{ +# "success": true +# "item": { +# "extension": "apk", +# "id": 559003251828, // file_id + +### 获取下载链接 +# @no-redirect +# @no-cookie-jar +https://share-d94258c2ebfde2a83a7d5931e8da5221.fangcloud.cn/apps/files/download?file_id=559003251828&scenario=share&unique_name=9cbe4b73521ba4d65a8cd38a8c +Cookie:fc_session=eyJpdiI6Im9hQ0Njc1pKczNsaDl4Z2pubHRDVnc9PSIsInZhbHVlIjoieDAwRUc4NkNMSHZkMzZsVzVwWGJKd0M2dFNKcEM5elpsWFZONURRYkFqTm9maDN6aXpsMWNwR0ZydXliSDBENE1Cclh2SzNyNXNmS2ttOHBKakxzSVE9PSIsIm1hYyI6IjRkNzg5ZDQwOTIzOGRiZDYyNjg2ZDE3ZDgzZDg2OWViNWRmNGIwZDFjNjQ0ODdkYTc0MjljZjI1YzU5NDY4ZGQifQ%3D%3D + + diff --git a/web-service/src/main/resources/http-tools/pan-fj.http b/web-service/src/main/resources/http-tools/pan-fj.http new file mode 100644 index 0000000..d37fa91 --- /dev/null +++ b/web-service/src/main/resources/http-tools/pan-fj.http @@ -0,0 +1,22 @@ +### +# devType: 6 +# devModel: Chrome +# uuid: M_S4dl58NrtLkHCxonmWc +# extra: 2 +# timestamp: C421C95B7A6E20745D98DD462118EEDA +# shareId: 146731 +# type: 0 +# offset: 1 +# limit: 60 +# @no-cookie-jar +POST https://api.feijipan.com/ws/recommend/list?devType=6&devModel=Chrome&extra=2&shareId=146731&type=0&offset=1&limit=60 + + +### +https://api.feijipan.com/ws/file/redirect?downloadId=4703B103BD6871F83441233393695EF3&enable=1&devType=6&uuid=z1PkRuW9of6Lg6_Y_NiNK×tamp=7FBE54506F49A38070E62936EA41D9B1&auth=159F4D596FC74050EACC77E2854CD2EDBF5F4A7B953DF72F95886E38F3DD9D3C + +# 654488C79332E7279F9A38367BD72D3B +# 4703B103BD6871F83441233393695EF3 + +### +https://api.feijipan.com/ws/file/redirect?downloadId=4703B103BD6871F83441233393695EF3&enable=1&devType=6&uuid=M_S4dl58NrtLkHCxonmWc×tamp=B4C5B9833113ACA41F16AABADE17349C&auth=159F4D596FC74050EACC77E2854CD2ED3805DDAAF2AEA1EFC67BD687D22F19E3 diff --git a/web-service/src/main/resources/http-tools/pan-qk.http b/web-service/src/main/resources/http-tools/pan-qk.http new file mode 100644 index 0000000..bd1a3e5 --- /dev/null +++ b/web-service/src/main/resources/http-tools/pan-qk.http @@ -0,0 +1,107 @@ +### quark_pan not login >10M download file size limit[b3faf7f72ac64f94b4749588fc197816] +#no-cookie-jar +# 解除文件大小限制需要UA +POST https://drive-pc.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc +content-type: application/json;charset=UTF-8 +#cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; +user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch + +{"fids":["b3faf7f72ac64f94b4749588fc197816"]} + + + + +### +POST https://drive.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc&ve=2.1.5 +content-type: application/json;charset=UTF-8 +cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; +user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch + +{"fids":["b3faf7f72ac64f94b4749588fc197816"]} + +### +https://dl-pc-zb-cf.pds.quark.cn/KTb1G4Lr/623810984/645b44ef8d9c47afbd2f4947b4b89d098f725188/645b44ef1eb3ebc1a8b448eb992b0e9195dfb646?Expires=1684137387&OSSAccessKeyId=LTAIyYfxTqY7YZsg&Signature=M5X1La7lpOJLRGZioFIMHRujuPs%3D&x-oss-traffic-limit=503316480&response-content-disposition=attachment%3B%20filename%3DC%23%20Shell%20%28C%23%20Offline%20Compiler%29_2.5.16.apk&u5=489aa5c778a51f717585a253ce8290a1&callback=eyJjYWxsYmFja0JvZHlUeXBlIjoiYXBwbGljYXRpb24vanNvbiIsImNhbGxiYWNrU3RhZ2UiOiJiZWZvcmUtZXhlY3V0ZSIsImNhbGxiYWNrRmFpbHVyZUFjdGlvbiI6Imlnbm9yZSIsImNhbGxiYWNrVXJsIjoiaHR0cHM6Ly9hdXRoLWNkbi51Yy5jbi9vdXRlci9vc3MvY2hlY2twbGF5IiwiY2FsbGJhY2tCb2R5Ijoie1wiaG9zdFwiOiR7aHR0cEhlYWRlci5ob3N0fSxcInNpemVcIjoke3NpemV9LFwicmFuZ2VcIjoke2h0dHBIZWFkZXIucmFuZ2V9LFwicmVmZXJlclwiOiR7aHR0cEhlYWRlci5yZWZlcmVyfSxcImNvb2tpZVwiOiR7aHR0cEhlYWRlci5jb29raWV9LFwibWV0aG9kXCI6JHtodHRwSGVhZGVyLm1ldGhvZH0sXCJpcFwiOiR7Y2xpZW50SXB9LFwib2JqZWN0XCI6JHtvYmplY3R9LFwic3BcIjoke3g6c3B9LFwidG9rZW5cIjoke3g6dG9rZW59LFwidHRsXCI6JHt4OnR0bH0sXCJjbGllbnRfdG9rZW5cIjoke3F1ZXJ5U3RyaW5nLmNsaWVudF90b2tlbn19In0%3D&callback-var=eyJ4OnNwIjoiMzc4IiwieDp0b2tlbiI6IjItNDg5YWE1Yzc3OGE1MWY3MTc1ODVhMjUzY2U4MjkwYTEtOC0xLTIwNDgtNDNiNGMxMzk4NTBjNDkyZWFmMTIwNTA2MWI5NjZiYTEtYTk2MDhlNTFlMjUwMDJlNTkyODJkYzNmMjA3MGU0M2EiLCJ4OnR0bCI6IjIxNjAwIn0%3D +cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; +user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch + + +### quark_pan +# 我用夸克网盘分享了「yh-cloud_20230320114659.rar」,点击链接即可保存。打开「夸克APP」,无需下载在线播放视频,畅享原画5倍速,支持电视投屏。 +# 链接:https://pan.quark.cn/s/fde352875597 +# step1 获取stoken +POST https://drive-pc.quark.cn/1/clouddrive/share/sharepage/token?pr=ucpro&fr=pc +accept: application/json, text/plain, */* +content-type: application/json + +{"pwd_id":"fde352875597","passcode":""} + +### +# { +# "status": 200, +# "code": 0, +# "data": { +# "stoken": "jWnLFnfoQMYTglPy5NsDZ8pBKQ5ZeQfJRdawZBru9IA=", +# "author": { +# }, +# } +# } + + +### quark_pan +# step2 获取fid +https://drive-pc.quark.cn/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd_id=fde352875597&stoken=jWnLFnfoQMYTglPy5NsDZ8pBKQ5ZeQfJRdawZBru9IA%3D&pdir_fid=0&force=0&_page=1&_size=50&_fetch_banner=1&_fetch_share=1&_fetch_total=1&_sort=file_type:asc,updated_at:desc + +### +# { +# "status": 200, +# "code": 0, +# "data": { +# "is_owner": 0, +# "share": { +# "first_fid": "a7d83e634e70427e86c86bf215feeafa", + +### quark_pan + +### step3 获取下载链接需要pus 生成puus的cookie +POST https://drive.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc&ve=2.1.5 +content-type: application/json;charset=UTF-8 +#cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; +#user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch + +{"fids":["a7d83e634e70427e86c86bf215feeafa"]} + + +### 二维码登录 +# 1获取token +POST https://uop.quark.cn/cas/ajax/getTokenForQrcodeLogin + +### 2. 循环获取用户扫码状态(扫码后会返回st码) +POST https://uop.quark.cn/cas/ajax/getServiceTicketByQrcodeToken?__dt=5910&__t=1686191457201 +Content-Type: application/x-www-form-urlencoded + +client_id=532&v=1.2&request_id=1686191457201&token=cc9856e9-5bd3-4b91-ac47-7934710dc493 + +### 拼接token参数生成二维码 +https://su.quark.cn/4_eMHBJ?uc_param_str=&token={{token}}&client_id=532&uc_biz_str=S%3Acustom%7COPT%3ASAREA%400%7COPT%3AIMMERSIVE%401%7COPT%3ABACK_BTN_STYLE%400 + +# https://su.quark.cn/4_eMHBJ?uc_param_str=&token=d3d6244a-f477-4c73-8d5e-4e59c2b38771&client_id=532&uc_biz_str=S%3Acustom%7COPT%3ASAREA%400%7COPT%3AIMMERSIVE%401%7COPT%3ABACK_BTN_STYLE%400 + + +### 3. 基于st码信息获取用户信息 pus的cookie +https://pan.quark.cn/account/info?st=st9026333a8yugxx3wteqyn2hc4fv9fn&fr=pc&platform=pc + + + +# { +# "status": 2000000, +# "message": "ok", +# "data": { +# "members": { +# "service_ticket": "st9026333d4f0ha0asnjjf0kz3k8xyog" +# } +# } +# } + +### 需要puus +# @no-redirect +https://dl-pc-zb-cf.pds.quark.cn/aZ3Dtotu/623810984/645cb18e1f5104a87e6548d5a0025186fa5a4a50/645cb18e005da587561c407dac8a14962d006ba3?Expires=1686212388&OSSAccessKeyId=LTAIyYfxTqY7YZsg&Signature=6W%2F3qVJ3m%2FExuuMtAfDcNUXeN6E%3D&x-oss-traffic-limit=503316480&response-content-disposition=attachment%3B%20filename%3Dyh-cloud_20230320114659.rar&u5=489aa5c778a51f717585a253ce8290a1&callback=eyJjYWxsYmFja0JvZHlUeXBlIjoiYXBwbGljYXRpb24vanNvbiIsImNhbGxiYWNrU3RhZ2UiOiJiZWZvcmUtZXhlY3V0ZSIsImNhbGxiYWNrRmFpbHVyZUFjdGlvbiI6Imlnbm9yZSIsImNhbGxiYWNrVXJsIjoiaHR0cHM6Ly9hdXRoLWNkbi51Yy5jbi9vdXRlci9vc3MvY2hlY2twbGF5IiwiY2FsbGJhY2tCb2R5Ijoie1wiaG9zdFwiOiR7aHR0cEhlYWRlci5ob3N0fSxcInNpemVcIjoke3NpemV9LFwicmFuZ2VcIjoke2h0dHBIZWFkZXIucmFuZ2V9LFwicmVmZXJlclwiOiR7aHR0cEhlYWRlci5yZWZlcmVyfSxcImNvb2tpZVwiOiR7aHR0cEhlYWRlci5jb29raWV9LFwibWV0aG9kXCI6JHtodHRwSGVhZGVyLm1ldGhvZH0sXCJpcFwiOiR7Y2xpZW50SXB9LFwib2JqZWN0XCI6JHtvYmplY3R9LFwic3BcIjoke3g6c3B9LFwidG9rZW5cIjoke3g6dG9rZW59LFwidHRsXCI6JHt4OnR0bH0sXCJjbGllbnRfdG9rZW5cIjoke3F1ZXJ5U3RyaW5nLmNsaWVudF90b2tlbn19In0%3D&callback-var=eyJ4OnNwIjoiMzc4IiwieDp0b2tlbiI6IjItNDg5YWE1Yzc3OGE1MWY3MTc1ODVhMjUzY2U4MjkwYTEtMi0xLTIwNDgtMDBlMWE3ZTg4ZTQ1NGJjYjk1ZTNmYTQwY2ExZDZhYjMtNTQzYzJiNDAwN2M2ZTEyZTE5ZTY0MGU5MDk5ZDlhMzMiLCJ4OnR0bCI6IjIxNjAwIn0%3D diff --git a/web-service/src/main/resources/http-tools/ucpan.http b/web-service/src/main/resources/http-tools/pan-uc.http similarity index 100% rename from web-service/src/main/resources/http-tools/ucpan.http rename to web-service/src/main/resources/http-tools/pan-uc.http diff --git a/web-service/src/main/resources/http-tools/pan-ws.http b/web-service/src/main/resources/http-tools/pan-ws.http new file mode 100644 index 0000000..db45fe2 --- /dev/null +++ b/web-service/src/main/resources/http-tools/pan-ws.http @@ -0,0 +1,53 @@ +POST https://www.wenshushu.cn/ap/ufile/nlist +Accept: application/json, text/plain, */* +X-Token: 2QujUq7M4xZpkeydcAnOmk4FVqw + +{"start":0,"sort":{"name":"asc"},"bid":"5zl01fgbops","pid":"5zl01fgehuo","options":{"uploader":"true"},"size":50} + +### +# @no-cookie-jar +POST https://www.wenshushu.cn/ap/user/userinfo +Accept: application/json, text/plain, */* +X-Token: 2QujUq7M4xZpkeydcAnOmk4FVqw + +{"plat":"pcweb"} + + + +### 分享文件信息 (有效期) +# https://t.wss.ink/f/bekolxi7hqb +POST https://www.wenshushu.cn/ap/task/mgrtask +Accept: application/json, text/plain, */* +X-Token: 2QujUq7M4xZpkeydcAnOmk4FVqw + +{"tid":"bekolxi7hqb","password":""} + +### 分享延期 需要<24小时 延期间隔=? +POST https://www.wenshushu.cn/ap/task/delay +Accept: application/json, text/plain, */* +X-Token: 2QujUq7M4xZpkeydcAnOmk4FVqw + +{"tid":"bekolxi7hqb","delay_time":1,"is_extension":false} + + +### 获取匿名TOKEN +POST https://www.wenshushu.cn/ap/login/anonymous +Accept: application/json, text/plain, */* + +### 获取下载文件URL +POST https://www.wenshushu.cn/ap/dl/sign +Accept: application/json, text/plain, */* +X-Token:wss:bekzdwsfwwf + +{"ufileid":"bekoe5n508z","consumeCode":0,"type":1} + +### +# { +# "code": 0, +# "message": "success", +# "data": { +# "url": "https://down.wss.show/zkrk4th/9/yj/9yjvzkrk4th?cdn_sign=1686211254-31-0-6edd2e228a030be23210158daeb2c4a1&exp=4800&response-content-disposition=attachment%3B%20filename%3D%22supervision.sql%22%3B%20filename%2A%3Dutf-8%27%27supervision.sql", + +### 直接下载 +https://down.wss.show/zkrk4th/9/yj/9yjvzkrk4th?cdn_sign=1686211254-31-0-6edd2e228a030be23210158daeb2c4a1&exp=4800&response-content-disposition=attachment%3B%20filename%3D%22supervision.sql%22%3B%20filename%2A%3Dutf-8%27%27supervision.sql + diff --git a/web-service/src/main/resources/http-tools/test.http b/web-service/src/main/resources/http-tools/test.http index a309a05..c371799 100644 --- a/web-service/src/main/resources/http-tools/test.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -93,51 +93,6 @@ Content-Type: application/json < ./request-form-data.json --WebAppBoundary-- -### -POST https://drive-pc.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc -content-type: application/json;charset=UTF-8 -cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; - -{"fids":["b3faf7f72ac64f94b4749588fc197816"]} - - -### -POST https://drive.quark.cn/1/clouddrive/file/download?pr=ucpro&fr=pc&ve=2.1.5 -content-type: application/json;charset=UTF-8 -cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; -user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch - -{"fids":["b3faf7f72ac64f94b4749588fc197816"]} - -### -https://dl-pc-zb-cf.pds.quark.cn/KTb1G4Lr/623810984/645b44ef8d9c47afbd2f4947b4b89d098f725188/645b44ef1eb3ebc1a8b448eb992b0e9195dfb646?Expires=1684137387&OSSAccessKeyId=LTAIyYfxTqY7YZsg&Signature=M5X1La7lpOJLRGZioFIMHRujuPs%3D&x-oss-traffic-limit=503316480&response-content-disposition=attachment%3B%20filename%3DC%23%20Shell%20%28C%23%20Offline%20Compiler%29_2.5.16.apk&u5=489aa5c778a51f717585a253ce8290a1&callback=eyJjYWxsYmFja0JvZHlUeXBlIjoiYXBwbGljYXRpb24vanNvbiIsImNhbGxiYWNrU3RhZ2UiOiJiZWZvcmUtZXhlY3V0ZSIsImNhbGxiYWNrRmFpbHVyZUFjdGlvbiI6Imlnbm9yZSIsImNhbGxiYWNrVXJsIjoiaHR0cHM6Ly9hdXRoLWNkbi51Yy5jbi9vdXRlci9vc3MvY2hlY2twbGF5IiwiY2FsbGJhY2tCb2R5Ijoie1wiaG9zdFwiOiR7aHR0cEhlYWRlci5ob3N0fSxcInNpemVcIjoke3NpemV9LFwicmFuZ2VcIjoke2h0dHBIZWFkZXIucmFuZ2V9LFwicmVmZXJlclwiOiR7aHR0cEhlYWRlci5yZWZlcmVyfSxcImNvb2tpZVwiOiR7aHR0cEhlYWRlci5jb29raWV9LFwibWV0aG9kXCI6JHtodHRwSGVhZGVyLm1ldGhvZH0sXCJpcFwiOiR7Y2xpZW50SXB9LFwib2JqZWN0XCI6JHtvYmplY3R9LFwic3BcIjoke3g6c3B9LFwidG9rZW5cIjoke3g6dG9rZW59LFwidHRsXCI6JHt4OnR0bH0sXCJjbGllbnRfdG9rZW5cIjoke3F1ZXJ5U3RyaW5nLmNsaWVudF90b2tlbn19In0%3D&callback-var=eyJ4OnNwIjoiMzc4IiwieDp0b2tlbiI6IjItNDg5YWE1Yzc3OGE1MWY3MTc1ODVhMjUzY2U4MjkwYTEtOC0xLTIwNDgtNDNiNGMxMzk4NTBjNDkyZWFmMTIwNTA2MWI5NjZiYTEtYTk2MDhlNTFlMjUwMDJlNTkyODJkYzNmMjA3MGU0M2EiLCJ4OnR0bCI6IjIxNjAwIn0%3D -cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; -user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch - - -### quark_pan -# 我用夸克网盘分享了「C# Shell (C# Offline Compiler)_2.5.16.apk」,点击链接即可保存。打开「夸克APP」,无需下载在线播放视频,畅享原画5倍速,支持电视投屏。 -#链接:https://pan.quark.cn/s/8f816f506409 -# step1 获取stoken -POST https://drive-pc.quark.cn/1/clouddrive/share/sharepage/token?pr=ucpro&fr=pc -accept: application/json, text/plain, */* -content-type: application/json - -{"pwd_id":"8f816f506409","passcode":""} - -### quark_pan -# step2 获取fid -https://drive-pc.quark.cn/1/clouddrive/share/sharepage/detail?pr=ucpro&fr=pc&pwd_id=8f816f506409&stoken=JX6p1XFG5hD2VaUJFxazvE72u9TuhcKiXd81%2BXaFFsI%3D&pdir_fid=0&force=0&_page=1&_size=50&_fetch_banner=1&_fetch_share=1&_fetch_total=1&_sort=file_type:asc,updated_at:desc - - -### quark_pan -https://drive-pc.quark.cn/1/clouddrive/auth/pc/flush?pr=ucpro&fr=pc -cookie: __pus=77641f2139b914c29ed2b0caf246723dAAQbjDyR/fi1Z9YqqWbfO2qPZYeRTrFSC2P30uuWJwtY2ZwwQTRsEPHJKc9nuPnrXfQxir+0N8K/mVfr7SIwGc2t; - - -### -https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https:%2F%2Fwww.ecpan.cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&data=aa0cae0164d8885e6d35826b5b2901eckbWJBalM&parentId=-1 - ### # @no-redirect GET http://127.0.0.1:6400/parser?url=https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare= From 03c4c8c5814612709e0987408298e06cae61abc5 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Fri, 9 Jun 2023 15:43:21 +0800 Subject: [PATCH 39/48] =?UTF-8?q?-=20=E5=8A=A0=E5=85=A5=E5=B0=8F=E9=A3=9E?= =?UTF-8?q?=E6=9C=BA=E7=9B=98=E7=9B=B4=E9=93=BE=E8=A7=A3=E6=9E=90=20-=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 25 +- .../java/cn/qaiu/lz/common/util/AESUtils.java | 239 ++++++++++++++++++ .../cn/qaiu/lz/common/util/CommonUtils.java | 11 + .../cn/qaiu/lz/common/util/ConnectUtil.java | 19 -- .../java/cn/qaiu/lz/common/util/EcTool.java | 4 +- .../java/cn/qaiu/lz/common/util/FjTool.java | 75 ++++++ .../java/cn/qaiu/lz/common/util/UcTool.java | 7 +- .../java/cn/qaiu/lz/common/util/WoTools.java | 6 - .../java/cn/qaiu/lz/web/http/ServerApi.java | 29 ++- .../src/main/resources/http-tools/curl.sh | 4 +- .../http-tools/{ecpan.http => pan-ec.http} | 0 .../src/main/resources/http-tools/pan-fj.http | 32 ++- .../http-tools/{lz.http => pan-lz.http} | 0 .../src/main/resources/http-tools/test.http | 16 +- .../java/cn/qaiu/web/test/TestAESUtil.java | 57 +++++ 15 files changed, 466 insertions(+), 58 deletions(-) create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/AESUtils.java create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java delete mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/FjTool.java delete mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/WoTools.java rename web-service/src/main/resources/http-tools/{ecpan.http => pan-ec.http} (100%) rename web-service/src/main/resources/http-tools/{lz.http => pan-lz.http} (100%) create mode 100644 web-service/src/test/java/cn/qaiu/web/test/TestAESUtil.java diff --git a/README.md b/README.md index 6e68812..7a9c04d 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,12 @@ - [ ] 登录, 上传, 下载, 分享 - [x] 直链解析 - UC网盘 (uc) - - [ ] 登录, 上传, 下载, 分享 - - [x] 直链解析 + - [ ] 登录, 上传, 下载, 分享 + - [x] 直链解析 +- 小飞机网盘 (fj) + - [ ] 登录, 上传, 下载, 分享 + - [x] 直链解析 +- 文叔叔 (ws) - 夸克网盘 (qk) - TODO @@ -30,7 +34,7 @@ API接口 http(s)://you_host/网盘标识/分享id(#分享密码) 2. 获取解析后的直链--JSON格式 http(s)://you_host/json/网盘标识/分享id(#分享密码) - +3. 有些网盘的加密分享的密码可以忽略: 如移动云空间,小飞机网盘 ``` @@ -63,11 +67,12 @@ TODO: # 网盘对比 -| 网盘名称 | 可直接下载分享 | 加密分享 | 初始网盘空间 | 单文件大小限制 | 登录接口 | -|-------|-------------|----------|----------|----------------|------| -| 蓝奏云 | √ | √ | 不限空间 | 100M | TODO | -| 奶牛快传 | √ | X | 10G | 不限大小 | TODO | -| 移动云空间 | √ | √(密码可忽略) | 5G(个人) | 不限大小 | TODO | -| UC网盘 | √ | √ | 10G | 不限大小 | TODO | -| 夸克网盘 | √(>10M需要登录) | √ | 10G(20G) | 不限大小(>10M需要登录) | X | +| 网盘名称 | 可直接下载分享 | 加密分享 | 初始网盘空间 | 单文件大小限制 | 登录接口 | +|------------|---------|----------|----------|---------|------| +| 蓝奏云 | √ | √ | 不限空间 | 100M | TODO | +| 奶牛快传 | √ | X | 10G | 不限大小 | TODO | +| 移动云空间 | √ | √(密码可忽略) | 5G(个人) | 不限大小 | TODO | +| UC网盘 | √ | √ | 10G | 不限大小 | TODO | +| 小飞机网盘 | √ | √(密码可忽略) | 10G | 不限大小 | TODO | +| 夸克网盘(TODO) | 需要登录 | √ | 10G(20G) | 不限大小 | TODO | diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/AESUtils.java b/web-service/src/main/java/cn/qaiu/lz/common/util/AESUtils.java new file mode 100644 index 0000000..630e7e2 --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/AESUtils.java @@ -0,0 +1,239 @@ +package cn.qaiu.lz.common.util; + +import org.apache.commons.lang3.StringUtils; + +import javax.crypto.*; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.util.Base64; +import java.util.HexFormat; + +/** + * AES加解密工具类 + * + * @author qaiu + **/ +public class AESUtils { + + /** + * AES密钥标识 + */ + public static final String SIGN_AES = "AES"; + + /** + * 密码器AES模式 + */ + public static final String CIPHER_AES = "AES/ECB/PKCS5Padding"; + + public static final String CIPHER_AES2 = "YbQHZqK/PdQql2+7ATcPQHREAxt0Hn0Ob9v317QirZM="; + + public static final String CIPHER_AES0; + + /** + * 秘钥长度 + */ + public static final int KEY_LENGTH = 16; + + /** + * 密钥长度128 + */ + public static final int KEY_SIZE_128_LENGTH = 128; + + /** + * 密钥长度192 + */ + public static final int KEY_SIZE_192_LENGTH = 192; + + /** + * 密钥长度256 + */ + public static final int KEY_SIZE_256_LENGTH = 256; + + static { + try { + CIPHER_AES0 = decryptByBase64AES(CIPHER_AES2, CIPHER_AES); + } catch (IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException | NoSuchAlgorithmException | + InvalidKeyException e) { + throw new RuntimeException(e); + } + } + + /** + * 随机生成密钥,请使用合适的长度128 192 256 + */ + public static Key createKeyString(int keySize) throws NoSuchAlgorithmException { + KeyGenerator keyGenerator = KeyGenerator.getInstance(SIGN_AES); + keyGenerator.init(keySize); + SecretKey secretKey = keyGenerator.generateKey(); + return new SecretKeySpec(secretKey.getEncoded(), SIGN_AES); + } + + /** + * 生成Key对象 + */ + public static Key generateKey(String keyString) { + if (keyString.length() > KEY_LENGTH) { + keyString = keyString.substring(0, KEY_LENGTH); + } else if (keyString.length() < KEY_LENGTH) { + keyString = StringUtils.rightPad(keyString, 16, 'L'); + } + return new SecretKeySpec(keyString.getBytes(), SIGN_AES); + } + + /** + * AES加密 + * + * @param source 原文 + * @param keyString 秘钥 + * @return byte arrays + */ + public static byte[] encryptByAES(String source, String keyString) throws NoSuchPaddingException, + NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + Cipher cipher = Cipher.getInstance(CIPHER_AES); + cipher.init(Cipher.ENCRYPT_MODE, generateKey(keyString)); + return cipher.doFinal(source.getBytes(StandardCharsets.UTF_8)); + } + + public static byte[] encryptByAES(String source, Key key) throws NoSuchPaddingException, + NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + Cipher cipher = Cipher.getInstance(CIPHER_AES); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(source.getBytes(StandardCharsets.UTF_8)); + } + + /** + * AES加密Base64 + * + * @param source 原文 + * @param keyString 秘钥 + * @return BASE64 + */ + public static String encryptBase64ByAES(String source, String keyString) throws NoSuchPaddingException, + NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + byte[] encrypted = encryptByAES(source, keyString); + return Base64.getEncoder().encodeToString(encrypted); + } + + public static String encryptBase64ByAES(String source, Key key) throws NoSuchPaddingException, + NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + byte[] encrypted = encryptByAES(source, key); + return Base64.getEncoder().encodeToString(encrypted); + } + + /** + * AES加密Hex + * + * @param source 原文 + * @param keyString 秘钥 + */ + public static String encryptHexByAES(String source, String keyString) throws NoSuchPaddingException, + NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + byte[] encrypted = encryptByAES(source, keyString); + return HexFormat.of().formatHex(encrypted); + } + + public static String encryptHexByAES(String source, Key key) throws NoSuchPaddingException, + NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + byte[] encrypted = encryptByAES(source, key); + return HexFormat.of().formatHex(encrypted); + } + + public static String encrypt2Hex(String source) { + try { + return encryptHexByAES(source, CIPHER_AES0); + } catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException | IllegalBlockSizeException | + BadPaddingException e) { + throw new RuntimeException("加密失败: "+ e.getMessage()); + } + } + + /** + * AES解密 + * + * @param encrypted 密文 byte + * @param keyString 秘钥 + */ + public static String decryptByAES(byte[] encrypted, String keyString) throws IllegalBlockSizeException, + BadPaddingException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException { + return decryptByAES(encrypted, generateKey(keyString)); + } + + public static String decryptByAES(byte[] encrypted, Key key) throws IllegalBlockSizeException, + BadPaddingException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException { + Cipher cipher = Cipher.getInstance(CIPHER_AES); + cipher.init(Cipher.DECRYPT_MODE, key); + byte[] decrypted = cipher.doFinal(encrypted); + return new String(decrypted, StandardCharsets.UTF_8); + } + + /** + * AES解密 + * + * @param encrypted 密文 Hex + * @param keyString 秘钥 + */ + public static String decryptByHexAES(String encrypted, String keyString) throws IllegalBlockSizeException, + BadPaddingException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException { + return decryptByAES(HexFormat.of().parseHex(encrypted), keyString); + } + + public static String decryptByHexAES(String encrypted, Key key) throws IllegalBlockSizeException, + BadPaddingException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException { + return decryptByAES(HexFormat.of().parseHex(encrypted), key); + } + + /** + * AES解密 + * + * @param encrypted 密文 Base64 + * @param keyString 秘钥 + */ + public static String decryptByBase64AES(String encrypted, String keyString) throws IllegalBlockSizeException, + BadPaddingException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException { + return decryptByAES(Base64.getDecoder().decode(encrypted), keyString); + } + + public static String decryptByBase64AES(String encrypted, Key key) throws IllegalBlockSizeException, + BadPaddingException, InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException { + return decryptByAES(Base64.getDecoder().decode(encrypted), key); + } + + // ================================飞机盘Id解密========================================== // + private static final char[] array = { + 'T', 'U', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + '0', 'M', 'N', 'O', 'P', 'X', 'Y', 'Z', 'V', 'W', + 'Q', '1', '2', '3', '4', 'a', 'b', 'c', 'd', 'e', + '5', '6', '7', '8', '9', 'v', 'w', 'x', 'y', 'z', + 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'L', 'R', 'S', 'I', + 'J', 'K'}; + + private static int decodeChar(char c) { + for (int i = 0; i < array.length; i++) { + if (c == array[i]) { + return i; + } + } + return -1; + } + + // id解密 + public static int idEncrypt(String str) { + // 倍数 + int multiple = 1; + int result = 0; + if (StringUtils.isNotEmpty(str) && str.length() > 4) { + str = str.substring(2, str.length() - 2); + char c; + for (int i = 0; i < str.length(); i++) { + c = str.charAt(str.length() - i - 1); + result += decodeChar(c) * multiple; + multiple = multiple * 62; + } + } + return result; + } +} diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java b/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java new file mode 100644 index 0000000..78f5f46 --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java @@ -0,0 +1,11 @@ +package cn.qaiu.lz.common.util; + +public class CommonUtils { + + public static String parseURL(String urlPrefix, String url) { + if (!url.startsWith(urlPrefix)) { + url = urlPrefix + url; + } + return url.substring(urlPrefix.length()); + } +} diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java b/web-service/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java deleted file mode 100644 index 0ea396a..0000000 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/ConnectUtil.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.qaiu.lz.common.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 获取连接 - * - * @author QAIU - */ -public enum ConnectUtil { - - // 实现枚举单例 - INSTANCE; - - private static final Logger LOGGER = LoggerFactory.getLogger(ConnectUtil.class); - - -} diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/EcTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/EcTool.java index 8697146..b9df23a 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/EcTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/EcTool.java @@ -14,7 +14,7 @@ import lombok.extern.slf4j.Slf4j; */ @Slf4j public class EcTool { - private static final String FULL_URL_PREFIX = "https://www.ecpan.cn/drive/fileextoverrid" + + private static final String SHARE_URL_PREFIX = "https://www.ecpan.cn/drive/fileextoverrid" + ".do?chainUrlTemplate=https:%2F%2Fwww.ecpan" + ".cn%2Fweb%2F%23%2FyunpanProxy%3Fpath%3D%252F%2523%252Fdrive%252Foutside&parentId=-1&data={dataKey}"; @@ -26,7 +26,7 @@ public class EcTool { Promise promise = Promise.promise(); WebClient client = WebClient.create(VertxHolder.getVertxInstance()); // 第一次请求 获取文件信息 - client.getAbs(UriTemplate.of(FULL_URL_PREFIX)).setTemplateParam("dataKey", dataKey).send().onSuccess(res -> { + client.getAbs(UriTemplate.of(SHARE_URL_PREFIX)).setTemplateParam("dataKey", dataKey).send().onSuccess(res -> { JsonObject jsonObject = res.bodyAsJsonObject(); log.debug("ecPan get file info -> {}", jsonObject); JsonObject fileInfo = jsonObject diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/FjTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/FjTool.java new file mode 100644 index 0000000..34b00f6 --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/FjTool.java @@ -0,0 +1,75 @@ +package cn.qaiu.lz.common.util; + +import cn.qaiu.vx.core.util.VertxHolder; +import io.vertx.core.Future; +import io.vertx.core.MultiMap; +import io.vertx.core.Promise; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.client.WebClient; +import io.vertx.ext.web.client.WebClientOptions; +import io.vertx.uritemplate.UriTemplate; + +import java.util.UUID; + +/** + * 小飞机网盘 + * + * @version V016_230609 + */ +public class FjTool { + + public static final String SHARE_URL_PREFIX = "https://www.feijix.com/s/"; + private static final String API_URL_PREFIX = "https://api.feijipan.com/ws/"; + + private static final String FIRST_REQUEST_URL = API_URL_PREFIX + "recommend/list?devType=6&devModel=Chrome&extra" + + "=2&shareId={shareId}&type=0&offset=1&limit=60"; + + private static final String SECOND_REQUEST_URL = API_URL_PREFIX + "file/redirect?downloadId={fidEncode}&enable=1" + + "&devType=6&uuid={uuid}×tamp={ts}&auth={auth}"; + + public static Future parse(String data) { + String dataKey = CommonUtils.parseURL(SHARE_URL_PREFIX, data); + + Promise promise = Promise.promise(); + WebClient client = WebClient.create(VertxHolder.getVertxInstance(), + new WebClientOptions().setFollowRedirects(false)); + String shareId = String.valueOf(AESUtils.idEncrypt(dataKey)); + + // 第一次请求 获取文件信息 + // POST https://api.feijipan.com/ws/recommend/list?devType=6&devModel=Chrome&extra=2&shareId=146731&type=0&offset=1&limit=60 + client.postAbs(UriTemplate.of(FIRST_REQUEST_URL)).setTemplateParam("shareId", shareId).send().onSuccess(res -> { + JsonObject resJson = res.bodyAsJsonObject(); + if (resJson.getInteger("code") != 200) { + promise.fail(FIRST_REQUEST_URL + " 返回异常: " + resJson); + return; + } + if (resJson.getJsonArray("list").size() == 0) { + promise.fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson); + return; + } + // 文件Id + String fileId = resJson.getJsonArray("list").getJsonObject(0).getString("fileIds"); + // 其他参数 + long nowTs = System.currentTimeMillis(); + String tsEncode = AESUtils.encrypt2Hex(Long.toString(nowTs)); + String uuid = UUID.randomUUID().toString(); + String fidEncode = AESUtils.encrypt2Hex(fileId + "|"); + String auth = AESUtils.encrypt2Hex(fileId + "|" + nowTs); + // 第二次请求 + client.getAbs(UriTemplate.of(SECOND_REQUEST_URL)) + .setTemplateParam("fidEncode", fidEncode) + .setTemplateParam("uuid", uuid) + .setTemplateParam("ts", tsEncode) + .setTemplateParam("auth", auth).send().onSuccess(res2 -> { + MultiMap headers = res2.headers(); + if (!headers.contains("Location")) { + promise.fail(SECOND_REQUEST_URL + " 未找到重定向URL: \n" + res.headers()); + return; + } + promise.complete(headers.get("Location")); + }); + }); + + return promise.future(); + } +} diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java index 4a7f688..d49bcb3 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java @@ -16,7 +16,7 @@ import lombok.extern.slf4j.Slf4j; public class UcTool { private static final String API_URL_PREFIX = "https://pc-api.uc.cn/1/clouddrive/"; - public static final String FULL_URL_PREFIX = "https://fast.uc.cn/s/"; + public static final String SHARE_URL_PREFIX = "https://fast.uc.cn/s/"; private static final String FIRST_REQUEST_URL = API_URL_PREFIX + "share/sharepage/token?entry=ft&fr=pc&pr" + "=UCBrowser"; @@ -27,11 +27,8 @@ public class UcTool { private static final String THIRD_REQUEST_URL = API_URL_PREFIX + "file/download?entry=ft&fr=pc&pr=UCBrowser"; public static Future parse(String data, String code) { - if (!data.startsWith(FULL_URL_PREFIX)) { - data = FULL_URL_PREFIX + data; - } + var dataKey = CommonUtils.parseURL(SHARE_URL_PREFIX, data); var passcode = (code == null) ? "" : code; - var dataKey = data.substring(FULL_URL_PREFIX.length()); Promise promise = Promise.promise(); var client = WebClient.create(VertxHolder.getVertxInstance()); var jsonObject = JsonObject.of("share_for_transfer", true); diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/WoTools.java b/web-service/src/main/java/cn/qaiu/lz/common/util/WoTools.java deleted file mode 100644 index 6fcef6c..0000000 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/WoTools.java +++ /dev/null @@ -1,6 +0,0 @@ -package cn.qaiu.lz.common.util; - -public class WoTools { - - -} diff --git a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 9bd0b6b..9d39128 100644 --- a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -1,9 +1,6 @@ package cn.qaiu.lz.web.http; -import cn.qaiu.lz.common.util.CowTool; -import cn.qaiu.lz.common.util.EcTool; -import cn.qaiu.lz.common.util.LzTool; -import cn.qaiu.lz.common.util.UcTool; +import cn.qaiu.lz.common.util.*; import cn.qaiu.lz.web.model.SysUser; import cn.qaiu.lz.web.service.UserService; import cn.qaiu.vx.core.annotaions.RouteHandler; @@ -74,13 +71,20 @@ public class ServerApi { }).onFailure(t -> { promise.fail(t.fillInStackTrace()); }); - } else if (url.contains(UcTool.FULL_URL_PREFIX)) { + } else if (url.contains(UcTool.SHARE_URL_PREFIX)) { UcTool.parse(url, pwd).onSuccess(resUrl -> { response.putHeader("location", resUrl).setStatusCode(302).end(); promise.complete(); }).onFailure(t -> { promise.fail(t.fillInStackTrace()); }); + } else if (url.contains(FjTool.SHARE_URL_PREFIX)) { + FjTool.parse(url).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> { + promise.fail(t.fillInStackTrace()); + }); } return promise.future(); } @@ -155,4 +159,19 @@ public class ServerApi { } return UcTool.parse(id, code); } + + @RouteMapping(value = "/fj/:id", method = RouteMethod.GET) + public void fjParse(HttpServerResponse response, String id) { + FjTool.parse(id).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + }).onFailure(t -> { + response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); + response.end(t.getMessage()); + }); + } + + @RouteMapping(value = "/json/fj/:id", method = RouteMethod.GET) + public Future fjParseJson(HttpServerResponse response, String id) { + return FjTool.parse(id); + } } diff --git a/web-service/src/main/resources/http-tools/curl.sh b/web-service/src/main/resources/http-tools/curl.sh index 12c98d7..6a966ec 100644 --- a/web-service/src/main/resources/http-tools/curl.sh +++ b/web-service/src/main/resources/http-tools/curl.sh @@ -1,3 +1,3 @@ -curl -F "file=@C:\Users\qaiu\Desktop\real\lz-web\web\src\main\resources\logback.xml" -i -XPOST 127.0.0.1:8088/demo/basePointApi/importTags +curl -F "file=@C:\Users\qaiu\Desktop\real\lz-web\web\src\main\resources\logback.xml" -i -XPOST 127.0.0.1:6400/demo/XXX/XXX -curl -F "file=@C:\Users\qaiu\Desktop\3.csv" -i -XPOST 127.0.0.1:8088/demo/basePointApi/importTags +curl -F "file=@C:\Users\qaiu\Desktop\3.csv" -i -XPOST 127.0.0.1:6400/demo/XXX/XXX diff --git a/web-service/src/main/resources/http-tools/ecpan.http b/web-service/src/main/resources/http-tools/pan-ec.http similarity index 100% rename from web-service/src/main/resources/http-tools/ecpan.http rename to web-service/src/main/resources/http-tools/pan-ec.http diff --git a/web-service/src/main/resources/http-tools/pan-fj.http b/web-service/src/main/resources/http-tools/pan-fj.http index d37fa91..027f825 100644 --- a/web-service/src/main/resources/http-tools/pan-fj.http +++ b/web-service/src/main/resources/http-tools/pan-fj.http @@ -1,22 +1,40 @@ -### +# 飞机盘分享URL=https://www.feijix.com/s/7jy0zlv + +### step1 获取fid # devType: 6 # devModel: Chrome # uuid: M_S4dl58NrtLkHCxonmWc # extra: 2 # timestamp: C421C95B7A6E20745D98DD462118EEDA -# shareId: 146731 +# shareId: 146731 ==> decode(7jy0zlv) # type: 0 # offset: 1 # limit: 60 # @no-cookie-jar POST https://api.feijipan.com/ws/recommend/list?devType=6&devModel=Chrome&extra=2&shareId=146731&type=0&offset=1&limit=60 - -### -https://api.feijipan.com/ws/file/redirect?downloadId=4703B103BD6871F83441233393695EF3&enable=1&devType=6&uuid=z1PkRuW9of6Lg6_Y_NiNK×tamp=7FBE54506F49A38070E62936EA41D9B1&auth=159F4D596FC74050EACC77E2854CD2EDBF5F4A7B953DF72F95886E38F3DD9D3C - # 654488C79332E7279F9A38367BD72D3B # 4703B103BD6871F83441233393695EF3 +# https://web.feejii.com/files/2023/05/27/6/3975316/1459088526174041?filename=nginx-release-1.21.6.zip + +### step2 获取下载直链Location +# AES123-ECB-PKCS7 +# downloadId=fileIds| = 115206329| +# timestamp=1686215935703 B4C5B9833113ACA41F16AABADE17349C +# auth=115206329|1686215935703 = downloadId+timestamp + +https://api.feijipan.com/ws/file/redirect?downloadId=4703B103BD6871F83441233393695EF3&enable=1&devType=6&uuid=M_S4dl58NrtLkHCxonmWc×tamp=B4C5B9833113ACA41F16AABADE17349C&auth=159F4D596FC74050EACC77E2854CD2ED3805DDAAF2AEA1EFC67BD687D22F19E3 + +### +# @no-redirect +https://api.feijipan.com/ws/file/redirect?downloadId=4703B103BD6871F83441233393695EF3&enable=1&devType=6&uuid=M_S4dl58NrtLkHCxonmWc×tamp=B3C7DBF6101393344EABFE1EEEAF8F91&auth=A872D9EB60313B2648F7F4233B3417FC5C7C136982E51B0D128EA7AF4EDC48F0 +# Location: https://web.feejii.com/ee433d6e5102ad79af58a2aa0e6cf758/1686279412/files/2023/05/27/6/3975316/1459088526174041?filename=nginx-release-1.21.6.zip +# 11bc0a16dc31480812aa69bea1c20e2a ee433d6e5102ad79af58a2aa0e6cf758 + + +### 下载直链 +https://web.feejii.com/ee433d6e5102ad79af58a2aa0e6cf758/1686279412/files/2023/05/27/6/3975316/1459088526174041?filename=nginx-release-1.21.6.zip + + ### -https://api.feijipan.com/ws/file/redirect?downloadId=4703B103BD6871F83441233393695EF3&enable=1&devType=6&uuid=M_S4dl58NrtLkHCxonmWc×tamp=B4C5B9833113ACA41F16AABADE17349C&auth=159F4D596FC74050EACC77E2854CD2ED3805DDAAF2AEA1EFC67BD687D22F19E3 diff --git a/web-service/src/main/resources/http-tools/lz.http b/web-service/src/main/resources/http-tools/pan-lz.http similarity index 100% rename from web-service/src/main/resources/http-tools/lz.http rename to web-service/src/main/resources/http-tools/pan-lz.http diff --git a/web-service/src/main/resources/http-tools/test.http b/web-service/src/main/resources/http-tools/test.http index c371799..c2dc270 100644 --- a/web-service/src/main/resources/http-tools/test.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -93,9 +93,9 @@ Content-Type: application/json < ./request-form-data.json --WebAppBoundary-- -### +### https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare=1 # @no-redirect -GET http://127.0.0.1:6400/parser?url=https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare= +GET http://127.0.0.1:6400/parser?url=https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare=1 # https://www.ecpan.cn/drive/fileextoverrid.do?chainUrlTemplate=https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=aa0cae0164d8885e6d35826b5b2901eckbWJBalM&parentId=-1 ### @@ -127,3 +127,15 @@ action=downprocess&sign=AGYHOQk4BjdTWgQ7BzcGOlU_bATVSNQMxBDFQZgZoBj4HMFEgWnMOZ1I https://developer.lanzoug.com/file/?VDJbZVxtADFSWwY+U2YHa1FuU2tTYgBnBnUGZFNmWylSOVMpCTJQZQQhBSdQKQFkBjMOfAMyA21VPVs8V28BLVRkWyJcMAB6UjcGfVNlB29RZVN4U3YAawZxBiZTaVszUj5TYQkLUG0ENgVuUDUBMQZkDjsDbgMxVWBbZFc8ASZUMlt/XDwAZVIyBmFTNwc3UTtTYFM8ACQGcQZwUzJbaFJiUzYJZ1ArBGIFZlArATIGaQ4kAz8DMlVnWz9XMwE1VGZbOFw3AG1SPQY0UzcHMVFqUzdTbwBmBjEGMVNsW2NSM1MzCWxQNwRkBWVQNwEwBmQOPwNyA3tVO1stVy0BdVQnW2lccwA9UmAGbVM2BzZRPlNvUzgAOwY5BiZTe1szUj9TYQkyUDkEYwVjUDQBMAZsDiUDcgMnVTRbMVd8AT1UZVs6XDkAYVI0BmBTNQc/UTlTZVMqAHcGcQZ3UzJba1JkUzwJYVA0BGIFYVA0ATAGaw4tAykDaFUiW2BXOgExVGZbIlwzAGdSNgZ%2BUzYHMlE9U3hTOwA6 ### https://developer.lanzoug.com/file/?VTNVa1tqAjMFDAM7BDEAbAE+U2tfbgZhBnVbOQUwVCYEb1IoAToCNwQhVnRXLlcyVWAEdl9uVzkEbFYxVm5VeVVlVSxbNwJ4BWADeAQyAGgBNVN4X3oGbQZxW3sFP1Q8BGhSYAEDAj8ENlY9VzJXZ1U3BDFfMldlBDFWaVY9VXJVM1VxWzsCZwVlA2QEYAAwAWtTYF8wBiIGcVstBWRUZwQ0UjcBbwJ5BGJWNVcsV2RVOgQuX2NXZgQ2VjJWMlVhVWdVNlswAm8FagMxBGAANgE6UzdfYwZgBjFbbAU6VGwEZVIyAWQCZQRkVjZXMFdmVTcENV8uVy8EalYgVixVIVUmVWdbdAI/BTcDaARhADEBblNvXzQGPQY5W3sFLVQ8BGlSYAE6AmsEY1Y2VztXY1U/BDFfM1dnBDRWZFYkVXpVc1VkW2oCIQVuA2QEZgA5AW5TZl8wBjYGMFtkBWFUcwRxUnUBKwJrBGNWNlc7V2NVPwQxXzJXZQQzVmdWLFUhVTxVcls7AmcFYgNnBH4AMwFoU2RfLgY1BjVbawV3VGIEPA== + + +### +# @no-redirect +GET http://127.0.0.1:6400/parser?url=https://www.feijix.com/s/tIfhRqH + +### +GET http://127.0.0.1:6400/json/fj/tIfhRqH + +### +# @no-redirect +GET http://127.0.0.1:6400/fj/tIfhRqH diff --git a/web-service/src/test/java/cn/qaiu/web/test/TestAESUtil.java b/web-service/src/test/java/cn/qaiu/web/test/TestAESUtil.java new file mode 100644 index 0000000..60cdcff --- /dev/null +++ b/web-service/src/test/java/cn/qaiu/web/test/TestAESUtil.java @@ -0,0 +1,57 @@ +package cn.qaiu.web.test; + +import cn.qaiu.lz.common.util.AESUtils; +import org.junit.Assert; +import org.junit.Test; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.HexFormat; + +public class TestAESUtil { + + // 1686215935703 + // B4C5B9833113ACA41F16AABADE17349C + @Test + public void decode() throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, + BadPaddingException, InvalidKeyException { + String hex = AESUtils.encryptHexByAES("1686215935703", AESUtils.CIPHER_AES2); + Assert.assertEquals("B4C5B9833113ACA41F16AABADE17349C", hex.toUpperCase()); + } + + @Test + public void encode() throws IllegalBlockSizeException, NoSuchPaddingException, BadPaddingException, + NoSuchAlgorithmException, InvalidKeyException { + String source = AESUtils.decryptByHexAES("B4C5B9833113ACA41F16AABADE17349C", AESUtils.CIPHER_AES2); + Assert.assertEquals("1686215935703", source); + } + + @Test + public void toHex() { + byte[] d234EF67A1s = HexFormat.of().parseHex("D234EF67A1"); + Assert.assertArrayEquals(new byte[]{(byte) 0xd2, (byte) 0x34, (byte) 0xef, (byte) 0x67, (byte) 0xa1}, + d234EF67A1s); + } + + @Test + public void base64AES() throws NoSuchAlgorithmException { + System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_128_LENGTH).getEncoded())); + System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_192_LENGTH).getEncoded())); + System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_256_LENGTH).getEncoded())); + + // TODO Base64-AES + } + + @Test + public void testIdDecode() { + Assert.assertEquals(146731, AESUtils.idEncrypt("7jy0zlv")); + } + + @Test + public void testTs() { + System.out.println(System.currentTimeMillis()); + } +} From ea9d1067ede040b5f5ef66deb8196fecd015d243 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Sat, 10 Jun 2023 13:29:22 +0800 Subject: [PATCH 40/48] =?UTF-8?q?-=20=E5=8A=A0=E5=85=A5360=E4=BA=BF?= =?UTF-8?q?=E6=96=B9=E4=BA=91=E7=9B=B4=E9=93=BE=E8=A7=A3=E6=9E=90=20-=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 67 +++++++---- .../java/cn/qaiu/lz/common/util/FcTool.java | 105 ++++++++++++++++++ .../java/cn/qaiu/lz/common/util/LzTool.java | 2 + .../java/cn/qaiu/lz/web/http/ServerApi.java | 100 ++++++++++------- .../src/main/resources/http-tools/pan-fc.http | 26 ++++- .../src/main/resources/http-tools/test.http | 15 ++- .../test/java/cn/qaiu/web/test/TestRegex.java | 24 ++++ 7 files changed, 274 insertions(+), 65 deletions(-) create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/FcTool.java create mode 100644 web-service/src/test/java/cn/qaiu/web/test/TestRegex.java diff --git a/README.md b/README.md index 7a9c04d..ca146b0 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ - 小飞机网盘 (fj) - [ ] 登录, 上传, 下载, 分享 - [x] 直链解析 +- 亿方云 (fc) + - [ ] 登录, 上传, 下载, 分享 + - [x] 直链解析 - 文叔叔 (ws) - 夸克网盘 (qk) - TODO @@ -27,37 +30,51 @@ Jdk17+Vert.x4.4.1+Jsoup Core模块集成Vert.x实现类spring的注解式路由API API接口 -```shell -(括号内表示可选内容) +``` +括号内是可选内容: 表示当带有分享密码时需要加上密码参数 +parse接口加上参数pwd=密码;其他接口在分享Key后面加上$密码 + 1. 解析并自动302跳转 : - http(s)://you_host/parser?url=分享链接 - http(s)://you_host/网盘标识/分享id(#分享密码) + http(s)://you_host/parser?url=分享链接(&pwd=xxx) + http(s)://you_host/网盘标识/分享id($分享密码) 2. 获取解析后的直链--JSON格式 - http(s)://you_host/json/网盘标识/分享id(#分享密码) + http(s)://you_host/json/网盘标识/分享id($分享密码) 3. 有些网盘的加密分享的密码可以忽略: 如移动云空间,小飞机网盘 ``` -示例: +IDEA HttpClient示例: ``` -// 解析并重定向到直链 -### +# 解析并重定向到直链 +### 蓝奏云普通分享 # @no-redirect GET http://127.0.0.1:6400/parser?url=https://lanzoux.com/ia2cntg -### +### 奶牛快传普通分享 # @no-redirect GET http://127.0.0.1:6400/parser?url=https://cowtransfer.com/s/9a644fe3e3a748 +### 360亿方云加密分享 +# @no-redirect +GET http://127.0.0.1:6400/parser?url=https://v2.fangcloud.com/sharing/e5079007dc31226096628870c7&pwd=QAIU -// Rest请求(只提供共享文件Id): -### +# Rest请求自动302跳转(只提供共享文件Id): +### 蓝奏云普通分享 +# @no-redirect +GET http://127.0.0.1:6400/lz/ia2cntg +### 奶牛快传普通分享 # @no-redirect GET http://127.0.0.1:6400/cow/9a644fe3e3a748 +### 360亿方云加密分享 +GET http://127.0.0.1:6400/json/fc/e5079007dc31226096628870c7$QAIU -// 解析返回json直链 -### -GET http://127.0.0.1:6400/json/cow/9a644fe3e3a748 -### + +# 解析返回json直链 +### 蓝奏云普通分享 GET http://127.0.0.1:6400/json/lz/ia2cntg +### 奶牛快传普通分享 +GET http://127.0.0.1:6400/json/cow/9a644fe3e3a748 +### 360亿方云加密分享 +GET http://127.0.0.1:6400/json/fc/e5079007dc31226096628870c7$QAIU + ``` @@ -67,12 +84,16 @@ TODO: # 网盘对比 -| 网盘名称 | 可直接下载分享 | 加密分享 | 初始网盘空间 | 单文件大小限制 | 登录接口 | -|------------|---------|----------|----------|---------|------| -| 蓝奏云 | √ | √ | 不限空间 | 100M | TODO | -| 奶牛快传 | √ | X | 10G | 不限大小 | TODO | -| 移动云空间 | √ | √(密码可忽略) | 5G(个人) | 不限大小 | TODO | -| UC网盘 | √ | √ | 10G | 不限大小 | TODO | -| 小飞机网盘 | √ | √(密码可忽略) | 10G | 不限大小 | TODO | -| 夸克网盘(TODO) | 需要登录 | √ | 10G(20G) | 不限大小 | TODO | +| 网盘名称 | 可直接下载分享 | 加密分享 | 初始网盘空间 | 单文件大小限制 | 登录接口 | +|------------|------------|----------|-----------|---------|------| +| 蓝奏云 | √ | √ | 不限空间 | 100M | TODO | +| 奶牛快传 | √ | X | 10G | 不限大小 | TODO | +| 移动云空间 | √ | √(密码可忽略) | 5G(个人) | 不限大小 | TODO | +| UC网盘 | √ | √ | 10G | 不限大小 | TODO | +| 小飞机网盘 | √ | √(密码可忽略) | 10G | 不限大小 | TODO | +| 360亿方云 | √(注意有流量限制) | √(密码可忽略) | 100G(须实名) | 不限大小 | TODO | +| 文叔叔(TODO) | √(注意有时间限制) | √ | 10G | 不限大小 | TODO | +| 夸克网盘(TODO) | 需要登录 | √ | 10G(20G) | 不限大小 | TODO | +# 打包部署 +TODO diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/FcTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/FcTool.java new file mode 100644 index 0000000..452a824 --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/FcTool.java @@ -0,0 +1,105 @@ +package cn.qaiu.lz.common.util; + +import cn.qaiu.vx.core.util.VertxHolder; +import io.vertx.core.Future; +import io.vertx.core.MultiMap; +import io.vertx.core.Promise; +import io.vertx.core.Vertx; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.client.HttpResponse; +import io.vertx.ext.web.client.WebClient; +import io.vertx.ext.web.client.WebClientOptions; +import io.vertx.ext.web.client.WebClientSession; +import io.vertx.uritemplate.UriTemplate; +import org.apache.commons.lang3.StringUtils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 亿方云 + */ +public class FcTool { + + public static final String SHARE_URL_PREFIX = "https://v2.fangcloud.com/sharing/"; + public static final String SHARE_URL_PREFIX2 = "https://v2.fangcloud.cn/sharing/"; + private static final String DOWN_REQUEST_URL = "https://v2.fangcloud.cn/apps/files/download?file_id={fid}" + + "&scenario=share&unique_name={uname}"; + + public static Future parse(String data, String code) { + String dataKey = CommonUtils.parseURL(SHARE_URL_PREFIX, data); + + Promise promise = Promise.promise(); + + Vertx vertx = VertxHolder.getVertxInstance(); + WebClient client = WebClient.create(vertx); + WebClientSession sClient = WebClientSession.create(client); + // 第一次请求 自动重定向 + sClient.getAbs(SHARE_URL_PREFIX + dataKey).send().onSuccess(res -> { + + // 判断是否是加密分享 + if (StringUtils.isNotEmpty(code)) { + // 获取requesttoken + String html = res.bodyAsString(); + Pattern compile = Pattern.compile("name=\"requesttoken\"\\s+value=\"([a-zA-Z0-9_+=]+)\""); + Matcher matcher = compile.matcher(html); + if (!matcher.find()) { + promise.fail(SHARE_URL_PREFIX + " 未匹配到加密分享的密码输入页面的requesttoken: \n" + html); + return; + } + String token = matcher.group(1); + + sClient.postAbs(SHARE_URL_PREFIX2 + dataKey).sendForm(MultiMap.caseInsensitiveMultiMap() + .set("requesttoken", token) + .set("password", code)).onSuccess(res2 -> { + if (res2.statusCode() == 302) { + sClient.getAbs(res2.getHeader("Location")).send().onSuccess(res3 -> { + getDownURL(dataKey, promise, res3, sClient); + }); + } else { + promise.fail(SHARE_URL_PREFIX + " 密码跳转后获取重定向失败 \n" + html); + } + }); + return; + } + getDownURL(dataKey, promise, res, sClient); + }); + return promise.future(); + } + + private static void getDownURL(String dataKey, Promise promise, HttpResponse res, + WebClientSession sClient) { + // 从HTML中找到文件id + String html = res.bodyAsString(); + Pattern compile = Pattern.compile("id=\"typed_id\"\\s+value=\"file_(\\d+)\""); + Matcher matcher = compile.matcher(html); + if (!matcher.find()) { + promise.fail(SHARE_URL_PREFIX + " 未匹配到文件id(typed_id): \n" + html); + return; + } + String fid = matcher.group(1); + + // 创建一个不自动重定向的WebClientSession + WebClient clientNoRedirects = WebClient.create(VertxHolder.getVertxInstance(), + new WebClientOptions().setFollowRedirects(false)); + WebClientSession sClientNoRedirects = WebClientSession.create(clientNoRedirects, sClient.cookieStore()); + // 第二次请求 + sClientNoRedirects.getAbs(UriTemplate.of(DOWN_REQUEST_URL)) + .setTemplateParam("fid", fid) + .setTemplateParam("unique_name", dataKey).send().onSuccess(res2 -> { + JsonObject resJson; + try { + resJson = res2.bodyAsJsonObject(); + } catch (Exception e) { + promise.fail(DOWN_REQUEST_URL + " 第二次请求没有返回JSON, 可能下载受限: " + res2.bodyAsString()); + return; + } + if (!resJson.getBoolean("success")) { + promise.fail(DOWN_REQUEST_URL + " 第二次请求未得到正确相应: " + resJson); + return; + } + promise.complete(resJson.getString("download_url")); + }); + } +} diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java index 497a971..edb7b32 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -3,6 +3,7 @@ package cn.qaiu.lz.common.util; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; import java.io.IOException; import java.util.HashMap; @@ -90,6 +91,7 @@ public class LzTool { .headers(); //得到重定向的地址进行重定向 url = headers.get("Location"); + return url; } } diff --git a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 9d39128..c926779 100644 --- a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -42,8 +42,30 @@ public class ServerApi { @RouteMapping(value = "/parser", method = RouteMethod.GET) public Future parse(HttpServerResponse response, HttpServerRequest request, String url, String pwd) { Promise promise = Promise.promise(); - if (url.contains("lanzou")) { - String urlDownload = null; + if (url.contains(EcTool.EC_HOST)) { + // 默认读取Url参数会被截断手动获取一下其他参数 + String data = request.getParam("data"); + EcTool.parse(data).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> promise.fail(t.fillInStackTrace())); + } else if (url.contains(UcTool.SHARE_URL_PREFIX)) { + UcTool.parse(url, pwd).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> promise.fail(t.fillInStackTrace())); + } else if (url.contains(FjTool.SHARE_URL_PREFIX)) { + FjTool.parse(url).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> promise.fail(t.fillInStackTrace())); + } else if (url.contains(FcTool.SHARE_URL_PREFIX)) { + FcTool.parse(url, pwd).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> promise.fail(t.fillInStackTrace())); + } else if (url.contains("lanzou")) { + String urlDownload; try { urlDownload = LzTool.parse(url); log.info("url = {}", urlDownload); @@ -53,7 +75,7 @@ public class ServerApi { promise.fail(e); } } else if (url.contains("cowtransfer.com")) { - String urlDownload = null; + String urlDownload; try { urlDownload = CowTool.parse(url); response.putHeader("location", urlDownload).setStatusCode(302).end(); @@ -62,29 +84,6 @@ public class ServerApi { promise.fail(e); } - } else if (url.contains(EcTool.EC_HOST)) { - // 默认读取Url参数会被截断手动获取一下其他参数 - String data = request.getParam("data"); - EcTool.parse(data).onSuccess(resUrl -> { - response.putHeader("location", resUrl).setStatusCode(302).end(); - promise.complete(); - }).onFailure(t -> { - promise.fail(t.fillInStackTrace()); - }); - } else if (url.contains(UcTool.SHARE_URL_PREFIX)) { - UcTool.parse(url, pwd).onSuccess(resUrl -> { - response.putHeader("location", resUrl).setStatusCode(302).end(); - promise.complete(); - }).onFailure(t -> { - promise.fail(t.fillInStackTrace()); - }); - } else if (url.contains(FjTool.SHARE_URL_PREFIX)) { - FjTool.parse(url).onSuccess(resUrl -> { - response.putHeader("location", resUrl).setStatusCode(302).end(); - promise.complete(); - }).onFailure(t -> { - promise.fail(t.fillInStackTrace()); - }); } return promise.future(); } @@ -120,9 +119,8 @@ public class ServerApi { @RouteMapping(value = "/ec/:id", method = RouteMethod.GET) public void ecParse(HttpServerResponse response, String id) { - EcTool.parse(id).onSuccess(resUrl -> { - response.putHeader("location", resUrl).setStatusCode(302).end(); - }).onFailure(t -> { + EcTool.parse(id).onSuccess(resUrl -> response.putHeader("location", resUrl) + .setStatusCode(302).end()).onFailure(t -> { response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); response.end(t.getMessage()); }); @@ -136,14 +134,13 @@ public class ServerApi { @RouteMapping(value = "/uc/:id", method = RouteMethod.GET) public void ucParse(HttpServerResponse response, String id) { String code = ""; - if (id.contains("#")) { - String[] ids = id.split("#"); + if (id.contains("$")) { + String[] ids = id.split("\\$"); id = ids[0]; code = ids[1]; } - UcTool.parse(id, code).onSuccess(resUrl -> { - response.putHeader("location", resUrl).setStatusCode(302).end(); - }).onFailure(t -> { + UcTool.parse(id, code).onSuccess(resUrl -> response.putHeader("location", resUrl) + .setStatusCode(302).end()).onFailure(t -> { response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); response.end(t.getMessage()); }); @@ -152,8 +149,8 @@ public class ServerApi { @RouteMapping(value = "/json/uc/:id", method = RouteMethod.GET) public Future ucParseJson(String id) { String code = ""; - if (id.contains("#")) { - String[] ids = id.split("#"); + if (id.contains("$")) { + String[] ids = id.split("\\$"); id = ids[0]; code = ids[1]; } @@ -162,9 +159,8 @@ public class ServerApi { @RouteMapping(value = "/fj/:id", method = RouteMethod.GET) public void fjParse(HttpServerResponse response, String id) { - FjTool.parse(id).onSuccess(resUrl -> { - response.putHeader("location", resUrl).setStatusCode(302).end(); - }).onFailure(t -> { + FjTool.parse(id).onSuccess(resUrl -> response.putHeader("location", resUrl) + .setStatusCode(302).end()).onFailure(t -> { response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); response.end(t.getMessage()); }); @@ -174,4 +170,30 @@ public class ServerApi { public Future fjParseJson(HttpServerResponse response, String id) { return FjTool.parse(id); } + + @RouteMapping(value = "/fc/:id", method = RouteMethod.GET) + public void fcParse(HttpServerResponse response, String id) { + String code = ""; + if (id.contains("$")) { + String[] ids = id.split("\\$"); + id = ids[0]; + code = ids[1]; + } + FcTool.parse(id, code).onSuccess(resUrl -> response.putHeader("location", resUrl) + .setStatusCode(302).end()).onFailure(t -> { + response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); + response.end(t.getMessage()); + }); + } + + @RouteMapping(value = "/json/fc/:id", method = RouteMethod.GET) + public Future fcParseJson(HttpServerResponse response, String id) { + String code = ""; + if (id.contains("$")) { + String[] ids = id.split("\\$"); + id = ids[0]; + code = ids[1]; + } + return FcTool.parse(id, code); + } } diff --git a/web-service/src/main/resources/http-tools/pan-fc.http b/web-service/src/main/resources/http-tools/pan-fc.http index 3029de5..99c10b7 100644 --- a/web-service/src/main/resources/http-tools/pan-fc.http +++ b/web-service/src/main/resources/http-tools/pan-fc.http @@ -8,7 +8,7 @@ https://share-d94258c2ebfde2a83a7d5931e8da5221.fangcloud.cn/share/9cbe4b73521ba4 ### cookie: fc_session=xxx 获取file_id # @no-cookie-jar https://share-d94258c2ebfde2a83a7d5931e8da5221.fangcloud.cn/apps/files/get_info?scenario=share&item_typed_id=file_559003251828 -Cookie:fc_session=eyJpdiI6Im9hQ0Njc1pKczNsaDl4Z2pubHRDVnc9PSIsInZhbHVlIjoieDAwRUc4NkNMSHZkMzZsVzVwWGJKd0M2dFNKcEM5elpsWFZONURRYkFqTm9maDN6aXpsMWNwR0ZydXliSDBENE1Cclh2SzNyNXNmS2ttOHBKakxzSVE9PSIsIm1hYyI6IjRkNzg5ZDQwOTIzOGRiZDYyNjg2ZDE3ZDgzZDg2OWViNWRmNGIwZDFjNjQ0ODdkYTc0MjljZjI1YzU5NDY4ZGQifQ%3D%3D +Cookie:fc_session=eyJpdiI6IndQYzJoVkdQWjhJSmNOYVIwZnpiTVE9PSIsInZhbHVlIjoiUThocXBGcHA3MXN0SHZYV3R1a282djlpWEl0YmlxMzE2SUpFUjZQbFwvMytoU0NjNXRVbm10ejg0b1wvaVpSZXJaUVRIeTV2NmlvUDZlMlJsRnEyRTY1Zz09IiwibWFjIjoiNGM2NTFkN2Q2NTI3ZWUwOTc2ZmY1ODUzODEzYWRkZjIyNjg0ZGM1NDhhZDg1NjU1NzRkNjZiZWFjOGYyOWYxZiJ9 #{ # "success": true @@ -20,6 +20,28 @@ Cookie:fc_session=eyJpdiI6Im9hQ0Njc1pKczNsaDl4Z2pubHRDVnc9PSIsInZhbHVlIjoieDAwRU # @no-redirect # @no-cookie-jar https://share-d94258c2ebfde2a83a7d5931e8da5221.fangcloud.cn/apps/files/download?file_id=559003251828&scenario=share&unique_name=9cbe4b73521ba4d65a8cd38a8c -Cookie:fc_session=eyJpdiI6Im9hQ0Njc1pKczNsaDl4Z2pubHRDVnc9PSIsInZhbHVlIjoieDAwRUc4NkNMSHZkMzZsVzVwWGJKd0M2dFNKcEM5elpsWFZONURRYkFqTm9maDN6aXpsMWNwR0ZydXliSDBENE1Cclh2SzNyNXNmS2ttOHBKakxzSVE9PSIsIm1hYyI6IjRkNzg5ZDQwOTIzOGRiZDYyNjg2ZDE3ZDgzZDg2OWViNWRmNGIwZDFjNjQ0ODdkYTc0MjljZjI1YzU5NDY4ZGQifQ%3D%3D +Cookie:fc_session=eyJpdiI6IndQYzJoVkdQWjhJSmNOYVIwZnpiTVE9PSIsInZhbHVlIjoiUThocXBGcHA3MXN0SHZYV3R1a282djlpWEl0YmlxMzE2SUpFUjZQbFwvMytoU0NjNXRVbm10ejg0b1wvaVpSZXJaUVRIeTV2NmlvUDZlMlJsRnEyRTY1Zz09IiwibWFjIjoiNGM2NTFkN2Q2NTI3ZWUwOTc2ZmY1ODUzODEzYWRkZjIyNjg0ZGM1NDhhZDg1NjU1NzRkNjZiZWFjOGYyOWYxZiJ9 + +### 加密分享 +# @no-redirect +https://v2.fangcloud.cn/share/e5079007dc31226096628870c7 + +### 加密分享 +# @no-redirect +# @no-cookie-jar +POST https://v2.fangcloud.cn/share/e5079007dc31226096628870c7 +Content-Type: application/x-www-form-urlencoded +Cookie:XSRF-TOKEN=eyJpdiI6IkQ2TlNTOEtBRHZkUWZsVFErcVNPTkE9PSIsInZhbHVlIjoiZXJYUlZVcU94WjlMaThQcU5lU1dHRGJ4TkljVFJYOVpaS0xRS3JldHlBdlwvc3RSakphR1dZK015VkxzbWlBZU5yZFdmaW1yVnk0bWJ6dGhsWEk2b0F3PT0iLCJtYWMiOiIxODI1OGY5NDkwYmY3ZmJhZjMzNDliNTNiNjgxZTM2MTQ2ODhiMGIyNjU3MjQxYzdkNjZkYWMyM2EyMGRjZDg5In0%3D; fc_session=eyJpdiI6IlppZW1UQVwvSHRWSDhVZWZwampkNHZRPT0iLCJ2YWx1ZSI6IjliWlBUZ0VPMlhoTXlUN3hXU25qYjlIdnRQRmtqbFdBR2cyaW1RVDdBN0s5OFRwcGFURjZ3TTZxZnQ4VVRGS2hNbWdPUFhrU0tlUTg1ZTJLZVZFS0FnPT0iLCJtYWMiOiJjMTM0YjI5ZTEwYjQwMGU0MGNlN2UyZmM4MWM2NzAyZmZhYjg5NWNlMjc3ODRhMmIzMzhmODg5ZTZlNzcyMGM2In0%3D; __DC_monitor_count=1; __DC_sid=265210824.1779672371747793700.1686368845992.5159; __guid=265210824.1677826520974775000.1686368845996.6543; device_token=5c99442e32e7b8e5edecd4221f992b41; Hm_lvt_762d2bc251bef4b42a758268dc7edda3=1686367033; Hm_lpvt_762d2bc251bef4b42a758268dc7edda3=1686368846; __DC_gid=265210824.275572345.1686368845996.1686368883043.2 +Host:v2.fangcloud.cn +Referer:https://v2.fangcloud.cn/share/e5079007dc31226096628870c7 +User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.37 + +requesttoken=se2GpxdjP9zU4rajy1ro3vZ8x0nYE64KdTzgOUtG&password=QAIU + +### +# @no-redirect +# @no-cookie-jar +https://v2.fangcloud.cn/share/e5079007dc31226096628870c7 +Cookie:XSRF-TOKEN=eyJpdiI6ImVpdW9XOFwvazVka0xRQ2JUQ1p4c1dRPT0iLCJ2YWx1ZSI6Im1NcTJuQW8xdlF4MEg1XC9NZERZUnE4TUgxNm9UYWhoV3pKMlhKcngwakMxR2VHeTFZZ0EzSlBcL244YXlRTWtKZ3NOd1JxYTl4ZktsdXdcL0t5dVlTMXhnPT0iLCJtYWMiOiJhMjZlODE3NDFlMTRkMjg1MzVhMjRjOGVmYTgzYjk1NGM1NmY1N2NmZjljZmIzMmRjZGFmOTVkNDhhMWYwMDRhIn0%3D; fc_session=eyJpdiI6IlppZW1UQVwvSHRWSDhVZWZwampkNHZRPT0iLCJ2YWx1ZSI6IjliWlBUZ0VPMlhoTXlUN3hXU25qYjlIdnRQRmtqbFdBR2cyaW1RVDdBN0s5OFRwcGFURjZ3TTZxZnQ4VVRGS2hNbWdPUFhrU0tlUTg1ZTJLZVZFS0FnPT0iLCJtYWMiOiJjMTM0YjI5ZTEwYjQwMGU0MGNlN2UyZmM4MWM2NzAyZmZhYjg5NWNlMjc3ODRhMmIzMzhmODg5ZTZlNzcyMGM2In0%3D; diff --git a/web-service/src/main/resources/http-tools/test.http b/web-service/src/main/resources/http-tools/test.http index c2dc270..83bd18d 100644 --- a/web-service/src/main/resources/http-tools/test.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -129,7 +129,7 @@ https://developer.lanzoug.com/file/?VDJbZVxtADFSWwY+U2YHa1FuU2tTYgBnBnUGZFNmWylS https://developer.lanzoug.com/file/?VTNVa1tqAjMFDAM7BDEAbAE+U2tfbgZhBnVbOQUwVCYEb1IoAToCNwQhVnRXLlcyVWAEdl9uVzkEbFYxVm5VeVVlVSxbNwJ4BWADeAQyAGgBNVN4X3oGbQZxW3sFP1Q8BGhSYAEDAj8ENlY9VzJXZ1U3BDFfMldlBDFWaVY9VXJVM1VxWzsCZwVlA2QEYAAwAWtTYF8wBiIGcVstBWRUZwQ0UjcBbwJ5BGJWNVcsV2RVOgQuX2NXZgQ2VjJWMlVhVWdVNlswAm8FagMxBGAANgE6UzdfYwZgBjFbbAU6VGwEZVIyAWQCZQRkVjZXMFdmVTcENV8uVy8EalYgVixVIVUmVWdbdAI/BTcDaARhADEBblNvXzQGPQY5W3sFLVQ8BGlSYAE6AmsEY1Y2VztXY1U/BDFfM1dnBDRWZFYkVXpVc1VkW2oCIQVuA2QEZgA5AW5TZl8wBjYGMFtkBWFUcwRxUnUBKwJrBGNWNlc7V2NVPwQxXzJXZQQzVmdWLFUhVTxVcls7AmcFYgNnBH4AMwFoU2RfLgY1BjVbawV3VGIEPA== -### +### 小飞机盘 # @no-redirect GET http://127.0.0.1:6400/parser?url=https://www.feijix.com/s/tIfhRqH @@ -139,3 +139,16 @@ GET http://127.0.0.1:6400/json/fj/tIfhRqH ### # @no-redirect GET http://127.0.0.1:6400/fj/tIfhRqH + +### 360亿方云 +# @no-redirect +GET http://127.0.0.1:6400/parser?url=https://v2.fangcloud.com/sharing/e5079007dc31226096628870c7&pwd=QAIU + +### +GET http://127.0.0.1:6400/json/fc/30646fefc8bf936a4766ab8a5e + +### +# @no-redirect +GET http://127.0.0.1:6400/fc/e5079007dc31226096628870c7$QAIU + +#https://v2.fangcloud.com/sharing/e5079007dc31226096628870c7 diff --git a/web-service/src/test/java/cn/qaiu/web/test/TestRegex.java b/web-service/src/test/java/cn/qaiu/web/test/TestRegex.java new file mode 100644 index 0000000..28beaae --- /dev/null +++ b/web-service/src/test/java/cn/qaiu/web/test/TestRegex.java @@ -0,0 +1,24 @@ +package cn.qaiu.web.test; + +import org.junit.Test; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class TestRegex { + + @Test + public void regexYFC() { + String html = """ + + + """; + + Pattern compile = Pattern.compile("id=\"typed_id\"\\s+value=\"file_(\\d+)\""); + Matcher matcher = compile.matcher(html); + if (matcher.find()) { + System.out.println(matcher.group(0)); + System.out.println(matcher.group(1)); + } + } +} From f2280c8e86089b88ddeaf50d28144fcd08c41d3c Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Sat, 10 Jun 2023 13:34:01 +0800 Subject: [PATCH 41/48] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=88=86=E9=9A=94=E7=AC=A6$->@?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++----- .../main/java/cn/qaiu/lz/web/http/ServerApi.java | 16 ++++++++-------- .../src/main/resources/http-tools/test.http | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ca146b0..aabbcc0 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,13 @@ Core模块集成Vert.x实现类spring的注解式路由API API接口 ``` 括号内是可选内容: 表示当带有分享密码时需要加上密码参数 -parse接口加上参数pwd=密码;其他接口在分享Key后面加上$密码 +parse接口加上参数pwd=密码;其他接口在分享Key后面加上@密码 1. 解析并自动302跳转 : http(s)://you_host/parser?url=分享链接(&pwd=xxx) - http(s)://you_host/网盘标识/分享id($分享密码) + http(s)://you_host/网盘标识/分享id(@分享密码) 2. 获取解析后的直链--JSON格式 - http(s)://you_host/json/网盘标识/分享id($分享密码) + http(s)://you_host/json/网盘标识/分享id(@分享密码) 3. 有些网盘的加密分享的密码可以忽略: 如移动云空间,小飞机网盘 ``` @@ -64,7 +64,7 @@ GET http://127.0.0.1:6400/lz/ia2cntg # @no-redirect GET http://127.0.0.1:6400/cow/9a644fe3e3a748 ### 360亿方云加密分享 -GET http://127.0.0.1:6400/json/fc/e5079007dc31226096628870c7$QAIU +GET http://127.0.0.1:6400/json/fc/e5079007dc31226096628870c7@QAIU # 解析返回json直链 @@ -73,7 +73,7 @@ GET http://127.0.0.1:6400/json/lz/ia2cntg ### 奶牛快传普通分享 GET http://127.0.0.1:6400/json/cow/9a644fe3e3a748 ### 360亿方云加密分享 -GET http://127.0.0.1:6400/json/fc/e5079007dc31226096628870c7$QAIU +GET http://127.0.0.1:6400/json/fc/e5079007dc31226096628870c7@QAIU ``` diff --git a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index c926779..81848f6 100644 --- a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -134,8 +134,8 @@ public class ServerApi { @RouteMapping(value = "/uc/:id", method = RouteMethod.GET) public void ucParse(HttpServerResponse response, String id) { String code = ""; - if (id.contains("$")) { - String[] ids = id.split("\\$"); + if (id.contains("@")) { + String[] ids = id.split("@"); id = ids[0]; code = ids[1]; } @@ -149,8 +149,8 @@ public class ServerApi { @RouteMapping(value = "/json/uc/:id", method = RouteMethod.GET) public Future ucParseJson(String id) { String code = ""; - if (id.contains("$")) { - String[] ids = id.split("\\$"); + if (id.contains("@")) { + String[] ids = id.split("@"); id = ids[0]; code = ids[1]; } @@ -174,8 +174,8 @@ public class ServerApi { @RouteMapping(value = "/fc/:id", method = RouteMethod.GET) public void fcParse(HttpServerResponse response, String id) { String code = ""; - if (id.contains("$")) { - String[] ids = id.split("\\$"); + if (id.contains("@")) { + String[] ids = id.split("@"); id = ids[0]; code = ids[1]; } @@ -189,8 +189,8 @@ public class ServerApi { @RouteMapping(value = "/json/fc/:id", method = RouteMethod.GET) public Future fcParseJson(HttpServerResponse response, String id) { String code = ""; - if (id.contains("$")) { - String[] ids = id.split("\\$"); + if (id.contains("@")) { + String[] ids = id.split("@"); id = ids[0]; code = ids[1]; } diff --git a/web-service/src/main/resources/http-tools/test.http b/web-service/src/main/resources/http-tools/test.http index 83bd18d..2e861e7 100644 --- a/web-service/src/main/resources/http-tools/test.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -149,6 +149,6 @@ GET http://127.0.0.1:6400/json/fc/30646fefc8bf936a4766ab8a5e ### # @no-redirect -GET http://127.0.0.1:6400/fc/e5079007dc31226096628870c7$QAIU +GET http://127.0.0.1:6400/fc/e5079007dc31226096628870c7@QAIU #https://v2.fangcloud.com/sharing/e5079007dc31226096628870c7 From e9ed8715af46d0d6a8246d665c019fca5ebe742a Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Sat, 10 Jun 2023 16:31:17 +0800 Subject: [PATCH 42/48] =?UTF-8?q?=E6=B7=BB=E5=8A=A0123=E4=BA=91=E7=9B=98?= =?UTF-8?q?=E7=9B=B4=E9=93=BE=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/qaiu/lz/common/util/CommonUtils.java | 29 ++++- .../java/cn/qaiu/lz/common/util/FcTool.java | 2 +- .../java/cn/qaiu/lz/common/util/FjTool.java | 2 +- .../java/cn/qaiu/lz/common/util/UcTool.java | 2 +- .../java/cn/qaiu/lz/common/util/YeTool.java | 102 ++++++++++++++++++ .../java/cn/qaiu/lz/web/http/ServerApi.java | 31 ++++++ .../src/main/resources/http-tools/pan-ye.http | 84 +++++++++++++++ .../src/main/resources/http-tools/test.http | 11 ++ 8 files changed, 259 insertions(+), 4 deletions(-) create mode 100644 web-service/src/main/java/cn/qaiu/lz/common/util/YeTool.java create mode 100644 web-service/src/main/resources/http-tools/pan-ye.http diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java b/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java index 78f5f46..8c855cd 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java @@ -1,11 +1,38 @@ package cn.qaiu.lz.common.util; +import java.net.MalformedURLException; +import java.net.URL; +import java.text.ParseException; +import java.util.HashMap; +import java.util.Map; + public class CommonUtils { - public static String parseURL(String urlPrefix, String url) { + public static String adaptShortPaths(String urlPrefix, String url) { if (!url.startsWith(urlPrefix)) { url = urlPrefix + url; } + if (url.endsWith(".html")) { + url = url.substring(0, url.length() - 5); + } return url.substring(urlPrefix.length()); } + + public static Map getURLParams(String url) throws MalformedURLException { + URL fullUrl = new URL(url); + String query = fullUrl.getQuery(); + String[] params = query.split("&"); + Map map = new HashMap<>(); + for (String param : params) { + if (!param.contains("=")) { + throw new RuntimeException("解析URL异常: 匹配不到参数中的="); + } + int endIndex = param.indexOf('='); + String key = param.substring(0, endIndex); + String value = param.substring(endIndex + 1); + map.put(key, value); + } + return map; + } + } diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/FcTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/FcTool.java index 452a824..24ddf59 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/FcTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/FcTool.java @@ -28,7 +28,7 @@ public class FcTool { "&scenario=share&unique_name={uname}"; public static Future parse(String data, String code) { - String dataKey = CommonUtils.parseURL(SHARE_URL_PREFIX, data); + String dataKey = CommonUtils.adaptShortPaths(SHARE_URL_PREFIX, data); Promise promise = Promise.promise(); diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/FjTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/FjTool.java index 34b00f6..577862a 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/FjTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/FjTool.java @@ -28,7 +28,7 @@ public class FjTool { "&devType=6&uuid={uuid}×tamp={ts}&auth={auth}"; public static Future parse(String data) { - String dataKey = CommonUtils.parseURL(SHARE_URL_PREFIX, data); + String dataKey = CommonUtils.adaptShortPaths(SHARE_URL_PREFIX, data); Promise promise = Promise.promise(); WebClient client = WebClient.create(VertxHolder.getVertxInstance(), diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java index d49bcb3..6adfda7 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/UcTool.java @@ -27,7 +27,7 @@ public class UcTool { private static final String THIRD_REQUEST_URL = API_URL_PREFIX + "file/download?entry=ft&fr=pc&pr=UCBrowser"; public static Future parse(String data, String code) { - var dataKey = CommonUtils.parseURL(SHARE_URL_PREFIX, data); + var dataKey = CommonUtils.adaptShortPaths(SHARE_URL_PREFIX, data); var passcode = (code == null) ? "" : code; Promise promise = Promise.promise(); var client = WebClient.create(VertxHolder.getVertxInstance()); diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/YeTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/YeTool.java new file mode 100644 index 0000000..e212a08 --- /dev/null +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/YeTool.java @@ -0,0 +1,102 @@ +package cn.qaiu.lz.common.util; + +import cn.qaiu.vx.core.util.VertxHolder; +import io.vertx.core.Future; +import io.vertx.core.Promise; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.client.WebClient; +import io.vertx.uritemplate.UriTemplate; +import org.apache.commons.lang3.StringUtils; + +import java.net.MalformedURLException; +import java.util.Base64; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 123网盘 + */ +public class YeTool { + public static final String SHARE_URL_PREFIX = "https://www.123pan.com/s/"; + public static final String FIRST_REQUEST_URL = SHARE_URL_PREFIX + "{key}.html"; + private static final String GET_FILE_INFO_URL = "https://www.123pan.com/a/api/share/get?limit=100&next=1&orderBy" + + "=file_name&orderDirection=asc&shareKey={shareKey}&SharePwd={pwd}&ParentFileId=0&Page=1&event" + + "=homeListFile&operateType=1"; + + public static Future parse(String data, String code) { + + String dataKey = CommonUtils.adaptShortPaths(SHARE_URL_PREFIX, data); + Promise promise = Promise.promise(); + WebClient client = WebClient.create(VertxHolder.getVertxInstance()); + + client.getAbs(UriTemplate.of(FIRST_REQUEST_URL)).setTemplateParam("key", dataKey).send().onSuccess(res -> { + + String html = res.bodyAsString(); + Pattern compile = Pattern.compile("window.g_initialProps\\s*=\\s*(.*);"); + Matcher matcher = compile.matcher(html); + + if (!matcher.find()) { + System.out.println("err"); + return; + } + String fileInfoString = matcher.group(1); + JsonObject fileInfoJson = new JsonObject(fileInfoString); + JsonObject resJson = fileInfoJson.getJsonObject("res"); + JsonObject resListJson = fileInfoJson.getJsonObject("reslist"); + + if (resJson == null || resJson.getInteger("code") != 0) { + promise.fail(dataKey + " 解析到异常JSON: "+resJson); + return; + } + String shareKey = resJson.getJsonObject("data").getString("ShareKey"); + if (resListJson == null || resListJson.getInteger("code") != 0) { + // 加密分享 + if (StringUtils.isNotEmpty(code)) { + client.getAbs(UriTemplate.of(GET_FILE_INFO_URL)) + .setTemplateParam("shareKey", shareKey) + .setTemplateParam("pwd", code) + .send().onSuccess(res2 -> { + JsonObject infoJson = res2.bodyAsJsonObject(); + if (infoJson.getInteger("code") != 0) { + return; + } + JsonObject getFileInfoJson = + infoJson.getJsonObject("data").getJsonArray("InfoList").getJsonObject(0); + getFileInfoJson.put("ShareKey", shareKey); + getDownUrl(promise, client, getFileInfoJson); + }); + } else { + promise.fail(dataKey + " 该分享需要密码"); + } + return; + } + + JsonObject reqBodyJson = resListJson.getJsonObject("data").getJsonArray("InfoList").getJsonObject(0); + reqBodyJson.put("ShareKey", shareKey); + getDownUrl(promise, client, reqBodyJson); + }); + + return promise.future(); + } + + private static void getDownUrl(Promise promise, WebClient client, JsonObject reqBodyJson) { + System.out.println(reqBodyJson); + client.postAbs("https://www.123pan.com/a/api/share/download/info").sendJsonObject(reqBodyJson).onSuccess(res2 -> { + JsonObject downURLJson = res2.bodyAsJsonObject(); + System.out.println(downURLJson); + if (downURLJson.getInteger("code") != 0) { + return; + } + String downURL = downURLJson.getJsonObject("data").getString("DownloadURL"); + try { + Map urlParams = CommonUtils.getURLParams(downURL); + String params = urlParams.get("params"); + byte[] decodeByte = Base64.getDecoder().decode(params); + promise.complete(new String(decodeByte)); + } catch (MalformedURLException e) { + promise.fail("urlParams解析异常" + e.getMessage()); + } + }); + } +} diff --git a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 81848f6..74d3215 100644 --- a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -64,6 +64,11 @@ public class ServerApi { response.putHeader("location", resUrl).setStatusCode(302).end(); promise.complete(); }).onFailure(t -> promise.fail(t.fillInStackTrace())); + } else if (url.contains(YeTool.SHARE_URL_PREFIX)) { + YeTool.parse(url, pwd).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> promise.fail(t.fillInStackTrace())); } else if (url.contains("lanzou")) { String urlDownload; try { @@ -196,4 +201,30 @@ public class ServerApi { } return FcTool.parse(id, code); } + + @RouteMapping(value = "/ye/:id", method = RouteMethod.GET) + public void YeParse(HttpServerResponse response, String id) { + String code = ""; + if (id.contains("@")) { + String[] ids = id.split("@"); + id = ids[0]; + code = ids[1]; + } + YeTool.parse(id, code).onSuccess(resUrl -> response.putHeader("location", resUrl) + .setStatusCode(302).end()).onFailure(t -> { + response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); + response.end(t.getMessage()); + }); + } + + @RouteMapping(value = "/json/ye/:id", method = RouteMethod.GET) + public Future YeParseJson(HttpServerResponse response, String id) { + String code = ""; + if (id.contains("@")) { + String[] ids = id.split("@"); + id = ids[0]; + code = ids[1]; + } + return YeTool.parse(id, code); + } } diff --git a/web-service/src/main/resources/http-tools/pan-ye.http b/web-service/src/main/resources/http-tools/pan-ye.http new file mode 100644 index 0000000..89d71f5 --- /dev/null +++ b/web-service/src/main/resources/http-tools/pan-ye.http @@ -0,0 +1,84 @@ +### 123网盘 +# auto_redirect 0 +# filename libc++_shared.so +# r L7PQ1A +# s 16864619537565b1bbecb509ef377f6e8487a6a99b +# t 1686461953 +# v 5 +# x-mf-biz-cid 4010bf7a-c68c-42d2-bdf4-13e2b5545904-a0d664 +# @no-redirect +# @no-cookie-jar +https://download-cdn.123pan.cn/123-670/af2b7957/1813857424-0/af2b7957d3f4062a06a7b9ef6a3d5a9e?t=1686461953&s=16864619537565b1bbecb509ef377f6e8487a6a99b&r=L7PQ1A&filename=libc%2B%2B_shared.so&auto_redirect=0 + + + +### 获取下载 +# FileID S3keyFlag Size Etag + +# @no-redirect +# @no-cookie-jar +POST https://www.123pan.com/a/api/share/download/info +Content-Type:application/json;charset=UTF-8 + +{ + "ShareKey": "iaKtVv-qOECd", + "FileID": 2193733, + "S3keyFlag": "1813857424-0", + "Size": 976880, + "Etag": "af2b7957d3f4062a06a7b9ef6a3d5a9e" +} + +### +POST https://www.123pan.com/a/api/share/download/info +Content-Type:application/json;charset=UTF-8 + +{ + "res": { + "code": 0, + "message": "ok", + "data": { + "UserNickName": "15********0", + "UserID": 1815268665, + "ShareName": "libc++_shared.so", + "HasPwd": false, + "Expiration": "2099-01-01T00:00:00+08:00", + "CreateAt": "2023-06-10T13:36:44+08:00", + "Expired": false, + "ShareKey": "iaKtVv-qOECd", + "HeadImage": "https://thirdwx.qlogo.cn/mmopen/vi_32/0G2KQrJ4105icYkK0zBADdHhxyM2W7Q5jf0xh9OyfOM6INOaB3Mgov6CUjdibz43ZvhnZm2MLe8zgd1cZv4C72XQ/132", + "IsVip": false, + "DisplayStatus": 1 + } + }, + "reslist": { + "code": 0, + "message": "ok", + "data": { + "Next": "-1", + "Len": 1, + "IsFirst": true, + "Expired": false, + "InfoList": [ + { + "FileId": 2193733, + "FileName": "libc++_shared.so", + "Type": 0, + "Size": 976880, + "ContentType": "0", + "S3KeyFlag": "1813857424-0", + "CreateAt": "2023-06-10T13:36:12+08:00", + "UpdateAt": "2023-06-10T13:36:44+08:00", + "Etag": "af2b7957d3f4062a06a7b9ef6a3d5a9e", + "DownloadUrl": "", + "Status": 5, + "ParentFileId": 0, + "Category": 0, + "PunishFlag": 0, + "StorageNode": "m0", + "checked": true + } + ] + } + }, + "publicPath": "https://www.123pan.com/a/api/" +} diff --git a/web-service/src/main/resources/http-tools/test.http b/web-service/src/main/resources/http-tools/test.http index 2e861e7..8db0302 100644 --- a/web-service/src/main/resources/http-tools/test.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -152,3 +152,14 @@ GET http://127.0.0.1:6400/json/fc/30646fefc8bf936a4766ab8a5e GET http://127.0.0.1:6400/fc/e5079007dc31226096628870c7@QAIU #https://v2.fangcloud.com/sharing/e5079007dc31226096628870c7 + +### 123 +GET http://127.0.0.1:6400/json/ye/iaKtVv-qOECd + +### 123 +# @no-redirect +GET http://127.0.0.1:6400/ye/iaKtVv-qOECd@asdads + +### 123 +# @no-redirect +GET http://127.0.0.1:6400/parser?url=https://www.123pan.com/s/iaKtVv-6OECd.html&pwd=DcGe From daadb6e9cca768631821c7fa7effc69e3849a928 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Sat, 10 Jun 2023 16:35:33 +0800 Subject: [PATCH 43/48] change README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aabbcc0..2ad68bd 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ - 亿方云 (fc) - [ ] 登录, 上传, 下载, 分享 - [x] 直链解析 +- 123云盘 (fc) + - [ ] 登录, 上传, 下载, 分享 + - [x] 直链解析 - 文叔叔 (ws) - 夸克网盘 (qk) - TODO @@ -92,8 +95,9 @@ TODO: | UC网盘 | √ | √ | 10G | 不限大小 | TODO | | 小飞机网盘 | √ | √(密码可忽略) | 10G | 不限大小 | TODO | | 360亿方云 | √(注意有流量限制) | √(密码可忽略) | 100G(须实名) | 不限大小 | TODO | +| 123云盘 | √ | √ | 2T | 不限大小 | TODO | | 文叔叔(TODO) | √(注意有时间限制) | √ | 10G | 不限大小 | TODO | -| 夸克网盘(TODO) | 需要登录 | √ | 10G(20G) | 不限大小 | TODO | +| 夸克网盘(TODO) | 需要登录 | √ | 10G | 不限大小 | TODO | # 打包部署 TODO From e2945b8f346d67316c0785ab4b5318e9b70954cb Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Sat, 10 Jun 2023 16:41:25 +0800 Subject: [PATCH 44/48] change README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ad68bd..045aee7 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ - 亿方云 (fc) - [ ] 登录, 上传, 下载, 分享 - [x] 直链解析 -- 123云盘 (fc) +- 123云盘 (ye) - [ ] 登录, 上传, 下载, 分享 - [x] 直链解析 - 文叔叔 (ws) From fff8cfe460b220cfac2a15f2f7faaf5bb1ca69f8 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Sat, 10 Jun 2023 17:32:25 +0800 Subject: [PATCH 45/48] =?UTF-8?q?=E8=93=9D=E5=A5=8F=E4=BA=91=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E8=A7=A3=E6=9E=90=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/qaiu/lz/common/util/CommonUtils.java | 1 - .../java/cn/qaiu/lz/common/util/LzTool.java | 85 ++++++++++++++++++- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java b/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java index 8c855cd..4757a9c 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/CommonUtils.java @@ -2,7 +2,6 @@ package cn.qaiu.lz.common.util; import java.net.MalformedURLException; import java.net.URL; -import java.text.ParseException; import java.util.HashMap; import java.util.Map; diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java index edb7b32..1cb80f1 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -2,6 +2,12 @@ package cn.qaiu.lz.common.util; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import io.vertx.core.MultiMap; +import io.vertx.core.Vertx; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.client.HttpRequest; +import io.vertx.ext.web.client.WebClient; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -21,7 +27,8 @@ import java.util.regex.Pattern; public class LzTool { public static String parse(String fullUrl) throws Exception { - var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.3"; + var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0" + + ".3626.121 Safari/537.3"; var url = fullUrl.substring(0, fullUrl.lastIndexOf('/') + 1); var id = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); Map header = new HashMap<>(); @@ -34,7 +41,8 @@ public class LzTool { sec-ch-ua-mobile: ?1 sec-ch-ua-platform: "Android" */ - var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; + var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like " + + "Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; Map header2 = new HashMap<>(); header2.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); header2.put("sec-ch-ua-mobile", "sec-ch-ua-mobile"); @@ -55,7 +63,8 @@ public class LzTool { .get() .html(); // System.out.println(result); - // 'sign':'AWcGOFprUGFWX1BvBTVXawdrBDZTOAU_bV2FTZFU7W2sBJ1t4DW0FYFIyBmgDZVJgUjAFNV41UGQFNg_c_c' 改下正则TMD 最近上传竟然没_c_c + // 'sign':'AWcGOFprUGFWX1BvBTVXawdrBDZTOAU_bV2FTZFU7W2sBJ1t4DW0FYFIyBmgDZVJgUjAFNV41UGQFNg_c_c' 改下正则TMD + // 最近上传竟然没_c_c Matcher matcher = Pattern.compile("'sign'\s*:\s*'([0-9a-zA-Z_]+)'").matcher(result); Map params = new LinkedHashMap<>(); if (matcher.find()) { @@ -78,7 +87,8 @@ public class LzTool { .text() .replace("\\", ""); //json转为map - params = new ObjectMapper().readValue(result, new TypeReference<>() {}); + params = new ObjectMapper().readValue(result, new TypeReference<>() { + }); // System.out.println(params); //通过json的数据拼接出最终的URL发起第最终请求,并得到响应信息头 url = params.get("dom") + "/file/" + params.get("url"); @@ -94,4 +104,71 @@ public class LzTool { return url; } + + public static void main(String[] args) { +// String key = "https://lanzoux.com/ia2cntg"; + String key = "https://wwsd.lanzoue.com/icBp6qqj82b"; + String urlPrefix = "https://lanzoux.com"; + String code = "QAIU"; + + WebClient client = WebClient.create(Vertx.vertx()); + client.getAbs(key).send().onSuccess(res -> { + String html = res.bodyAsString(); + // 匹配iframe + Pattern compile = Pattern.compile("class=\"ifr2\" name=.+src=\"(/fn\\?[a-zA-Z0-9_+/=]{16,})\""); + Matcher matcher = compile.matcher(html); + if (!matcher.find()) { + // $.ajax({ + // type : 'post', + // url : '/ajaxm.php', + // //data : 'action=downprocess&sign=VTMAPgs6UG&p='+pwd, + // data : 'action=downprocess&sign + // =VzEBPwAxBzYIAQo1BjYBPVA_bDj1fNgEwUWNTYFUwAzMJL1V2Xj5XMlMzVjhTMVFjUzEHOlM4AjEBNQ_c_c&p + // ='+pwd, + // //data : 'action=downprocess&sign=VTMAPgs6UG&p='+pwd, + // dataType : 'json', + // success:function(msg){ + // var date = msg; + // if(date.zt == '1'){ + // $("#downajax").html("下载"); + // }else{ + // $("#info").text(date.inf); + // }; + // + // }, + // 匹配不到说明需要密码 直接解析并请求ajaxm.php + + // 匹配sign + Pattern compile2 = Pattern.compile("sign=([0-9a-zA-Z_]{16,})"); + Matcher matcher2 = compile2.matcher(html); + if (!matcher2.find()) { + return; + } + String sign = matcher2.group(1); + + var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like " + + "Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; + + HttpRequest bufferHttpRequest = client.postAbs(urlPrefix + "/ajaxm.php"); +// bufferHttpRequest.putHeader("User-Agent", userAgent2); + bufferHttpRequest.putHeader("referer", key); + bufferHttpRequest.sendForm(MultiMap.caseInsensitiveMultiMap() + .set("action", "downprocess") + .set("sign", sign).set("p", code)).onSuccess(res2 -> { + JsonObject urlJson = res2.bodyAsJsonObject(); + System.out.println(urlJson); + System.out.println(urlJson.getString("dom")+"/file/"+urlJson.getString("url")); + }); + + return; + } + String iframePath = matcher.group(1); + System.out.println(iframePath); + client.getAbs(urlPrefix + iframePath).send().onSuccess(res2 -> { + System.out.println(res2.bodyAsString()); + }); + }); + + } } From f492e3c031f3c23dd52b2b7ad391709c52584137 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Sat, 10 Jun 2023 17:45:25 +0800 Subject: [PATCH 46/48] =?UTF-8?q?=E8=93=9D=E5=A5=8F=E4=BA=91=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E8=A7=A3=E6=9E=90=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/qaiu/lz/common/util/LzTool.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java index 1cb80f1..b795939 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -8,6 +8,7 @@ import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.client.HttpRequest; import io.vertx.ext.web.client.WebClient; +import io.vertx.ext.web.client.WebClientOptions; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -106,12 +107,12 @@ public class LzTool { } public static void main(String[] args) { -// String key = "https://lanzoux.com/ia2cntg"; +// String key = "https://wwsd.lanzoue.com/iNvid035jgcb"; String key = "https://wwsd.lanzoue.com/icBp6qqj82b"; String urlPrefix = "https://lanzoux.com"; String code = "QAIU"; - WebClient client = WebClient.create(Vertx.vertx()); + WebClient client = WebClient.create(Vertx.vertx(), new WebClientOptions().setFollowRedirects(false)); client.getAbs(key).send().onSuccess(res -> { String html = res.bodyAsString(); // 匹配iframe @@ -147,18 +148,28 @@ public class LzTool { } String sign = matcher2.group(1); - var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like " + + var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, " + + "like " + "Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; HttpRequest bufferHttpRequest = client.postAbs(urlPrefix + "/ajaxm.php"); -// bufferHttpRequest.putHeader("User-Agent", userAgent2); + bufferHttpRequest.putHeader("User-Agent", userAgent2); bufferHttpRequest.putHeader("referer", key); + bufferHttpRequest.putHeader("sec-ch-ua-platform", "Android"); + + bufferHttpRequest.putHeader("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); + bufferHttpRequest.putHeader("sec-ch-ua-mobile", "sec-ch-ua-mobile"); bufferHttpRequest.sendForm(MultiMap.caseInsensitiveMultiMap() .set("action", "downprocess") .set("sign", sign).set("p", code)).onSuccess(res2 -> { JsonObject urlJson = res2.bodyAsJsonObject(); System.out.println(urlJson); - System.out.println(urlJson.getString("dom")+"/file/"+urlJson.getString("url")); + String downUrl = urlJson.getString("dom") + "/file/" + urlJson.getString("url"); + System.out.println(downUrl); + client.getAbs(downUrl).send().onSuccess(res3 -> { + System.out.println(res3.headers()); + System.out.println(res3.bodyAsString()); + }); }); return; From 7d8b39ad92a85c165f49cc471eb30c516fbf9e0e Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Mon, 12 Jun 2023 10:39:33 +0800 Subject: [PATCH 47/48] =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=93=9D=E5=A5=8F?= =?UTF-8?q?=E4=BA=91=E8=A7=A3=E6=9E=90=E4=BB=A3=E7=A0=81,=20=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E8=93=9D=E5=A5=8F=E4=BA=91=E5=8A=A0=E5=AF=86=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/qaiu/lz/common/util/LzTool.java | 195 +++++------------- .../java/cn/qaiu/lz/web/http/ServerApi.java | 46 +++-- .../src/main/resources/http-tools/test.http | 6 +- 3 files changed, 83 insertions(+), 164 deletions(-) diff --git a/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java index b795939..0147ebc 100644 --- a/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java +++ b/web-service/src/main/java/cn/qaiu/lz/common/util/LzTool.java @@ -1,21 +1,14 @@ package cn.qaiu.lz.common.util; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; +import cn.qaiu.vx.core.util.VertxHolder; +import io.vertx.core.Future; import io.vertx.core.MultiMap; +import io.vertx.core.Promise; import io.vertx.core.Vertx; -import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; -import io.vertx.ext.web.client.HttpRequest; import io.vertx.ext.web.client.WebClient; import io.vertx.ext.web.client.WebClientOptions; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import java.io.IOException; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,159 +20,71 @@ import java.util.regex.Pattern; */ public class LzTool { - public static String parse(String fullUrl) throws Exception { - var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0" + - ".3626.121 Safari/537.3"; - var url = fullUrl.substring(0, fullUrl.lastIndexOf('/') + 1); - var id = fullUrl.substring(fullUrl.lastIndexOf('/') + 1); - Map header = new HashMap<>(); - header.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); - header.put("referer", url); + public static final String SHARE_URL_PREFIX = "https://wwwa.lanzoui.com"; - /* - // 部分链接需要设置安卓UA - sec-ch-ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111" - sec-ch-ua-mobile: ?1 - sec-ch-ua-platform: "Android" - */ - var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like " + - "Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; - Map header2 = new HashMap<>(); - header2.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); - header2.put("sec-ch-ua-mobile", "sec-ch-ua-mobile"); - header2.put("sec-ch-ua-platform", "Android"); - header2.put("referer", url); + public static Future parse(String data, String code) { + Promise promise = Promise.promise(); + String key = data.indexOf('/') > 0 ? data : SHARE_URL_PREFIX + "/" + data; - //第一次请求,获取iframe的地址 - String result = Jsoup.connect(url + id) - .userAgent(userAgent) - .get() - .select(".ifr2") - .attr("src"); - - //第二次请求得到js里的json数据里的sign - result = Jsoup.connect(url + result) - .headers(header) - .userAgent(userAgent) - .get() - .html(); -// System.out.println(result); - // 'sign':'AWcGOFprUGFWX1BvBTVXawdrBDZTOAU_bV2FTZFU7W2sBJ1t4DW0FYFIyBmgDZVJgUjAFNV41UGQFNg_c_c' 改下正则TMD - // 最近上传竟然没_c_c - Matcher matcher = Pattern.compile("'sign'\s*:\s*'([0-9a-zA-Z_]+)'").matcher(result); - Map params = new LinkedHashMap<>(); - if (matcher.find()) { - String sn = matcher.group(1).replace("'", ""); - params.put("action", "downprocess"); - params.put("sign", sn); - params.put("ves", "1"); -// System.out.println(sn); - - } else { - throw new IOException(); - } - //第三次请求 通过参数发起post请求,返回json数据 - result = Jsoup - .connect(url + "ajaxm.php") - .headers(header) - .userAgent(userAgent) - .data(params) - .post() - .text() - .replace("\\", ""); - //json转为map - params = new ObjectMapper().readValue(result, new TypeReference<>() { - }); -// System.out.println(params); - //通过json的数据拼接出最终的URL发起第最终请求,并得到响应信息头 - url = params.get("dom") + "/file/" + params.get("url"); - var headers = Jsoup.connect(url) - .ignoreContentType(true) - .userAgent(userAgent2) - .headers(header2) - .followRedirects(false) - .execute() - .headers(); - //得到重定向的地址进行重定向 - url = headers.get("Location"); - - return url; - } - - public static void main(String[] args) { -// String key = "https://wwsd.lanzoue.com/iNvid035jgcb"; - String key = "https://wwsd.lanzoue.com/icBp6qqj82b"; - String urlPrefix = "https://lanzoux.com"; - String code = "QAIU"; - - WebClient client = WebClient.create(Vertx.vertx(), new WebClientOptions().setFollowRedirects(false)); + WebClient client = WebClient.create(VertxHolder.getVertxInstance(), + new WebClientOptions().setFollowRedirects(false)); client.getAbs(key).send().onSuccess(res -> { String html = res.bodyAsString(); // 匹配iframe - Pattern compile = Pattern.compile("class=\"ifr2\" name=.+src=\"(/fn\\?[a-zA-Z0-9_+/=]{16,})\""); + Pattern compile = Pattern.compile("src=\"(/fn\\?[a-zA-Z0-9_+/=]{16,})\""); Matcher matcher = compile.matcher(html); if (!matcher.find()) { - // $.ajax({ - // type : 'post', - // url : '/ajaxm.php', - // //data : 'action=downprocess&sign=VTMAPgs6UG&p='+pwd, - // data : 'action=downprocess&sign - // =VzEBPwAxBzYIAQo1BjYBPVA_bDj1fNgEwUWNTYFUwAzMJL1V2Xj5XMlMzVjhTMVFjUzEHOlM4AjEBNQ_c_c&p - // ='+pwd, - // //data : 'action=downprocess&sign=VTMAPgs6UG&p='+pwd, - // dataType : 'json', - // success:function(msg){ - // var date = msg; - // if(date.zt == '1'){ - // $("#downajax").html("下载"); - // }else{ - // $("#info").text(date.inf); - // }; - // - // }, - // 匹配不到说明需要密码 直接解析并请求ajaxm.php - - // 匹配sign + // 没有Iframe说明是加密分享, 匹配sign通过密码请求下载页面 Pattern compile2 = Pattern.compile("sign=([0-9a-zA-Z_]{16,})"); Matcher matcher2 = compile2.matcher(html); if (!matcher2.find()) { + promise.fail(key + ": sign正则匹配失败, 可能分享已失效: " + html); return; } String sign = matcher2.group(1); - - var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, " + - "like " + - "Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; - - HttpRequest bufferHttpRequest = client.postAbs(urlPrefix + "/ajaxm.php"); - bufferHttpRequest.putHeader("User-Agent", userAgent2); - bufferHttpRequest.putHeader("referer", key); - bufferHttpRequest.putHeader("sec-ch-ua-platform", "Android"); - - bufferHttpRequest.putHeader("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); - bufferHttpRequest.putHeader("sec-ch-ua-mobile", "sec-ch-ua-mobile"); - bufferHttpRequest.sendForm(MultiMap.caseInsensitiveMultiMap() - .set("action", "downprocess") - .set("sign", sign).set("p", code)).onSuccess(res2 -> { - JsonObject urlJson = res2.bodyAsJsonObject(); - System.out.println(urlJson); - String downUrl = urlJson.getString("dom") + "/file/" + urlJson.getString("url"); - System.out.println(downUrl); - client.getAbs(downUrl).send().onSuccess(res3 -> { - System.out.println(res3.headers()); - System.out.println(res3.bodyAsString()); - }); - }); - + getDownURL(promise, code, key, client, sign); return; } String iframePath = matcher.group(1); - System.out.println(iframePath); - client.getAbs(urlPrefix + iframePath).send().onSuccess(res2 -> { - System.out.println(res2.bodyAsString()); + client.getAbs(SHARE_URL_PREFIX + iframePath).send().onSuccess(res2 -> { + String html2 = res2.bodyAsString(); + System.out.println(html); + Matcher matcher2 = Pattern.compile("'sign'\s*:\s*'([0-9a-zA-Z_]+)'").matcher(html2); + if (!matcher2.find()) { + promise.fail(SHARE_URL_PREFIX + iframePath + " -> " + key + ": sign正则匹配失败, 可能分享已失效: " + html2); + return; + } + String sign = matcher2.group(1); + getDownURL(promise, code, key, client, sign); }); }); + return promise.future(); + } + private static void getDownURL(Promise promise, String code, String key, WebClient client, String sign) { + MultiMap headers = MultiMap.caseInsensitiveMultiMap(); + var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, " + + "like " + + "Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"; + headers.set("User-Agent", userAgent2); + headers.set("referer", key); + headers.set("sec-ch-ua-platform", "Android"); + headers.set("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"); + headers.set("sec-ch-ua-mobile", "sec-ch-ua-mobile"); + + client.postAbs(SHARE_URL_PREFIX + "/ajaxm.php").putHeaders(headers).sendForm(MultiMap + .caseInsensitiveMultiMap() + .set("action", "downprocess") + .set("sign", sign).set("p", code)).onSuccess(res2 -> { + JsonObject urlJson = res2.bodyAsJsonObject(); + if (urlJson.getInteger("zt") != 1) { + promise.fail(urlJson.getString("inf")); + return; + } + String downUrl = urlJson.getString("dom") + "/file/" + urlJson.getString("url"); + client.getAbs(downUrl).putHeaders(headers).send().onSuccess(res3 -> { + promise.complete(res3.headers().get("Location")); + }); + }); } } diff --git a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java index 74d3215..eac12df 100644 --- a/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java +++ b/web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java @@ -70,12 +70,11 @@ public class ServerApi { promise.complete(); }).onFailure(t -> promise.fail(t.fillInStackTrace())); } else if (url.contains("lanzou")) { - String urlDownload; try { - urlDownload = LzTool.parse(url); - log.info("url = {}", urlDownload); - response.putHeader("location", urlDownload).setStatusCode(302).end(); - promise.complete(); + LzTool.parse(url, pwd).onSuccess(resUrl -> { + response.putHeader("location", resUrl).setStatusCode(302).end(); + promise.complete(); + }).onFailure(t -> promise.fail(t.fillInStackTrace())); } catch (Exception e) { promise.fail(e); } @@ -94,11 +93,30 @@ public class ServerApi { } @RouteMapping(value = "/lz/:id", method = RouteMethod.GET) - public void lzParse(HttpServerResponse response, String id) throws Exception { - var url = "https://wwsd.lanzoue.com/" + id; - var urlDownload = LzTool.parse(url); - log.info("url = {}", urlDownload); - response.putHeader("location", urlDownload).setStatusCode(302).end(); + public void lzParse(HttpServerResponse response, String id) { + String code = ""; + if (id.contains("@")) { + String[] ids = id.split("@"); + id = ids[0]; + code = ids[1]; + } + LzTool.parse(id, code).onSuccess(resUrl -> response.putHeader("location", resUrl) + .setStatusCode(302).end()).onFailure(t -> { + response.putHeader(CONTENT_TYPE, "text/html;charset=utf-8"); + response.end(t.getMessage()); + }); + } + + + @RouteMapping(value = "/json/lz/:id", method = RouteMethod.GET) + public Future lzParseJson(HttpServerResponse response, String id) { + String code = ""; + if (id.contains("@")) { + String[] ids = id.split("@"); + id = ids[0]; + code = ids[1]; + } + return LzTool.parse(id, code); } @RouteMapping(value = "/cow/:id", method = RouteMethod.GET) @@ -108,14 +126,6 @@ public class ServerApi { response.putHeader("location", urlDownload).setStatusCode(302).end(); } - @RouteMapping(value = "/json/lz/:id", method = RouteMethod.GET) - public JsonResult lzParseJson(HttpServerResponse response, String id) throws Exception { - var url = "https://wwsd.lanzoue.com/" + id; - var urlDownload = LzTool.parse(url); - log.info("url = {}", urlDownload); - return JsonResult.data(urlDownload); - } - @RouteMapping(value = "/json/cow/:id", method = RouteMethod.GET) public JsonResult cowParseJson(HttpServerResponse response, String id) throws Exception { var url = "https://cowtransfer.com/s/" + id; diff --git a/web-service/src/main/resources/http-tools/test.http b/web-service/src/main/resources/http-tools/test.http index 8db0302..0ff5a98 100644 --- a/web-service/src/main/resources/http-tools/test.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -16,7 +16,11 @@ GET http://127.0.0.1:6400/cow/9a644fe3e3a748 ### # @no-redirect -GET http://127.0.0.1:6400/lz/ia2cntg +GET http://127.0.0.1:6400/lz/i6SqHmp1yfc + +### +# @no-redirect +GET http://127.0.0.1:6400/lz/icBp6qqj82b@QAIU ### GET http://127.0.0.1:6400/json/lz/ia2cntg From 089dc5713b6a65135eba0912ddb84b96f6880de2 Mon Sep 17 00:00:00 2001 From: QAIU <736226400@qq.com> Date: Mon, 12 Jun 2023 16:07:28 +0800 Subject: [PATCH 48/48] Zzzz --- README.md | 8 ++++---- web-service/src/main/resources/http-tools/pan-cow.http | 0 web-service/src/main/resources/http-tools/test.http | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 web-service/src/main/resources/http-tools/pan-cow.http diff --git a/README.md b/README.md index 045aee7..0e8ecc8 100644 --- a/README.md +++ b/README.md @@ -38,15 +38,15 @@ API接口 parse接口加上参数pwd=密码;其他接口在分享Key后面加上@密码 1. 解析并自动302跳转 : - http(s)://you_host/parser?url=分享链接(&pwd=xxx) - http(s)://you_host/网盘标识/分享id(@分享密码) + http(s)://your_hostname/parser?url=分享链接(&pwd=xxx) + http(s)://your_hostname/网盘标识/分享id(@分享密码) 2. 获取解析后的直链--JSON格式 - http(s)://you_host/json/网盘标识/分享id(@分享密码) + http(s)://your_hostname/json/网盘标识/分享id(@分享密码) 3. 有些网盘的加密分享的密码可以忽略: 如移动云空间,小飞机网盘 ``` -IDEA HttpClient示例: +IDEA HttpClient示例: ``` # 解析并重定向到直链 ### 蓝奏云普通分享 diff --git a/web-service/src/main/resources/http-tools/pan-cow.http b/web-service/src/main/resources/http-tools/pan-cow.http new file mode 100644 index 0000000..e69de29 diff --git a/web-service/src/main/resources/http-tools/test.http b/web-service/src/main/resources/http-tools/test.http index 0ff5a98..0f33a86 100644 --- a/web-service/src/main/resources/http-tools/test.http +++ b/web-service/src/main/resources/http-tools/test.http @@ -55,11 +55,11 @@ Content-Type: multipart/form-data; boundary=WebAppBoundary --WebAppBoundary Content-Disposition: form-data; name="email" -736226400@qq.com +111@sad.com --WebAppBoundary Content-Disposition: form-data; name="password" -4458225ff +11111 --WebAppBoundary-- # eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDc1OTMwNGItMDEwZS00MGJiLTlhNDUtZTczY2Q5ODYzMDQwIiwiZXhwIjoxNjg0NDYyMjMzfQ.AeuB5-aQUlgudoLDRgvFodlHx2qKiPFx3BAqGA0R-eE # eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDc1OTMwNGItMDEwZS00MGJiLTlhNDUtZTczY2Q5ODYzMDQwIiwiZXhwIjoxNjg0NDYyMjMzfQ.AeuB5-aQUlgudoLDRgvFodlHx2qKiPFx3BAqGA0R-eE