Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMHSanaei <ho3ein.sanaei@gmail.com>2026-02-02 19:50:30 +0300
committerMHSanaei <ho3ein.sanaei@gmail.com>2026-02-02 19:50:30 +0300
commite8d2973be77317b345e540b32fe04fca97dbf101 (patch)
treedc531db33815f1d9929f114b48f49db21e47b145 /web/assets/js/model/outbound.js
parentf3d47ebb3fbc65fc25a39d4ef0d4561407acc941 (diff)
Finalmask: Add XICMP
Diffstat (limited to 'web/assets/js/model/outbound.js')
-rw-r--r--web/assets/js/model/outbound.js59
1 files changed, 31 insertions, 28 deletions
diff --git a/web/assets/js/model/outbound.js b/web/assets/js/model/outbound.js
index 3e0dd0d4..fc110b4e 100644
--- a/web/assets/js/model/outbound.js
+++ b/web/assets/js/model/outbound.js
@@ -568,7 +568,7 @@ class SockoptStreamSettings extends CommonClass {
}
}
-class FinalMask extends CommonClass {
+class UdpMask extends CommonClass {
constructor(type = 'salamander', settings = {}) {
super();
this.type = type;
@@ -596,21 +596,35 @@ class FinalMask extends CommonClass {
}
static fromJson(json = {}) {
- return new FinalMask(
+ return new UdpMask(
json.type || 'salamander',
json.settings || {}
);
}
toJson() {
- const result = {
- type: this.type
+ return {
+ type: this.type,
+ settings: (this.settings && Object.keys(this.settings).length > 0) ? this.settings : undefined
};
- // Only include settings if they exist and are not empty
- if (this.settings && Object.keys(this.settings).length > 0) {
- result.settings = this.settings;
- }
- return result;
+ }
+}
+
+class FinalMaskStreamSettings extends CommonClass {
+ constructor(udp = []) {
+ super();
+ this.udp = Array.isArray(udp) ? udp.map(u => new UdpMask(u.type, u.settings)) : [new UdpMask(udp.type, udp.settings)];
+ }
+
+ static fromJson(json = {}) {
+ return new FinalMaskStreamSettings(json.udp || []);
+ }
+
+ toJson() {
+ return {
+ udp: this.udp.map(udp => udp.toJson())
+ };
+
}
}
@@ -627,7 +641,7 @@ class StreamSettings extends CommonClass {
httpupgradeSettings = new HttpUpgradeStreamSettings(),
xhttpSettings = new xHTTPStreamSettings(),
hysteriaSettings = new HysteriaStreamSettings(),
- finalmask = { udp: [] },
+ finalmask = new FinalMaskStreamSettings(),
sockopt = undefined,
) {
super();
@@ -647,10 +661,7 @@ class StreamSettings extends CommonClass {
}
addUdpMask(type = 'salamander') {
- if (!this.finalmask.udp) {
- this.finalmask.udp = [];
- }
- this.finalmask.udp.push(new FinalMask(type));
+ this.finalmask.udp.push(new UdpMask(type));
}
delUdpMask(index) {
@@ -659,6 +670,10 @@ class StreamSettings extends CommonClass {
}
}
+ get hasFinalMask() {
+ return this.finalmask.udp && this.finalmask.udp.length > 0;
+ }
+
get isTls() {
return this.security === 'tls';
}
@@ -676,16 +691,6 @@ class StreamSettings extends CommonClass {
}
static fromJson(json = {}) {
- let finalmask = { udp: [] };
- if (json.finalmask) {
- if (Array.isArray(json.finalmask)) {
- // Legacy format: direct array (backward compatibility)
- finalmask.udp = json.finalmask.map(mask => FinalMask.fromJson(mask));
- } else if (json.finalmask.udp) {
- // New format: object with udp array
- finalmask.udp = json.finalmask.udp.map(mask => FinalMask.fromJson(mask));
- }
- }
return new StreamSettings(
json.network,
json.security,
@@ -698,7 +703,7 @@ class StreamSettings extends CommonClass {
HttpUpgradeStreamSettings.fromJson(json.httpupgradeSettings),
xHTTPStreamSettings.fromJson(json.xhttpSettings),
HysteriaStreamSettings.fromJson(json.hysteriaSettings),
- finalmask,
+ FinalMaskStreamSettings.fromJson(json.finalmask),
SockoptStreamSettings.fromJson(json.sockopt),
);
}
@@ -717,9 +722,7 @@ class StreamSettings extends CommonClass {
httpupgradeSettings: network === 'httpupgrade' ? this.httpupgrade.toJson() : undefined,
xhttpSettings: network === 'xhttp' ? this.xhttp.toJson() : undefined,
hysteriaSettings: network === 'hysteria' ? this.hysteria.toJson() : undefined,
- finalmask: (this.finalmask.udp && this.finalmask.udp.length > 0) ? {
- udp: this.finalmask.udp.map(mask => mask.toJson())
- } : undefined,
+ finalmask: this.hasFinalMask ? this.finalmask.toJson() : undefined,
sockopt: this.sockopt != undefined ? this.sockopt.toJson() : undefined,
};
}