!1 增加xbase64配置文件生成逻辑

Merge pull request !1 from wisokey/master
This commit is contained in:
M0914
2025-12-11 01:44:39 +00:00
committed by Gitee
5 changed files with 68 additions and 2 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
FROM maven:3-openjdk-8 as build
FROM maven:3-openjdk-8 AS build
WORKDIR /app
COPY . .
RUN mvn clean package
@@ -7,6 +7,7 @@ FROM eclipse-temurin:8-jre
WORKDIR /app
COPY --from=build /app/target/QiuMo-Jetbrains-Help.jar QiuMo-Jetbrains-Help.jar
ENV TZ=Asia/Shanghai
ENV XBASE64_DOMAIN=mihuyo.cc
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
EXPOSE 10768
ENTRYPOINT ["java", "-jar", "QiuMo-Jetbrains-Help.jar"]
+2
View File
@@ -3,6 +3,8 @@ services:
build: .
image: qiumo-jetbrains-help:latest
container_name: QiuMo-Jetbrains-Help
environment:
- XBASE64_DOMAIN=mihuyo.cc
ports:
- 10768:10768
volumes:
@@ -81,9 +81,12 @@ public class AgentContextHolder {
/** ja-netfilter工具文件夹路径 */
private static final String JA_NETFILTER_FILE_PATH = "external/agent/ja-netfilter";
/** ja-netfilter主配置文件路径 */
/** POWER配置文件路径 */
private static final String POWER_CONF_FILE_NAME = JA_NETFILTER_FILE_PATH + "/config/power.conf";
/** XBASE64配置文件路径 */
private static final String XBASE64_CONF_FILE_NAME = JA_NETFILTER_FILE_PATH + "/config/xbase64.conf";
// ==================== 静态字段 ====================
/** ja-netfilter工具文件夹对象 */
@@ -102,6 +105,7 @@ public class AgentContextHolder {
if (!powerConfHasInit()) {
log.info("配置初始化中...");
loadPowerConf();
loadXbase64Conf();
zipJaNetfilter();
log.info("配置初始化成功!");
}
@@ -195,6 +199,22 @@ public class AgentContextHolder {
}
}
private static void loadXbase64Conf() {
String domain = SpringContextHolder.getProperty("xbase64.domain");
if (CharSequenceUtil.isBlank(domain)) {
log.warn("配置 xbase64.domain 未设置,跳过 xbase64.conf 初始化");
return;
}
String configStr = CharSequenceUtil.format("[Decoder]\nEQUAL,{}->jrebel.com", domain);
File xbase64ConfFile = FileTools.getFileOrCreat(XBASE64_CONF_FILE_NAME);
try {
FileUtil.writeString(configStr, xbase64ConfFile, StandardCharsets.UTF_8);
log.info("xbase64.conf 初始化成功: {}", domain);
} catch (IORuntimeException e) {
throw new IllegalArgumentException(CharSequenceUtil.format("{} 文件写入失败!", XBASE64_CONF_FILE_NAME), e);
}
}
/**
* 证书sha256摘要结果转换为ASN1格式数据
*
@@ -0,0 +1,41 @@
package com.qiumo.help.context;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* Spring 上下文工具类
* 用于在任意代码处获取 Spring 配置和 Bean
*/
@Component
public class SpringContextHolder implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext context) {
applicationContext = context;
}
/**
* 获取配置属性
*
* @param key 配置键(支持 application.yml 中的配置和环境变量)
* @return 配置值,不存在返回 null
*/
public static String getProperty(String key) {
return applicationContext != null ? applicationContext.getEnvironment().getProperty(key) : null;
}
/**
* 获取配置属性,带默认值
*
* @param key 配置键
* @param defaultValue 默认值
* @return 配置值,不存在返回默认值
*/
public static String getProperty(String key, String defaultValue) {
return applicationContext != null ? applicationContext.getEnvironment().getProperty(key, defaultValue) : defaultValue;
}
}
+2
View File
@@ -1,6 +1,8 @@
spring:
application:
name: QiuMo-Jetbrains-Help
xbase64:
domain: mihuyo.cc
server:
port: 10768
# 插件信息获取配置