[ server ] [ xray ] - 完成Xray基础Bean模板
This commit is contained in:
35
agent/all-agent-hosts.txt
Normal file
35
agent/all-agent-hosts.txt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
146.56.147.12 Seoul-arm64-01
|
||||||
|
|
||||||
|
146.56.159.175 Seoul-arm64-02
|
||||||
|
|
||||||
|
140.238.8.73 Seoul-amd64-01 seoul-1 s1
|
||||||
|
|
||||||
|
140.238.30.110 Seoul-amd64-02 seoul-2 s2
|
||||||
|
|
||||||
|
140.238.29.102 Seoul-amd64-03 seoul-3 s3
|
||||||
|
|
||||||
|
140.238.14.103 Seoul-amd64-04 seoul-4 s4
|
||||||
|
|
||||||
|
150.230.198.103 Tokyo-arm64-01 tokyo-0 t0
|
||||||
|
|
||||||
|
140.238.63.37 Tokyo-amd64-01 tokyo-1 t1
|
||||||
|
|
||||||
|
140.238.52.228 Tokyo-amd64-02 tokyo-2 t2
|
||||||
|
|
||||||
|
42.192.52.227 Shanghai-amd64-01 tc-sh
|
||||||
|
|
||||||
|
43.154.83.213 Hongkong-amd64-01 tc-hk
|
||||||
|
|
||||||
|
43.136.177.228 Chengdu-amd64-01 tc-cd
|
||||||
|
|
||||||
|
129.146.171.163 Phoenix-amd64-02 phoenix-2 p2
|
||||||
|
|
||||||
|
129.146.65.80 Phoenix-arm64-01 phoenix-3 p3
|
||||||
|
|
||||||
|
129.146.57.94 Phoenix-arm64-02 phoenix-4 p4
|
||||||
|
|
||||||
|
141.147.99.91 London-amd64-01 london-1 l1
|
||||||
|
|
||||||
|
141.147.106.62 London-amd64-02 london-2 l2
|
||||||
|
|
||||||
|
132.145.28.48 London-arm64-02 london-4 l4
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package io.wdd.func.xray.beans.config;
|
||||||
|
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.HttpHeaderObject;
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.InboundObject;
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.StreamSettingsObject;
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.TcpObject;
|
||||||
|
import io.wdd.func.xray.beans.xray.protocol.inbound.vmess.VMESS;
|
||||||
|
|
||||||
|
import static io.wdd.func.xray.beans.config.TcpHttpHeaderTemplate.HttpRequestTemplate;
|
||||||
|
import static io.wdd.func.xray.beans.config.TcpHttpHeaderTemplate.HttpResponseTemplate;
|
||||||
|
|
||||||
|
public class InboundVmessHTTPTemplate {
|
||||||
|
|
||||||
|
public static InboundObject InboundTemplate;
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
InboundTemplate = new VMESS();
|
||||||
|
|
||||||
|
// 构建 settings- vmess-tcp-http的对象
|
||||||
|
TcpObject tcpObject = new TcpObject();
|
||||||
|
|
||||||
|
// 构建RequestHttp属性对象
|
||||||
|
HttpHeaderObject httpHeaderObject = new HttpHeaderObject();
|
||||||
|
httpHeaderObject.setRequest(HttpRequestTemplate);
|
||||||
|
httpHeaderObject.setResponse(HttpResponseTemplate);
|
||||||
|
|
||||||
|
tcpObject.setHeader(httpHeaderObject);
|
||||||
|
|
||||||
|
// 设置 settings属性
|
||||||
|
StreamSettingsObject streamSettingsObject = new StreamSettingsObject();
|
||||||
|
streamSettingsObject.setTcpSettings(tcpObject);
|
||||||
|
InboundTemplate.setStreamSettings(streamSettingsObject);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
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.transport.HttpHeaderObject;
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.OutboundObject;
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.TcpObject;
|
||||||
|
|
||||||
|
import static io.wdd.func.xray.beans.config.TcpHttpHeaderTemplate.HttpResponseTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* outbound 不具备此形式
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public class OutboundVmessHTTPTemplate {
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
OutboundConfigurationObject OutboundTemplate = new VMESS();
|
||||||
|
|
||||||
|
// 构造TCP
|
||||||
|
TcpObject tcpObject = new TcpObject();
|
||||||
|
|
||||||
|
|
||||||
|
HttpHeaderObject httpHeaderObject = new HttpHeaderObject();
|
||||||
|
httpHeaderObject.setResponse(HttpResponseTemplate);
|
||||||
|
tcpObject.setHeader(httpHeaderObject);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package io.wdd.func.xray.beans.config;
|
||||||
|
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.HTTPRequestObject;
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.HTTPResponseObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TcpHttpHeaderTemplate {
|
||||||
|
|
||||||
|
|
||||||
|
public static HTTPRequestObject HttpRequestTemplate;
|
||||||
|
public static HTTPResponseObject HttpResponseTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
List<String> xrayFakeHostName = List.of(
|
||||||
|
"www.baidu.com",
|
||||||
|
"www.google.com",
|
||||||
|
"www.bing.com",
|
||||||
|
"www.github.com"
|
||||||
|
);
|
||||||
|
|
||||||
|
List<String> xrayFakeUserAgent = List.of(
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
|
||||||
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"
|
||||||
|
);
|
||||||
|
|
||||||
|
List<String> xrayFakeEncoding = List.of(
|
||||||
|
"gzip",
|
||||||
|
"deflate"
|
||||||
|
);
|
||||||
|
|
||||||
|
List<String> xrayFakePath = List.of(
|
||||||
|
"/news/",
|
||||||
|
"/finance/",
|
||||||
|
"/sports/",
|
||||||
|
"weathers"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
HTTPRequestObject.HeadersDTO reqHeadersDTO = HTTPRequestObject.HeadersDTO
|
||||||
|
.builder()
|
||||||
|
.host(xrayFakeHostName)
|
||||||
|
.userAgent(xrayFakeUserAgent)
|
||||||
|
.acceptEncoding(xrayFakeEncoding)
|
||||||
|
.pragma("no-cache")
|
||||||
|
.connection(List.of("keep-alive"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpRequestTemplate = HTTPRequestObject
|
||||||
|
.builder()
|
||||||
|
.version("1.1")
|
||||||
|
.method("GET")
|
||||||
|
.path(xrayFakePath)
|
||||||
|
.headers(
|
||||||
|
reqHeadersDTO
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HTTPResponseObject.HeadersDTO resHeadersDTO = HTTPResponseObject
|
||||||
|
.HeadersDTO
|
||||||
|
.builder()
|
||||||
|
.contentType(List.of(
|
||||||
|
"application/octet-stream",
|
||||||
|
"video/mpeg"
|
||||||
|
))
|
||||||
|
.transferEncoding(List.of("chunked"))
|
||||||
|
.connection(List.of("keep-alive"))
|
||||||
|
.pragma("no-cache")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponseTemplate = HTTPResponseObject
|
||||||
|
.builder()
|
||||||
|
.version("1.1")
|
||||||
|
.status("200")
|
||||||
|
.reason("Accept")
|
||||||
|
.headers(
|
||||||
|
resHeadersDTO
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package io.wdd.func.xray.beans.node;
|
package io.wdd.func.xray.beans.node;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -12,10 +14,12 @@ import lombok.experimental.SuperBuilder;
|
|||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@SuperBuilder(toBuilder = true)
|
@SuperBuilder(toBuilder = true)
|
||||||
|
@ApiModel("网络模型中的有向权重边")
|
||||||
public class Edge {
|
public class Edge {
|
||||||
|
|
||||||
ProxyNode source, destination;
|
ProxyNode source, destination;
|
||||||
|
|
||||||
|
@ApiModelProperty("权重值, 值的范围在0-100,数字越小表示阻力越小")
|
||||||
int weight;
|
int weight;
|
||||||
|
|
||||||
Edge(ProxyNode source, ProxyNode destination, int weight) {
|
Edge(ProxyNode source, ProxyNode destination, int weight) {
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package io.wdd.func.xray.beans.node;
|
||||||
|
|
||||||
|
import static io.wdd.func.xray.beans.node.ProxyNodeSet.*;
|
||||||
|
|
||||||
|
public class EdgeSet {
|
||||||
|
|
||||||
|
|
||||||
|
public static Edge chengduToShanghai;
|
||||||
|
|
||||||
|
public static Edge shanghaiToSeoul2;
|
||||||
|
public static Edge shanghaiToTokyo2;
|
||||||
|
|
||||||
|
public static Edge hongkongToSeoul2;
|
||||||
|
public static Edge hongkongToTokyo2;
|
||||||
|
public static Edge hongkongToPhoenix2;
|
||||||
|
|
||||||
|
public static Edge seoul2ToTokyo2;
|
||||||
|
public static Edge seoul2ToPhoenix2;
|
||||||
|
public static Edge seoul2ToLondon2;
|
||||||
|
|
||||||
|
public static Edge tokyo2ToPhoenix2;
|
||||||
|
public static Edge tokyo2ToLondon2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算 网络路径中的路径权重
|
||||||
|
* 值的范围在0-100,数字越小表示阻力越小
|
||||||
|
* 指标 1.延迟 2.丢包率 3.带宽 4.节点稳定性
|
||||||
|
*/
|
||||||
|
public void EdgeWeightCalculate(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
chengduToShanghai = new Edge(
|
||||||
|
chengdu,
|
||||||
|
shanghai,
|
||||||
|
10
|
||||||
|
);
|
||||||
|
|
||||||
|
shanghaiToSeoul2 = new Edge(
|
||||||
|
shanghai,
|
||||||
|
seoul2,
|
||||||
|
40
|
||||||
|
);
|
||||||
|
|
||||||
|
shanghaiToTokyo2 = new Edge(
|
||||||
|
shanghai,
|
||||||
|
tokyo2,
|
||||||
|
60
|
||||||
|
);
|
||||||
|
|
||||||
|
seoul2ToTokyo2 = new Edge(
|
||||||
|
seoul2,
|
||||||
|
tokyo2,
|
||||||
|
10
|
||||||
|
);
|
||||||
|
tokyo2ToPhoenix2 = new Edge(
|
||||||
|
tokyo2,
|
||||||
|
phoenix2,
|
||||||
|
30
|
||||||
|
);
|
||||||
|
tokyo2ToLondon2 = new Edge(
|
||||||
|
tokyo2,
|
||||||
|
london2,
|
||||||
|
50
|
||||||
|
);
|
||||||
|
hongkongToTokyo2 = new Edge(
|
||||||
|
hongkong,
|
||||||
|
tokyo2,
|
||||||
|
40
|
||||||
|
);
|
||||||
|
hongkongToSeoul2 = new Edge(
|
||||||
|
hongkong,
|
||||||
|
seoul2,
|
||||||
|
20
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -107,27 +107,7 @@ class Graph {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
List<Edge> edgeList = Arrays.asList(
|
List<Edge> edgeList = Arrays.asList(
|
||||||
new Edge(chengdu,
|
|
||||||
shanghai,
|
|
||||||
10),
|
|
||||||
new Edge(shanghai,
|
|
||||||
seoul2,
|
|
||||||
40),
|
|
||||||
new Edge(seoul2,
|
|
||||||
tokyo2,
|
|
||||||
10),
|
|
||||||
new Edge(tokyo2,
|
|
||||||
phoenix2,
|
|
||||||
30),
|
|
||||||
new Edge(tokyo2,
|
|
||||||
london2,
|
|
||||||
50),
|
|
||||||
new Edge(hongkong,
|
|
||||||
tokyo2,
|
|
||||||
40),
|
|
||||||
new Edge(hongkong,
|
|
||||||
seoul2,
|
|
||||||
20)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Graph graph = new Graph(edgeList);
|
Graph graph = new Graph(edgeList);
|
||||||
|
|||||||
@@ -11,10 +11,13 @@ import lombok.experimental.SuperBuilder;
|
|||||||
@SuperBuilder(toBuilder = true)
|
@SuperBuilder(toBuilder = true)
|
||||||
public class ProxyNode {
|
public class ProxyNode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简称,自己使用
|
||||||
|
*/
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于定位在图中的位置
|
* 用于定位在图中的 顺序位置
|
||||||
*/
|
*/
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package io.wdd.func.xray.beans.xray;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class OutboundObject {
|
|
||||||
|
|
||||||
private String sendThrough;
|
|
||||||
private String protocol;
|
|
||||||
private Object settings;
|
|
||||||
private String tag;
|
|
||||||
private StreamSettingsObject streamSettings;
|
|
||||||
private ProxySettingsObject proxySettings;
|
|
||||||
private MuxObject mux;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
class ProxySettingsObject {
|
|
||||||
private String tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
class MuxObject {
|
|
||||||
|
|
||||||
private Boolean enabled;
|
|
||||||
private Integer concurrency;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package io.wdd.func.xray.beans.xray;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class TransportObject {
|
|
||||||
|
|
||||||
private TcpObject tcpSettings;
|
|
||||||
private KcpObject kcpSettings;
|
|
||||||
private WebSocketObject wsSettings;
|
|
||||||
private HttpObject httpSettings;
|
|
||||||
private QuicObject quicSettings;
|
|
||||||
private DomainSocketObject dsSettings;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class TcpObject {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class KcpObject {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
class WebSocketObject {
|
|
||||||
|
|
||||||
private Boolean acceptProxyProtocol;
|
|
||||||
private String path;
|
|
||||||
private Map<String, String> headers;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class HttpObject {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class QuicObject {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class DomainSocketObject {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package io.wdd.func.xray.beans.xray;
|
package io.wdd.func.xray.beans.xray;
|
||||||
|
|
||||||
|
|
||||||
import io.wdd.func.xray.beans.xray.*;
|
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.TransportObject;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.wdd.func.xray.beans.xray.protocol.inbound;
|
package io.wdd.func.xray.beans.xray.protocol.inbound;
|
||||||
|
|
||||||
import io.wdd.func.xray.beans.xray.InboundObject;
|
import io.wdd.func.xray.beans.xray.transport.InboundObject;
|
||||||
|
|
||||||
public class DokodemoDoor extends InboundObject {
|
public class DokodemoDoor extends InboundObject {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.wdd.func.xray.beans.xray.protocol.inbound.vless;
|
package io.wdd.func.xray.beans.xray.protocol.inbound.vless;
|
||||||
|
|
||||||
import io.wdd.func.xray.beans.xray.InboundObject;
|
import io.wdd.func.xray.beans.xray.transport.InboundObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.wdd.func.xray.beans.xray.protocol.inbound.vmess;
|
package io.wdd.func.xray.beans.xray.protocol.inbound.vmess;
|
||||||
|
|
||||||
import io.wdd.func.xray.beans.xray.InboundObject;
|
import io.wdd.func.xray.beans.xray.transport.InboundObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -1,4 +1,39 @@
|
|||||||
package io.wdd.func.xray.beans.xray.protocol.outbound;
|
package io.wdd.func.xray.beans.xray.protocol.outbound;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
public abstract class OutboundConfigurationObject {
|
public abstract class OutboundConfigurationObject {
|
||||||
|
|
||||||
|
@JsonProperty("vnext")
|
||||||
|
private List<ServerObject> vnext;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class ServerObject {
|
||||||
|
@JsonProperty("address")
|
||||||
|
private String address;
|
||||||
|
@JsonProperty("port")
|
||||||
|
private Integer port;
|
||||||
|
@JsonProperty("users")
|
||||||
|
private List<UserObject> users;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class UserObject {
|
||||||
|
@JsonProperty("id")
|
||||||
|
private String id;
|
||||||
|
@JsonProperty("alterId")
|
||||||
|
private Integer alterId;
|
||||||
|
@JsonProperty("security")
|
||||||
|
private String security;
|
||||||
|
@JsonProperty("level")
|
||||||
|
private Integer level;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.wdd.func.xray.beans.xray.protocol.outbound;
|
package io.wdd.func.xray.beans.xray.protocol.outbound;
|
||||||
|
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.OutboundObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package io.wdd.func.xray.beans.xray.transport;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@SuperBuilder(toBuilder = true)
|
||||||
|
public class HTTPRequestObject {
|
||||||
|
|
||||||
|
@JsonProperty(value = "version", defaultValue = "1.1")
|
||||||
|
private String version;
|
||||||
|
@JsonProperty(value = "method", defaultValue = "GET")
|
||||||
|
private String method;
|
||||||
|
@JsonProperty("path")
|
||||||
|
private List<String> path;
|
||||||
|
@JsonProperty("headers")
|
||||||
|
private HeadersDTO headers;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@SuperBuilder(toBuilder = true)
|
||||||
|
public static class HeadersDTO {
|
||||||
|
@JsonProperty(value = "Host")
|
||||||
|
private List<String> host;
|
||||||
|
@JsonProperty("User-Agent")
|
||||||
|
private List<String> userAgent;
|
||||||
|
@JsonProperty("Accept-Encoding")
|
||||||
|
private List<String> acceptEncoding;
|
||||||
|
@JsonProperty("Connection")
|
||||||
|
private List<String> connection;
|
||||||
|
@JsonProperty("Pragma")
|
||||||
|
private String pragma;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package io.wdd.func.xray.beans.xray.transport;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@SuperBuilder(toBuilder = true)
|
||||||
|
public class HTTPResponseObject {
|
||||||
|
@JsonProperty(value = "version", defaultValue = "1.1")
|
||||||
|
private String version;
|
||||||
|
@JsonProperty("status")
|
||||||
|
private String status;
|
||||||
|
@JsonProperty("reason")
|
||||||
|
private String reason;
|
||||||
|
@JsonProperty("headers")
|
||||||
|
private HeadersDTO headers;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@SuperBuilder(toBuilder = true)
|
||||||
|
public static class HeadersDTO {
|
||||||
|
@JsonProperty("Content-Type")
|
||||||
|
private List<String> contentType;
|
||||||
|
@JsonProperty("Transfer-Encoding")
|
||||||
|
private List<String> transferEncoding;
|
||||||
|
@JsonProperty("Connection")
|
||||||
|
private List<String> connection;
|
||||||
|
@JsonProperty("Pragma")
|
||||||
|
private String pragma;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package io.wdd.func.xray.beans.xray.transport;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class HttpHeaderObject extends TCPHeaderObject {
|
||||||
|
|
||||||
|
HTTPRequestObject request;
|
||||||
|
|
||||||
|
HTTPResponseObject response;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package io.wdd.func.xray.beans.xray;
|
package io.wdd.func.xray.beans.xray.transport;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package io.wdd.func.xray.beans.xray.transport;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
|
;
|
||||||
|
import io.wdd.func.xray.beans.xray.protocol.outbound.OutboundConfigurationObject;
|
||||||
|
import io.wdd.func.xray.beans.xray.protocol.outbound.VLESS;
|
||||||
|
import io.wdd.func.xray.beans.xray.protocol.outbound.VMESS;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "protocol")
|
||||||
|
@JsonSubTypes(value = {
|
||||||
|
@JsonSubTypes.Type(value = VLESS.class, name = "vless"),
|
||||||
|
@JsonSubTypes.Type(value = VMESS.class, name = "vmess"),
|
||||||
|
})
|
||||||
|
public class OutboundObject {
|
||||||
|
|
||||||
|
private String sendThrough;
|
||||||
|
private String protocol;
|
||||||
|
private OutboundConfigurationObject settings;
|
||||||
|
private String tag;
|
||||||
|
private StreamSettingsObject streamSettings;
|
||||||
|
private ProxySettingsObject proxySettings;
|
||||||
|
private MuxObject mux;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
class ProxySettingsObject {
|
||||||
|
private String tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
class MuxObject {
|
||||||
|
|
||||||
|
private Boolean enabled;
|
||||||
|
private Integer concurrency;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
package io.wdd.func.xray.beans.xray;
|
package io.wdd.func.xray.beans.xray.transport;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class StreamSettingsObject extends TransportObject{
|
public class StreamSettingsObject extends TransportObject {
|
||||||
|
|
||||||
private String network;
|
private String network;
|
||||||
private String security;
|
private String security;
|
||||||
private TLSObject tlsSettings;
|
private TLSObject tlsSettings;
|
||||||
private XTLSObject xtlsSettings;
|
private XTLSObject xtlsSettings;
|
||||||
|
|
||||||
private SockoptObject sockopt;
|
private SockoptObject sockopt;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.wdd.func.xray.beans.xray.transport;
|
||||||
|
|
||||||
|
import io.wdd.func.xray.beans.xray.transport.TCPHeaderObject;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://www.v2ray.com/chapter_02/transport/tcp.html
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public
|
||||||
|
class TcpObject {
|
||||||
|
|
||||||
|
TCPHeaderObject header;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package io.wdd.func.xray.beans.xray.transport;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TransportObject {
|
||||||
|
|
||||||
|
private TcpObject tcpSettings;
|
||||||
|
private KcpObject kcpSettings;
|
||||||
|
private WebSocketObject wsSettings;
|
||||||
|
private HttpObject httpSettings;
|
||||||
|
private QuicObject quicSettings;
|
||||||
|
private DomainSocketObject dsSettings;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
|
||||||
|
@JsonSubTypes(value = {
|
||||||
|
@JsonSubTypes.Type(value = NoneHeaderObject.class, name = "none"),
|
||||||
|
@JsonSubTypes.Type(value = HttpHeaderObject.class, name = "http"),
|
||||||
|
})
|
||||||
|
abstract class TCPHeaderObject {
|
||||||
|
String type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class NoneHeaderObject extends TCPHeaderObject{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class KcpObject {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://www.v2ray.com/chapter_02/transport/websocket.html
|
||||||
|
* 官方参考
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
class WebSocketObject {
|
||||||
|
|
||||||
|
private Boolean acceptProxyProtocol;
|
||||||
|
private String path;
|
||||||
|
private Map<String, String> headers;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
class HttpObject {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class QuicObject {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class DomainSocketObject {
|
||||||
|
|
||||||
|
}
|
||||||
3
server/src/main/java/io/wdd/func/xray/result/simple.json
Normal file
3
server/src/main/java/io/wdd/func/xray/result/simple.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,12 @@
|
|||||||
package io.wdd.func.xray.service;
|
package io.wdd.func.xray.service;
|
||||||
|
|
||||||
|
import io.wdd.func.xray.beans.node.ProxyNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public interface XrayCoreService {
|
public interface XrayCoreService {
|
||||||
|
|
||||||
|
void generateXrayJsonFromNodeList(ArrayList<ArrayList<ProxyNode>> allNetworkPathList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,104 @@
|
|||||||
package io.wdd.func.xray.service;
|
package io.wdd.func.xray.service;
|
||||||
|
|
||||||
public class XrayCoreServiceImpl implements XrayCoreService{
|
import io.wdd.func.xray.beans.node.ProxyNode;
|
||||||
|
import io.wdd.func.xray.beans.xray.XrayConfig;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import static io.wdd.func.xray.beans.node.ProxyNodeSet.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class XrayCoreServiceImpl implements XrayCoreService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateXrayJsonFromNodeList(ArrayList<ArrayList<ProxyNode>> allNetworkPathList) {
|
||||||
|
|
||||||
|
|
||||||
|
allNetworkPathList = new ArrayList<>();
|
||||||
|
|
||||||
|
ArrayList<ProxyNode> pathA = new ArrayList<>(
|
||||||
|
Arrays.asList(
|
||||||
|
shanghai,
|
||||||
|
seoul2,
|
||||||
|
tokyo2,
|
||||||
|
phoenix2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ArrayList<ProxyNode> pathB = new ArrayList<>(
|
||||||
|
Arrays.asList(
|
||||||
|
shanghai,
|
||||||
|
seoul2,
|
||||||
|
london2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ArrayList<ProxyNode> pathC = new ArrayList<>(
|
||||||
|
Arrays.asList(
|
||||||
|
seoul2,
|
||||||
|
phoenix2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
allNetworkPathList.add(pathA);
|
||||||
|
allNetworkPathList.add(pathB);
|
||||||
|
allNetworkPathList.add(pathC);
|
||||||
|
|
||||||
|
|
||||||
|
// 需要根据所有的交叉链路进行计算
|
||||||
|
// A -> B -> C -> D
|
||||||
|
// B -> D
|
||||||
|
// A -> B -> F
|
||||||
|
// B点需要具有 4对inbound和outbound对
|
||||||
|
// C点需要具有 2对inbound和outbound对
|
||||||
|
|
||||||
|
|
||||||
|
// 解析所有的Node对
|
||||||
|
|
||||||
|
// 返回每一条的结果至于 Map中 key => shanghai->seoul2->tokyo2
|
||||||
|
// value => xray配置信息
|
||||||
|
HashMap<String, String> interfaceMap = new HashMap<>();
|
||||||
|
|
||||||
|
// 最终Xray Json配置应该放置于 Map中 key => ProxyNode
|
||||||
|
// value => Xray Config Json
|
||||||
|
HashMap<ProxyNode, XrayConfig> resultMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
allNetworkPathList
|
||||||
|
.stream()
|
||||||
|
.forEach(
|
||||||
|
networkPathList -> {
|
||||||
|
// 每一条每一条的执行,依次添加相应的 in-out 连接
|
||||||
|
generateXrayJsonSinglePath(
|
||||||
|
networkPathList,
|
||||||
|
interfaceMap,
|
||||||
|
resultMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateXrayJsonSinglePath(ArrayList<ProxyNode> networkPathList, HashMap<String, String> interfaceMap, HashMap<ProxyNode, XrayConfig> resultMap) {
|
||||||
|
int pathLength = networkPathList.size();
|
||||||
|
if (pathLength < 2) {
|
||||||
|
log.error("网络路径节点不能小于2个");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 采用 VMESS + websocket的形式形成 链状代理
|
||||||
|
// 由于 Vlss+XTLS的形式形成 链状结构
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user