sub-store-convert 2.24.7 → 2.24.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +287 -186
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1494,7 +1494,7 @@ import _ from "lodash";
|
|
|
1494
1494
|
import { Base64 } from "js-base64";
|
|
1495
1495
|
|
|
1496
1496
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/xhttp-utils.js
|
|
1497
|
-
function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } = {}) {
|
|
1497
|
+
function parseNormalizedXhttpRangeBounds(value, { allowZeroLowerBound = true, allowZeroUpperBound = true } = {}) {
|
|
1498
1498
|
if (typeof value !== "string" && typeof value !== "number") {
|
|
1499
1499
|
return void 0;
|
|
1500
1500
|
}
|
|
@@ -1508,9 +1508,14 @@ function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } =
|
|
|
1508
1508
|
};
|
|
1509
1509
|
const normalizedValue = `${value}`.trim();
|
|
1510
1510
|
const rangeParts = normalizedValue.split("-");
|
|
1511
|
+
const minimumAllowedLowerBound = allowZeroLowerBound ? 0 : 1;
|
|
1512
|
+
const minimumAllowedUpperBound = allowZeroUpperBound ? 0 : 1;
|
|
1511
1513
|
if (rangeParts.length === 1) {
|
|
1512
1514
|
const normalizedInteger = parseUnsignedIntegerToken(rangeParts[0]);
|
|
1513
|
-
const minimumAllowedValue =
|
|
1515
|
+
const minimumAllowedValue = Math.max(
|
|
1516
|
+
minimumAllowedLowerBound,
|
|
1517
|
+
minimumAllowedUpperBound
|
|
1518
|
+
);
|
|
1514
1519
|
return normalizedInteger >= minimumAllowedValue ? {
|
|
1515
1520
|
lowerBound: normalizedInteger,
|
|
1516
1521
|
upperBound: normalizedInteger
|
|
@@ -1524,8 +1529,7 @@ function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } =
|
|
|
1524
1529
|
if (lowerBound == null || upperBound == null) {
|
|
1525
1530
|
return void 0;
|
|
1526
1531
|
}
|
|
1527
|
-
|
|
1528
|
-
return upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
1532
|
+
return lowerBound >= minimumAllowedLowerBound && upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
1529
1533
|
lowerBound,
|
|
1530
1534
|
upperBound
|
|
1531
1535
|
} : void 0;
|
|
@@ -1535,9 +1539,11 @@ function parseNormalizedXhttpPositiveRangeBounds(value) {
|
|
|
1535
1539
|
allowZeroUpperBound: false
|
|
1536
1540
|
});
|
|
1537
1541
|
}
|
|
1538
|
-
function
|
|
1539
|
-
|
|
1540
|
-
|
|
1542
|
+
function parseNormalizedXhttpStrictPositiveRangeBounds(value) {
|
|
1543
|
+
return parseNormalizedXhttpRangeBounds(value, {
|
|
1544
|
+
allowZeroLowerBound: false,
|
|
1545
|
+
allowZeroUpperBound: false
|
|
1546
|
+
});
|
|
1541
1547
|
}
|
|
1542
1548
|
function normalizeXhttpPositiveRange(value) {
|
|
1543
1549
|
const normalizedBounds = parseNormalizedXhttpPositiveRangeBounds(value);
|
|
@@ -1547,6 +1553,22 @@ function normalizeXhttpPositiveRange(value) {
|
|
|
1547
1553
|
const { lowerBound, upperBound } = normalizedBounds;
|
|
1548
1554
|
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
1549
1555
|
}
|
|
1556
|
+
function normalizeXhttpStrictPositiveRangeString(value) {
|
|
1557
|
+
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
1558
|
+
if (!normalizedBounds) {
|
|
1559
|
+
return void 0;
|
|
1560
|
+
}
|
|
1561
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
1562
|
+
return lowerBound === upperBound ? `${upperBound}` : `${lowerBound}-${upperBound}`;
|
|
1563
|
+
}
|
|
1564
|
+
function normalizeXhttpStrictPositiveRangeValue(value) {
|
|
1565
|
+
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
1566
|
+
if (!normalizedBounds) {
|
|
1567
|
+
return void 0;
|
|
1568
|
+
}
|
|
1569
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
1570
|
+
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
1571
|
+
}
|
|
1550
1572
|
function normalizeXhttpNonNegativeRange(value) {
|
|
1551
1573
|
const normalizedBounds = parseNormalizedXhttpRangeBounds(value);
|
|
1552
1574
|
if (!normalizedBounds) {
|
|
@@ -2630,7 +2652,7 @@ function URI_VLESS() {
|
|
|
2630
2652
|
}
|
|
2631
2653
|
const parsedHeaders = {};
|
|
2632
2654
|
for (const [key, value] of Object.entries(headers)) {
|
|
2633
|
-
if (typeof value === "string"
|
|
2655
|
+
if (typeof value === "string") {
|
|
2634
2656
|
parsedHeaders[key] = value;
|
|
2635
2657
|
}
|
|
2636
2658
|
}
|
|
@@ -2682,7 +2704,7 @@ function URI_VLESS() {
|
|
|
2682
2704
|
}
|
|
2683
2705
|
const unsupportedHeaders = {};
|
|
2684
2706
|
for (const [key, value] of Object.entries(headers)) {
|
|
2685
|
-
if (typeof value === "string"
|
|
2707
|
+
if (typeof value === "string") {
|
|
2686
2708
|
continue;
|
|
2687
2709
|
}
|
|
2688
2710
|
setUnsupportedXhttpField(unsupportedHeaders, key, value);
|
|
@@ -2748,18 +2770,37 @@ function URI_VLESS() {
|
|
|
2748
2770
|
}
|
|
2749
2771
|
break;
|
|
2750
2772
|
case "xPaddingBytes":
|
|
2773
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2774
|
+
setUnsupportedXhttpField(
|
|
2775
|
+
unsupportedExtra,
|
|
2776
|
+
key,
|
|
2777
|
+
value
|
|
2778
|
+
);
|
|
2779
|
+
}
|
|
2780
|
+
break;
|
|
2751
2781
|
case "xPaddingKey":
|
|
2752
2782
|
case "xPaddingHeader":
|
|
2753
2783
|
case "xPaddingPlacement":
|
|
2754
2784
|
case "xPaddingMethod":
|
|
2755
2785
|
case "uplinkHTTPMethod":
|
|
2786
|
+
case "sessionIDPlacement":
|
|
2756
2787
|
case "sessionPlacement":
|
|
2788
|
+
case "sessionIDKey":
|
|
2757
2789
|
case "sessionKey":
|
|
2758
2790
|
case "seqPlacement":
|
|
2759
2791
|
case "seqKey":
|
|
2760
2792
|
case "uplinkDataPlacement":
|
|
2761
2793
|
case "uplinkDataKey":
|
|
2762
|
-
if (
|
|
2794
|
+
if (typeof value !== "string") {
|
|
2795
|
+
setUnsupportedXhttpField(
|
|
2796
|
+
unsupportedExtra,
|
|
2797
|
+
key,
|
|
2798
|
+
value
|
|
2799
|
+
);
|
|
2800
|
+
}
|
|
2801
|
+
break;
|
|
2802
|
+
case "sessionIDTable":
|
|
2803
|
+
if (typeof value !== "string") {
|
|
2763
2804
|
setUnsupportedXhttpField(
|
|
2764
2805
|
unsupportedExtra,
|
|
2765
2806
|
key,
|
|
@@ -2777,7 +2818,7 @@ function URI_VLESS() {
|
|
|
2777
2818
|
}
|
|
2778
2819
|
break;
|
|
2779
2820
|
case "scMaxEachPostBytes":
|
|
2780
|
-
if (
|
|
2821
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2781
2822
|
setUnsupportedXhttpField(
|
|
2782
2823
|
unsupportedExtra,
|
|
2783
2824
|
key,
|
|
@@ -2794,6 +2835,15 @@ function URI_VLESS() {
|
|
|
2794
2835
|
);
|
|
2795
2836
|
}
|
|
2796
2837
|
break;
|
|
2838
|
+
case "sessionIDLength":
|
|
2839
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2840
|
+
setUnsupportedXhttpField(
|
|
2841
|
+
unsupportedExtra,
|
|
2842
|
+
key,
|
|
2843
|
+
value
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2846
|
+
break;
|
|
2797
2847
|
case "xmux": {
|
|
2798
2848
|
const unsupportedXmux = collectUnsupportedXmux(value);
|
|
2799
2849
|
if (unsupportedXmux !== void 0) {
|
|
@@ -3106,8 +3156,11 @@ function URI_VLESS() {
|
|
|
3106
3156
|
if (extra.noGRPCHeader === true) {
|
|
3107
3157
|
target["no-grpc-header"] = true;
|
|
3108
3158
|
}
|
|
3109
|
-
|
|
3110
|
-
|
|
3159
|
+
const xPaddingBytes = normalizeXhttpStrictPositiveRangeString(
|
|
3160
|
+
extra.xPaddingBytes
|
|
3161
|
+
);
|
|
3162
|
+
if (xPaddingBytes != null) {
|
|
3163
|
+
target["x-padding-bytes"] = xPaddingBytes;
|
|
3111
3164
|
}
|
|
3112
3165
|
if (extra.xPaddingObfsMode === true) {
|
|
3113
3166
|
target["x-padding-obfs-mode"] = true;
|
|
@@ -3127,12 +3180,25 @@ function URI_VLESS() {
|
|
|
3127
3180
|
if (isNotBlank(extra.uplinkHTTPMethod)) {
|
|
3128
3181
|
target["uplink-http-method"] = extra.uplinkHTTPMethod;
|
|
3129
3182
|
}
|
|
3130
|
-
if (isNotBlank(extra.
|
|
3183
|
+
if (isNotBlank(extra.sessionIDPlacement)) {
|
|
3184
|
+
target["session-placement"] = extra.sessionIDPlacement;
|
|
3185
|
+
} else if (isNotBlank(extra.sessionPlacement)) {
|
|
3131
3186
|
target["session-placement"] = extra.sessionPlacement;
|
|
3132
3187
|
}
|
|
3133
|
-
if (isNotBlank(extra.
|
|
3188
|
+
if (isNotBlank(extra.sessionIDKey)) {
|
|
3189
|
+
target["session-key"] = extra.sessionIDKey;
|
|
3190
|
+
} else if (isNotBlank(extra.sessionKey)) {
|
|
3134
3191
|
target["session-key"] = extra.sessionKey;
|
|
3135
3192
|
}
|
|
3193
|
+
if (typeof extra.sessionIDTable === "string") {
|
|
3194
|
+
target["session-table"] = extra.sessionIDTable;
|
|
3195
|
+
}
|
|
3196
|
+
const sessionIDLength = normalizeXhttpStrictPositiveRangeString(
|
|
3197
|
+
extra.sessionIDLength
|
|
3198
|
+
);
|
|
3199
|
+
if (sessionIDLength != null) {
|
|
3200
|
+
target["session-length"] = sessionIDLength;
|
|
3201
|
+
}
|
|
3136
3202
|
if (isNotBlank(extra.seqPlacement)) {
|
|
3137
3203
|
target["seq-placement"] = extra.seqPlacement;
|
|
3138
3204
|
}
|
|
@@ -3151,7 +3217,7 @@ function URI_VLESS() {
|
|
|
3151
3217
|
if (uplinkChunkSize != null) {
|
|
3152
3218
|
target["uplink-chunk-size"] = uplinkChunkSize;
|
|
3153
3219
|
}
|
|
3154
|
-
const scMaxEachPostBytes =
|
|
3220
|
+
const scMaxEachPostBytes = normalizeXhttpStrictPositiveRangeValue(
|
|
3155
3221
|
extra.scMaxEachPostBytes
|
|
3156
3222
|
);
|
|
3157
3223
|
if (scMaxEachPostBytes != null) {
|
|
@@ -4738,7 +4804,19 @@ function quoteSurgeValue(value) {
|
|
|
4738
4804
|
function hasNonBlankValue(value) {
|
|
4739
4805
|
return value != null && `${value}`.trim().length > 0;
|
|
4740
4806
|
}
|
|
4741
|
-
function
|
|
4807
|
+
function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
4808
|
+
if (!enabled) {
|
|
4809
|
+
return;
|
|
4810
|
+
}
|
|
4811
|
+
result.appendIfPresent(
|
|
4812
|
+
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4813
|
+
"tls-fingerprint"
|
|
4814
|
+
);
|
|
4815
|
+
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4816
|
+
result.appendIfPresent(
|
|
4817
|
+
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4818
|
+
"skip-cert-verify"
|
|
4819
|
+
);
|
|
4742
4820
|
const clientCert = isPresent2(proxy, "keystore-client-cert") ? proxy["keystore-client-cert"] : proxy["client-cert"];
|
|
4743
4821
|
if (isPresent2(proxy, "keystore-client-cert") || isPresent2(proxy, "client-cert")) {
|
|
4744
4822
|
result.append(`,client-cert=${quoteSurgeValue(clientCert)}`);
|
|
@@ -4758,6 +4836,12 @@ function warnMaxStreamsIfNeeded(proxy) {
|
|
|
4758
4836
|
`Surge ${proxy.type} proxy ${proxy.name}: max-streams=${maxStreams} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`
|
|
4759
4837
|
);
|
|
4760
4838
|
}
|
|
4839
|
+
function hasSnellObfs(proxy) {
|
|
4840
|
+
return isPresent2(proxy, "obfs-opts.mode") || isPresent2(proxy, "obfs-opts.host") || isPresent2(proxy, "obfs-opts.path");
|
|
4841
|
+
}
|
|
4842
|
+
function isUnsupportedSnellV6Obfs(proxy) {
|
|
4843
|
+
return Number(proxy.version) === 6 && hasSnellObfs(proxy);
|
|
4844
|
+
}
|
|
4761
4845
|
function Surge_Producer() {
|
|
4762
4846
|
const produce2 = (proxy, type, opts = {}) => {
|
|
4763
4847
|
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -4947,16 +5031,7 @@ function trojan(proxy) {
|
|
|
4947
5031
|
);
|
|
4948
5032
|
handleTransport(result, proxy);
|
|
4949
5033
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
4950
|
-
result
|
|
4951
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4952
|
-
"tls-fingerprint"
|
|
4953
|
-
);
|
|
4954
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4955
|
-
result.appendIfPresent(
|
|
4956
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4957
|
-
"skip-cert-verify"
|
|
4958
|
-
);
|
|
4959
|
-
appendClientCert(result, proxy);
|
|
5034
|
+
appendTlsProxyParams(result, proxy);
|
|
4960
5035
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4961
5036
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
4962
5037
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5004,16 +5079,7 @@ function anytls(proxy) {
|
|
|
5004
5079
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5005
5080
|
"no-error-alert"
|
|
5006
5081
|
);
|
|
5007
|
-
result
|
|
5008
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5009
|
-
"tls-fingerprint"
|
|
5010
|
-
);
|
|
5011
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5012
|
-
result.appendIfPresent(
|
|
5013
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5014
|
-
"skip-cert-verify"
|
|
5015
|
-
);
|
|
5016
|
-
appendClientCert(result, proxy);
|
|
5082
|
+
appendTlsProxyParams(result, proxy);
|
|
5017
5083
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5018
5084
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5019
5085
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5058,16 +5124,7 @@ function trusttunnel(proxy) {
|
|
|
5058
5124
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5059
5125
|
"no-error-alert"
|
|
5060
5126
|
);
|
|
5061
|
-
result
|
|
5062
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5063
|
-
"tls-fingerprint"
|
|
5064
|
-
);
|
|
5065
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5066
|
-
result.appendIfPresent(
|
|
5067
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5068
|
-
"skip-cert-verify"
|
|
5069
|
-
);
|
|
5070
|
-
appendClientCert(result, proxy);
|
|
5127
|
+
appendTlsProxyParams(result, proxy);
|
|
5071
5128
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5072
5129
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5073
5130
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5112,16 +5169,7 @@ function h2Connect(proxy) {
|
|
|
5112
5169
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5113
5170
|
"no-error-alert"
|
|
5114
5171
|
);
|
|
5115
|
-
result
|
|
5116
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5117
|
-
"tls-fingerprint"
|
|
5118
|
-
);
|
|
5119
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5120
|
-
result.appendIfPresent(
|
|
5121
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5122
|
-
"skip-cert-verify"
|
|
5123
|
-
);
|
|
5124
|
-
appendClientCert(result, proxy);
|
|
5172
|
+
appendTlsProxyParams(result, proxy);
|
|
5125
5173
|
if (proxy.tfo) {
|
|
5126
5174
|
app_default.info(`Option tfo is not supported by Surge, thus omitted`);
|
|
5127
5175
|
}
|
|
@@ -5181,17 +5229,8 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
5181
5229
|
} else {
|
|
5182
5230
|
result.append(`,vmess-aead=${proxy.alterId === 0}`);
|
|
5183
5231
|
}
|
|
5184
|
-
result.appendIfPresent(
|
|
5185
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5186
|
-
"tls-fingerprint"
|
|
5187
|
-
);
|
|
5188
5232
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
5189
|
-
result
|
|
5190
|
-
result.appendIfPresent(
|
|
5191
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5192
|
-
"skip-cert-verify"
|
|
5193
|
-
);
|
|
5194
|
-
appendClientCert(result, proxy);
|
|
5233
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5195
5234
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5196
5235
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5197
5236
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5288,16 +5327,7 @@ function http(proxy) {
|
|
|
5288
5327
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5289
5328
|
"no-error-alert"
|
|
5290
5329
|
);
|
|
5291
|
-
result.
|
|
5292
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5293
|
-
"tls-fingerprint"
|
|
5294
|
-
);
|
|
5295
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5296
|
-
result.appendIfPresent(
|
|
5297
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5298
|
-
"skip-cert-verify"
|
|
5299
|
-
);
|
|
5300
|
-
appendClientCert(result, proxy);
|
|
5330
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5301
5331
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5302
5332
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5303
5333
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5383,16 +5413,7 @@ function socks5(proxy) {
|
|
|
5383
5413
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5384
5414
|
"no-error-alert"
|
|
5385
5415
|
);
|
|
5386
|
-
result.
|
|
5387
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5388
|
-
"tls-fingerprint"
|
|
5389
|
-
);
|
|
5390
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5391
|
-
result.appendIfPresent(
|
|
5392
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5393
|
-
"skip-cert-verify"
|
|
5394
|
-
);
|
|
5395
|
-
appendClientCert(result, proxy);
|
|
5416
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5396
5417
|
if (proxy.tfo) {
|
|
5397
5418
|
app_default.info(`Option tfo is not supported by Surge, thus omitted`);
|
|
5398
5419
|
}
|
|
@@ -5448,6 +5469,12 @@ function formatHeaderMap(headers, separator) {
|
|
|
5448
5469
|
return Object.entries(headers).filter(([key, value]) => isNotBlank(key) && value != null).map(([key, value]) => `${key}:${quoteSurgeValue(value)}`).join(separator);
|
|
5449
5470
|
}
|
|
5450
5471
|
function snell(proxy) {
|
|
5472
|
+
if (isUnsupportedSnellV6Obfs(proxy)) {
|
|
5473
|
+
app_default.error(
|
|
5474
|
+
`Platform ${targetPlatform} does not support Snell version ${proxy.version} with obfs`
|
|
5475
|
+
);
|
|
5476
|
+
return "";
|
|
5477
|
+
}
|
|
5451
5478
|
const result = new Result(proxy);
|
|
5452
5479
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
5453
5480
|
result.appendIfPresent(`,version=${proxy.version}`, "version");
|
|
@@ -5536,16 +5563,7 @@ function tuic(proxy) {
|
|
|
5536
5563
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5537
5564
|
"no-error-alert"
|
|
5538
5565
|
);
|
|
5539
|
-
result
|
|
5540
|
-
result.appendIfPresent(
|
|
5541
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5542
|
-
"skip-cert-verify"
|
|
5543
|
-
);
|
|
5544
|
-
appendClientCert(result, proxy);
|
|
5545
|
-
result.appendIfPresent(
|
|
5546
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5547
|
-
"tls-fingerprint"
|
|
5548
|
-
);
|
|
5566
|
+
appendTlsProxyParams(result, proxy);
|
|
5549
5567
|
if (isPresent2(proxy, "tfo")) {
|
|
5550
5568
|
result.append(`,tfo=${proxy["tfo"]}`);
|
|
5551
5569
|
} else if (isPresent2(proxy, "fast-open")) {
|
|
@@ -5755,16 +5773,7 @@ function hysteria2(proxy) {
|
|
|
5755
5773
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5756
5774
|
"no-error-alert"
|
|
5757
5775
|
);
|
|
5758
|
-
result
|
|
5759
|
-
result.appendIfPresent(
|
|
5760
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5761
|
-
"skip-cert-verify"
|
|
5762
|
-
);
|
|
5763
|
-
appendClientCert(result, proxy);
|
|
5764
|
-
result.appendIfPresent(
|
|
5765
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5766
|
-
"tls-fingerprint"
|
|
5767
|
-
);
|
|
5776
|
+
appendTlsProxyParams(result, proxy);
|
|
5768
5777
|
if (isPresent2(proxy, "tfo")) {
|
|
5769
5778
|
result.append(`,tfo=${proxy["tfo"]}`);
|
|
5770
5779
|
} else if (isPresent2(proxy, "fast-open")) {
|
|
@@ -6853,7 +6862,7 @@ function shadowsocks2(proxy) {
|
|
|
6853
6862
|
}
|
|
6854
6863
|
}
|
|
6855
6864
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
6856
|
-
result.append(`,shadow-tls-password
|
|
6865
|
+
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
6857
6866
|
result.appendIfPresent(
|
|
6858
6867
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
6859
6868
|
"shadow-tls-version"
|
|
@@ -6868,7 +6877,7 @@ function shadowsocks2(proxy) {
|
|
|
6868
6877
|
const host = proxy["plugin-opts"].host;
|
|
6869
6878
|
const version = proxy["plugin-opts"].version;
|
|
6870
6879
|
if (password) {
|
|
6871
|
-
result.append(`,shadow-tls-password
|
|
6880
|
+
result.append(`,shadow-tls-password=${password}`);
|
|
6872
6881
|
if (host) {
|
|
6873
6882
|
result.append(`,shadow-tls-sni=${host}`);
|
|
6874
6883
|
}
|
|
@@ -6927,7 +6936,7 @@ function shadowsocksr(proxy) {
|
|
|
6927
6936
|
result.appendIfPresent(`,obfs=${proxy.obfs}`, "obfs");
|
|
6928
6937
|
result.appendIfPresent(`,obfs-param=${proxy["obfs-param"]}`, "obfs-param");
|
|
6929
6938
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
6930
|
-
result.append(`,shadow-tls-password
|
|
6939
|
+
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
6931
6940
|
result.appendIfPresent(
|
|
6932
6941
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
6933
6942
|
"shadow-tls-version"
|
|
@@ -6942,7 +6951,7 @@ function shadowsocksr(proxy) {
|
|
|
6942
6951
|
const host = proxy["plugin-opts"].host;
|
|
6943
6952
|
const version = proxy["plugin-opts"].version;
|
|
6944
6953
|
if (password) {
|
|
6945
|
-
result.append(`,shadow-tls-password
|
|
6954
|
+
result.append(`,shadow-tls-password=${password}`);
|
|
6946
6955
|
if (host) {
|
|
6947
6956
|
result.append(`,shadow-tls-sni=${host}`);
|
|
6948
6957
|
}
|
|
@@ -7417,7 +7426,7 @@ function toStringHeaderMap(headers, { excludeHost = false } = {}) {
|
|
|
7417
7426
|
}
|
|
7418
7427
|
const parsedHeaders = {};
|
|
7419
7428
|
for (const [key, value] of Object.entries(headers)) {
|
|
7420
|
-
if (typeof value !== "string"
|
|
7429
|
+
if (typeof value !== "string") {
|
|
7421
7430
|
continue;
|
|
7422
7431
|
}
|
|
7423
7432
|
if (excludeHost && /^host$/i.test(key)) {
|
|
@@ -7556,10 +7565,21 @@ function applyStructuredXhttpExtraFields(target, xhttpOpts, { excludeHostHeader
|
|
|
7556
7565
|
target.uplinkHTTPMethod = xhttpOpts["uplink-http-method"];
|
|
7557
7566
|
}
|
|
7558
7567
|
if (xhttpOpts["session-placement"]) {
|
|
7559
|
-
target.
|
|
7568
|
+
target.sessionIDPlacement = xhttpOpts["session-placement"];
|
|
7560
7569
|
}
|
|
7561
7570
|
if (xhttpOpts["session-key"]) {
|
|
7562
|
-
target.
|
|
7571
|
+
target.sessionIDKey = xhttpOpts["session-key"];
|
|
7572
|
+
}
|
|
7573
|
+
if (typeof xhttpOpts["session-table"] === "string") {
|
|
7574
|
+
target.sessionIDTable = xhttpOpts["session-table"];
|
|
7575
|
+
}
|
|
7576
|
+
if (xhttpOpts["session-length"] != null) {
|
|
7577
|
+
const sessionIDLength = normalizeXhttpStrictPositiveRangeValue(
|
|
7578
|
+
xhttpOpts["session-length"]
|
|
7579
|
+
);
|
|
7580
|
+
if (sessionIDLength != null) {
|
|
7581
|
+
target.sessionIDLength = sessionIDLength;
|
|
7582
|
+
}
|
|
7563
7583
|
}
|
|
7564
7584
|
if (xhttpOpts["seq-placement"]) {
|
|
7565
7585
|
target.seqPlacement = xhttpOpts["seq-placement"];
|
|
@@ -7580,7 +7600,7 @@ function applyStructuredXhttpExtraFields(target, xhttpOpts, { excludeHostHeader
|
|
|
7580
7600
|
target.uplinkChunkSize = uplinkChunkSize;
|
|
7581
7601
|
}
|
|
7582
7602
|
if (xhttpOpts["sc-max-each-post-bytes"] != null) {
|
|
7583
|
-
const scMaxEachPostBytes =
|
|
7603
|
+
const scMaxEachPostBytes = normalizeXhttpStrictPositiveRangeValue(
|
|
7584
7604
|
xhttpOpts["sc-max-each-post-bytes"]
|
|
7585
7605
|
);
|
|
7586
7606
|
if (scMaxEachPostBytes != null) {
|
|
@@ -9384,6 +9404,20 @@ var targetPlatform5 = "Surfboard";
|
|
|
9384
9404
|
function hasNonBlankValue2(value) {
|
|
9385
9405
|
return value != null && `${value}`.trim().length > 0;
|
|
9386
9406
|
}
|
|
9407
|
+
function appendTlsProxyParams2(result, proxy, enabled = true) {
|
|
9408
|
+
if (!enabled) {
|
|
9409
|
+
return;
|
|
9410
|
+
}
|
|
9411
|
+
result.appendIfPresent(
|
|
9412
|
+
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
9413
|
+
"tls-fingerprint"
|
|
9414
|
+
);
|
|
9415
|
+
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
9416
|
+
result.appendIfPresent(
|
|
9417
|
+
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9418
|
+
"skip-cert-verify"
|
|
9419
|
+
);
|
|
9420
|
+
}
|
|
9387
9421
|
function Surfboard_Producer() {
|
|
9388
9422
|
const produce2 = (proxy) => {
|
|
9389
9423
|
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -9439,34 +9473,28 @@ function hysteria23(proxy) {
|
|
|
9439
9473
|
if (hasNonBlankValue2(proxy["hop-interval"])) {
|
|
9440
9474
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
9441
9475
|
}
|
|
9442
|
-
result
|
|
9443
|
-
result.appendIfPresent(
|
|
9444
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9445
|
-
"skip-cert-verify"
|
|
9446
|
-
);
|
|
9476
|
+
appendTlsProxyParams2(result, proxy);
|
|
9447
9477
|
result.appendIfPresent(
|
|
9448
9478
|
`,download-bandwidth=${`${proxy["down"]}`.match(/\d+/)?.[0] || 0}`,
|
|
9449
9479
|
"down"
|
|
9450
9480
|
);
|
|
9451
9481
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9482
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9452
9483
|
return result.toString();
|
|
9453
9484
|
}
|
|
9454
9485
|
function anytls4(proxy) {
|
|
9455
9486
|
const result = new Result(proxy);
|
|
9456
9487
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
9457
9488
|
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
9458
|
-
result
|
|
9459
|
-
result.appendIfPresent(
|
|
9460
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9461
|
-
"skip-cert-verify"
|
|
9462
|
-
);
|
|
9489
|
+
appendTlsProxyParams2(result, proxy);
|
|
9463
9490
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
9464
9491
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9465
9492
|
result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
|
|
9493
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9466
9494
|
return result.toString();
|
|
9467
9495
|
}
|
|
9468
9496
|
function snell2(proxy) {
|
|
9469
|
-
if (proxy
|
|
9497
|
+
if (isPresent2(proxy, "version") && ![1, 2, 3, 4, 5].includes(Number(proxy.version))) {
|
|
9470
9498
|
throw new Error(
|
|
9471
9499
|
`Platform ${targetPlatform5} does not support snell version ${proxy.version}`
|
|
9472
9500
|
);
|
|
@@ -9491,6 +9519,7 @@ function snell2(proxy) {
|
|
|
9491
9519
|
if (proxy.version >= 3) {
|
|
9492
9520
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9493
9521
|
}
|
|
9522
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9494
9523
|
return result.toString();
|
|
9495
9524
|
}
|
|
9496
9525
|
function shadowsocks4(proxy) {
|
|
@@ -9540,6 +9569,7 @@ function shadowsocks4(proxy) {
|
|
|
9540
9569
|
}
|
|
9541
9570
|
}
|
|
9542
9571
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9572
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9543
9573
|
return result.toString();
|
|
9544
9574
|
}
|
|
9545
9575
|
function trojan4(proxy) {
|
|
@@ -9548,13 +9578,10 @@ function trojan4(proxy) {
|
|
|
9548
9578
|
result.appendIfPresent(`,password=${proxy.password}`, "password");
|
|
9549
9579
|
handleTransport2(result, proxy);
|
|
9550
9580
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
9551
|
-
result
|
|
9552
|
-
result.appendIfPresent(
|
|
9553
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9554
|
-
"skip-cert-verify"
|
|
9555
|
-
);
|
|
9581
|
+
appendTlsProxyParams2(result, proxy);
|
|
9556
9582
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
9557
9583
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9584
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9558
9585
|
return result.toString();
|
|
9559
9586
|
}
|
|
9560
9587
|
function vmess4(proxy) {
|
|
@@ -9568,12 +9595,9 @@ function vmess4(proxy) {
|
|
|
9568
9595
|
result.append(`,vmess-aead=${proxy.alterId === 0}`);
|
|
9569
9596
|
}
|
|
9570
9597
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
9571
|
-
result
|
|
9572
|
-
result.appendIfPresent(
|
|
9573
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9574
|
-
"skip-cert-verify"
|
|
9575
|
-
);
|
|
9598
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9576
9599
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9600
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9577
9601
|
return result.toString();
|
|
9578
9602
|
}
|
|
9579
9603
|
function http4(proxy) {
|
|
@@ -9582,12 +9606,9 @@ function http4(proxy) {
|
|
|
9582
9606
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
9583
9607
|
result.appendIfPresent(`,${proxy.username}`, "username");
|
|
9584
9608
|
result.appendIfPresent(`,${proxy.password}`, "password");
|
|
9585
|
-
result
|
|
9586
|
-
result.appendIfPresent(
|
|
9587
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9588
|
-
"skip-cert-verify"
|
|
9589
|
-
);
|
|
9609
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9590
9610
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9611
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9591
9612
|
return result.toString();
|
|
9592
9613
|
}
|
|
9593
9614
|
function socks54(proxy) {
|
|
@@ -9596,12 +9617,9 @@ function socks54(proxy) {
|
|
|
9596
9617
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
9597
9618
|
result.appendIfPresent(`,${proxy.username}`, "username");
|
|
9598
9619
|
result.appendIfPresent(`,${proxy.password}`, "password");
|
|
9599
|
-
result
|
|
9600
|
-
result.appendIfPresent(
|
|
9601
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9602
|
-
"skip-cert-verify"
|
|
9603
|
-
);
|
|
9620
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9604
9621
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9622
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9605
9623
|
return result.toString();
|
|
9606
9624
|
}
|
|
9607
9625
|
function wireguard3(proxy) {
|
|
@@ -9611,6 +9629,7 @@ function wireguard3(proxy) {
|
|
|
9611
9629
|
`,section-name=${proxy["section-name"]}`,
|
|
9612
9630
|
"section-name"
|
|
9613
9631
|
);
|
|
9632
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9614
9633
|
return result.toString();
|
|
9615
9634
|
}
|
|
9616
9635
|
function handleTransport2(result, proxy) {
|
|
@@ -10938,7 +10957,8 @@ function Egern_Producer() {
|
|
|
10938
10957
|
"tuic",
|
|
10939
10958
|
"wireguard",
|
|
10940
10959
|
"anytls",
|
|
10941
|
-
"ssh"
|
|
10960
|
+
"ssh",
|
|
10961
|
+
"snell"
|
|
10942
10962
|
].includes(proxy.type) || proxy.type === "ss" && (proxy.plugin === "obfs" && !["http", "tls"].includes(
|
|
10943
10963
|
proxy["plugin-opts"]?.mode
|
|
10944
10964
|
) || ![
|
|
@@ -10970,13 +10990,22 @@ function Egern_Producer() {
|
|
|
10970
10990
|
"chacha20-ietf",
|
|
10971
10991
|
"2022-blake3-aes-128-gcm",
|
|
10972
10992
|
"2022-blake3-aes-256-gcm"
|
|
10973
|
-
].includes(proxy.cipher)) || proxy.type === "vmess" && !["h2", "http", "ws", "tcp"
|
|
10993
|
+
].includes(proxy.cipher)) || proxy.type === "vmess" && (!["h2", "http", "ws", "tcp", "grpc"].includes(
|
|
10994
|
+
proxy.network
|
|
10995
|
+
) && proxy.network || !isEgernGrpcGun(proxy)) || proxy.type === "trojan" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "vless" && (!["h2", "http", "ws", "tcp", "grpc"].includes(
|
|
10974
10996
|
proxy.network
|
|
10975
|
-
) && proxy.network || typeof proxy.flow !== "undefined" && !["xtls-rprx-vision", ""].includes(
|
|
10997
|
+
) && proxy.network || !isEgernGrpcGun(proxy) || typeof proxy.flow !== "undefined" && !["xtls-rprx-vision", ""].includes(
|
|
10976
10998
|
proxy.flow
|
|
10977
10999
|
)) || proxy.type === "tuic" && proxy.token && proxy.token.length !== 0) {
|
|
10978
11000
|
return false;
|
|
10979
|
-
} else if (
|
|
11001
|
+
} else if (proxy.type === "snell" && normalizeSnellVersion(proxy.version) === null) {
|
|
11002
|
+
return false;
|
|
11003
|
+
} else if (proxy.type === "snell" && hasShadowTls(proxy)) {
|
|
11004
|
+
app_default.error(
|
|
11005
|
+
`Platform Egern does not support Snell shadow-tls proxy ${proxy.name}. Proxy has been filtered.`
|
|
11006
|
+
);
|
|
11007
|
+
return false;
|
|
11008
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && !["tcp"].includes(proxy.network)) {
|
|
10980
11009
|
return false;
|
|
10981
11010
|
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
10982
11011
|
return false;
|
|
@@ -11002,10 +11031,11 @@ function Egern_Producer() {
|
|
|
11002
11031
|
...hasHeaders(proxy) ? {
|
|
11003
11032
|
headers: proxy.headers
|
|
11004
11033
|
} : {},
|
|
11005
|
-
tfo: proxy
|
|
11034
|
+
tfo: getTfo(proxy),
|
|
11006
11035
|
...proxy.tls ? {
|
|
11007
11036
|
sni: proxy.sni,
|
|
11008
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11037
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11038
|
+
reality: getReality(proxy)
|
|
11009
11039
|
} : {}
|
|
11010
11040
|
};
|
|
11011
11041
|
} else if (proxy.type === "https") {
|
|
@@ -11019,20 +11049,26 @@ function Egern_Producer() {
|
|
|
11019
11049
|
...hasHeaders(proxy) ? {
|
|
11020
11050
|
headers: proxy.headers
|
|
11021
11051
|
} : {},
|
|
11022
|
-
tfo: proxy
|
|
11052
|
+
tfo: getTfo(proxy),
|
|
11023
11053
|
sni: proxy.sni,
|
|
11024
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11054
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11055
|
+
reality: getReality(proxy)
|
|
11025
11056
|
};
|
|
11026
11057
|
} else if (proxy.type === "socks5") {
|
|
11027
11058
|
proxy = {
|
|
11028
|
-
type: "socks5",
|
|
11059
|
+
type: proxy.tls ? "socks5_tls" : "socks5",
|
|
11029
11060
|
name: proxy.name,
|
|
11030
11061
|
server: proxy.server,
|
|
11031
11062
|
port: proxy.port,
|
|
11032
11063
|
username: proxy.username,
|
|
11033
11064
|
password: proxy.password,
|
|
11034
|
-
tfo: proxy
|
|
11035
|
-
udp_relay: proxy
|
|
11065
|
+
tfo: getTfo(proxy),
|
|
11066
|
+
udp_relay: getUdpRelay(proxy),
|
|
11067
|
+
...proxy.tls ? {
|
|
11068
|
+
sni: proxy.sni,
|
|
11069
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11070
|
+
reality: getReality(proxy)
|
|
11071
|
+
} : {}
|
|
11036
11072
|
};
|
|
11037
11073
|
} else if (proxy.type === "ss") {
|
|
11038
11074
|
proxy = {
|
|
@@ -11042,8 +11078,8 @@ function Egern_Producer() {
|
|
|
11042
11078
|
server: proxy.server,
|
|
11043
11079
|
port: proxy.port,
|
|
11044
11080
|
password: proxy.password,
|
|
11045
|
-
tfo: proxy
|
|
11046
|
-
udp_relay: proxy
|
|
11081
|
+
tfo: getTfo(proxy),
|
|
11082
|
+
udp_relay: getUdpRelay(proxy)
|
|
11047
11083
|
};
|
|
11048
11084
|
if (isPresent2(original, "plugin")) {
|
|
11049
11085
|
if (original.plugin === "obfs") {
|
|
@@ -11069,8 +11105,8 @@ function Egern_Producer() {
|
|
|
11069
11105
|
10
|
|
11070
11106
|
)
|
|
11071
11107
|
} : {},
|
|
11072
|
-
tfo: proxy
|
|
11073
|
-
udp_relay: proxy
|
|
11108
|
+
tfo: getTfo(proxy),
|
|
11109
|
+
udp_relay: getUdpRelay(proxy),
|
|
11074
11110
|
sni: proxy.sni,
|
|
11075
11111
|
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11076
11112
|
port_hopping: proxy.ports,
|
|
@@ -11107,10 +11143,11 @@ function Egern_Producer() {
|
|
|
11107
11143
|
server: proxy.server,
|
|
11108
11144
|
port: proxy.port,
|
|
11109
11145
|
password: proxy.password,
|
|
11110
|
-
tfo: proxy
|
|
11111
|
-
udp_relay: proxy
|
|
11146
|
+
tfo: getTfo(proxy),
|
|
11147
|
+
udp_relay: getUdpRelay(proxy),
|
|
11112
11148
|
sni: proxy.sni,
|
|
11113
11149
|
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11150
|
+
reality: getReality(proxy),
|
|
11114
11151
|
websocket: proxy.websocket
|
|
11115
11152
|
};
|
|
11116
11153
|
} else if (proxy.type === "anytls") {
|
|
@@ -11120,10 +11157,11 @@ function Egern_Producer() {
|
|
|
11120
11157
|
server: proxy.server,
|
|
11121
11158
|
port: proxy.port,
|
|
11122
11159
|
password: proxy.password,
|
|
11123
|
-
tfo: proxy
|
|
11124
|
-
udp_relay: proxy
|
|
11160
|
+
tfo: getTfo(proxy),
|
|
11161
|
+
udp_relay: getUdpRelay(proxy),
|
|
11125
11162
|
sni: proxy.sni,
|
|
11126
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11163
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11164
|
+
reality: getReality(proxy)
|
|
11127
11165
|
};
|
|
11128
11166
|
} else if (proxy.type === "vmess") {
|
|
11129
11167
|
const security = normalizeVmessSecurity(proxy.cipher);
|
|
@@ -11163,6 +11201,8 @@ function Egern_Producer() {
|
|
|
11163
11201
|
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11164
11202
|
}
|
|
11165
11203
|
};
|
|
11204
|
+
} else if (proxy.network === "grpc") {
|
|
11205
|
+
proxy.transport = getGrpcTransport(proxy);
|
|
11166
11206
|
} else if ((proxy.network === "tcp" || !proxy.network) && proxy.tls) {
|
|
11167
11207
|
proxy.transport = {
|
|
11168
11208
|
tls: {
|
|
@@ -11171,10 +11211,10 @@ function Egern_Producer() {
|
|
|
11171
11211
|
}
|
|
11172
11212
|
};
|
|
11173
11213
|
}
|
|
11174
|
-
let legacy;
|
|
11214
|
+
let legacy = false;
|
|
11175
11215
|
if (isPresent2(proxy, "aead") && !proxy.aead) {
|
|
11176
11216
|
legacy = true;
|
|
11177
|
-
} else if (proxy.alterId !== 0) {
|
|
11217
|
+
} else if (isPresent2(proxy, "alterId") && proxy.alterId !== 0) {
|
|
11178
11218
|
legacy = true;
|
|
11179
11219
|
}
|
|
11180
11220
|
proxy = {
|
|
@@ -11184,9 +11224,9 @@ function Egern_Producer() {
|
|
|
11184
11224
|
port: proxy.port,
|
|
11185
11225
|
user_id: proxy.uuid,
|
|
11186
11226
|
security,
|
|
11187
|
-
tfo: proxy
|
|
11227
|
+
tfo: getTfo(proxy),
|
|
11188
11228
|
legacy,
|
|
11189
|
-
udp_relay: proxy
|
|
11229
|
+
udp_relay: getUdpRelay(proxy),
|
|
11190
11230
|
transport: proxy.transport
|
|
11191
11231
|
};
|
|
11192
11232
|
} else if (proxy.type === "vless") {
|
|
@@ -11230,19 +11270,14 @@ function Egern_Producer() {
|
|
|
11230
11270
|
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11231
11271
|
}
|
|
11232
11272
|
};
|
|
11273
|
+
} else if (proxy.network === "grpc") {
|
|
11274
|
+
proxy.transport = getGrpcTransport(proxy);
|
|
11233
11275
|
} else if (proxy.network === "tcp" || !proxy.network) {
|
|
11234
|
-
let reality;
|
|
11235
|
-
if (proxy["reality-opts"]?.["short-id"] || proxy["reality-opts"]?.["public-key"]) {
|
|
11236
|
-
reality = {
|
|
11237
|
-
short_id: proxy["reality-opts"]["short-id"],
|
|
11238
|
-
public_key: proxy["reality-opts"]["public-key"]
|
|
11239
|
-
};
|
|
11240
|
-
}
|
|
11241
11276
|
proxy.transport = {
|
|
11242
11277
|
[proxy.tls ? "tls" : "tcp"]: {
|
|
11243
11278
|
sni: proxy.tls ? proxy.sni : void 0,
|
|
11244
11279
|
skip_tls_verify: proxy.tls ? proxy["skip-cert-verify"] : void 0,
|
|
11245
|
-
reality
|
|
11280
|
+
reality: getReality(proxy)
|
|
11246
11281
|
}
|
|
11247
11282
|
};
|
|
11248
11283
|
flow = proxy.flow;
|
|
@@ -11255,8 +11290,8 @@ function Egern_Producer() {
|
|
|
11255
11290
|
port: proxy.port,
|
|
11256
11291
|
user_id: proxy.uuid,
|
|
11257
11292
|
security: proxy.cipher,
|
|
11258
|
-
tfo: proxy
|
|
11259
|
-
udp_relay: proxy
|
|
11293
|
+
tfo: getTfo(proxy),
|
|
11294
|
+
udp_relay: getUdpRelay(proxy),
|
|
11260
11295
|
transport: proxy.transport,
|
|
11261
11296
|
flow
|
|
11262
11297
|
};
|
|
@@ -11303,7 +11338,26 @@ function Egern_Producer() {
|
|
|
11303
11338
|
private_key: proxy["private-key"],
|
|
11304
11339
|
// private_key_passphrase: proxy['private-key-passphrase'],
|
|
11305
11340
|
host_keys: proxy["host-key"],
|
|
11306
|
-
tfo: proxy
|
|
11341
|
+
tfo: getTfo(proxy)
|
|
11342
|
+
};
|
|
11343
|
+
} else if (proxy.type === "snell") {
|
|
11344
|
+
const snellVersion = normalizeSnellVersion(
|
|
11345
|
+
proxy.version
|
|
11346
|
+
);
|
|
11347
|
+
proxy = {
|
|
11348
|
+
type: "snell",
|
|
11349
|
+
name: proxy.name,
|
|
11350
|
+
server: proxy.server,
|
|
11351
|
+
port: proxy.port,
|
|
11352
|
+
psk: proxy.psk,
|
|
11353
|
+
version: snellVersion,
|
|
11354
|
+
...snellVersion == null || snellVersion >= 3 ? {
|
|
11355
|
+
udp_relay: getUdpRelay(proxy)
|
|
11356
|
+
} : {},
|
|
11357
|
+
reuse: proxy.reuse,
|
|
11358
|
+
obfs: proxy["obfs-opts"]?.mode || proxy.obfs,
|
|
11359
|
+
obfs_host: proxy["obfs-opts"]?.host || proxy["obfs-host"] || proxy.obfs_host,
|
|
11360
|
+
tfo: getTfo(proxy)
|
|
11307
11361
|
};
|
|
11308
11362
|
}
|
|
11309
11363
|
if ([
|
|
@@ -11357,7 +11411,8 @@ function Egern_Producer() {
|
|
|
11357
11411
|
"tuic",
|
|
11358
11412
|
"hysteria2",
|
|
11359
11413
|
"anytls",
|
|
11360
|
-
"ssh"
|
|
11414
|
+
"ssh",
|
|
11415
|
+
"snell"
|
|
11361
11416
|
].includes(original.type)) {
|
|
11362
11417
|
if (["on", "true", true, "1", 1].includes(
|
|
11363
11418
|
original["block-quic"]
|
|
@@ -11379,9 +11434,9 @@ function Egern_Producer() {
|
|
|
11379
11434
|
delete proxy["no-resolve"];
|
|
11380
11435
|
if (proxy.transport) {
|
|
11381
11436
|
for (const key in proxy.transport) {
|
|
11382
|
-
if (Object.keys(proxy.transport[key]).length === 0 || Object.values(proxy.transport[key]).every(
|
|
11437
|
+
if (key !== "grpc" && (Object.keys(proxy.transport[key]).length === 0 || Object.values(proxy.transport[key]).every(
|
|
11383
11438
|
(value) => value == null
|
|
11384
|
-
)) {
|
|
11439
|
+
))) {
|
|
11385
11440
|
delete proxy.transport[key];
|
|
11386
11441
|
}
|
|
11387
11442
|
}
|
|
@@ -11418,6 +11473,52 @@ Reason: ${err}`
|
|
|
11418
11473
|
function hasHeaders(proxy) {
|
|
11419
11474
|
return proxy?.headers && typeof proxy.headers === "object" && Object.keys(proxy.headers).length > 0;
|
|
11420
11475
|
}
|
|
11476
|
+
function getTfo(proxy) {
|
|
11477
|
+
return proxy.tfo ?? proxy["fast-open"];
|
|
11478
|
+
}
|
|
11479
|
+
function getUdpRelay(proxy) {
|
|
11480
|
+
return proxy.udp ?? proxy.udp_relay;
|
|
11481
|
+
}
|
|
11482
|
+
function hasShadowTls(proxy) {
|
|
11483
|
+
return proxy.plugin === "shadow-tls" || isPresent2(proxy, "shadow-tls-password") || isPresent2(proxy, "shadow-tls-sni") || isPresent2(proxy, "shadow-tls-version");
|
|
11484
|
+
}
|
|
11485
|
+
function getNonEmptyValue(value) {
|
|
11486
|
+
if (value == null) return void 0;
|
|
11487
|
+
if (typeof value === "string" && value.length === 0) return void 0;
|
|
11488
|
+
return value;
|
|
11489
|
+
}
|
|
11490
|
+
function getReality(proxy) {
|
|
11491
|
+
const realityOpts = proxy?.["reality-opts"];
|
|
11492
|
+
if (!realityOpts) return void 0;
|
|
11493
|
+
const reality = {};
|
|
11494
|
+
const publicKey = getNonEmptyValue(realityOpts["public-key"]);
|
|
11495
|
+
const shortId = getNonEmptyValue(realityOpts["short-id"]);
|
|
11496
|
+
if (publicKey != null) reality.public_key = publicKey;
|
|
11497
|
+
if (shortId != null) reality.short_id = shortId;
|
|
11498
|
+
return Object.keys(reality).length > 0 ? reality : void 0;
|
|
11499
|
+
}
|
|
11500
|
+
function getGrpcTransport(proxy) {
|
|
11501
|
+
return {
|
|
11502
|
+
grpc: {
|
|
11503
|
+
service_name: proxy["grpc-opts"]?.["grpc-service-name"],
|
|
11504
|
+
sni: proxy.sni,
|
|
11505
|
+
reality: getReality(proxy),
|
|
11506
|
+
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11507
|
+
}
|
|
11508
|
+
};
|
|
11509
|
+
}
|
|
11510
|
+
function isEgernGrpcGun(proxy) {
|
|
11511
|
+
if (proxy.network !== "grpc") return true;
|
|
11512
|
+
const grpcType = proxy["grpc-opts"]?.["_grpc-type"];
|
|
11513
|
+
if (grpcType == null) return true;
|
|
11514
|
+
return `${grpcType}`.trim().toLowerCase() === "gun";
|
|
11515
|
+
}
|
|
11516
|
+
function normalizeSnellVersion(version) {
|
|
11517
|
+
if (version == null) return void 0;
|
|
11518
|
+
const normalized = `${version}`.trim();
|
|
11519
|
+
if (!/^[1-5]$/.test(normalized)) return null;
|
|
11520
|
+
return parseInt(normalized, 10);
|
|
11521
|
+
}
|
|
11421
11522
|
function getFirstHeaderValue(headers, ...keys) {
|
|
11422
11523
|
for (const key of keys) {
|
|
11423
11524
|
const value = getFirstValue(headers?.[key]);
|
|
@@ -11459,11 +11560,11 @@ function getFingerprintSha256(proxy) {
|
|
|
11459
11560
|
function supportsRootFingerprintSha256(original, proxy) {
|
|
11460
11561
|
return ["anytls", "https", "hysteria2", "trojan", "tuic"].includes(
|
|
11461
11562
|
original.type
|
|
11462
|
-
) || original.type === "http" && proxy.type === "https";
|
|
11563
|
+
) || original.type === "socks5" && proxy.type === "socks5_tls" || original.type === "http" && proxy.type === "https";
|
|
11463
11564
|
}
|
|
11464
11565
|
function addTransportFingerprintSha256(transport, fingerprintSha256) {
|
|
11465
11566
|
if (!transport) return;
|
|
11466
|
-
for (const key of ["http2", "tls", "wss"]) {
|
|
11567
|
+
for (const key of ["grpc", "http2", "tls", "wss"]) {
|
|
11467
11568
|
if (transport[key]) {
|
|
11468
11569
|
transport[key].fingerprint_sha256 = fingerprintSha256;
|
|
11469
11570
|
}
|