[server][xary] - 完成实际Xray配置更新的全流程 - 2
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="RunServerToRemote" type="docker-deploy" factoryName="dockerfile"
|
<configuration default="false" name="RunServerToRemote" type="docker-deploy" factoryName="dockerfile"
|
||||||
server-name="UbuntuStation">
|
server-name="Oracle-Seoul-0">
|
||||||
<deployment type="dockerfile">
|
<deployment type="dockerfile">
|
||||||
<settings>
|
<settings>
|
||||||
<option name="imageTag" value="remote-idea"/>
|
<option name="imageTag" value="remote-idea"/>
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ public class TcpHttpHeaderTemplate {
|
|||||||
);
|
);
|
||||||
|
|
||||||
List<String> xrayFakePath = List.of(
|
List<String> xrayFakePath = List.of(
|
||||||
"/news/",
|
"/"
|
||||||
"/finance/",
|
|
||||||
"/sports/",
|
|
||||||
"/weathers"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class XrayOssOperator {
|
|||||||
// 存储到特定的桶中
|
// 存储到特定的桶中
|
||||||
OssConfig ossConfig = ossBackendSelect.one(SUBSCRIBE_OSS_BUCKET_PREFIX);
|
OssConfig ossConfig = ossBackendSelect.one(SUBSCRIBE_OSS_BUCKET_PREFIX);
|
||||||
|
|
||||||
log.debug(
|
log.info(
|
||||||
"开始存储 Xray订阅文件 [ {} ] 至OSS [ {} ]中",
|
"开始存储 Xray订阅文件 [ {} ] 至OSS [ {} ]中",
|
||||||
subscribeXrayConfigInfo,
|
subscribeXrayConfigInfo,
|
||||||
ossConfig
|
ossConfig
|
||||||
@@ -93,8 +93,9 @@ public class XrayOssOperator {
|
|||||||
);
|
);
|
||||||
if (!deleteObject) {
|
if (!deleteObject) {
|
||||||
log.error(
|
log.error(
|
||||||
"删除旧的订阅信息失败! 请检查桶 => [{}]",
|
"删除旧的订阅信息失败! 请检查桶 => [{}], 文件名称为 => [ {} ]",
|
||||||
ossConfig
|
ossConfig,
|
||||||
|
subscribeXrayConfigInfo.getXrayConfigFileName()
|
||||||
);
|
);
|
||||||
throw new MyRuntimeException();
|
throw new MyRuntimeException();
|
||||||
}
|
}
|
||||||
@@ -102,7 +103,7 @@ public class XrayOssOperator {
|
|||||||
// 上传新的订阅信息
|
// 上传新的订阅信息
|
||||||
OctopusObjectSummary objectSummary = ossCoreService.createObject(
|
OctopusObjectSummary objectSummary = ossCoreService.createObject(
|
||||||
ossConfig,
|
ossConfig,
|
||||||
SUBSCRIBE_OSS_BUCKET_PREFIX,
|
subscribeXrayConfigInfo.getXrayConfigFileName(),
|
||||||
subscribeXrayConfigInfo.getXrayConfigFile()
|
subscribeXrayConfigInfo.getXrayConfigFile()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.wdd.func.xray.service;
|
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.ProxyNode;
|
||||||
import io.wdd.func.xray.beans.node.XrayConfigInfo;
|
import io.wdd.func.xray.beans.node.XrayConfigInfo;
|
||||||
import io.wdd.func.xray.beans.xray.RoutingObject;
|
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.inbound.vmess.VMESS;
|
||||||
import io.wdd.func.xray.beans.xray.protocol.outbound.Freedom;
|
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.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.share.VmessShare;
|
||||||
import io.wdd.func.xray.beans.xray.transport.InboundObject;
|
import io.wdd.func.xray.beans.xray.transport.InboundObject;
|
||||||
import io.wdd.func.xray.beans.xray.transport.OutboundObject;
|
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();
|
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 {
|
try {
|
||||||
|
|
||||||
BeanUtils.copyProperties(
|
BeanUtils.copyProperties(
|
||||||
vmessOutbound,
|
vmessOutbound,
|
||||||
OutboundVmessHTTPTemplate
|
OutboundVmessHTTPTemplate
|
||||||
);
|
);
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new RuntimeException(e);
|
// 解决深拷贝的问题
|
||||||
} catch (InvocationTargetException e) {
|
BeanUtils.copyProperties(
|
||||||
throw new RuntimeException(e);
|
realClientObject,
|
||||||
|
clientObject
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
|
log.error("复制模板OutBound失败!");
|
||||||
|
throw new MyRuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置Tag信息
|
// 设置Tag信息
|
||||||
vmessOutbound.setTag(chainTag);
|
vmessOutbound.setTag(chainTag);
|
||||||
|
|
||||||
// 设置出口信息
|
//
|
||||||
OutboundConfigurationObject.ServerObject serverObject = vmessOutbound
|
OutboundConfigurationObject.ServerObject serverObject = new OutboundConfigurationObject.ServerObject();
|
||||||
.getSettings()
|
|
||||||
.getVnext()
|
|
||||||
.get(0);
|
|
||||||
|
|
||||||
// 出口的IP应该为下一节点
|
// 出口的IP应该为下一节点
|
||||||
serverObject.setAddress(networkPathList
|
serverObject.setAddress(networkPathList
|
||||||
@@ -500,11 +510,23 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
|||||||
|
|
||||||
// 端口
|
// 端口
|
||||||
serverObject.setPort(chainPort);
|
serverObject.setPort(chainPort);
|
||||||
|
// 用户
|
||||||
serverObject.setUsers(
|
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);
|
outboundObjectList.add(vmessOutbound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
##### environment variables ######
|
##### environment variables ######
|
||||||
|
|
||||||
JAVA_OPTS="-Xms2048m -Xmx2048m -Dfile.encoding=utf-8 -Dspring.profiles.active=k3s -Dspring.cloud.nacos.config.group=k3s -Dspring.cloud.nacos.config.extension-configs[0].dataId=common-k3s.yaml -Dspring.cloud.nacos.config.extension-configs[0].group=k3s -Ddebug=false -Dlogging.level.io.wdd.server=info"
|
JAVA_OPTS="-Xms4096m -Xmx4096m -Dfile.encoding=utf-8 -Dspring.profiles.active=k3s -Dspring.cloud.nacos.config.group=k3s -Dspring.cloud.nacos.config.extension-configs[0].dataId=common-k3s.yaml -Dspring.cloud.nacos.config.extension-configs[0].group=k3s -Ddebug=false -Dlogging.level.io.wdd.server=info"
|
||||||
|
|
||||||
DOCKER_VERSION="20.10.10"
|
DOCKER_VERSION="20.10.10"
|
||||||
|
|
||||||
@@ -558,9 +558,10 @@ BootUPServer() {
|
|||||||
FunctionSuccess
|
FunctionSuccess
|
||||||
colorEcho $BLUE "[ Octopus Server] - start to boot up octopus server!"
|
colorEcho $BLUE "[ Octopus Server] - start to boot up octopus server!"
|
||||||
docker run -d \
|
docker run -d \
|
||||||
-p 9999:9999 \
|
-p 29999:9999 \
|
||||||
--name ${OctopusServerContainerName} \
|
--name ${OctopusServerContainerName} \
|
||||||
--env JAVA_OPTS="${JAVA_OPTS}" \
|
--env JAVA_OPTS="${JAVA_OPTS}" \
|
||||||
|
-v /octopus-server:/octopus-server \
|
||||||
docker.io/icederce/wdd-octopus-server:latest
|
docker.io/icederce/wdd-octopus-server:latest
|
||||||
|
|
||||||
FunctionSuccess
|
FunctionSuccess
|
||||||
|
|||||||
Reference in New Issue
Block a user