|
@@ -319,14 +319,12 @@ TcpStreamSettings.TcpResponse = class extends XrayCommonClass {
|
|
|
class KcpStreamSettings extends XrayCommonClass {
|
|
class KcpStreamSettings extends XrayCommonClass {
|
|
|
constructor(
|
|
constructor(
|
|
|
mtu = 1350,
|
|
mtu = 1350,
|
|
|
- tti = 50,
|
|
|
|
|
|
|
+ tti = 20,
|
|
|
uplinkCapacity = 5,
|
|
uplinkCapacity = 5,
|
|
|
downlinkCapacity = 20,
|
|
downlinkCapacity = 20,
|
|
|
congestion = false,
|
|
congestion = false,
|
|
|
- readBufferSize = 2,
|
|
|
|
|
- writeBufferSize = 2,
|
|
|
|
|
- type = 'none',
|
|
|
|
|
- seed = RandomUtil.randomSeq(10),
|
|
|
|
|
|
|
+ readBufferSize = 1,
|
|
|
|
|
+ writeBufferSize = 1,
|
|
|
) {
|
|
) {
|
|
|
super();
|
|
super();
|
|
|
this.mtu = mtu;
|
|
this.mtu = mtu;
|
|
@@ -336,8 +334,6 @@ class KcpStreamSettings extends XrayCommonClass {
|
|
|
this.congestion = congestion;
|
|
this.congestion = congestion;
|
|
|
this.readBuffer = readBufferSize;
|
|
this.readBuffer = readBufferSize;
|
|
|
this.writeBuffer = writeBufferSize;
|
|
this.writeBuffer = writeBufferSize;
|
|
|
- this.type = type;
|
|
|
|
|
- this.seed = seed;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static fromJson(json = {}) {
|
|
static fromJson(json = {}) {
|
|
@@ -349,8 +345,6 @@ class KcpStreamSettings extends XrayCommonClass {
|
|
|
json.congestion,
|
|
json.congestion,
|
|
|
json.readBufferSize,
|
|
json.readBufferSize,
|
|
|
json.writeBufferSize,
|
|
json.writeBufferSize,
|
|
|
- ObjectUtil.isEmpty(json.header) ? 'none' : json.header.type,
|
|
|
|
|
- json.seed,
|
|
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -363,10 +357,6 @@ class KcpStreamSettings extends XrayCommonClass {
|
|
|
congestion: this.congestion,
|
|
congestion: this.congestion,
|
|
|
readBufferSize: this.readBuffer,
|
|
readBufferSize: this.readBuffer,
|
|
|
writeBufferSize: this.writeBuffer,
|
|
writeBufferSize: this.writeBuffer,
|
|
|
- header: {
|
|
|
|
|
- type: this.type,
|
|
|
|
|
- },
|
|
|
|
|
- seed: this.seed,
|
|
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -929,6 +919,51 @@ class SockoptStreamSettings extends XrayCommonClass {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+class FinalMask extends XrayCommonClass {
|
|
|
|
|
+ constructor(type = 'salamander', settings = {}) {
|
|
|
|
|
+ super();
|
|
|
|
|
+ this.type = type;
|
|
|
|
|
+ this.settings = this._getDefaultSettings(type, settings);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ _getDefaultSettings(type, settings = {}) {
|
|
|
|
|
+ switch (type) {
|
|
|
|
|
+ case 'salamander':
|
|
|
|
|
+ case 'mkcp-aes128gcm':
|
|
|
|
|
+ return { password: settings.password || '' };
|
|
|
|
|
+ case 'header-dns':
|
|
|
|
|
+ case 'xdns':
|
|
|
|
|
+ return { domain: settings.domain || '' };
|
|
|
|
|
+ case 'mkcp-original':
|
|
|
|
|
+ case 'header-dtls':
|
|
|
|
|
+ case 'header-srtp':
|
|
|
|
|
+ case 'header-utp':
|
|
|
|
|
+ case 'header-wechat':
|
|
|
|
|
+ case 'header-wireguard':
|
|
|
|
|
+ return {};
|
|
|
|
|
+ default:
|
|
|
|
|
+ return settings;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static fromJson(json = {}) {
|
|
|
|
|
+ return new FinalMask(
|
|
|
|
|
+ json.type || 'salamander',
|
|
|
|
|
+ json.settings || {}
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ toJson() {
|
|
|
|
|
+ const result = {
|
|
|
|
|
+ type: this.type
|
|
|
|
|
+ };
|
|
|
|
|
+ if (this.settings && Object.keys(this.settings).length > 0) {
|
|
|
|
|
+ result.settings = this.settings;
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
class StreamSettings extends XrayCommonClass {
|
|
class StreamSettings extends XrayCommonClass {
|
|
|
constructor(network = 'tcp',
|
|
constructor(network = 'tcp',
|
|
|
security = 'none',
|
|
security = 'none',
|
|
@@ -941,6 +976,7 @@ class StreamSettings extends XrayCommonClass {
|
|
|
grpcSettings = new GrpcStreamSettings(),
|
|
grpcSettings = new GrpcStreamSettings(),
|
|
|
httpupgradeSettings = new HTTPUpgradeStreamSettings(),
|
|
httpupgradeSettings = new HTTPUpgradeStreamSettings(),
|
|
|
xhttpSettings = new xHTTPStreamSettings(),
|
|
xhttpSettings = new xHTTPStreamSettings(),
|
|
|
|
|
+ finalmask = { udp: [] },
|
|
|
sockopt = undefined,
|
|
sockopt = undefined,
|
|
|
) {
|
|
) {
|
|
|
super();
|
|
super();
|
|
@@ -955,9 +991,23 @@ class StreamSettings extends XrayCommonClass {
|
|
|
this.grpc = grpcSettings;
|
|
this.grpc = grpcSettings;
|
|
|
this.httpupgrade = httpupgradeSettings;
|
|
this.httpupgrade = httpupgradeSettings;
|
|
|
this.xhttp = xhttpSettings;
|
|
this.xhttp = xhttpSettings;
|
|
|
|
|
+ this.finalmask = finalmask;
|
|
|
this.sockopt = sockopt;
|
|
this.sockopt = sockopt;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ addUdpMask(type = 'salamander') {
|
|
|
|
|
+ if (!this.finalmask.udp) {
|
|
|
|
|
+ this.finalmask.udp = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ this.finalmask.udp.push(new FinalMask(type));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ delUdpMask(index) {
|
|
|
|
|
+ if (this.finalmask.udp) {
|
|
|
|
|
+ this.finalmask.udp.splice(index, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
get isTls() {
|
|
get isTls() {
|
|
|
return this.security === "tls";
|
|
return this.security === "tls";
|
|
|
}
|
|
}
|
|
@@ -992,6 +1042,14 @@ class StreamSettings extends XrayCommonClass {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static fromJson(json = {}) {
|
|
static fromJson(json = {}) {
|
|
|
|
|
+ let finalmask = { udp: [] };
|
|
|
|
|
+ if (json.finalmask) {
|
|
|
|
|
+ if (Array.isArray(json.finalmask)) {
|
|
|
|
|
+ finalmask.udp = json.finalmask.map(mask => FinalMask.fromJson(mask));
|
|
|
|
|
+ } else if (json.finalmask.udp) {
|
|
|
|
|
+ finalmask.udp = json.finalmask.udp.map(mask => FinalMask.fromJson(mask));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return new StreamSettings(
|
|
return new StreamSettings(
|
|
|
json.network,
|
|
json.network,
|
|
|
json.security,
|
|
json.security,
|
|
@@ -1004,6 +1062,7 @@ class StreamSettings extends XrayCommonClass {
|
|
|
GrpcStreamSettings.fromJson(json.grpcSettings),
|
|
GrpcStreamSettings.fromJson(json.grpcSettings),
|
|
|
HTTPUpgradeStreamSettings.fromJson(json.httpupgradeSettings),
|
|
HTTPUpgradeStreamSettings.fromJson(json.httpupgradeSettings),
|
|
|
xHTTPStreamSettings.fromJson(json.xhttpSettings),
|
|
xHTTPStreamSettings.fromJson(json.xhttpSettings),
|
|
|
|
|
+ finalmask,
|
|
|
SockoptStreamSettings.fromJson(json.sockopt),
|
|
SockoptStreamSettings.fromJson(json.sockopt),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
@@ -1022,6 +1081,9 @@ class StreamSettings extends XrayCommonClass {
|
|
|
grpcSettings: network === 'grpc' ? this.grpc.toJson() : undefined,
|
|
grpcSettings: network === 'grpc' ? this.grpc.toJson() : undefined,
|
|
|
httpupgradeSettings: network === 'httpupgrade' ? this.httpupgrade.toJson() : undefined,
|
|
httpupgradeSettings: network === 'httpupgrade' ? this.httpupgrade.toJson() : undefined,
|
|
|
xhttpSettings: network === 'xhttp' ? this.xhttp.toJson() : undefined,
|
|
xhttpSettings: network === 'xhttp' ? this.xhttp.toJson() : undefined,
|
|
|
|
|
+ finalmask: (this.finalmask.udp && this.finalmask.udp.length > 0) ? {
|
|
|
|
|
+ udp: this.finalmask.udp.map(mask => mask.toJson())
|
|
|
|
|
+ } : undefined,
|
|
|
sockopt: this.sockopt != undefined ? this.sockopt.toJson() : undefined,
|
|
sockopt: this.sockopt != undefined ? this.sockopt.toJson() : undefined,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
@@ -1947,7 +2009,9 @@ Inbound.VLESSSettings = class extends Inbound.Settings {
|
|
|
json.selectedAuth = this.selectedAuth;
|
|
json.selectedAuth = this.selectedAuth;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (this.testseed && this.testseed.length >= 4) {
|
|
|
|
|
|
|
+ // Only include testseed if at least one client has a flow set
|
|
|
|
|
+ const hasFlow = this.vlesses && this.vlesses.some(vless => vless.flow && vless.flow !== '');
|
|
|
|
|
+ if (hasFlow && this.testseed && this.testseed.length >= 4) {
|
|
|
json.testseed = this.testseed;
|
|
json.testseed = this.testseed;
|
|
|
}
|
|
}
|
|
|
|
|
|