UCpan和移动云空间API测试

This commit is contained in:
QAIU
2023-05-23 17:34:11 +08:00
parent b95238664b
commit 455225e566
18 changed files with 332 additions and 34 deletions

View File

@@ -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);
}

View File

@@ -19,7 +19,7 @@
<lombok.version>1.18.12</lombok.version>
<slf4j.version>2.0.5</slf4j.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<jackson.version>2.11.3</jackson.version>
<jackson.version>2.14.2</jackson.version>
</properties>
<dependencyManagement>

View File

@@ -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<JsonObject> handle;
private Thread mainThread;
public static Deploy instance() {
return INSTANCE;
}
public void start(String[] args, Handler<JsonObject> 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<String, Object> localMap = sharedData.getLocalMap("local");
localMap.put("globalConfig", globalConfig);
localMap.put("customConfig", customConfig);
localMap.put("server", globalConfig.getJsonObject("server"));
handle.handle(globalConfig);
LocalMap<String, Object> 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) {

View File

@@ -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";
}

View File

@@ -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<JsonObject> CONFIG = ConfigUtil.readYamlConfig(PATH_PROXY_CONFIG);
private static final String DEFAULT_PATH_404 = "webroot/err/404.html";

View File

@@ -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();
}

View File

@@ -10,6 +10,8 @@ import org.jsoup.Jsoup;
import java.util.Map;
/**
* 奶牛快传解析工具
*
* @author <a href="https://qaiu.top">QAIU</a>
* @date 2023/4/21 21:19
*/

View File

@@ -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");
}
}

View File

@@ -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
*/

View File

@@ -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<String> login(RealUser user) {
public Future<String> login(SysUser user) {
log.info("<------- login: {}", user.getUsername());
return userService.login(user);
}

View File

@@ -0,0 +1,4 @@
package cn.qaiu.lz.web.model;
public class CowUser {
}

View File

@@ -0,0 +1,4 @@
package cn.qaiu.lz.web.model;
public class LzUser {
}

View File

@@ -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");
}

View File

@@ -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<String> login(RealUser user);
Future<String> login(SysUser user);
}

View File

@@ -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<String> login(RealUser user) {
public Future<String> login(SysUser user) {
return Future.succeededFuture("111");
}

View File

@@ -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": "<fileExtends><shareRoot></shareRoot><isLock>0</isLock><isEncrypt>0</isEncrypt></fileExtends>",
"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": "<fileExtends><shareRoot></shareRoot><isLock>0</isLock><isEncrypt>0</isEncrypt></fileExtends>",
"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
}]
}

View File

@@ -53,6 +53,7 @@
</appender>
<logger name="io.netty" level="warn"/>
<logger name="io.vertx" level="info"/>
<logger name="com.zaxxer.hikari" level="info"/>
<root level="debug">
<appender-ref ref="STDOUT"/>
<!-- <appender-ref ref="FILE"/>-->

View File

@@ -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();
});
}
}