Skip to content

Commit dde54ed

Browse files
authored
Merge pull request #13 from qaiu/dev
蓝奏云规则修改, 奶牛功能增强
2 parents 8441954 + 3c56a71 commit dde54ed

File tree

30 files changed

+411
-106
lines changed

30 files changed

+411
-106
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
# netdisk-fast-download
2+
云盘解析服务 (nfd云解析)
23
预览地址 https://lz.qaiu.top
34

45
[![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)
56
[![jdk](https://img.shields.io/badge/jdk-%3E%3D17-blue)](https://www.oracle.com/cn/java/technologies/downloads/)
67
[![vert.x](https://img.shields.io/badge/vert.x-4.4.1-blue)](https://vertx-china.github.io/)
78
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/qaiu/netdisk-fast-download)](https://github.com/qaiu/netdisk-fast-download/releases/tag/0.1.6-releases)
89

10+
## 项目介绍
11+
网盘直链解析工具能把网盘分享下载链接转化为直链,已支持蓝奏云/奶牛快传/移动云云空间/小飞机盘/亿方云/123云盘等,支持私密分享。
12+
13+
## 应用场景:
14+
1. 游戏:使用本站工具可自动生成高速直流下载器,用于游戏客户端自动化高速下载安装、更新等。
15+
2. 下载:可根据网盘分享的地址解析为直链,方便放到自己网站上供用户下载,节约服务器带宽和磁盘。
16+
3. 音视频:可解析为音视频直链,可直接在网页上播放,高清,高速,节约服务器带宽和磁盘。
17+
4. 图床:可支持图床。
18+
919
## 网盘支持情况:
1020
> 20230722 UC网盘解析失效,需要登录
1121

core-database/src/main/java/cn/qaiu/db/ddl/CreateTable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ public static String getCreateTableSQL(Class<?> clz) {
157157
return sql.substring(0, sql.length() - 1) + ");\r\n";
158158
}
159159

160-
public static void createTable(JDBCPool pool, String tableClassPath) {
161-
Set<Class<?>> tableClassList = ReflectionUtil.getReflections(tableClassPath).getTypesAnnotatedWith(Table.class);
160+
public static void createTable(JDBCPool pool) {
161+
Set<Class<?>> tableClassList = ReflectionUtil.getReflections().getTypesAnnotatedWith(Table.class);
162162
if (tableClassList.isEmpty()) LOGGER.info("Table model class not fount");
163163
tableClassList.forEach(clazz -> {
164164
String createTableSQL = getCreateTableSQL(clazz);

core-database/src/main/java/cn/qaiu/db/pool/JDBCPoolInit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void initPool() {
9292
private void poolInitExecute(Promise<String> promise) {
9393
// 初始化连接池
9494
pool = JDBCPool.pool(vertx, dbConfig);
95-
CreateTable.createTable(pool, dbConfig.getString("tableClassPath"));
95+
CreateTable.createTable(pool);
9696
promise.complete("init jdbc pool success");
9797

9898
}

core/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<slf4j.version>2.0.5</slf4j.version>
2121
<commons-lang3.version>3.12.0</commons-lang3.version>
2222
<jackson.version>2.14.2</jackson.version>
23+
<logback.version>1.4.6</logback.version>
2324
</properties>
2425

2526
<dependencyManagement>
@@ -39,7 +40,7 @@
3940
<dependency>
4041
<groupId>ch.qos.logback</groupId>
4142
<artifactId>logback-classic</artifactId>
42-
<version>1.4.6</version>
43+
<version>${logback.version}</version>
4344
</dependency>
4445
<dependency>
4546
<groupId>org.slf4j</groupId>

core/src/main/java/cn/qaiu/vx/core/Deploy.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package cn.qaiu.vx.core;
22

3-
import cn.qaiu.vx.core.util.ConfigConstant;
43
import cn.qaiu.vx.core.util.ConfigUtil;
54
import cn.qaiu.vx.core.util.VertxHolder;
65
import cn.qaiu.vx.core.verticle.ReverseProxyVerticle;
@@ -18,6 +17,8 @@
1817
import java.util.Date;
1918
import java.util.concurrent.locks.LockSupport;
2019

20+
import static cn.qaiu.vx.core.util.ConfigConstant.*;
21+
2122
/**
2223
* vertx启动类 需要在主启动类完成回调
2324
* <br>Create date 2021-05-07 10:26:54
@@ -108,10 +109,10 @@ private void outLogo(JsonObject conf) {
108109
private void deployVerticle() {
109110
tempVertx.close();
110111
LOGGER.info("配置读取成功");
111-
customConfig = globalConfig.getJsonObject(ConfigConstant.CUSTOM);
112+
customConfig = globalConfig.getJsonObject(CUSTOM);
112113

113-
JsonObject vertxConfig = globalConfig.getJsonObject(ConfigConstant.VERTX);
114-
Integer vertxConfigELPS = vertxConfig.getInteger(ConfigConstant.EVENT_LOOP_POOL_SIZE);
114+
JsonObject vertxConfig = globalConfig.getJsonObject(VERTX);
115+
Integer vertxConfigELPS = vertxConfig.getInteger(EVENT_LOOP_POOL_SIZE);
115116
var vertxOptions = vertxConfigELPS == 0 ?
116117
new VertxOptions() : new VertxOptions(vertxConfig);
117118

@@ -122,10 +123,10 @@ private void deployVerticle() {
122123
VertxHolder.init(vertx);
123124
//配置保存在共享数据中
124125
var sharedData = vertx.sharedData();
125-
LocalMap<String, Object> localMap = sharedData.getLocalMap(ConfigConstant.LOCAL);
126-
localMap.put(ConfigConstant.GLOBAL_CONFIG, globalConfig);
127-
localMap.put(ConfigConstant.CUSTOM_CONFIG, customConfig);
128-
localMap.put(ConfigConstant.SERVER, globalConfig.getJsonObject(ConfigConstant.SERVER));
126+
LocalMap<String, Object> localMap = sharedData.getLocalMap(LOCAL);
127+
localMap.put(GLOBAL_CONFIG, globalConfig);
128+
localMap.put(CUSTOM_CONFIG, customConfig);
129+
localMap.put(SERVER, globalConfig.getJsonObject(SERVER));
129130
var future0 = vertx.createSharedWorkerExecutor("other-handle").executeBlocking(bch -> {
130131
handle.handle(globalConfig);
131132
bch.complete("other handle complete");
@@ -169,7 +170,7 @@ private void deployWorkVerticalSuccess(CompositeFuture compositeFuture) {
169170
* @return Deployment Options
170171
*/
171172
private DeploymentOptions getWorkDeploymentOptions(String name) {
172-
return getWorkDeploymentOptions(name, customConfig.getInteger(ConfigConstant.ASYNC_SERVICE_INSTANCES));
173+
return getWorkDeploymentOptions(name, customConfig.getInteger(ASYNC_SERVICE_INSTANCES));
173174
}
174175

175176
private DeploymentOptions getWorkDeploymentOptions(String name, int ins) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cn.qaiu.vx.core.annotaions;
2+
3+
import java.lang.annotation.*;
4+
5+
/**
6+
* 拦截器配置注解
7+
* 正则匹配拦截途径
8+
*
9+
* @author <a href="https://qaiu.top">QAIU</a>
10+
*/
11+
@Documented
12+
@Inherited
13+
@Target(ElementType.TYPE)
14+
@Retention(RetentionPolicy.RUNTIME)
15+
public @interface InterceptorConfig {
16+
17+
String pattern() default "";
18+
19+
/**
20+
* 注册顺序,数字越大越先注册
21+
*/
22+
int order() default 0;
23+
}

core/src/main/java/cn/qaiu/vx/core/handlerfactory/RouterHandlerFactory.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import cn.qaiu.vx.core.annotaions.SockRouteMapper;
77
import cn.qaiu.vx.core.base.BaseHttpApi;
88
import cn.qaiu.vx.core.enums.MIMEType;
9+
import cn.qaiu.vx.core.interceptor.Interceptor;
910
import cn.qaiu.vx.core.model.JsonResult;
1011
import cn.qaiu.vx.core.util.*;
1112
import io.vertx.core.Future;
@@ -22,6 +23,7 @@
2223
import io.vertx.ext.web.handler.BodyHandler;
2324
import io.vertx.ext.web.handler.CorsHandler;
2425
import io.vertx.ext.web.handler.StaticHandler;
26+
import io.vertx.ext.web.handler.TimeoutHandler;
2527
import io.vertx.ext.web.handler.sockjs.SockJSHandler;
2628
import io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions;
2729
import javassist.CtClass;
@@ -38,6 +40,7 @@
3840
import java.util.stream.Collectors;
3941
import java.util.stream.Stream;
4042

43+
import static cn.qaiu.vx.core.util.ConfigConstant.ROUTE_TIME_OUT;
4144
import static io.vertx.core.http.HttpHeaders.*;
4245

4346
/**
@@ -62,10 +65,9 @@ public class RouterHandlerFactory implements BaseHttpApi {
6265

6366
private final String gatewayPrefix;
6467

65-
public RouterHandlerFactory(String routerScanAddress, String gatewayPrefix) {
66-
Objects.requireNonNull(routerScanAddress, "The router package address scan is empty.");
68+
public RouterHandlerFactory(String gatewayPrefix) {
6769
Objects.requireNonNull(gatewayPrefix, "The gateway prefix is empty.");
68-
reflections = ReflectionUtil.getReflections(routerScanAddress);
70+
reflections = ReflectionUtil.getReflections();
6971
this.gatewayPrefix = gatewayPrefix;
7072
}
7173

@@ -173,6 +175,8 @@ private void registerNewHandler(Router router, Class<?> handler) throws Throwabl
173175
route.consumes(mineType);
174176
}
175177

178+
// 设置默认超时
179+
route.handler(TimeoutHandler.create(SharedDataUtil.getCustomConfig().getInteger(ROUTE_TIME_OUT)));
176180
// 先执行拦截方法, 再进入业务请求
177181
route.handler(interceptor);
178182
route.handler(ctx -> handlerMethod(instance, method, ctx)).failureHandler(ctx -> {
@@ -234,10 +238,8 @@ private String getRouteUrl(String methodName, String mapperValue) {
234238
private Handler<RoutingContext> getInterceptor() throws Throwable {
235239
// 配置拦截
236240
Class<?> interceptorClass = Class.forName(SharedDataUtil.getValueForCustomConfig("interceptorClassPath"));
237-
Object handleInstance = ReflectionUtil.newWithNoParam(interceptorClass);
238-
Method doHandle = interceptorClass.getMethod("doHandle");
239-
// 反射调用
240-
return CastUtil.cast(ReflectionUtil.invoke(doHandle, handleInstance));
241+
Interceptor handleInstance = (Interceptor)ReflectionUtil.newWithNoParam(interceptorClass);
242+
return handleInstance.doHandle();
241243
}
242244

243245
/**

core/src/main/java/cn/qaiu/vx/core/util/ConfigConstant.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
public interface ConfigConstant {
44
String CUSTOM = "custom";
55
String VERTX = "vertx";
6-
76
String EVENT_LOOP_POOL_SIZE = "eventLoopPoolSize";
87
String LOCAL = "local";
98
String SERVER = "server";
109
String GLOBAL_CONFIG = "globalConfig";
1110
String CUSTOM_CONFIG = "customConfig";
1211
String ASYNC_SERVICE_INSTANCES = "asyncServiceInstances";
12+
String IGNORES_REG="ignoresReg";
13+
String BASE_LOCATIONS="baseLocations";
14+
15+
String ROUTE_TIME_OUT="routeTimeOut";
1316
}

core/src/main/java/cn/qaiu/vx/core/util/ReflectionUtil.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.text.ParseException;
2525
import java.util.*;
2626

27+
import static cn.qaiu.vx.core.util.ConfigConstant.BASE_LOCATIONS;
28+
2729
/**
2830
* 基于org.reflection和javassist的反射工具包
2931
* 通过包扫描实现路由地址的注解映射
@@ -33,6 +35,16 @@
3335
*/
3436
public final class ReflectionUtil {
3537

38+
39+
/**
40+
* 以默认配置的基础包路径获取反射器
41+
*
42+
* @return Reflections object
43+
*/
44+
public static Reflections getReflections() {
45+
return getReflections(SharedDataUtil.getStringForCustomConfig(BASE_LOCATIONS));
46+
}
47+
3648
/**
3749
* 获取反射器
3850
*
@@ -48,6 +60,7 @@ public static Reflections getReflections(String packageAddress) {
4860
} else {
4961
packageAddressList = Collections.singletonList(packageAddress);
5062
}
63+
5164
return getReflections(packageAddressList);
5265
}
5366

@@ -70,10 +83,11 @@ public static Reflections getReflections(List<String> packageAddresses) {
7083
// 发现注解api层 没有继承父类时 这里反射一直有问题(Scanner SubTypesScanner was not configured)
7184
// 因此这里需要手动配置各种Scanner扫描器 -- https://blog.csdn.net/qq_29499107/article/details/106889781
7285
configurationBuilder.setScanners(
73-
Scanners.SubTypes.filterResultsBy(s -> true), //允许getAllTypes获取所有Object的子类, 不设置为false则 getAllTypes 会报错.默认为true.
86+
Scanners.SubTypes.filterResultsBy(s -> true), //允许getAllTypes获取所有Object的子类, 不设置为false则 getAllTypes
87+
// 会报错.默认为true.
7488
new MethodParameterNamesScanner(), //设置方法参数名称 扫描器,否则调用getConstructorParamNames 会报错
7589
Scanners.MethodsAnnotated, //设置方法注解 扫描器, 否则getConstructorsAnnotatedWith,getMethodsAnnotatedWith 会报错
76-
new MemberUsageScanner(), //设置 member 扫描器,否则 getMethodUsage 会报错, 不推荐使用,有可能会报错 Caused by: java.lang.ClassCastException: javassist.bytecode.InterfaceMethodrefInfo cannot be cast to javassist.bytecode.MethodrefInfo
90+
new MemberUsageScanner(), //设置 member 扫描器,否则 getMethodUsage 会报错
7791
Scanners.TypesAnnotated //设置类注解 扫描器 ,否则 getTypesAnnotatedWith 会报错
7892
);
7993

@@ -98,7 +112,8 @@ public static Map<String, Pair<Annotation[], CtClass>> getMethodParameter(Method
98112
MethodInfo methodInfo = cm.getMethodInfo();
99113
CtClass[] parameterTypes = cm.getParameterTypes();
100114
CodeAttribute codeAttribute = methodInfo.getCodeAttribute();
101-
LocalVariableAttribute attr = (LocalVariableAttribute) codeAttribute.getAttribute(LocalVariableAttribute.tag);
115+
LocalVariableAttribute attr =
116+
(LocalVariableAttribute) codeAttribute.getAttribute(LocalVariableAttribute.tag);
102117

103118
boolean flag = true;
104119
boolean flag2 = cm.getModifiers() - 1 != AccessFlag.STATIC;
@@ -110,7 +125,8 @@ public static Map<String, Pair<Annotation[], CtClass>> getMethodParameter(Method
110125
continue;
111126
}
112127
flag = false;
113-
paramMap.put(attr.variableName(j + (flag2 ? 1 : 0)), Pair.of(parameterAnnotations[j - k], parameterTypes[j - k]));
128+
paramMap.put(attr.variableName(j + (flag2 ? 1 : 0)), Pair.of(parameterAnnotations[j - k],
129+
parameterTypes[j - k]));
114130
}
115131
} catch (NotFoundException e) {
116132
e.printStackTrace();
@@ -214,7 +230,8 @@ public static boolean isBasicType(CtClass ctClass) {
214230
if (ctClass.isPrimitive() || "java.util.Date".equals(ctClass.getName())) {
215231
return true;
216232
}
217-
return ctClass.getName().matches("^java\\.lang\\.((Boolean)|(Character)|(Byte)|(Short)|(Integer)|(Long)|(Float)|(Double)|(String))$");
233+
return ctClass.getName().matches("^java\\.lang\\.((Boolean)|(Character)|(Byte)|(Short)|(Integer)|(Long)|" +
234+
"(Float)|(Double)|(String))$");
218235
}
219236

220237
/**
@@ -238,7 +255,8 @@ public static boolean isBasicTypeArray(CtClass ctClass) {
238255
* @throws InstantiationException InstantiationException
239256
* @throws IllegalAccessException IllegalAccessException
240257
*/
241-
public static <T> T newWithNoParam(Class<T> handler) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
258+
public static <T> T newWithNoParam(Class<T> handler) throws NoSuchMethodException, InvocationTargetException,
259+
InstantiationException, IllegalAccessException {
242260
return handler.getConstructor().newInstance();
243261
}
244262

core/src/main/java/cn/qaiu/vx/core/util/SharedDataUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public static JsonObject getJsonConfig(String key) {
3232
return (JsonObject) localMap.get(key);
3333
}
3434

35-
public static JsonObject getJsonObjectForCustomConfig(String key) {
36-
return getJsonConfig("customConfig").getJsonObject(key);
35+
public static JsonObject getCustomConfig() {
36+
return getJsonConfig("customConfig");
3737
}
3838

39-
public static String getJsonStringForCustomConfig(String key) {
39+
public static String getStringForCustomConfig(String key) {
4040
return getJsonConfig("customConfig").getString(key);
4141
}
4242

core/src/main/java/cn/qaiu/vx/core/verticle/RouterVerticle.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class RouterVerticle extends AbstractVerticle {
2323

2424
private static final int port = SharedDataUtil.getValueForServerConfig("port");
2525
private static final Router router = new RouterHandlerFactory(
26-
SharedDataUtil.getJsonStringForCustomConfig("routerLocations"),
2726
SharedDataUtil.getJsonStringForServerConfig("contextPath")).createRouter();
2827

2928
private static final JsonObject globalConfig = SharedDataUtil.getJsonConfig("globalConfig");

core/src/main/java/cn/qaiu/vx/core/verticle/ServiceVerticle.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import cn.qaiu.vx.core.annotaions.Service;
44
import cn.qaiu.vx.core.base.BaseAsyncService;
55
import cn.qaiu.vx.core.util.ReflectionUtil;
6-
import cn.qaiu.vx.core.util.SharedDataUtil;
76
import io.vertx.core.AbstractVerticle;
87
import io.vertx.core.Promise;
98
import io.vertx.serviceproxy.ServiceBinder;
@@ -27,8 +26,7 @@ public class ServiceVerticle extends AbstractVerticle {
2726
private static final Set<Class<?>> handlers;
2827

2928
static {
30-
String handlerLocations = SharedDataUtil.getJsonStringForCustomConfig("handlerLocations");
31-
Reflections reflections = ReflectionUtil.getReflections(handlerLocations);
29+
Reflections reflections = ReflectionUtil.getReflections();
3230
handlers = reflections.getTypesAnnotatedWith(Service.class);
3331
}
3432

web-service/src/main/java/cn/qaiu/lz/common/interceptorImpl/DefaultInterceptor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import io.vertx.ext.web.RoutingContext;
88
import lombok.extern.slf4j.Slf4j;
99

10+
import static cn.qaiu.vx.core.util.ConfigConstant.IGNORES_REG;
11+
1012
/**
1113
* 默认拦截器实现
1214
* 校验用户是否合法 <br>
@@ -15,15 +17,16 @@
1517
@Slf4j
1618
public class DefaultInterceptor implements Interceptor, BaseHttpApi {
1719

18-
private final JsonArray ignores = SharedDataUtil.getJsonArrayForCustomConfig("ignoresReg");
20+
21+
protected final JsonArray ignores = SharedDataUtil.getJsonArrayForCustomConfig(IGNORES_REG);
1922

2023
@Override
2124
public void beforeHandle(RoutingContext ctx) {
2225
ctx.next();
2326
}
2427

2528
@Override
26-
public void afterHandle(RoutingContext context) {
29+
public void afterHandle(RoutingContext ctx) {
2730

2831
}
2932
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cn.qaiu.lz.common.model;
2+
3+
import cn.qaiu.lz.common.util.SnowflakeIdWorker;
4+
import lombok.Data;
5+
6+
import java.util.Date;
7+
8+
@Data
9+
abstract public class BaseModel {
10+
public static final long serialVersionUID = 1L;
11+
12+
13+
private String id = String.valueOf(SnowflakeIdWorker.idWorker().nextId());
14+
15+
private String createBy;
16+
17+
private Date createTime;
18+
19+
private String updateBy;
20+
21+
private Date updateTime;
22+
23+
}

0 commit comments

Comments
 (0)