[ Xray ] 修改Xray的文件格式为TCP伪装类型为None格式
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package io.wdd.func.xray.beans.config;
|
||||
|
||||
import io.wdd.func.xray.beans.xray.protocol.inbound.vmess.VMESS;
|
||||
import io.wdd.func.xray.beans.xray.transport.InboundObject;
|
||||
import io.wdd.func.xray.beans.xray.transport.NoneHeaderObject;
|
||||
import io.wdd.func.xray.beans.xray.transport.StreamSettingsObject;
|
||||
import io.wdd.func.xray.beans.xray.transport.TcpObject;
|
||||
|
||||
public class InboundVmessTCPTemplateClass {
|
||||
|
||||
public static InboundObject InboundVmessTCPTemplate;
|
||||
|
||||
|
||||
static {
|
||||
|
||||
InboundVmessTCPTemplate = new VMESS();
|
||||
|
||||
// 构建 settings- vmess-tcp-http的对象
|
||||
TcpObject tcpObject = new TcpObject();
|
||||
|
||||
// none type
|
||||
NoneHeaderObject noneHeaderObject = new NoneHeaderObject();
|
||||
tcpObject.setHeader(noneHeaderObject);
|
||||
|
||||
// 设置 settings属性
|
||||
StreamSettingsObject streamSettingsObject = new StreamSettingsObject();
|
||||
streamSettingsObject.setTcpSettings(tcpObject);
|
||||
InboundVmessTCPTemplate.setStreamSettings(streamSettingsObject);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,8 @@ public class OutboundVmessHTTPTemplateClass {
|
||||
// 构造TCP
|
||||
TcpObject tcpObject = new TcpObject();
|
||||
|
||||
|
||||
// 设置TCP的伪装部分
|
||||
// 参考 https://www.v2ray.com/chapter_02/transport/tcp.html
|
||||
HttpHeaderObject httpHeaderObject = new HttpHeaderObject();
|
||||
httpHeaderObject.setRequest(HttpRequestTemplate);
|
||||
tcpObject.setHeader(httpHeaderObject);
|
||||
@@ -32,7 +33,7 @@ public class OutboundVmessHTTPTemplateClass {
|
||||
streamSettingsObject.setTcpSettings(tcpObject);
|
||||
OutboundVmessHTTPTemplate.setStreamSettings(streamSettingsObject);
|
||||
|
||||
// 需要初始化这个
|
||||
// 需要初始化这个,作为结构的补充
|
||||
VmessOutSettings vmessOutSettings = new VmessOutSettings();
|
||||
OutboundConfigurationObject.ServerObject serverObject = new OutboundConfigurationObject.ServerObject();
|
||||
vmessOutSettings.setVnext(
|
||||
@@ -42,13 +43,14 @@ public class OutboundVmessHTTPTemplateClass {
|
||||
);
|
||||
OutboundVmessHTTPTemplate.setSettings(vmessOutSettings);
|
||||
|
||||
|
||||
// mux的部分
|
||||
MuxObject muxObject = new MuxObject();
|
||||
muxObject.setConcurrency(-1);
|
||||
muxObject.setEnabled(Boolean.FALSE);
|
||||
|
||||
OutboundVmessHTTPTemplate.setMux(muxObject);
|
||||
|
||||
|
||||
// 其它的部分
|
||||
OutboundFree = new Freedom();
|
||||
|
||||
OutboundBlackHole = new Blackhole();
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package io.wdd.func.xray.beans.config;
|
||||
|
||||
import io.wdd.func.xray.beans.xray.protocol.outbound.OutboundConfigurationObject;
|
||||
import io.wdd.func.xray.beans.xray.protocol.outbound.VMESS;
|
||||
import io.wdd.func.xray.beans.xray.protocol.outbound.VmessOutSettings;
|
||||
import io.wdd.func.xray.beans.xray.transport.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class OutboundVmessTCPTemplateClass {
|
||||
|
||||
public static OutboundObject OutboundVmessTCPTemplate;
|
||||
|
||||
static {
|
||||
OutboundVmessTCPTemplate = new VMESS();
|
||||
|
||||
// 构造TCP
|
||||
TcpObject tcpObject = new TcpObject();
|
||||
// 默认的Header结构为
|
||||
// {
|
||||
// "header": {
|
||||
// "type": "none"
|
||||
// }
|
||||
//}
|
||||
NoneHeaderObject noneHeaderObject = new NoneHeaderObject();
|
||||
tcpObject.setHeader(noneHeaderObject);
|
||||
|
||||
StreamSettingsObject streamSettingsObject = new StreamSettingsObject();
|
||||
streamSettingsObject.setTcpSettings(tcpObject);
|
||||
OutboundVmessTCPTemplate.setStreamSettings(streamSettingsObject);
|
||||
|
||||
// 需要初始化这个,作为结构的补充
|
||||
VmessOutSettings vmessOutSettings = new VmessOutSettings();
|
||||
OutboundConfigurationObject.ServerObject serverObject = new OutboundConfigurationObject.ServerObject();
|
||||
vmessOutSettings.setVnext(
|
||||
new ArrayList<>(
|
||||
List.of(serverObject)
|
||||
)
|
||||
);
|
||||
OutboundVmessTCPTemplate.setSettings(vmessOutSettings);
|
||||
|
||||
// mux的部分
|
||||
MuxObject muxObject = new MuxObject();
|
||||
muxObject.setConcurrency(4);
|
||||
muxObject.setEnabled(Boolean.TRUE);
|
||||
OutboundVmessTCPTemplate.setMux(muxObject);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ public class TcpHttpHeaderTemplate {
|
||||
public static HTTPRequestObject HttpRequestTemplate;
|
||||
public static HTTPResponseObject HttpResponseTemplate;
|
||||
|
||||
|
||||
static {
|
||||
|
||||
List<String> xrayFakeHostName = List.of(
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package io.wdd.func.xray.beans.xray.transport;
|
||||
|
||||
public class NoneHeaderObject extends TCPHeaderObject {
|
||||
|
||||
}
|
||||
@@ -30,11 +30,6 @@ abstract class TCPHeaderObject {
|
||||
}
|
||||
|
||||
|
||||
class NoneHeaderObject extends TCPHeaderObject{
|
||||
|
||||
}
|
||||
|
||||
|
||||
class KcpObject {
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,12 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.wdd.func.xray.beans.config.InboundVmessHTTPTemplateClass.InboundVmessHTTPTemplate;
|
||||
import static io.wdd.func.xray.beans.config.InboundVmessHTTPTemplateClass.ListenAddress;
|
||||
import static io.wdd.func.xray.beans.config.InboundVmessTCPTemplateClass.InboundVmessTCPTemplate;
|
||||
import static io.wdd.func.xray.beans.config.LogTemplateClass.LogTemplate;
|
||||
import static io.wdd.func.xray.beans.config.OutboundVmessHTTPTemplateClass.*;
|
||||
import static io.wdd.func.xray.beans.config.OutboundVmessHTTPTemplateClass.OutboundBlackHole;
|
||||
import static io.wdd.func.xray.beans.config.OutboundVmessHTTPTemplateClass.OutboundFree;
|
||||
import static io.wdd.func.xray.beans.config.OutboundVmessTCPTemplateClass.OutboundVmessTCPTemplate;
|
||||
import static io.wdd.func.xray.persisit.cache.ProxyNodeCache.*;
|
||||
import static io.wdd.func.xray.service.XrayConfigPersistor.*;
|
||||
|
||||
@@ -234,6 +236,7 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
.getXrayConfig()
|
||||
.getInbounds();
|
||||
|
||||
// 构造Inbound Object
|
||||
VMESS realInboundObject = (VMESS) inboundObjectList
|
||||
.stream()
|
||||
.filter(
|
||||
@@ -325,6 +328,14 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一条代理链
|
||||
*
|
||||
* @param chainPort 代理连使用的端口
|
||||
* @param networkPathList 代理链上的每一个服务器节点
|
||||
* @param currentVersion
|
||||
* @param chainTag 代理链的tag
|
||||
*/
|
||||
private void generateXrayJsonSinglePath(int chainPort, List<ProxyNode> networkPathList, int currentVersion, String chainTag) {
|
||||
|
||||
int pathLength = networkPathList.size();
|
||||
@@ -370,6 +381,16 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实际身长Xray的配置
|
||||
*
|
||||
* @param chainTag
|
||||
* @param clientObject
|
||||
* @param chainPort
|
||||
* @param networkPathList
|
||||
* @param pos
|
||||
* @return
|
||||
*/
|
||||
private XrayConfig doBuildXrayConfig(String chainTag, ClientObject clientObject, int chainPort, List<ProxyNode> networkPathList, int pos) {
|
||||
|
||||
// 需要从现有的XrayConfig基础上进行生成
|
||||
@@ -473,7 +494,6 @@ 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();
|
||||
|
||||
// 深拷贝的问题
|
||||
@@ -483,7 +503,7 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
|
||||
BeanUtils.copyProperties(
|
||||
vmessOutbound,
|
||||
OutboundVmessHTTPTemplate
|
||||
OutboundVmessTCPTemplate
|
||||
);
|
||||
|
||||
// 解决深拷贝的问题
|
||||
@@ -544,7 +564,7 @@ public class XrayCoreServiceImpl implements XrayCoreService {
|
||||
try {
|
||||
BeanUtils.copyProperties(
|
||||
inboundObject,
|
||||
InboundVmessHTTPTemplate
|
||||
InboundVmessTCPTemplate
|
||||
);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
Reference in New Issue
Block a user