[server][xary] - 完成实际Xray配置更新的全流程 - 2
This commit is contained in:
@@ -32,10 +32,7 @@ public class TcpHttpHeaderTemplate {
|
||||
);
|
||||
|
||||
List<String> xrayFakePath = List.of(
|
||||
"/news/",
|
||||
"/finance/",
|
||||
"/sports/",
|
||||
"/weathers"
|
||||
"/"
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class XrayOssOperator {
|
||||
// 存储到特定的桶中
|
||||
OssConfig ossConfig = ossBackendSelect.one(SUBSCRIBE_OSS_BUCKET_PREFIX);
|
||||
|
||||
log.debug(
|
||||
log.info(
|
||||
"开始存储 Xray订阅文件 [ {} ] 至OSS [ {} ]中",
|
||||
subscribeXrayConfigInfo,
|
||||
ossConfig
|
||||
@@ -93,8 +93,9 @@ public class XrayOssOperator {
|
||||
);
|
||||
if (!deleteObject) {
|
||||
log.error(
|
||||
"删除旧的订阅信息失败! 请检查桶 => [{}]",
|
||||
ossConfig
|
||||
"删除旧的订阅信息失败! 请检查桶 => [{}], 文件名称为 => [ {} ]",
|
||||
ossConfig,
|
||||
subscribeXrayConfigInfo.getXrayConfigFileName()
|
||||
);
|
||||
throw new MyRuntimeException();
|
||||
}
|
||||
@@ -102,7 +103,7 @@ public class XrayOssOperator {
|
||||
// 上传新的订阅信息
|
||||
OctopusObjectSummary objectSummary = ossCoreService.createObject(
|
||||
ossConfig,
|
||||
SUBSCRIBE_OSS_BUCKET_PREFIX,
|
||||
subscribeXrayConfigInfo.getXrayConfigFileName(),
|
||||
subscribeXrayConfigInfo.getXrayConfigFile()
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.wdd.func.xray.service;
|
||||
|
||||
import io.wdd.common.handler.MyRuntimeException;
|
||||
import io.wdd.func.xray.beans.node.ProxyNode;
|
||||
import io.wdd.func.xray.beans.node.XrayConfigInfo;
|
||||
import io.wdd.func.xray.beans.xray.RoutingObject;
|
||||
@@ -10,6 +11,7 @@ import io.wdd.func.xray.beans.xray.protocol.inbound.vmess.InboundConfigurationOb
|
||||
import io.wdd.func.xray.beans.xray.protocol.inbound.vmess.VMESS;
|
||||
import io.wdd.func.xray.beans.xray.protocol.outbound.Freedom;
|
||||
import io.wdd.func.xray.beans.xray.protocol.outbound.OutboundConfigurationObject;
|
||||
import io.wdd.func.xray.beans.xray.protocol.outbound.VmessOutSettings;
|
||||
import io.wdd.func.xray.beans.xray.share.VmessShare;
|
||||
import io.wdd.func.xray.beans.xray.transport.InboundObject;
|
||||
import io.wdd.func.xray.beans.xray.transport.OutboundObject;
|
||||
@@ -473,25 +475,33 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
// 中间节点,需要进行特定的构建
|
||||
|
||||
io.wdd.func.xray.beans.xray.protocol.outbound.VMESS vmessOutbound = new io.wdd.func.xray.beans.xray.protocol.outbound.VMESS();
|
||||
|
||||
// 深拷贝的问题
|
||||
ClientObject realClientObject = new ClientObject();
|
||||
|
||||
try {
|
||||
|
||||
BeanUtils.copyProperties(
|
||||
vmessOutbound,
|
||||
OutboundVmessHTTPTemplate
|
||||
);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
// 解决深拷贝的问题
|
||||
BeanUtils.copyProperties(
|
||||
realClientObject,
|
||||
clientObject
|
||||
);
|
||||
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
log.error("复制模板OutBound失败!");
|
||||
throw new MyRuntimeException(e);
|
||||
}
|
||||
|
||||
// 设置Tag信息
|
||||
vmessOutbound.setTag(chainTag);
|
||||
|
||||
// 设置出口信息
|
||||
OutboundConfigurationObject.ServerObject serverObject = vmessOutbound
|
||||
.getSettings()
|
||||
.getVnext()
|
||||
.get(0);
|
||||
//
|
||||
OutboundConfigurationObject.ServerObject serverObject = new OutboundConfigurationObject.ServerObject();
|
||||
|
||||
// 出口的IP应该为下一节点
|
||||
serverObject.setAddress(networkPathList
|
||||
@@ -500,11 +510,23 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
|
||||
// 端口
|
||||
serverObject.setPort(chainPort);
|
||||
|
||||
// 用户
|
||||
serverObject.setUsers(
|
||||
List.of(clientObject)
|
||||
List.of(realClientObject)
|
||||
);
|
||||
|
||||
// 直接新建一个Settings的对象
|
||||
VmessOutSettings vmessOutSettings = new VmessOutSettings();
|
||||
vmessOutSettings.setVnext(
|
||||
List.of(
|
||||
serverObject
|
||||
)
|
||||
);
|
||||
|
||||
// 设置 Settings对象
|
||||
vmessOutbound.setSettings(vmessOutSettings);
|
||||
|
||||
|
||||
outboundObjectList.add(vmessOutbound);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user