🎉 优化系统架构.
This commit is contained in:
26
orion-visor-modules/orion-visor-module-common/pom.xml
Normal file
26
orion-visor-modules/orion-visor-module-common/pom.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<parent>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-modules</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>orion-visor-module-common</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>项目公共模块</description>
|
||||
<url>https://github.com/dromara/orion-visor</url>
|
||||
|
||||
<dependencies>
|
||||
<!-- common -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -20,7 +20,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.module.asset.define.config;
|
||||
package org.dromara.visor.module.common.config;
|
||||
|
||||
import org.dromara.visor.common.config.ConfigRef;
|
||||
import org.dromara.visor.common.config.ConfigStore;
|
||||
@@ -20,7 +20,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.module.asset.define.config;
|
||||
package org.dromara.visor.module.common.config;
|
||||
|
||||
import org.dromara.visor.common.config.ConfigRef;
|
||||
import org.dromara.visor.common.config.ConfigStore;
|
||||
@@ -20,7 +20,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.module.infra.define.config;
|
||||
package org.dromara.visor.module.common.config;
|
||||
|
||||
import org.dromara.visor.common.config.ConfigRef;
|
||||
import org.dromara.visor.common.config.ConfigStore;
|
||||
@@ -20,7 +20,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.module.asset.define.config;
|
||||
package org.dromara.visor.module.common.config;
|
||||
|
||||
import org.dromara.visor.common.config.ConfigRef;
|
||||
import org.dromara.visor.common.config.ConfigStore;
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2023 - present Dromara, All rights reserved.
|
||||
*
|
||||
* https://visor.dromara.org
|
||||
* https://visor.dromara.org.cn
|
||||
* https://visor.orionsec.cn
|
||||
*
|
||||
* Members:
|
||||
* Jiahang Li - ljh1553488six@139.com - author
|
||||
*
|
||||
* Licensed 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 org.dromara.visor.module.common.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* guacd 配置
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2025/6/9 19:41
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "guacd")
|
||||
public class GuacdConfig {
|
||||
|
||||
/**
|
||||
* guacd 主机
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* guacd 端口
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* guacd 驱动路径
|
||||
*/
|
||||
private String drivePath;
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.module.asset.handler.host.transfer.model;
|
||||
package org.dromara.visor.module.common.entity.dto;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import lombok.Data;
|
||||
@@ -35,7 +35,7 @@ import java.util.Date;
|
||||
* @since 2024/4/15 23:13
|
||||
*/
|
||||
@Data
|
||||
public class SftpFileBackupParams {
|
||||
public class SftpFileBackupDTO {
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
@@ -52,9 +52,9 @@ public class SftpFileBackupParams {
|
||||
*/
|
||||
private String time;
|
||||
|
||||
public SftpFileBackupParams(String fileName) {
|
||||
this.fileName = fileName;
|
||||
public SftpFileBackupDTO(String fileName) {
|
||||
Date date = new Date();
|
||||
this.fileName = fileName;
|
||||
this.timestamp = date.getTime();
|
||||
this.time = Dates.format(date, Dates.YMD_HMS2);
|
||||
}
|
||||
@@ -20,16 +20,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.dromara.visor.module.asset.utils;
|
||||
package org.dromara.visor.module.common.utils;
|
||||
|
||||
import org.dromara.visor.module.common.config.AppSftpConfig;
|
||||
import org.dromara.visor.module.common.entity.dto.SftpFileBackupDTO;
|
||||
import cn.orionsec.kit.lang.constant.Letters;
|
||||
import cn.orionsec.kit.lang.utils.Booleans;
|
||||
import cn.orionsec.kit.lang.utils.Strings;
|
||||
import cn.orionsec.kit.lang.utils.io.Files1;
|
||||
import cn.orionsec.kit.net.host.sftp.SftpExecutor;
|
||||
import cn.orionsec.kit.net.host.sftp.SftpFile;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.dromara.visor.module.asset.define.config.AppSftpConfig;
|
||||
import org.dromara.visor.module.asset.handler.host.transfer.model.SftpFileBackupParams;
|
||||
|
||||
/**
|
||||
* sftp 工具类
|
||||
@@ -60,11 +62,28 @@ public class SftpUtils {
|
||||
SftpFile file = executor.getFile(path);
|
||||
if (file != null) {
|
||||
// 文件存在则备份
|
||||
SftpFileBackupParams backupParams = new SftpFileBackupParams(file.getName());
|
||||
SftpFileBackupDTO backupParams = new SftpFileBackupDTO(file.getName());
|
||||
String target = Strings.format(appSftpConfig.getUploadBackupFileName(), JSON.parseObject(JSON.toJSONString(backupParams)));
|
||||
// 移动
|
||||
executor.move(path, target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取移动目标路径
|
||||
*
|
||||
* @param source source
|
||||
* @param target target
|
||||
* @return absolute target
|
||||
*/
|
||||
public static String getAbsoluteTargetPath(String source, String target) {
|
||||
if (target.charAt(0) == Letters.SLASH) {
|
||||
// 绝对路径
|
||||
return Files1.getPath(Files1.normalize(target));
|
||||
} else {
|
||||
// 相对路径
|
||||
return Files1.getPath(Files1.normalize(Files1.getPath(source + "/../" + target)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"groups": [
|
||||
{
|
||||
"name": "guacd",
|
||||
"type": "org.dromara.visor.module.common.config.GuacdConfig",
|
||||
"sourceType": "org.dromara.visor.module.common.config.GuacdConfig"
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"name": "guacd.host",
|
||||
"type": "java.lang.String",
|
||||
"description": "guacd 主机."
|
||||
},
|
||||
{
|
||||
"name": "guacd.port",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "guacd 端口."
|
||||
},
|
||||
{
|
||||
"name": "guacd.drive-path",
|
||||
"type": "java.lang.String",
|
||||
"description": "guacd 驱动路径."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -16,8 +16,11 @@
|
||||
<url>https://github.com/dromara/orion-visor</url>
|
||||
|
||||
<modules>
|
||||
<module>orion-visor-module-common</module>
|
||||
<module>orion-visor-module-infra</module>
|
||||
<module>orion-visor-module-asset</module>
|
||||
<module>orion-visor-module-exec</module>
|
||||
<module>orion-visor-module-terminal</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
Reference in New Issue
Block a user