Compare commits

..

3 Commits

Author SHA1 Message Date
qaiu 91f4fcaa76 更新 README.md
oosmetrics不可用
2026-07-11 06:28:53 +08:00
qaiu 0754fe20f1 更新 README.md 2026-07-10 16:41:58 +08:00
qaiu 034fd20d3b 更新 README.md 2026-07-10 16:41:06 +08:00
3 changed files with 5 additions and 161 deletions
+3 -1
View File
@@ -6,8 +6,10 @@ QQ交流群:1017480890
<a href="https://vertx-china.github.io"><img src="https://img.shields.io/badge/vert.x-4.5.27-blue?style=flat"></a>
<a href="https://raw.githubusercontent.com/qaiu/netdisk-fast-download/master/LICENSE"><img src="https://img.shields.io/github/license/qaiu/netdisk-fast-download?style=flat"></a>
<a href="https://github.com/qaiu/netdisk-fast-download/releases/"><img src="https://img.shields.io/github/v/release/qaiu/netdisk-fast-download?style=flat"></a>
<a href="https://github.com/QAIU/netdisk-fast-download">
<img src="https://img.shields.io/github/stars/QAIU/netdisk-fast-download?style=flat&logo=github" alt="GitHub Stars">
</a>
<a href="https://atomgit.com/QAIU/netdisk-fast-download"><img src="https://atomgit.com/QAIU/netdisk-fast-download/star/badge.svg" alt="AtomGit"></a>
<a href="https://oosmetrics.com/repo/qaiu/netdisk-fast-download"><img src="https://api.oosmetrics.com/api/v1/badge/achievement/826aa27a-6e59-4de5-b7fa-cd189f484035.svg"></a>
<p align="center">
<a href="https://trendshift.io/repositories/12101" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12101" alt="qaiu%2Fnetdisk-fast-download | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
</p>
@@ -188,16 +188,9 @@ public class Ye2Tool extends PanBase {
private Future<String> resolveTokenFuture() {
MultiMap auths = (MultiMap) shareLinkInfo.getOtherParam().get("auths");
if (auths != null) {
String raw = null;
if (auths.contains("token")) {
raw = auths.get("token");
} else if (auths.contains("Authorization")) {
raw = auths.get("Authorization");
}
String providedToken = normalizeBearerToken(raw);
if (auths != null && auths.contains("token")) {
String providedToken = auths.get("token");
if (StringUtils.isNotEmpty(providedToken)) {
log.info("使用配置token,前8位: {}...", providedToken.substring(0, Math.min(8, providedToken.length())));
TokenCache.putToken(cacheKey, providedToken);
return Future.succeededFuture(providedToken);
}
@@ -210,17 +203,6 @@ public class Ye2Tool extends PanBase {
return Future.succeededFuture(cached);
}
private String normalizeBearerToken(String raw) {
if (StringUtils.isBlank(raw)) {
return null;
}
String token = raw.trim();
if (token.regionMatches(true, 0, "Bearer ", 0, 7)) {
token = token.substring(7).trim();
}
return StringUtils.isNotEmpty(token) ? token : null;
}
private Future<String> loginAndGetToken() {
MultiMap auths = (MultiMap) shareLinkInfo.getOtherParam().get("auths");
if (auths == null) {
@@ -1,140 +0,0 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import io.vertx.core.MultiMap;
import java.util.HashMap;
import java.util.Map;
/**
* Ye2Tool token 解析验证测试
* 验证 Authorization 字段和 ******
*/
public class Ye2ToolTokenValidationTest {
public static void main(String[] args) {
System.out.println("========================================");
System.out.println(" Ye2Tool Token 解析验证测试");
System.out.println("========================================\n");
testNormalizeBearerToken();
testYe2ToolWithTokenField();
testYe2ToolWithAuthorizationField();
testYe2ToolWithoutAuth();
System.out.println("\n========================================");
System.out.println(" 所有验证通过! ✓");
System.out.println("========================================");
}
/** 独立验证 normalizeBearerToken 逻辑(内联实现与 Ye2Tool 保持一致)*/
private static String normalizeBearerToken(String raw) {
if (raw == null || raw.trim().isEmpty()) {
return null;
}
String token = raw.trim();
if (token.regionMatches(true, 0, "Bearer ", 0, 7)) {
token = token.substring(7).trim();
}
return token.isEmpty() ? null : token;
}
private static void testNormalizeBearerToken() {
System.out.println("=== 验证 normalizeBearerToken 逻辑 ===");
assertNormalize("testtoken123abc", "testtoken123abc", "纯 token 不变");
assertNormalize("Bearer testtoken123abc", "testtoken123abc", "******");
assertNormalize("bearer testtoken123abc", "testtoken123abc", "小写 bearer 前缀被去掉");
assertNormalize("BEARER testtoken123abc", "testtoken123abc", "大写 BEARER 前缀被去掉");
assertNormalize(" Bearer testtoken123abc ", "testtoken123abc", "前后空格被 trim");
assertNormalizeNull(null, "null 输入返回 null");
assertNormalizeNull("", "空字符串返回 null");
assertNormalizeNull(" ", "纯空格返回 null");
System.out.println();
}
private static void assertNormalize(String input, String expected, String desc) {
String actual = normalizeBearerToken(input);
if (!expected.equals(actual)) {
throw new AssertionError("FAIL [" + desc + "]: expected='" + expected + "', actual='" + actual + "'");
}
System.out.println("" + desc);
}
private static void assertNormalizeNull(String input, String desc) {
String actual = normalizeBearerToken(input);
if (actual != null) {
throw new AssertionError("FAIL [" + desc + "]: expected null, actual='" + actual + "'");
}
System.out.println("" + desc);
}
private static void testYe2ToolWithTokenField() {
System.out.println("=== 测试 Ye2Tooltoken 字段)===");
try {
MultiMap auths = MultiMap.caseInsensitiveMultiMap();
auths.set("token", "testtoken123abc");
Map<String, Object> otherParam = new HashMap<>();
otherParam.put("auths", auths);
ShareLinkInfo shareLinkInfo = ShareLinkInfo.newBuilder()
.type("YE")
.panName("123网盘")
.shareKey("test_key_token")
.shareUrl("https://www.123pan.com/s/test123")
.build();
shareLinkInfo.setOtherParam(otherParam);
Ye2Tool ye2Tool = new Ye2Tool(shareLinkInfo);
System.out.println("✓ Ye2Tool 实例创建成功(token 字段)\n");
} catch (Exception e) {
System.err.println("✗ Ye2Tooltoken 字段)测试失败: " + e.getMessage());
e.printStackTrace();
}
}
private static void testYe2ToolWithAuthorizationField() {
System.out.println("=== 测试 Ye2ToolAuthorization 字段,带 Bearer===");
try {
MultiMap auths = MultiMap.caseInsensitiveMultiMap();
auths.set("Authorization", "Bearer testtoken123abc");
Map<String, Object> otherParam = new HashMap<>();
otherParam.put("auths", auths);
ShareLinkInfo shareLinkInfo = ShareLinkInfo.newBuilder()
.type("YE")
.panName("123网盘")
.shareKey("test_key_auth")
.shareUrl("https://www.123pan.com/s/test456")
.build();
shareLinkInfo.setOtherParam(otherParam);
Ye2Tool ye2Tool = new Ye2Tool(shareLinkInfo);
System.out.println("✓ Ye2Tool 实例创建成功(Authorization 字段)\n");
} catch (Exception e) {
System.err.println("✗ Ye2ToolAuthorization 字段)测试失败: " + e.getMessage());
e.printStackTrace();
}
}
private static void testYe2ToolWithoutAuth() {
System.out.println("=== 测试 Ye2Tool(无认证配置)===");
try {
ShareLinkInfo shareLinkInfo = ShareLinkInfo.newBuilder()
.type("YE")
.panName("123网盘")
.shareKey("test_key_noauth")
.shareUrl("https://www.123pan.com/s/test789")
.build();
Ye2Tool ye2Tool = new Ye2Tool(shareLinkInfo);
System.out.println("✓ Ye2Tool 实例创建成功(无认证)\n");
} catch (Exception e) {
System.err.println("✗ Ye2Tool(无认证)测试失败: " + e.getMessage());
e.printStackTrace();
}
}
}