mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 07:57:28 +00:00
fix: NPE 修复、资源泄漏修复及其他 Bug 修复
- 修复 12 处 NPE 风险: FjTool/FsTool/IzTool/LzTool/MkwTool/P115Tool/PdbTool/QQTool/ParserCreate/CommonUtils/ShareLinkInfo/URLParamUtil - 修复 4 处 Vert.x 资源泄漏: 测试类中 Vertx 实例未关闭 - 修复 CacheManager 防重入和 registerPeriodicCleanup 就绪检查 - 修复 ParserApi 中 redirectUrl()/viewUrl() Promise 未 complete - 修复 CacheManager.updateTotalByField Promise 永不完成 - 修复 AppMain ShutdownHook 注册,确保 Vert.x 先于 JDBCPoolInit 关闭 - 修复 RouterHandlerFactory failureHandler 恢复返回 failure message - 修复 ParserCreate/LzTool 收窄 catch 异常类型 - 修复 IzTool/FjTool/IzToolWithAuth 并发安全 (volatile + header 副本) - 修复 P115Tool UA 为 null 时的 NPE,添加默认 User-Agent - Font Awesome CDN 换源为 s4.zstatic.net,避免 bootcdn 投毒风险 - DirectoryTree selectAll 补 parserUrl 检查,Home 组件名 App→Home
This commit is contained in:
@@ -86,7 +86,10 @@ public class ShareLinkInfo {
|
||||
// 将type和shareKey组合成一个字符串作为缓存key
|
||||
String key = type + ":" + shareKey;
|
||||
if (type.equals("p115")) {
|
||||
key += ("_" + otherParam.get("UA").toString().hashCode());
|
||||
Object ua = otherParam != null ? otherParam.get("UA") : null;
|
||||
if (ua != null) {
|
||||
key += ("_" + ua.toString().hashCode());
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -81,16 +81,16 @@ public class ParserCreate {
|
||||
if (shareKey != null) {
|
||||
shareLinkInfo.setShareKey(shareKey);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
} catch (IllegalStateException | IllegalArgumentException ignored) {}
|
||||
|
||||
// 提取密码
|
||||
try {
|
||||
String pwd = matcher.group("PWD");
|
||||
if (StringUtils.isNotEmpty(pwd)) {
|
||||
shareLinkInfo.setSharePassword(pwd);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
} catch (IllegalStateException | IllegalArgumentException ignored) {}
|
||||
|
||||
// 设置标准URL
|
||||
if (customParserConfig.getStandardUrlTemplate() != null) {
|
||||
String standardUrl = customParserConfig.getStandardUrlTemplate()
|
||||
@@ -133,7 +133,7 @@ public class ParserCreate {
|
||||
shareLinkInfo.setSharePassword(pwd);
|
||||
}
|
||||
standardUrl = standardUrl.replace("{pwd}", pwd);
|
||||
} catch (Exception ignored) {}
|
||||
} catch (IllegalStateException | IllegalArgumentException ignored) {}
|
||||
|
||||
shareLinkInfo.setShareUrl(shareUrl);
|
||||
shareLinkInfo.setShareKey(shareKey);
|
||||
@@ -266,15 +266,15 @@ public class ParserCreate {
|
||||
if (shareKey != null) {
|
||||
shareLinkInfo.setShareKey(shareKey);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
} catch (IllegalStateException | IllegalArgumentException ignored) {}
|
||||
|
||||
try {
|
||||
String password = matcher.group("PWD");
|
||||
if (password != null) {
|
||||
shareLinkInfo.setSharePassword(password);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
} catch (IllegalStateException | IllegalArgumentException ignored) {}
|
||||
|
||||
// 设置标准URL(如果有模板)
|
||||
if (customConfig.getStandardUrlTemplate() != null) {
|
||||
String standardUrl = customConfig.getStandardUrlTemplate()
|
||||
|
||||
@@ -534,8 +534,8 @@ public class JsHttpClient {
|
||||
} else {
|
||||
promise.fail(result.cause());
|
||||
}
|
||||
}).onFailure(Throwable::printStackTrace);
|
||||
|
||||
}).onFailure(e -> log.error("HTTP请求失败", e));
|
||||
|
||||
// 等待响应完成(使用配置的超时时间)
|
||||
HttpResponse<Buffer> response = promise.future().toCompletionStage()
|
||||
.toCompletableFuture()
|
||||
|
||||
@@ -355,7 +355,7 @@ public class JsPlaygroundExecutor {
|
||||
*/
|
||||
public List<JsPlaygroundLogger.LogEntry> getLogs() {
|
||||
List<JsPlaygroundLogger.LogEntry> logs = playgroundLogger.getLogs();
|
||||
System.out.println("[JsPlaygroundExecutor] 获取日志,数量: " + logs.size());
|
||||
log.debug("获取日志,数量: {}", logs.size());
|
||||
return logs;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,9 +109,9 @@ public class FjTool extends PanBase {
|
||||
|
||||
// String uuid = UUID.randomUUID().toString().toLowerCase(); // 也可以使用 UUID.randomUUID().toString()
|
||||
|
||||
static String token = null;
|
||||
static String userId = null;
|
||||
public static boolean authFlag = true;
|
||||
static volatile String token = null;
|
||||
static volatile String userId = null;
|
||||
public static volatile boolean authFlag = true;
|
||||
|
||||
public FjTool(ShareLinkInfo shareLinkInfo) {
|
||||
super(shareLinkInfo);
|
||||
@@ -289,12 +289,14 @@ public class FjTool extends PanBase {
|
||||
JsonObject json = asJson(res2);
|
||||
if (json.getInteger("code") == 200) {
|
||||
token = json.getJsonObject("data").getString("appToken");
|
||||
header0.set("appToken", token);
|
||||
log.info("登录成功 token: {}", token);
|
||||
MultiMap h0 = MultiMap.caseInsensitiveMultiMap();
|
||||
h0.addAll(header0);
|
||||
h0.set("appToken", token);
|
||||
log.info("登录成功 token: {}...", token != null ? token.substring(0, Math.min(8, token.length())) : "null");
|
||||
client.postAbs(UriTemplate.of(TOKEN_VERIFY_URL))
|
||||
.setTemplateParam("uuid", uuid)
|
||||
.setTemplateParam("ts", tsEncode2)
|
||||
.putHeaders(header0).send().onSuccess(res -> {
|
||||
.putHeaders(h0).send().onSuccess(res -> {
|
||||
if (asJson(res).getInteger("code") == 200) {
|
||||
if (FjTool.userId == null) {
|
||||
FjTool.userId = asJson(res).getJsonObject("map").getString("userId");
|
||||
@@ -454,7 +456,10 @@ public class FjTool extends PanBase {
|
||||
// 如果参数里的目录ID不为空,则直接解析目录
|
||||
String dirId = (String) shareLinkInfo.getOtherParam().get("dirId");
|
||||
if (dirId != null && !dirId.isEmpty()) {
|
||||
uuid = shareLinkInfo.getOtherParam().get("uuid").toString();
|
||||
Object uuidObj = shareLinkInfo.getOtherParam().get("uuid");
|
||||
if (uuidObj != null) {
|
||||
uuid = uuidObj.toString();
|
||||
}
|
||||
parserDir(dirId, shareId, promise0);
|
||||
return promise0.future();
|
||||
}
|
||||
@@ -495,7 +500,7 @@ public class FjTool extends PanBase {
|
||||
JsonArray list;
|
||||
try {
|
||||
JsonObject jsonObject = asJson(res);
|
||||
System.out.println(jsonObject.encodePrettily());
|
||||
log.debug("目录列表: {}", jsonObject.encodePrettily());
|
||||
list = jsonObject.getJsonArray("list");
|
||||
} catch (Exception e) {
|
||||
log.error("解析目录失败: {}", res.bodyAsString());
|
||||
@@ -576,6 +581,10 @@ public class FjTool extends PanBase {
|
||||
|
||||
// 第二次请求
|
||||
JsonObject paramJson = (JsonObject)shareLinkInfo.getOtherParam().get("paramJson");
|
||||
if (paramJson == null) {
|
||||
promise.fail("缺少 paramJson 参数");
|
||||
return promise.future();
|
||||
}
|
||||
clientNoRedirects.getAbs(UriTemplate.of(SECOND_REQUEST_URL_VIP))
|
||||
.setTemplateParam("fidEncode", paramJson.getString("fidEncode"))
|
||||
.setTemplateParam("uuid", paramJson.getString("uuid"))
|
||||
|
||||
@@ -389,6 +389,10 @@ public class FsTool extends PanBase {
|
||||
|
||||
try {
|
||||
JsonObject paramJson = (JsonObject) shareLinkInfo.getOtherParam().get("paramJson");
|
||||
if (paramJson == null) {
|
||||
parsePromise.fail("缺少 paramJson 参数");
|
||||
return parsePromise.future();
|
||||
}
|
||||
String shareUrl = paramJson.getString("shareUrl");
|
||||
String objToken = paramJson.getString("objToken");
|
||||
String tenant = extractTenant(shareUrl);
|
||||
@@ -444,7 +448,7 @@ public class FsTool extends PanBase {
|
||||
if (m1.find()) {
|
||||
try {
|
||||
return URLDecoder.decode(m1.group(1).trim(), StandardCharsets.UTF_8);
|
||||
} catch (Exception ignored) {
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +457,7 @@ public class FsTool extends PanBase {
|
||||
if (m2.find()) {
|
||||
try {
|
||||
return URLDecoder.decode(m2.group(1).trim(), StandardCharsets.UTF_8);
|
||||
} catch (Exception ignored) {
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ public class IzTool extends PanBase {
|
||||
|
||||
String uuid = UUID.randomUUID().toString().toLowerCase(); // 也可以使用 UUID.randomUUID().toString()
|
||||
|
||||
public static String token = null;
|
||||
public static boolean authFlag = true;
|
||||
public static volatile String token = null;
|
||||
public static volatile boolean authFlag = true;
|
||||
|
||||
public Future<String> parse() {
|
||||
|
||||
@@ -101,8 +101,8 @@ public class IzTool extends PanBase {
|
||||
// 检查并输出认证状态
|
||||
if (shareLinkInfo.getOtherParam().containsKey("auths")) {
|
||||
boolean isTempAuth = shareLinkInfo.getOtherParam().containsKey("__TEMP_AUTH_ADDED");
|
||||
log.info("文件解析检测到认证信息: isTempAuth={}, authFlag={}, token={}",
|
||||
isTempAuth, authFlag, token != null ? "已登录(" + token.substring(0, Math.min(10, token.length())) + "...)" : "未登录");
|
||||
log.info("文件解析检测到认证信息: isTempAuth={}, authFlag={}, token={}",
|
||||
isTempAuth, authFlag, token != null ? "已登录(" + token.substring(0, Math.min(8, token.length())) + "...)" : "未登录");
|
||||
|
||||
// 如果需要认证但还没有token,先执行登录
|
||||
if ((isTempAuth || authFlag) && token == null) {
|
||||
@@ -118,7 +118,7 @@ public class IzTool extends PanBase {
|
||||
// 登录失败,继续使用免登录模式
|
||||
});
|
||||
} else if (token != null) {
|
||||
log.info("文件解析使用已有token: {}...", token.substring(0, Math.min(10, token.length())));
|
||||
log.info("文件解析使用已有token: {}...", token.substring(0, Math.min(8, token.length())));
|
||||
}
|
||||
} else {
|
||||
log.debug("文件解析无认证信息,使用免登录模式");
|
||||
@@ -247,7 +247,7 @@ public class IzTool extends PanBase {
|
||||
log.warn("登录失败: {}", failRes.getMessage());
|
||||
fail(failRes.getMessage());
|
||||
}).onSuccess(r-> {
|
||||
httpRequest.setTemplateParam("appToken", header.get("appToken"))
|
||||
httpRequest.setTemplateParam("appToken", token)
|
||||
.putHeaders(header);
|
||||
httpRequest.send().onSuccess(this::down).onFailure(handleFail("请求2"));
|
||||
});
|
||||
@@ -263,12 +263,12 @@ public class IzTool extends PanBase {
|
||||
log.warn("重新登录失败: {}", failRes.getMessage());
|
||||
fail(failRes.getMessage());
|
||||
}).onSuccess(r-> {
|
||||
httpRequest.setTemplateParam("appToken", header.get("appToken"))
|
||||
httpRequest.setTemplateParam("appToken", token)
|
||||
.putHeaders(header);
|
||||
httpRequest.send().onSuccess(this::down).onFailure(handleFail("请求2"));
|
||||
});
|
||||
} else {
|
||||
httpRequest.setTemplateParam("appToken", header.get("appToken"))
|
||||
httpRequest.setTemplateParam("appToken", token)
|
||||
.putHeaders(header);
|
||||
httpRequest.send().onSuccess(this::down).onFailure(handleFail("请求2"));
|
||||
}
|
||||
@@ -311,8 +311,7 @@ public class IzTool extends PanBase {
|
||||
JsonObject json = asJson(res2);
|
||||
if (json.getInteger("code") == 200) {
|
||||
token = json.getJsonObject("data").getString("appToken");
|
||||
header.set("appToken", token);
|
||||
log.info("登录成功 token: {}", token);
|
||||
log.info("登录成功 token: {}...", token != null ? token.substring(0, Math.min(8, token.length())) : "null");
|
||||
promise1.complete();
|
||||
} else {
|
||||
// 检查是否为临时认证
|
||||
@@ -463,7 +462,10 @@ public class IzTool extends PanBase {
|
||||
// 如果参数里的目录ID不为空,则直接解析目录
|
||||
String dirId = (String) shareLinkInfo.getOtherParam().get("dirId");
|
||||
if (dirId != null && !dirId.isEmpty()) {
|
||||
uuid = shareLinkInfo.getOtherParam().get("uuid").toString();
|
||||
Object uuidObj = shareLinkInfo.getOtherParam().get("uuid");
|
||||
if (uuidObj != null) {
|
||||
uuid = uuidObj.toString();
|
||||
}
|
||||
parserDir(dirId, shareId, promise);
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ public class IzToolWithAuth extends PanBase {
|
||||
|
||||
String uuid = UUID.randomUUID().toString().toLowerCase(); // 也可以使用 UUID.randomUUID().toString()
|
||||
|
||||
public static String token = null;
|
||||
public static boolean authFlag = true;
|
||||
public static volatile String token = null;
|
||||
public static volatile boolean authFlag = true;
|
||||
|
||||
public Future<String> parse() {
|
||||
|
||||
@@ -216,7 +216,7 @@ public class IzToolWithAuth extends PanBase {
|
||||
log.warn("登录失败: {}", failRes.getMessage());
|
||||
fail(failRes.getMessage());
|
||||
}).onSuccess(r-> {
|
||||
httpRequest.setTemplateParam("appToken", header.get("appToken"))
|
||||
httpRequest.setTemplateParam("appToken", token)
|
||||
.putHeaders(header);
|
||||
httpRequest.send().onSuccess(this::down).onFailure(handleFail("请求2"));
|
||||
});
|
||||
@@ -232,12 +232,12 @@ public class IzToolWithAuth extends PanBase {
|
||||
log.warn("重新登录失败: {}", failRes.getMessage());
|
||||
fail(failRes.getMessage());
|
||||
}).onSuccess(r-> {
|
||||
httpRequest.setTemplateParam("appToken", header.get("appToken"))
|
||||
httpRequest.setTemplateParam("appToken", token)
|
||||
.putHeaders(header);
|
||||
httpRequest.send().onSuccess(this::down).onFailure(handleFail("请求2"));
|
||||
});
|
||||
} else {
|
||||
httpRequest.setTemplateParam("appToken", header.get("appToken"))
|
||||
httpRequest.setTemplateParam("appToken", token)
|
||||
.putHeaders(header);
|
||||
httpRequest.send().onSuccess(this::down).onFailure(handleFail("请求2"));
|
||||
}
|
||||
@@ -280,8 +280,7 @@ public class IzToolWithAuth extends PanBase {
|
||||
JsonObject json = asJson(res2);
|
||||
if (json.getInteger("code") == 200) {
|
||||
token = json.getJsonObject("data").getString("appToken");
|
||||
header.set("appToken", token);
|
||||
log.info("登录成功 token: {}", token);
|
||||
log.info("登录成功 token: {}...", token != null ? token.substring(0, Math.min(8, token.length())) : "null");
|
||||
promise1.complete();
|
||||
} else {
|
||||
// 检查是否为临时认证
|
||||
@@ -432,7 +431,8 @@ public class IzToolWithAuth extends PanBase {
|
||||
// 如果参数里的目录ID不为空,则直接解析目录
|
||||
String dirId = (String) shareLinkInfo.getOtherParam().get("dirId");
|
||||
if (dirId != null && !dirId.isEmpty()) {
|
||||
uuid = shareLinkInfo.getOtherParam().get("uuid").toString();
|
||||
Object uuidObj = shareLinkInfo.getOtherParam().get("uuid");
|
||||
uuid = uuidObj != null ? uuidObj.toString() : null;
|
||||
parserDir(dirId, shareId, promise);
|
||||
return promise.future();
|
||||
}
|
||||
@@ -480,7 +480,7 @@ public class IzToolWithAuth extends PanBase {
|
||||
requestDirList(id, shareId, tsEncode, promise);
|
||||
})
|
||||
.onSuccess(r -> {
|
||||
log.info("目录解析登录成功,token={}, 使用 VIP 模式", token != null ? token.substring(0, 10) + "..." : "null");
|
||||
log.info("目录解析登录成功,token={}, 使用 VIP 模式", token != null ? token.substring(0, Math.min(8, token.length())) + "..." : "null");
|
||||
requestDirList(id, shareId, tsEncode, promise);
|
||||
});
|
||||
return;
|
||||
@@ -627,7 +627,7 @@ public class IzToolWithAuth extends PanBase {
|
||||
|
||||
// 如果有 token,使用 VIP 接口
|
||||
if (StringUtils.isNotBlank(appToken)) {
|
||||
log.debug("parseById 使用 VIP 接口, appToken={}", appToken.substring(0, Math.min(10, appToken.length())) + "...");
|
||||
log.debug("parseById 使用 VIP 接口, appToken={}", appToken.substring(0, Math.min(8, appToken.length())) + "...");
|
||||
webClientSession.getAbs(UriTemplate.of(SECOND_REQUEST_URL_VIP))
|
||||
.putHeaders(header)
|
||||
.setTemplateParam("fidEncode", paramJson.getString("fidEncode"))
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.vertx.ext.web.client.WebClientSession;
|
||||
import org.openjdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -107,7 +108,7 @@ public class LzTool extends PanBase {
|
||||
try {
|
||||
setFileInfo(html, shareLinkInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("文件信息解析异常", e);
|
||||
}
|
||||
// 匹配iframe
|
||||
Pattern compile = Pattern.compile("src=\"(/fn\\?[a-zA-Z\\d_+/=]{16,})\"");
|
||||
@@ -175,7 +176,7 @@ public class LzTool extends PanBase {
|
||||
if (firstDot >= 0) {
|
||||
domain = host.substring(firstDot); // e.g. ".lanzoum.com"
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (MalformedURLException ignored) {}
|
||||
// 创建一个 Cookie 并放入 CookieStore
|
||||
DefaultCookie nettyCookie = new DefaultCookie("acw_sc__v2", acw_sc__v2);
|
||||
nettyCookie.setDomain(domain);
|
||||
@@ -217,7 +218,7 @@ public class LzTool extends PanBase {
|
||||
return;
|
||||
}
|
||||
Map<?, ?> signMap = (Map<?, ?>)obj.get("data");
|
||||
String url0 = obj.get("url").toString();
|
||||
String url0 = String.valueOf(obj.get("url"));
|
||||
MultiMap map = MultiMap.caseInsensitiveMultiMap();
|
||||
signMap.forEach((k, v) -> {
|
||||
map.add((String) k, v.toString());
|
||||
@@ -275,7 +276,7 @@ public class LzTool extends PanBase {
|
||||
String h = du.getHost();
|
||||
int dot = h.indexOf('.');
|
||||
if (dot >= 0) downDomain = h.substring(dot);
|
||||
} catch (Exception ignored) {}
|
||||
} catch (MalformedURLException ignored) {}
|
||||
// 创建一个 Cookie 并放入 CookieStore
|
||||
DefaultCookie nettyCookie = new DefaultCookie("acw_sc__v2", acw_sc__v2);
|
||||
nettyCookie.setDomain(downDomain);
|
||||
@@ -290,12 +291,12 @@ public class LzTool extends PanBase {
|
||||
if (location0 == null) {
|
||||
fail(downUrl + " -> 直链获取失败2, 可能分享已失效");
|
||||
} else {
|
||||
setDateAndComplate(location0);
|
||||
setDateAndComplete(location0);
|
||||
}
|
||||
}).onFailure(handleFail(downUrl));
|
||||
return;
|
||||
}
|
||||
setDateAndComplate(location);
|
||||
setDateAndComplete(location);
|
||||
})
|
||||
.onFailure(handleFail(downUrl));
|
||||
} catch (Exception e) {
|
||||
@@ -304,7 +305,7 @@ public class LzTool extends PanBase {
|
||||
}).onFailure(handleFail(url));
|
||||
}
|
||||
|
||||
private void setDateAndComplate(String location0) {
|
||||
private void setDateAndComplete(String location0) {
|
||||
// 分享时间 提取url中的时间戳格式:lanzoui.com/abc/abc/yyyy/mm/dd/
|
||||
String regex = "(\\d{4}/\\d{1,2}/\\d{1,2})";
|
||||
Matcher matcher = Pattern.compile(regex).matcher(location0);
|
||||
|
||||
@@ -29,19 +29,19 @@ public class MkwTool extends PanBase {
|
||||
clientSession.getAbs(shareUrl).send().onSuccess(result -> {
|
||||
String cookie = result.headers().get("set-cookie");
|
||||
|
||||
if (!cookie.isEmpty()) {
|
||||
if (cookie != null && !cookie.isEmpty()) {
|
||||
|
||||
String regex = "([A-Za-z0-9_]+)=([A-Za-z0-9]+)";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(cookie);
|
||||
if (matcher.find()) {
|
||||
System.out.println(matcher.group(1));
|
||||
System.out.println(matcher.group(2));
|
||||
log.debug("cookie key: {}", matcher.group(1));
|
||||
log.debug("cookie value: {}", matcher.group(2));
|
||||
|
||||
var key = matcher.group(1);
|
||||
var token = matcher.group(2);
|
||||
String sign = JsExecUtils.getKwSign(token, key);
|
||||
System.out.println(sign);
|
||||
log.debug("sign: {}", sign);
|
||||
clientSession.getAbs(UriTemplate.of(API_URL)).setTemplateParam("mid", shareLinkInfo.getShareKey())
|
||||
.putHeader("Secret", sign).send().onSuccess(res -> {
|
||||
JsonObject json = asJson(res);
|
||||
@@ -54,7 +54,7 @@ public class MkwTool extends PanBase {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("解析失败", e);
|
||||
fail("解析失败");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -21,6 +21,8 @@ public class P115Tool extends PanBase {
|
||||
private static final String SECOND_REQUEST_URL = API_URL_PREFIX + "share/skip_login_downurl";
|
||||
|
||||
|
||||
private static final String DEFAULT_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
|
||||
|
||||
private static final MultiMap header;
|
||||
|
||||
static {
|
||||
@@ -49,9 +51,11 @@ public class P115Tool extends PanBase {
|
||||
|
||||
public Future<String> parse() {
|
||||
// 第一次请求 获取文件信息
|
||||
Object uaObj = shareLinkInfo.getOtherParam().get("UA");
|
||||
String ua = uaObj != null ? uaObj.toString() : DEFAULT_UA;
|
||||
client.getAbs(UriTemplate.of(FIRST_REQUEST_URL))
|
||||
.putHeaders(header)
|
||||
.putHeader("User-Agent", shareLinkInfo.getOtherParam().get("UA").toString())
|
||||
.putHeader("User-Agent", ua)
|
||||
.setTemplateParam("dataKey", shareLinkInfo.getShareKey())
|
||||
.setTemplateParam("dataPwd", shareLinkInfo.getSharePassword())
|
||||
.send().onSuccess(res -> {
|
||||
@@ -68,7 +72,7 @@ public class P115Tool extends PanBase {
|
||||
// share_code={dataKey}&receive_code={dataPwd}&file_id={file_id}
|
||||
client.postAbs(SECOND_REQUEST_URL)
|
||||
.putHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
|
||||
.putHeader("User-Agent", shareLinkInfo.getOtherParam().get("UA").toString())
|
||||
.putHeader("User-Agent", ua)
|
||||
.sendForm(MultiMap.caseInsensitiveMultiMap()
|
||||
.set("share_code", shareLinkInfo.getShareKey())
|
||||
.set("receive_code", shareLinkInfo.getSharePassword())
|
||||
|
||||
@@ -85,7 +85,7 @@ public class PdbTool extends PanBase implements IPanTool {
|
||||
})
|
||||
.onFailure(handleFail());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("URL编码异常", e);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
@@ -74,9 +74,9 @@ public class QQTool extends PanBase {
|
||||
});
|
||||
|
||||
// 调试匹配的情况
|
||||
System.out.println("文件名称: " + filename);
|
||||
System.out.println("文件大小: " + filesize);
|
||||
System.out.println("文件直链: " + fileurl);
|
||||
log.debug("文件名称: {}", filename);
|
||||
log.debug("文件大小: {}", filesize);
|
||||
log.debug("文件直链: {}", fileurl);
|
||||
|
||||
// 提交
|
||||
promise.complete(fileurl.replace("\\x26", "&"));
|
||||
|
||||
@@ -33,6 +33,9 @@ public class CommonUtils {
|
||||
public static Map<String, String> getURLParams(String url) throws MalformedURLException {
|
||||
URL fullUrl = new URL(url);
|
||||
String query = fullUrl.getQuery();
|
||||
if (query == null || query.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
String[] params = query.split("&");
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (String param : params) {
|
||||
|
||||
Reference in New Issue
Block a user